Skip to content

Commit

Permalink
chore: improve lint setup
Browse files Browse the repository at this point in the history
- update eslint config
- merged eslint rules for JS and TS to avoid duplicates
- extended stricter lint ruleset from typescript-eslint
- corrected wrong setup for certain eslint rulesets
- opt in to reportUnusedDisableDirectives config option
- fix or disable a lot of lint issues throughout codebase
- remove trailingComma: all from prettier config which is default in prettier v3
- add volta configuration to package.json to autoload correct node and pnpm versions
- upgrade all eslint and prettier related dependencies to latest
- remove config options from settings.json which are default anyways
- remove config options from settings.json which are outdated/unknown
- set up prettier as default formatter in settings.json
  • Loading branch information
mcmxcdev authored and vraravam committed Jul 24, 2023
1 parent cc30830 commit 3ec1dad
Show file tree
Hide file tree
Showing 59 changed files with 999 additions and 708 deletions.
159 changes: 51 additions & 108 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @type {import('eslint').Linter.Config} */

module.exports = {
root: true,
parserOptions: {
Expand All @@ -10,9 +9,14 @@ module.exports = {
sourceType: 'module',
project: './tsconfig.json',
},
ignorePatterns: ['node_modules', 'build', 'recipes', '.eslintrc.js'],
extends: ['airbnb', 'plugin:unicorn/recommended', 'prettier'],
plugins: ['jest', 'prettier'],
ignorePatterns: ['node_modules', 'build', 'recipes'],
extends: [
'airbnb',
'plugin:jest/recommended',
'plugin:unicorn/recommended',
'plugin:prettier/recommended',
],
plugins: ['jest'],
settings: {
react: {
pragma: 'React', // Pragma to use, default to "React"
Expand All @@ -28,123 +32,50 @@ module.exports = {
node: true,
jest: true,
},
reportUnusedDisableDirectives: true,
overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
extends: ['airbnb-typescript', 'plugin:unicorn/recommended', 'prettier'],
extends: [
'airbnb-typescript',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/strict',
// TODO: Opt-in to a stricter ruleset in the future
// 'plugin:@typescript-eslint/strict-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'jest', 'prettier'],
plugins: [],
rules: {
// eslint
'arrow-parens': 0,
'array-callback-return': 1,
'class-methods-use-this': 0,
'consistent-return': 0,
'function-paren-newline': 0,
'implicit-arrow-linebreak': 0,
'linebreak-style': 0,
'max-len': 0,
'no-confusing-arrow': 0,
'no-console': 0,
'no-param-reassign': 0,
'no-restricted-syntax': 0,
'no-return-assign': 1,
'no-underscore-dangle': 0,
'no-use-before-define': 0,
'prefer-destructuring': 1,
'object-curly-newline': 0,
'operator-linebreak': 0,
// @typescript-eslint
// TODO: Turn this rule on again after gulp -> webpack migration
// gulp-typescript doesn't consider custom index.d.ts in @types
// This is necessary as workaround for window.ferdium vs window['ferdium']
'@typescript-eslint/dot-notation': 0,
'@typescript-eslint/indent': 0,
'@typescript-eslint/no-shadow': 0,
'@typescript-eslint/no-unused-expressions': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-inferrable-types': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/prefer-nullish-coalescing': 0,
'@typescript-eslint/consistent-indexed-object-style': 0,
'@typescript-eslint/consistent-type-assertions': 0,
'@typescript-eslint/consistent-type-definitions': 0,
'@typescript-eslint/no-empty-interface': 0,

// eslint-plugin-import
'import/extensions': 0,
'import/no-cycle': 1,
'import/no-extraneous-dependencies': 0,
'import/no-unresolved': 0,
'import/prefer-default-export': 0,
// eslint-plugin-react
// TODO: [TS DEBT] should remove below config once application converted to TS
'react/default-props-match-prop-types': 0,
'react/require-default-props': 0,
'@typescript-eslint/no-useless-constructor': 0,
// eslint-plugin-react
'react/destructuring-assignment': 0,
'react/button-has-type': 0,
'react/forbid-prop-types': 0,
'react/jsx-curly-newline': 0,
'react/no-unused-prop-types': 1,
'react/react-in-jsx-scope': 0,
'react/jsx-no-bind': 0,
'react/jsx-no-target-blank': 0,
'react/jsx-props-no-spreading': 0,
'react/no-deprecated': 1,
'react/no-array-index-key': 0,
'react/prefer-stateless-function': 0,
'react/sort-comp': 0,
'react/state-in-constructor': 0,
'react/static-property-placement': 0,
'react/function-component-definition': 0,
'react/jsx-no-useless-fragment': 0,
// eslint-plugin-jsx-a11y
'jsx-a11y/click-events-have-key-events': 1,
'jsx-a11y/mouse-events-have-key-events': 1,
'jsx-a11y/label-has-for': [
2,
{
components: ['Label'],
required: {
every: ['id'],
},
allowChildren: false,
},
],
'jsx-a11y/no-static-element-interactions': 0,
'jsx-a11y/no-noninteractive-element-interactions': 1,
// eslint-plugin-unicorn
'unicorn/filename-case': 0,
'unicorn/no-null': 0,
'unicorn/no-useless-undefined': 0,
'unicorn/prefer-module': 0,
'unicorn/prevent-abbreviations': 0,
'unicorn/prefer-node-protocol': 0,
'unicorn/import-style': [
2,
{
styles: {
path: {
named: true,
},
},
},
],
'unicorn/consistent-destructuring': 0,
// INFO: Turned off due to src/internal-server/database/factory.js
'unicorn/no-empty-file': 0,
// eslint-plugin-prettier
'prettier/prettier': 1,
'import/no-extraneous-dependencies': 0, // various false positives, re-enable at some point
},
},
],
rules: {
// eslint
'arrow-parens': 0,
'array-callback-return': 1,
'class-methods-use-this': 0,
'consistent-return': 1,
'implicit-arrow-linebreak': 0,
indent: 0,
// TODO: Turn this rule on once the js to ts conversions are over
// This is necessary as workaround for window.ferdium vs window['ferdium']
'dot-notation': 0,
'function-paren-newline': 0,
'linebreak-style': 0,
'max-len': 0,
'no-await-in-loop': 1,
'no-return-assign': 1,
'no-console': [
1,
{
Expand All @@ -154,18 +85,16 @@ module.exports = {
'no-param-reassign': 1,
'no-restricted-syntax': 0,
'no-underscore-dangle': 0,
'operator-linebreak': 0,
'prefer-destructuring': 1,
'object-curly-newline': 0,
// eslint-plugin-import
'import/extensions': 0,
'import/prefer-default-export': 0,
'import/no-extraneous-dependencies': 0, // various false positives, re-enable at some point
'import/no-unresolved': 0,
'import/no-cycle': 1,
'import/no-extraneous-dependencies': 0, // various false positives, re-enable at some point
// eslint-plugin-react
'react/forbid-prop-types': 1,
'react/destructuring-assignment': 0,
'react/jsx-curly-newline': 0,
'react/react-in-jsx-scope': 0,
'react/jsx-filename-extension': 1,
'react/jsx-one-expression-per-line': 0,
Expand All @@ -178,11 +107,27 @@ module.exports = {
'react/sort-comp': 0,
'react/function-component-definition': 0,
'react/jsx-no-useless-fragment': 0,
// eslint-plugin-jsx-a11y
// TODO: [TS DEBT] should remove below config once application converted to TS
'react/default-props-match-prop-types': 0,
'react/require-default-props': 0,
'react/button-has-type': 0,
'react/no-unused-prop-types': 1,
'react/no-deprecated': 1,
// eslint-plugin-jsx-a11y
'jsx-a11y/click-events-have-key-events': 1,
'jsx-a11y/no-static-element-interactions': 1,
'jsx-a11y/no-noninteractive-element-interactions': 1,
// eslint-plugin-unicorn
'jsx-a11y/label-has-for': [
2,
{
components: ['Label'],
required: {
every: ['id'],
},
allowChildren: false,
},
],
// eslint-plugin-unicorn
'unicorn/filename-case': 0,
'unicorn/no-null': 0,
'unicorn/no-useless-undefined': 0,
Expand All @@ -202,7 +147,5 @@ module.exports = {
'unicorn/consistent-destructuring': 0,
// INFO: Turned off due to src/internal-server/database/factory.js
'unicorn/no-empty-file': 0,
// eslint-plugin-prettier
'prettier/prettier': 1,
},
};
1 change: 0 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
singleQuote: true,
arrowParens: 'avoid',
trailingComma: 'all',
};
27 changes: 9 additions & 18 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// "editor.fontFamily": "Fira Code",
// "editor.fontLigatures": true,
"editor.detectIndentation": false,
"editor.bracketPairColorization.enabled": true,
"editor.bracketPairColorization.independentColorPoolPerBracketType": true,
"editor.guides.bracketPairs": "active",
"editor.codeActionsOnSave": {
"source.fixAll": true,
Expand All @@ -19,21 +17,17 @@
// "explorer.confirmDelete": false,
// "explorer.confirmDragAndDrop": false,

"eslint.enable": true,
"eslint.runtime": "node",
"eslint.format.enable": true,
"eslint.alwaysShowStatus": true,
"eslint.workingDirectories": [ { "mode": "auto" } ],
"eslint.workingDirectories": [{ "mode": "auto" }],
// "eslint.packageManager": "npm",
"eslint.validate": ["javascript","javascriptreact","typescript","typescriptreact"],
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"[javascript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" },
"[javascriptreact]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" },
"[typescript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" },
"[typescriptreact]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" },
"[json]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
"[jsonc]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },

"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"editor.defaultFormatter": "esbenp.prettier-vscode",

// "workbench.colorTheme": "Visual Studio Dark",
// "workbench.iconTheme": "material-icon-theme",
Expand All @@ -42,15 +36,12 @@
// "terminal.integrated.copyOnSelection": true,
"terminal.integrated.defaultProfile.osx": "zsh",
"terminal.integrated.cursorBlinking": true,
"terminal.integrated.cursorStyle": "block",
"terminal.integrated.shellIntegration.enabled":true,

"git.mergeEditor": false,
"git.enableSmartCommit": true,
"diffEditor.ignoreTrimWhitespace": false,

// "formatFiles.runOrganizeImports": true,

"javascript.preferences.importModuleSpecifier": "relative",
"typescript.preferences.importModuleSpecifier": "relative",
"typescript.preferences.importModuleSpecifier": "relative"
}
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"pnpm": "8.6.2"
},
"engine-strict": true,
"volta": {
"node": "18.15.0",
"pnpm": "8.6.2"
},
"scripts": {
"prepare": "is-ci || husky install",
"start": "electron ./build",
Expand Down Expand Up @@ -143,8 +147,8 @@
"@types/tar": "6.1.5",
"@types/uuid": "9.0.2",
"@types/validator": "13.7.17",
"@typescript-eslint/eslint-plugin": "5.59.11",
"@typescript-eslint/parser": "5.59.11",
"@typescript-eslint/eslint-plugin": "6.1.0",
"@typescript-eslint/parser": "6.1.0",
"all-contributors-cli": "6.26.1",
"chalk": "5.3.0",
"concurrently": "8.2.0",
Expand All @@ -155,22 +159,22 @@
"esbuild-plugin-copy": "2.1.1",
"esbuild-runner": "2.2.2",
"esbuild-sass-plugin": "2.10.0",
"eslint": "8.39.0",
"eslint": "8.45.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "17.1.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "27.2.3",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-react": "7.33.0",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-unicorn": "46.0.0",
"eslint-plugin-unicorn": "48.0.0",
"gulp-livereload": "4.0.2",
"husky": "8.0.3",
"is-ci": "3.0.1",
"jest": "29.6.1",
"prettier": "2.8.8",
"prettier": "3.0.0",
"preval-build-info": "1.0.3",
"rimraf": "5.0.1",
"simple-git": "3.19.1",
Expand Down
Loading

0 comments on commit 3ec1dad

Please sign in to comment.