Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Prettier and Eslint configuration #114

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
"presets": [
"@babel/env",
"@babel/react",
"@babel/flow",
"@babel/typescript"
"@babel/flow"
],
"plugins": [
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-object-rest-spread",
["@babel/plugin-proposal-class-properties", { "loose": true }],
"lodash"
]
}
8 changes: 7 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
src/demoData/*
node_modules/*
static/*
dist/*
scripts/
cypress/
deploy/
lib/
44 changes: 44 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'prettier/@typescript-eslint',
'plugin:testing-library/react',
],
rules: {
'keyword-spacing': 2,
'switch-colon-spacing': ['error', { after: true, before: false }],
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-case-declarations': 'off',
'no-var-requires': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/camelcase': 'off',
'no-prototype-builtins': 'off',
'no-useless-escape': 'off',
'no-useless-catch': 'off',
},
parserOptions: {
ecmaVersion: 2016,
sourceType: 'module',
},
settings: {
react: {
version: 'detect',
},
},
globals: {
"window": true,
"document": true,
"global": true,
"insights": true,
}
};
121 changes: 0 additions & 121 deletions .eslintrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package.json
*.yaml
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

9 changes: 9 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
bracketSpacing: true,
printWidth: 100,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
};

16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ git clone https://github.com/project-xavier/xavier-ui.git
cd xavier-ui
npm ci

git clone https://github.com/RedHatInsights/insights-chrome
cd insights-chrome
npm ci

git clone https://github.com/RedHatInsights/insights-proxy.git
cd insights-proxy
npm install
Expand All @@ -48,19 +44,11 @@ npm ci # Always execute this when package.json changed
npm run start
```

### insights-chrome

```shell
cd insights-chrome
npm run build
npm run start
```

### insights-proxy
Move to insight-chrome/build folder and then execute:
```shell
cd insights-chrome/build
SPANDX_CONFIG=../../xavier-ui/profiles/local-frontend-and-api.js LOCAL_CHROME=true sh ../../insights-proxy/scripts/run.sh
cd insights-proxy
SPANDX_CONFIG=../xavier-ui/profiles/local-frontend-and-api.js sh scripts/run.sh
```

# Open you browser
Expand Down
97 changes: 97 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
require.extensions['.css'] = () => undefined;
const path = require('path');
const glob = require('glob');

// Mapper for Patternly components
const mapper = {
TextVariants: 'Text',
DropdownPosition: 'dropdownConstants',
EmptyStateVariant: 'EmptyState',
TextListItemVariants: 'TextListItem',
TextListVariants: 'TextList'
};

// Wrapper for Patternfly icons
const iconMapper = {}

// Mapper for cloud-services components
const FECMapper = {
SkeletonSize: 'Skeleton',
PageHeaderTitle: 'PageHeader'
};

module.exports = {
presets: [
'@babel/env',
'@babel/react'
],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'lodash',
[
'transform-imports',
{
'@patternfly/react-core': {
transform: (importName) => {
const files = glob.sync(
path.resolve(
__dirname,
`./node_modules/@patternfly/react-core/dist/js/**/${mapper[
importName
] || importName}.js`
)
);
if (files.length > 0) {
return files[0].replace(/.*(?=@patternfly)/, '');
} else {
throw `File with importName ${importName} does not exist`;
}
},
preventFullImport: false,
skipDefaultConversion: true
}
},
'react-core'
],
[
'transform-imports',
{
'@patternfly/react-icons': {
transform: (importName) =>
`@patternfly/react-icons/dist/js/icons/${importName
.split(/(?=[A-Z])/)
.join('-')
.toLowerCase()}`,
preventFullImport: true
}
},
'react-icons'
],
[
'transform-imports',
{
'@redhat-cloud-services/frontend-components': {
transform: (importName) =>
`@redhat-cloud-services/frontend-components/components/cjs/${FECMapper[importName] || importName}`,
preventFullImport: false,
skipDefaultConversion: true
}
},
'frontend-components'
],
[
'transform-imports',
{
'@redhat-cloud-services/frontend-components-notifications': {
transform: (importName) =>
`@redhat-cloud-services/frontend-components-notifications/cjs/${importName}`,
preventFullImport: true
}
},
'frontend-notifications'
]
]
};
19 changes: 0 additions & 19 deletions config/base.webpack.config.js

This file was deleted.

25 changes: 0 additions & 25 deletions config/base.webpack.rules.js

This file was deleted.

Loading