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

Improve frontend lint settings #969

Merged
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
86 changes: 82 additions & 4 deletions frontend/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
"plugins": [
"@typescript-eslint",
"react-hooks",
"eslint-plugin-react-hooks"
"eslint-plugin-react-hooks",
"import",
"no-relative-import-paths",
"prettier"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
"plugin:prettier/recommended",
"prettier"
],
"globals": {
"window": "readonly",
Expand All @@ -38,9 +41,34 @@
"settings": {
"react": {
"version": "detect"
},
"import/parsers": {
"@typescript-eslint/parser": [
".ts",
".tsx"
]
}
},
"rules": {
"arrow-body-style": "error",
"curly": "error",
"camelcase": "warn",
"no-else-return": "error",
"no-restricted-imports": [
"error",
{
"patterns": [
{
"group": [
"~/api/**"
],
"message": "Read from '~/api' instead."
}
]
}
],
"no-console": "error",
"no-param-reassign": "error",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-var-requires": "off",
Expand All @@ -51,6 +79,39 @@
"react-hooks/rules-of-hooks": "error",
"import/extensions": "off",
"import/no-unresolved": "off",
"import/order": [
"error",
{
"pathGroups": [
{
"pattern": "~/**",
"group": "external",
"position": "after"
}
],
"pathGroupsExcludedImportTypes": [
"builtin"
],
"groups": [
"builtin",
"external",
"internal",
"index",
"sibling",
"parent",
"object",
"unknown"
]
}
],
"no-relative-import-paths/no-relative-import-paths": [
"warn",
{
"allowSameFolder": true,
"rootDir": "src",
"prefix": "~"
}
],
"prettier/prettier": [
"error",
{
Expand All @@ -61,5 +122,22 @@
}
],
"react/prop-types": "off"
}
},
"overrides": [
{
"files": [
"./src/api/**"
],
"rules": {
"no-restricted-imports": [
"off",
{
"patterns": [
"~/api/**"
]
}
]
}
}
]
}
9 changes: 3 additions & 6 deletions frontend/config/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const { setupWebpackDotenvFilesForEnv } = require('./dotenv');

const RELATIVE_DIRNAME = process.env._ODH_RELATIVE_DIRNAME;
Expand Down Expand Up @@ -178,11 +177,9 @@ module.exports = env => {
],
resolve: {
extensions: ['.js', '.ts', '.tsx', '.jsx'],
plugins: [
new TsconfigPathsPlugin({
configFile: path.resolve(RELATIVE_DIRNAME, './tsconfig.json')
})
],
alias: {
"~": path.resolve(SRC_DIR)
},
symlinks: false,
cacheWithContext: false
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
'\\.(css|less|sass|scss)$': '<rootDir>/config/transform.style.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/config/transform.file.js',
'@app/(.*)': '<rootDir>/src/app/$1',
'~/(.*)': '<rootDir>/src/$1',
},

// A preset that is used as a base for Jest's configuration
Expand Down
Loading