From ce2046f3e5ebad530ba6bf7c3247f976ac3f9b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Wed, 5 Jan 2022 15:28:02 +0100 Subject: [PATCH] feat: simplify configs BREAKING CHANGE: ES6, import & main configs don't have sub-configs anymore --- README.md | 18 +- best-practices.js | 218 --------------------- deprecated-rules.js | 30 --- es6.js | 92 +++++++++ es6/best-practices.js | 37 ---- es6/index.js | 9 - es6/non-rules-config.js | 27 --- es6/possible-errors.js | 31 --- es6/stylistic.js | 34 ---- import.js | 84 ++++++++ import/best-practices.js | 19 -- import/deprecated-rules.js | 6 - import/disabled-rules.js | 16 -- import/index.js | 11 -- import/non-rules-config.js | 26 --- import/possible-errors.js | 25 --- import/stylistic.js | 24 --- index.js | 381 ++++++++++++++++++++++++++++++++++++- jest.js | 4 +- non-rules-config.js | 29 --- possible-errors.js | 79 -------- react.js | 4 +- stylistic.js | 95 --------- 23 files changed, 556 insertions(+), 743 deletions(-) delete mode 100644 best-practices.js delete mode 100644 deprecated-rules.js create mode 100644 es6.js delete mode 100644 es6/best-practices.js delete mode 100644 es6/index.js delete mode 100644 es6/non-rules-config.js delete mode 100644 es6/possible-errors.js delete mode 100644 es6/stylistic.js create mode 100644 import.js delete mode 100644 import/best-practices.js delete mode 100644 import/deprecated-rules.js delete mode 100644 import/disabled-rules.js delete mode 100644 import/index.js delete mode 100644 import/non-rules-config.js delete mode 100644 import/possible-errors.js delete mode 100644 import/stylistic.js delete mode 100644 non-rules-config.js delete mode 100644 possible-errors.js delete mode 100644 stylistic.js diff --git a/README.md b/README.md index 468705e..1805c63 100644 --- a/README.md +++ b/README.md @@ -102,24 +102,14 @@ for it. - All plugins needed for rules used by these configs are dependencies of this module so you don't have to install anything on your own. - The default config actually is composed of several configurations and you can - use those individually. These are the configs it's using: - `possible-errors.js`, `best-practices.js`, `stylistic.js`, `es6/index.js`, and - `import/index.js`. You can use each of these configs yourself if you want to - leave my own personal style out of it. Also, the `es6` and `import` configs - each have a `possible-errors.js`, `best-practices.js`, and `stylistic.js` - which they are composed of as well. + use those individually. You can use each of these configs yourself if you want + to leave my own personal style out of it. -#### Example of highly customized config +#### Example of customized config ```javascript module.exports = { - extends: [ - 'kentcdodds/possible-errors', - 'kentcdodds/best-practices', - 'kentcdodds/es6/possible-errors', - 'kentcdodds/import', - 'kentcdodds/jest', - ], + extends: ['kentcdodds/es6', 'kentcdodds/import', 'kentcdodds/jest'], rules: { /* custom rules */ }, diff --git a/best-practices.js b/best-practices.js deleted file mode 100644 index f7759ea..0000000 --- a/best-practices.js +++ /dev/null @@ -1,218 +0,0 @@ -module.exports = { - extends: './non-rules-config.js', - rules: { - 'accessor-pairs': 'error', - 'array-callback-return': 'error', - 'block-scoped-var': 'error', - 'class-methods-use-this': 'off', // three words: "componentDidMount" :) - complexity: ['error', 20], - 'consistent-return': 'error', - 'default-case': 'error', - 'default-case-last': 'error', - 'default-param-last': 'off', - 'dot-notation': 'error', - eqeqeq: 'off', - 'grouped-accessor-pairs': 'off', - 'guard-for-in': 'error', - 'max-classes-per-file': 'off', - 'no-alert': 'error', - 'no-caller': 'error', - 'no-case-declarations': 'error', - 'no-constructor-return': 'error', - 'no-div-regex': 'error', - 'no-else-return': 'off', - 'no-empty-function': 'off', // we're all grown ups here... - 'no-empty-pattern': 'error', - 'no-eq-null': 'off', - 'no-eval': 'error', - 'no-extend-native': 'error', - 'no-extra-bind': 'error', - 'no-extra-label': 'error', - 'no-fallthrough': 'error', - 'no-global-assign': 'error', - 'no-implicit-coercion': 'off', - 'no-implicit-globals': 'error', - 'no-implied-eval': 'error', - 'no-invalid-this': 'error', - 'no-iterator': 'error', - 'no-labels': 'error', - 'no-lone-blocks': 'error', - 'no-loop-func': 'error', - 'no-magic-numbers': 'off', // sometimes this is ok (foo.length - 1 == index of last one) - 'no-multi-str': 'error', - 'no-new': 'error', - 'no-new-func': 'error', - 'no-new-wrappers': 'error', - 'no-nonoctal-decimal-escape': 'error', - 'no-octal': 'error', - 'no-octal-escape': 'error', - 'no-param-reassign': 'off', - 'no-proto': 'error', - 'no-redeclare': 'error', - 'no-restricted-properties': 'off', // no ideas of what to disallow right now... - 'no-return-assign': 'error', - 'no-return-await': 'error', - 'no-script-url': 'error', - 'no-self-assign': 'error', - 'no-self-compare': 'error', - 'no-sequences': 'error', - 'no-throw-literal': 'error', - 'no-unmodified-loop-condition': 'error', - 'no-unused-expressions': 'off', - 'no-unused-labels': 'error', - 'no-useless-call': 'error', - 'no-useless-catch': 'error', - 'no-useless-concat': 'error', - 'no-useless-escape': 'error', - 'no-useless-return': 'error', - 'no-void': 'off', - 'no-warning-comments': ['error', {terms: ['fixme'], location: 'anywhere'}], - 'no-with': 'off', - 'prefer-named-capture-group': 'off', // maybe one day... But I'm not used to it yet. - 'prefer-promise-reject-errors': 'off', // maybe one day... Not sure I'm in... - 'prefer-regex-literals': 'off', - radix: 'error', - 'require-await': 'off', - 'require-unicode-regexp': 'off', - 'vars-on-top': 'error', - yoda: 'error', - - // strict - strict: 'error', - - // variables - 'no-delete-var': 'error', - 'no-label-var': 'error', - 'no-restricted-globals': ['error', 'event', 'fdescribe'], - 'no-shadow': 'error', - 'no-shadow-restricted-names': 'error', - 'no-undef': 'error', - 'no-undef-init': 'error', - 'no-undefined': 'off', - 'no-unused-vars': [ - 'error', - { - argsIgnorePattern: '^_', - varsIgnorePattern: '^ignored', - args: 'after-used', - ignoreRestSiblings: true, - }, - ], - }, - overrides: [ - { - files: ['**/*.ts?(x)'], - rules: { - 'no-undef': 'off', // ts(2304) - - 'consistent-return': 'off', // in TS this is much less an issue - - 'default-param-last': 'off', - '@typescript-eslint/default-param-last': 'off', - - 'dot-notation': 'off', - '@typescript-eslint/dot-notation': 'error', - - 'no-empty-function': 'off', - '@typescript-eslint/no-empty-function': 'off', - - 'no-implied-eval': 'error', - '@typescript-eslint/no-implied-eval': 'error', - - 'no-invalid-this': 'off', - '@typescript-eslint/no-invalid-this': 'error', - - 'no-loop-func': 'off', - '@typescript-eslint/no-loop-func': 'error', - - 'no-magic-numbers': 'off', - '@typescript-eslint/no-magic-numbers': 'off', - - 'no-redeclare': 'off', - '@typescript-eslint/no-redeclare': 'off', // ts(2451) - - 'no-return-await': 'off', - '@typescript-eslint/return-await': 'error', - - 'no-shadow': 'off', - '@typescript-eslint/no-shadow': 'error', - - 'no-throw-literal': 'off', - '@typescript-eslint/no-throw-literal': 'error', - - 'no-unused-expressions': 'off', - '@typescript-eslint/no-unused-expressions': 'off', - - 'no-unused-vars': 'off', - '@typescript-eslint/no-unused-vars': [ - 'error', - { - argsIgnorePattern: '^_', - varsIgnorePattern: '^ignored', - args: 'after-used', - ignoreRestSiblings: true, - }, - ], - - '@typescript-eslint/require-await': 'off', - - '@typescript-eslint/array-type': 'off', - '@typescript-eslint/await-thenable': 'error', - '@typescript-eslint/ban-ts-comment': 'error', - '@typescript-eslint/ban-types': 'off', // not useful in a reusable config - '@typescript-eslint/class-literal-property-style': 'off', - '@typescript-eslint/consistent-type-assertions': 'off', - '@typescript-eslint/no-base-to-string': 'warn', - '@typescript-eslint/no-confusing-void-expression': 'off', // honestly, it's probably a good rule, but I do this all the time so... - '@typescript-eslint/no-dynamic-delete': 'error', - '@typescript-eslint/no-empty-interface': 'error', - '@typescript-eslint/no-explicit-any': 'error', - '@typescript-eslint/no-extraneous-class': 'error', // stay away from classes when you can - '@typescript-eslint/no-floating-promises': 'warn', // not a bad rule, but can be annoying - '@typescript-eslint/no-for-in-array': 'error', - '@typescript-eslint/no-implicit-any-catch': 'warn', - '@typescript-eslint/no-inferrable-types': 'off', // I personally prefer relying on inference where possible, but I don't want to lint for it. - '@typescript-eslint/no-invalid-void-type': 'warn', - '@typescript-eslint/no-misused-new': 'error', - '@typescript-eslint/no-misused-promises': [ - 'warn', - {checksVoidReturn: false}, - ], - '@typescript-eslint/no-namespace': 'error', - '@typescript-eslint/no-require-imports': 'off', // sometimes you can't do it any other way - '@typescript-eslint/no-this-alias': 'error', - '@typescript-eslint/no-unnecessary-condition': 'error', - '@typescript-eslint/no-unnecessary-qualifier': 'warn', // I'm not sure I understand this one - '@typescript-eslint/no-unnecessary-type-arguments': 'off', - '@typescript-eslint/no-unnecessary-type-assertion': 'error', - '@typescript-eslint/no-unnecessary-type-constraint': 'error', - '@typescript-eslint/no-var-requires': 'error', - '@typescript-eslint/non-nullable-type-assertion-style': 'off', - '@typescript-eslint/prefer-as-const': 'error', - '@typescript-eslint/prefer-enum-initializers': 'error', // makes total sense - '@typescript-eslint/prefer-function-type': 'off', // though I'm not sure I understand it - '@typescript-eslint/prefer-includes': 'error', // normally I wouldn't but includes is just so much better - '@typescript-eslint/prefer-literal-enum-member': 'error', - '@typescript-eslint/prefer-namespace-keyword': 'error', - '@typescript-eslint/prefer-nullish-coalescing': 'error', - '@typescript-eslint/prefer-optional-chain': 'error', - '@typescript-eslint/prefer-readonly': 'off', - '@typescript-eslint/prefer-reduce-type-parameter': 'warn', - '@typescript-eslint/prefer-regexp-exec': 'off', - '@typescript-eslint/prefer-string-starts-ends-with': 'error', - '@typescript-eslint/prefer-ts-expect-error': 'error', - '@typescript-eslint/promise-function-async': 'off', - '@typescript-eslint/require-array-sort-compare': 'off', - '@typescript-eslint/restrict-plus-operands': 'error', - '@typescript-eslint/restrict-template-expressions': 'off', - '@typescript-eslint/strict-boolean-expressions': 'off', - '@typescript-eslint/switch-exhaustiveness-check': 'error', - '@typescript-eslint/triple-slash-reference': 'error', - '@typescript-eslint/unbound-method': 'error', - - // variables - '@typescript-eslint/unified-signatures': 'warn', - }, - }, - ], -} diff --git a/deprecated-rules.js b/deprecated-rules.js deleted file mode 100644 index 543af14..0000000 --- a/deprecated-rules.js +++ /dev/null @@ -1,30 +0,0 @@ -const {mapDeprecatedRules} = require('./utils') - -module.exports = { - extends: './non-rules-config.js', - rules: mapDeprecatedRules([ - 'callback-return', - 'global-require', - 'handle-callback-err', - 'id-blacklist', - 'indent-legacy', - 'lines-around-directive', - 'newline-after-var', - 'newline-before-return', - 'no-buffer-constructor', - 'no-catch-shadow', - 'no-mixed-requires', - 'no-native-reassign', - 'no-negated-in-lhs', - 'no-new-require', - 'no-path-concat', - 'no-process-env', - 'no-process-exit', - 'no-restricted-modules', - 'no-spaced-func', - 'no-sync', - 'prefer-reflect', - 'require-jsdoc', - 'valid-jsdoc', - ]), -} diff --git a/es6.js b/es6.js new file mode 100644 index 0000000..a77d617 --- /dev/null +++ b/es6.js @@ -0,0 +1,92 @@ +module.exports = { + env: { + es6: true, + }, + extends: ['prettier'], + parser: '@babel/eslint-parser', + parserOptions: { + babelOptions: { + presets: ['@babel/preset-react'], + }, + ecmaVersion: 2018, + requireConfigFile: false, + sourceType: 'module', + }, + plugins: ['@babel'], + rules: { + 'arrow-body-style': 'off', + 'constructor-super': 'error', + 'no-class-assign': 'error', + 'no-const-assign': 'error', + 'no-dupe-class-members': 'error', + 'no-duplicate-imports': 'error', + 'no-new-symbol': 'error', + 'no-restricted-exports': 'off', // not applicable for a config preset (should be configured only in projects) + 'no-restricted-imports': 'off', // not applicable for a config preset (should be configured only in projects) + 'no-this-before-super': 'error', + 'no-unsafe-optional-chaining': 'error', + 'no-useless-computed-key': 'error', + 'no-useless-constructor': 'error', + 'no-useless-rename': 'error', + 'no-var': 'error', + 'object-shorthand': ['error', 'properties'], // methods are optional so you can specify a name if you want + 'prefer-arrow-callback': [ + 'error', + {allowNamedFunctions: true, allowUnboundThis: true}, + ], + 'prefer-const': 'error', + 'prefer-destructuring': 'off', // nah, I like it, but not that much... + 'prefer-numeric-literals': 'error', + 'prefer-rest-params': 'error', + 'prefer-spread': 'error', + 'prefer-template': 'error', + 'require-yield': 'error', + 'sort-imports': 'off', + 'symbol-description': 'error', + + 'new-cap': 'off', + '@babel/new-cap': ['error', {capIsNew: true, newIsCap: true}], + + 'no-invalid-this': 'off', + '@babel/no-invalid-this': 'error', + + 'no-unused-expressions': 'off', + '@babel/no-unused-expressions': 'error', + }, + overrides: [ + { + files: ['**/*.ts?(x)'], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + plugins: ['@typescript-eslint'], + rules: { + 'constructor-super': 'off', // ts(2335) & ts(2377) + 'no-const-assign': 'off', // ts(2588) + 'no-new-symbol': 'off', // ts(2588) + 'no-this-before-super': 'off', // ts(2376) + 'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more + 'prefer-const': 'error', // ts provides better types with const + 'prefer-rest-params': 'error', // ts provides better types with rest args over arguments + 'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply + + 'no-dupe-class-members': 'off', + '@typescript-eslint/no-dupe-class-members': 'off', // ts(2393) & ts(2300) + + 'no-duplicate-imports': 'off', + '@typescript-eslint/no-duplicate-imports': 'error', + + 'no-useless-constructor': 'off', + '@typescript-eslint/no-useless-constructor': 'error', + + '@babel/no-invalid-this': 'off', + '@typescript-eslint/no-invalid-this': 'error', + + '@babel/no-unused-expressions': 'off', + '@typescript-eslint/no-unused-expressions': 'error', + }, + }, + ], +} diff --git a/es6/best-practices.js b/es6/best-practices.js deleted file mode 100644 index c97970c..0000000 --- a/es6/best-practices.js +++ /dev/null @@ -1,37 +0,0 @@ -module.exports = { - extends: './non-rules-config.js', - rules: { - 'no-class-assign': 'error', - 'no-duplicate-imports': 'error', - 'no-restricted-exports': 'off', // not applicable for a config preset (should be configured only in projects) - 'no-restricted-imports': 'off', // not applicable for a config preset (should be configured only in projects) - 'no-useless-computed-key': 'error', - 'no-useless-constructor': 'error', - 'no-useless-rename': 'error', - 'no-var': 'error', - 'prefer-const': 'error', - 'prefer-numeric-literals': 'error', - 'prefer-rest-params': 'error', - 'prefer-spread': 'error', - 'prefer-template': 'error', - 'require-yield': 'error', - 'symbol-description': 'error', - }, - overrides: [ - { - files: ['**/*.ts?(x)'], - rules: { - 'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more - 'prefer-const': 'error', // ts provides better types with const - 'prefer-rest-params': 'error', // ts provides better types with rest args over arguments - 'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply - - 'no-duplicate-imports': 'off', - '@typescript-eslint/no-duplicate-imports': 'error', - - 'no-useless-constructor': 'off', - '@typescript-eslint/no-useless-constructor': 'error', - }, - }, - ], -} diff --git a/es6/index.js b/es6/index.js deleted file mode 100644 index 15487b1..0000000 --- a/es6/index.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - extends: [ - './non-rules-config.js', - './stylistic.js', - './best-practices.js', - './possible-errors.js', - ], - rules: {}, -} diff --git a/es6/non-rules-config.js b/es6/non-rules-config.js deleted file mode 100644 index a09d455..0000000 --- a/es6/non-rules-config.js +++ /dev/null @@ -1,27 +0,0 @@ -module.exports = { - parser: '@babel/eslint-parser', - env: { - es6: true, - }, - parserOptions: { - babelOptions: { - presets: ['@babel/preset-react'], - }, - ecmaVersion: 2018, - sourceType: 'module', - requireConfigFile: false, - }, - plugins: ['@babel'], - overrides: [ - { - files: ['**/*.ts?(x)'], - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - plugins: ['@typescript-eslint'], - rules: {}, - }, - ], -} diff --git a/es6/possible-errors.js b/es6/possible-errors.js deleted file mode 100644 index c43140e..0000000 --- a/es6/possible-errors.js +++ /dev/null @@ -1,31 +0,0 @@ -module.exports = { - extends: './non-rules-config.js', - rules: { - 'constructor-super': 'error', - 'no-const-assign': 'error', - 'no-dupe-class-members': 'error', - 'no-new-symbol': 'error', - 'no-this-before-super': 'error', - 'no-unsafe-optional-chaining': 'error', - - 'no-unused-expressions': 'off', - '@babel/no-unused-expressions': 'error', - }, - overrides: [ - { - files: ['**/*.ts?(x)'], - rules: { - 'constructor-super': 'off', // ts(2335) & ts(2377) - 'no-const-assign': 'off', // ts(2588) - 'no-new-symbol': 'off', // ts(2588) - 'no-this-before-super': 'off', // ts(2376) - - 'no-dupe-class-members': 'off', - '@typescript-eslint/no-dupe-class-members': 'off', // ts(2393) & ts(2300) - - '@babel/no-unused-expressions': 'off', - '@typescript-eslint/no-unused-expressions': 'error', - }, - }, - ], -} diff --git a/es6/stylistic.js b/es6/stylistic.js deleted file mode 100644 index 2ca2d36..0000000 --- a/es6/stylistic.js +++ /dev/null @@ -1,34 +0,0 @@ -module.exports = { - extends: ['./non-rules-config.js', 'prettier'], - rules: { - 'arrow-body-style': 'off', - 'object-shorthand': ['error', 'properties'], // methods are optional so you can specify a name if you want - 'prefer-arrow-callback': [ - 'error', - {allowNamedFunctions: true, allowUnboundThis: true}, - ], - 'prefer-destructuring': 'off', // nah, I like it, but not that much... - 'sort-imports': 'off', - - 'new-cap': 'off', - '@babel/new-cap': [ - 'error', - { - newIsCap: true, - capIsNew: true, - }, - ], - - 'no-invalid-this': 'off', - '@babel/no-invalid-this': 'error', - }, - overrides: [ - { - files: ['**/*.ts?(x)'], - rules: { - '@babel/no-invalid-this': 'off', - '@typescript-eslint/no-invalid-this': 'error', - }, - }, - ], -} diff --git a/import.js b/import.js new file mode 100644 index 0000000..6f1d062 --- /dev/null +++ b/import.js @@ -0,0 +1,84 @@ +module.exports = { + env: { + es6: true, + }, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + plugins: ['import'], + settings: { + 'import/ignore': ['node_modules', '.json$', '.(scss|less|css|styl)$'], + }, + rules: { + 'global-require': 'off', // disable because no need to have both! + + 'import/default': 'error', + 'import/dynamic-import-chunkname': 'off', + 'import/export': 'error', + 'import/exports-last': 'off', + 'import/extensions': 'off', + 'import/first': 'error', + 'import/group-exports': 'off', + 'import/max-dependencies': 'off', + 'import/named': 'error', + 'import/namespace': 'error', + 'import/newline-after-import': 'off', + 'import/no-absolute-path': 'error', + 'import/no-amd': 'error', + 'import/no-anonymous-default-export': 'off', + 'import/no-commonjs': 'off', + 'import/no-cycle': 'off', // this rule is quite slow... + 'import/no-default-export': 'off', + 'import/no-deprecated': 'warn', // this is an in progress rule + 'import/no-duplicates': 'error', + 'import/no-dynamic-require': 'off', + 'import/no-extraneous-dependencies': 'error', + 'import/no-import-module-exports': 'error', + 'import/no-internal-modules': 'off', + 'import/no-mutable-exports': 'error', + 'import/no-named-as-default': 'error', + 'import/no-named-as-default-member': 'error', + 'import/no-named-default': 'error', + 'import/no-named-export': 'off', // Prohibit named exports. Mostly an inverse of no-default-export + 'import/no-namespace': 'off', + 'import/no-nodejs-modules': 'off', + 'import/no-relative-packages': 'warn', + 'import/no-relative-parent-imports': 'off', + 'import/no-restricted-paths': 'off', + 'import/no-self-import': 'error', + 'import/no-unassigned-import': 'off', + 'import/no-unresolved': 'error', + 'import/no-unused-modules': 'off', + 'import/no-useless-path-segments': 'off', + 'import/no-webpack-loader-syntax': 'error', + 'import/order': [ + 'warn', + { + groups: [ + 'builtin', + ['external', 'internal'], + 'parent', + ['sibling', 'index'], + ], + }, + ], + 'import/prefer-default-export': 'off', + 'import/unambiguous': 'off', // not sure I understand this rule well enough right now... + }, + overrides: [ + { + files: ['**/*.ts?(x)'], + extends: 'plugin:import/typescript', + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + plugins: ['@typescript-eslint'], + rules: { + 'import/no-unresolved': 'off', // ts(2307) + }, + }, + ], +} diff --git a/import/best-practices.js b/import/best-practices.js deleted file mode 100644 index d67b375..0000000 --- a/import/best-practices.js +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = { - extends: './non-rules-config.js', - rules: { - 'import/first': 'error', - 'import/no-anonymous-default-export': 'off', - 'import/no-absolute-path': 'error', - 'import/no-deprecated': 'warn', // this is an in progress rule - 'import/no-duplicates': 'error', - 'global-require': 'off', // disable because no need to have both! - 'import/no-import-module-exports': 'error', - 'import/no-internal-modules': 'off', - 'import/no-mutable-exports': 'error', - 'import/no-relative-packages': 'warn', - 'import/no-restricted-paths': 'off', - 'import/no-unassigned-import': 'off', - 'import/no-unused-modules': 'off', - 'import/no-webpack-loader-syntax': 'error', - }, -} diff --git a/import/deprecated-rules.js b/import/deprecated-rules.js deleted file mode 100644 index 5692de4..0000000 --- a/import/deprecated-rules.js +++ /dev/null @@ -1,6 +0,0 @@ -const {mapDeprecatedRules} = require('../utils') - -module.exports = { - extends: './non-rules-config.js', - rules: mapDeprecatedRules(['import/imports-first']), -} diff --git a/import/disabled-rules.js b/import/disabled-rules.js deleted file mode 100644 index c1ab4fa..0000000 --- a/import/disabled-rules.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - extends: './non-rules-config.js', - rules: { - 'import/max-dependencies': 'off', - 'import/dynamic-import-chunkname': 'off', - 'import/exports-last': 'off', - 'import/group-exports': 'off', - 'import/no-dynamic-require': 'off', - 'import/prefer-default-export': 'off', - 'import/no-default-export': 'off', - // Prohibit named exports. Mostly an inverse of no-default-export. - 'import/no-named-export': 'off', - 'import/unambiguous': 'off', // not sure I understand this rule well enough right now... - 'import/no-relative-parent-imports': 'off', - }, -} diff --git a/import/index.js b/import/index.js deleted file mode 100644 index 3cd1512..0000000 --- a/import/index.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - extends: [ - './non-rules-config.js', - './deprecated-rules.js', - './stylistic.js', - './best-practices.js', - './possible-errors.js', - './disabled-rules.js', - ], - rules: {}, -} diff --git a/import/non-rules-config.js b/import/non-rules-config.js deleted file mode 100644 index 21caa4c..0000000 --- a/import/non-rules-config.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - env: { - es6: true, - }, - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - plugins: ['import'], - settings: { - 'import/ignore': ['node_modules', '.json$', '.(scss|less|css|styl)$'], - }, - overrides: [ - { - files: ['**/*.ts?(x)'], - extends: 'plugin:import/typescript', - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - plugins: ['@typescript-eslint'], - rules: {}, - }, - ], -} diff --git a/import/possible-errors.js b/import/possible-errors.js deleted file mode 100644 index 43bbae0..0000000 --- a/import/possible-errors.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - extends: './non-rules-config.js', - rules: { - 'import/default': 'error', - 'import/export': 'error', - 'import/no-unresolved': 'error', - 'import/named': 'error', - 'import/namespace': 'error', - 'import/no-extraneous-dependencies': 'error', - 'import/no-named-as-default-member': 'error', - 'import/no-self-import': 'error', - 'import/no-useless-path-segments': 'off', - - // this rule is quite slow... - 'import/no-cycle': 'off', - }, - overrides: [ - { - files: ['**/*.ts?(x)'], - rules: { - 'import/no-unresolved': 'off', // ts(2307) - }, - }, - ], -} diff --git a/import/stylistic.js b/import/stylistic.js deleted file mode 100644 index 84471cd..0000000 --- a/import/stylistic.js +++ /dev/null @@ -1,24 +0,0 @@ -module.exports = { - extends: './non-rules-config.js', - rules: { - 'import/extensions': 'off', - 'import/newline-after-import': 'off', - 'import/no-named-as-default': 'error', - 'import/no-amd': 'error', - 'import/no-commonjs': 'off', - 'import/no-named-default': 'error', - 'import/no-namespace': 'off', - 'import/no-nodejs-modules': 'off', - 'import/order': [ - 'warn', - { - groups: [ - 'builtin', - ['external', 'internal'], - 'parent', - ['sibling', 'index'], - ], - }, - ], - }, -} diff --git a/index.js b/index.js index d228ae9..8e83c41 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,375 @@ +const fs = require('fs') +const path = require('path') + +const tsConfig = fs.existsSync('tsconfig.json') + ? path.resolve('tsconfig.json') + : fs.existsSync('types/tsconfig.json') + ? path.resolve('types/tsconfig.json') + : undefined + module.exports = { - extends: [ - './non-rules-config.js', - './deprecated-rules.js', - './stylistic.js', - './best-practices.js', - './possible-errors.js', - './import/index.js', - './es6/index.js', + env: { + browser: true, + node: true, + }, + extends: ['prettier', './import.js', './es6.js'], + rules: { + 'accessor-pairs': 'error', + 'array-callback-return': 'error', + 'block-scoped-var': 'error', + camelcase: 'off', // annoying to disable... + 'capitalized-comments': 'off', // wHO CaRes? + 'class-methods-use-this': 'off', // three words: "componentDidMount" :) + complexity: ['error', 20], + 'consistent-return': 'error', + 'consistent-this': 'off', // Too many use-cases for reassigning "this" to different values + curly: ['error', 'multi-line'], + 'default-case': 'error', + 'default-case-last': 'error', + 'default-param-last': 'off', + 'dot-notation': 'error', + eqeqeq: 'off', + 'for-direction': 'error', + 'func-name-matching': 'error', + 'func-names': 'error', + 'func-style': 'off', + 'getter-return': ['error', {allowImplicit: true}], + 'grouped-accessor-pairs': 'off', + 'guard-for-in': 'error', + 'id-denylist': 'error', + 'id-length': 'off', // when using short composable functions, using single-letter variables is fine + 'id-match': [ + 'error', + // camelCase, PascalCase, __filename, CONST_VALUE, stream$, $el + '^\\$?(__)?(([A-Z]|[a-z]|[0-9]+)|([A-Z_]))*\\$?$', + ], + 'init-declarations': 'off', + 'line-comment-position': 'off', + 'lines-between-class-members': 'off', + 'max-classes-per-file': 'off', + 'max-depth': ['error', 4], + 'max-lines': [ + 'error', + {max: 2500, skipBlankLines: false, skipComments: false}, + ], + 'max-lines-per-function': 'off', // this becomes an obvious problem when it's actually a problem... + 'max-nested-callbacks': ['error', 7], + 'max-params': ['error', 7], + 'max-statements': 'off', // this becomes an obvious problem when it's actually a problem... + 'max-statements-per-line': ['error', {max: 1}], + 'multiline-comment-style': 'off', // this would be cool to get the fixer, but too strict. + 'new-cap': 'error', + 'no-alert': 'error', + 'no-array-constructor': 'error', + 'no-async-promise-executor': 'off', + 'no-await-in-loop': 'error', + 'no-bitwise': 'error', + 'no-caller': 'error', + 'no-case-declarations': 'error', + 'no-compare-neg-zero': 'error', + 'no-cond-assign': 'error', + 'no-console': 'off', + 'no-constant-condition': 'error', + 'no-constructor-return': 'error', + 'no-continue': 'off', + 'no-control-regex': 'error', + 'no-debugger': 'error', + 'no-delete-var': 'error', + 'no-div-regex': 'error', + 'no-dupe-args': 'error', + 'no-dupe-else-if': 'error', + 'no-dupe-keys': 'error', + 'no-duplicate-case': 'error', + 'no-else-return': 'off', + 'no-empty': 'error', + 'no-empty-character-class': 'error', + 'no-empty-function': 'off', // we're all grown ups here... + 'no-empty-pattern': 'error', + 'no-eq-null': 'off', + 'no-eval': 'error', + 'no-ex-assign': 'error', + 'no-extend-native': 'error', + 'no-extra-bind': 'error', + 'no-extra-boolean-cast': 'off', + 'no-extra-label': 'error', + 'no-fallthrough': 'error', + 'no-func-assign': 'error', + 'no-global-assign': 'error', + 'no-implicit-coercion': 'off', + 'no-implicit-globals': 'error', + 'no-implied-eval': 'error', + 'no-import-assign': 'error', + 'no-inline-comments': 'off', + 'no-inner-declarations': 'error', + 'no-invalid-regexp': 'error', + 'no-invalid-this': 'error', + 'no-irregular-whitespace': 'error', + 'no-iterator': 'error', + 'no-label-var': 'error', + 'no-labels': 'error', + 'no-lone-blocks': 'error', + 'no-lonely-if': 'error', + 'no-loop-func': 'error', + 'no-loss-of-precision': 'error', + 'no-magic-numbers': 'off', // sometimes this is ok (foo.length - 1 == index of last one) + 'no-misleading-character-class': 'off', + 'no-multi-assign': 'error', // it's handy, but harder to read + 'no-multi-str': 'error', + 'no-negated-condition': 'error', + 'no-nested-ternary': 'off', + 'no-new': 'error', + 'no-new-func': 'error', + 'no-new-object': 'error', + 'no-new-wrappers': 'error', + 'no-nonoctal-decimal-escape': 'error', + 'no-obj-calls': 'error', + 'no-octal': 'error', + 'no-octal-escape': 'error', + 'no-param-reassign': 'off', + 'no-plusplus': 'off', + 'no-promise-executor-return': 'off', // prevents: new Promise(r => setTimeout(r)) + 'no-proto': 'error', + 'no-prototype-builtins': 'off', + 'no-redeclare': 'error', + 'no-regex-spaces': 'error', + 'no-restricted-globals': ['error', 'event', 'fdescribe'], + 'no-restricted-properties': 'off', // no ideas of what to disallow right now... + 'no-restricted-syntax': ['error', 'WithStatement'], + 'no-return-assign': 'error', + 'no-return-await': 'error', + 'no-script-url': 'error', + 'no-self-assign': 'error', + 'no-self-compare': 'error', + 'no-sequences': 'error', + 'no-setter-return': 'error', + 'no-shadow': 'error', + 'no-shadow-restricted-names': 'error', + 'no-sparse-arrays': 'error', + 'no-template-curly-in-string': 'error', + 'no-ternary': 'off', + 'no-throw-literal': 'error', + 'no-undef': 'error', + 'no-undef-init': 'error', + 'no-undefined': 'off', + 'no-underscore-dangle': 'off', + 'no-unmodified-loop-condition': 'error', + 'no-unneeded-ternary': 'error', + 'no-unreachable': 'error', + 'no-unreachable-loop': 'error', + 'no-unsafe-finally': 'error', + 'no-unsafe-negation': 'error', + 'no-unused-expressions': 'off', + 'no-unused-labels': 'error', + 'no-unused-vars': [ + 'error', + { + args: 'after-used', + argsIgnorePattern: '^_', + ignoreRestSiblings: true, + varsIgnorePattern: '^ignored', + }, + ], + 'no-use-before-define': ['error', 'nofunc'], + 'no-useless-backreference': 'error', + 'no-useless-call': 'error', + 'no-useless-catch': 'error', + 'no-useless-concat': 'error', + 'no-useless-escape': 'error', + 'no-useless-return': 'error', + 'no-void': 'off', + 'no-warning-comments': ['error', {location: 'anywhere', terms: ['fixme']}], + 'no-with': 'off', + 'one-var': ['error', {initialized: 'never', uninitialized: 'always'}], + 'operator-assignment': 'off', // readability on a case-by-case basis + 'padding-line-between-statements': 'off', // meh... + 'prefer-exponentiation-operator': 'warn', + 'prefer-named-capture-group': 'off', // maybe one day... But I'm not used to it yet. + 'prefer-object-spread': 'warn', + 'prefer-promise-reject-errors': 'off', // maybe one day... Not sure I'm in... + 'prefer-regex-literals': 'off', + radix: 'error', + 'require-atomic-updates': 'off', + 'require-await': 'off', + 'require-unicode-regexp': 'off', + 'sort-keys': 'off', + 'sort-vars': 'off', + 'spaced-comment': 'off', + strict: 'error', + 'use-isnan': 'error', + 'valid-typeof': 'error', + 'vars-on-top': 'error', + yoda: 'error', + }, + overrides: [ + { + files: ['**/*.ts?(x)'], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 2018, + project: tsConfig, + sourceType: 'module', + }, + plugins: ['@typescript-eslint'], + rules: { + 'getter-return': 'off', // ts(2378) + 'no-dupe-args': 'off', // ts(2300) + 'no-dupe-keys': 'off', // ts(1117) + 'no-func-assign': 'off', // ts(2539) + 'no-import-assign': 'off', // ts(2539) & ts(2540) + 'no-obj-calls': 'off', // ts(2349) + 'no-setter-return': 'off', // ts(2408) + 'no-undef': 'off', // ts(2304) + 'no-unreachable': 'off', // ts(7027) + 'no-unsafe-negation': 'off', // ts(2365) & ts(2360) & ts(2358) + 'valid-typeof': 'off', // ts(2367) + + 'consistent-return': 'off', // in TS this is much less an issue + + 'default-param-last': 'off', + '@typescript-eslint/default-param-last': 'off', + + 'dot-notation': 'off', + '@typescript-eslint/dot-notation': 'error', + + 'init-declarations': 'off', + '@typescript-eslint/init-declarations': 'off', + + 'lines-between-class-members': 'off', + '@typescript-eslint/lines-between-class-members': 'off', + + 'no-array-constructor': 'off', + '@typescript-eslint/no-array-constructor': 'error', + + 'no-empty-function': 'off', + '@typescript-eslint/no-empty-function': 'off', + + 'no-implied-eval': 'error', + '@typescript-eslint/no-implied-eval': 'error', + + 'no-invalid-this': 'off', + '@typescript-eslint/no-invalid-this': 'error', + + 'no-loop-func': 'off', + '@typescript-eslint/no-loop-func': 'error', + + 'no-loss-of-precision': 'off', + '@typescript-eslint/no-loss-of-precision': 'error', + + 'no-magic-numbers': 'off', + '@typescript-eslint/no-magic-numbers': 'off', + + 'no-redeclare': 'off', + '@typescript-eslint/no-redeclare': 'off', // ts(2451) + + 'no-return-await': 'off', + '@typescript-eslint/return-await': 'error', + + 'no-shadow': 'off', + '@typescript-eslint/no-shadow': 'error', + + 'no-throw-literal': 'off', + '@typescript-eslint/no-throw-literal': 'error', + + 'no-use-before-define': 'off', + '@typescript-eslint/no-use-before-define': ['error', 'nofunc'], + + 'no-unused-expressions': 'off', + '@typescript-eslint/no-unused-expressions': 'off', + + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'after-used', + argsIgnorePattern: '^_', + ignoreRestSiblings: true, + varsIgnorePattern: '^ignored', + }, + ], + + '@typescript-eslint/adjacent-overload-signatures': 'error', + '@typescript-eslint/array-type': 'off', + '@typescript-eslint/await-thenable': 'error', + '@typescript-eslint/ban-ts-comment': 'error', + '@typescript-eslint/ban-tslint-comment': 'error', + '@typescript-eslint/ban-types': 'off', // not useful in a reusable config + '@typescript-eslint/class-literal-property-style': 'off', + '@typescript-eslint/consistent-indexed-object-style': 'off', + '@typescript-eslint/consistent-type-assertions': 'off', + '@typescript-eslint/consistent-type-definitions': 'off', + '@typescript-eslint/consistent-type-imports': 'off', // I think I prefer typed imports, but you can't always use them + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/member-delimiter-style': 'off', + '@typescript-eslint/member-ordering': 'off', + '@typescript-eslint/method-signature-style': 'off', + '@typescript-eslint/naming-convention': 'off', + '@typescript-eslint/no-base-to-string': 'warn', + '@typescript-eslint/no-confusing-non-null-assertion': 'off', // prettier reformats their "correct" example anyway 🤷‍♂️ + '@typescript-eslint/no-confusing-void-expression': 'off', // honestly, it's probably a good rule, but I do this all the time so... + '@typescript-eslint/no-dynamic-delete': 'error', + '@typescript-eslint/no-empty-interface': 'error', + '@typescript-eslint/no-explicit-any': 'error', + '@typescript-eslint/no-extra-non-null-assertion': 'error', + '@typescript-eslint/no-extraneous-class': 'error', // stay away from classes when you can + '@typescript-eslint/no-floating-promises': 'warn', // not a bad rule, but can be annoying + '@typescript-eslint/no-for-in-array': 'error', + '@typescript-eslint/no-implicit-any-catch': 'warn', + '@typescript-eslint/no-inferrable-types': 'off', // I personally prefer relying on inference where possible, but I don't want to lint for it. + '@typescript-eslint/no-invalid-void-type': 'warn', + '@typescript-eslint/no-misused-new': 'error', + '@typescript-eslint/no-misused-promises': [ + 'warn', + {checksVoidReturn: false}, + ], + '@typescript-eslint/no-namespace': 'error', + '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', + '@typescript-eslint/no-non-null-assertion': 'error', + '@typescript-eslint/no-parameter-properties': 'error', // yeah, I don't like this feature + '@typescript-eslint/no-require-imports': 'off', // sometimes you can't do it any other way + '@typescript-eslint/no-this-alias': 'error', + '@typescript-eslint/no-type-alias': 'off', + '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn', + '@typescript-eslint/no-unnecessary-condition': 'error', + '@typescript-eslint/no-unnecessary-qualifier': 'warn', // I'm not sure I understand this one + '@typescript-eslint/no-unnecessary-type-arguments': 'off', + '@typescript-eslint/no-unnecessary-type-assertion': 'error', + '@typescript-eslint/no-unnecessary-type-constraint': 'error', + '@typescript-eslint/no-unsafe-argument': 'error', + '@typescript-eslint/no-unsafe-assignment': 'warn', // seems like an ok idea, but I don't have enough experience with TS yet. + '@typescript-eslint/no-unsafe-call': 'warn', // seems like an ok idea, but I don't have enough experience with TS yet. + '@typescript-eslint/no-unsafe-member-access': 'warn', // seems like an ok idea, but I don't have enough experience with TS yet. + '@typescript-eslint/no-unsafe-return': 'off', // seems like an ok idea, but it failed on a regular React Component + '@typescript-eslint/no-var-requires': 'error', + '@typescript-eslint/non-nullable-type-assertion-style': 'off', + '@typescript-eslint/prefer-as-const': 'error', + '@typescript-eslint/prefer-enum-initializers': 'error', // makes total sense + '@typescript-eslint/prefer-for-of': 'off', // I prefer for of, but I don't want to lint for it + '@typescript-eslint/prefer-function-type': 'off', // though I'm not sure I understand it + '@typescript-eslint/prefer-includes': 'error', // normally I wouldn't but includes is just so much better + '@typescript-eslint/prefer-literal-enum-member': 'error', + '@typescript-eslint/prefer-namespace-keyword': 'error', + '@typescript-eslint/prefer-nullish-coalescing': 'error', + '@typescript-eslint/prefer-optional-chain': 'error', + '@typescript-eslint/prefer-readonly': 'off', + '@typescript-eslint/prefer-readonly-parameter-types': 'off', + '@typescript-eslint/prefer-reduce-type-parameter': 'warn', + '@typescript-eslint/prefer-regexp-exec': 'off', + '@typescript-eslint/prefer-string-starts-ends-with': 'error', + '@typescript-eslint/prefer-ts-expect-error': 'error', + '@typescript-eslint/promise-function-async': 'off', + '@typescript-eslint/require-array-sort-compare': 'off', + '@typescript-eslint/require-await': 'off', + '@typescript-eslint/restrict-plus-operands': 'error', + '@typescript-eslint/restrict-template-expressions': 'off', + '@typescript-eslint/sort-type-union-intersection-members': 'off', + '@typescript-eslint/strict-boolean-expressions': 'off', + '@typescript-eslint/switch-exhaustiveness-check': 'error', + '@typescript-eslint/triple-slash-reference': 'error', + '@typescript-eslint/typedef': 'off', + '@typescript-eslint/unbound-method': 'error', + '@typescript-eslint/unified-signatures': 'warn', + }, + }, ], - rules: {}, } diff --git a/jest.js b/jest.js index 5fc3197..317f3ba 100644 --- a/jest.js +++ b/jest.js @@ -80,16 +80,16 @@ const rules = { ...(hasJestDom ? { 'jest-dom/prefer-checked': 'error', - 'jest-dom/prefer-in-document': 'error', 'jest-dom/prefer-empty': 'error', 'jest-dom/prefer-enabled-disabled': 'error', 'jest-dom/prefer-focus': 'error', + 'jest-dom/prefer-in-document': 'error', 'jest-dom/prefer-required': 'error', 'jest-dom/prefer-to-have-attribute': 'error', + 'jest-dom/prefer-to-have-class': 'error', 'jest-dom/prefer-to-have-style': 'error', 'jest-dom/prefer-to-have-text-content': 'error', 'jest-dom/prefer-to-have-value': 'error', - 'jest-dom/prefer-to-have-class': 'error', } : null), diff --git a/non-rules-config.js b/non-rules-config.js deleted file mode 100644 index 8ae9e25..0000000 --- a/non-rules-config.js +++ /dev/null @@ -1,29 +0,0 @@ -const fs = require('fs') -const path = require('path') - -const tsConfig = fs.existsSync('tsconfig.json') - ? path.resolve('tsconfig.json') - : fs.existsSync('types/tsconfig.json') - ? path.resolve('types/tsconfig.json') - : undefined - -module.exports = { - env: { - browser: true, - node: true, - }, - rules: {}, - overrides: [ - { - files: ['**/*.ts?(x)'], - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - project: tsConfig, - }, - plugins: ['@typescript-eslint'], - rules: {}, - }, - ], -} diff --git a/possible-errors.js b/possible-errors.js deleted file mode 100644 index cf2758c..0000000 --- a/possible-errors.js +++ /dev/null @@ -1,79 +0,0 @@ -module.exports = { - extends: './non-rules-config.js', - rules: { - 'for-direction': 'error', - 'getter-return': ['error', {allowImplicit: true}], - 'no-async-promise-executor': 'off', - 'no-await-in-loop': 'error', - 'no-compare-neg-zero': 'error', - 'no-cond-assign': 'error', - 'no-console': 'off', - 'no-constant-condition': 'error', - 'no-control-regex': 'error', - 'no-debugger': 'error', - 'no-dupe-args': 'error', - 'no-dupe-else-if': 'error', - 'no-dupe-keys': 'error', - 'no-duplicate-case': 'error', - 'no-empty': 'error', - 'no-empty-character-class': 'error', - 'no-ex-assign': 'error', - 'no-extra-boolean-cast': 'off', - 'no-func-assign': 'error', - 'no-import-assign': 'error', - 'no-inner-declarations': 'error', - 'no-invalid-regexp': 'error', - 'no-irregular-whitespace': 'error', - 'no-loss-of-precision': 'error', - 'no-misleading-character-class': 'off', - 'no-obj-calls': 'error', - 'no-promise-executor-return': 'off', // prevents: new Promise(r => setTimeout(r)) - 'no-prototype-builtins': 'off', - 'no-regex-spaces': 'error', - 'no-setter-return': 'error', - 'no-sparse-arrays': 'error', - 'no-template-curly-in-string': 'error', - 'no-unreachable': 'error', - 'no-unreachable-loop': 'error', - 'no-unsafe-finally': 'error', - 'no-unsafe-negation': 'error', - 'no-useless-backreference': 'error', - 'require-atomic-updates': 'off', - 'use-isnan': 'error', - 'valid-typeof': 'error', - - // variables - 'no-use-before-define': ['error', 'nofunc'], - }, - overrides: [ - { - files: ['**/*.ts?(x)'], - rules: { - 'getter-return': 'off', // ts(2378) - 'no-dupe-args': 'off', // ts(2300) - 'no-dupe-keys': 'off', // ts(1117) - 'no-func-assign': 'off', // ts(2539) - 'no-import-assign': 'off', // ts(2539) & ts(2540) - 'no-obj-calls': 'off', // ts(2349) - 'no-setter-return': 'off', // ts(2408) - 'no-unreachable': 'off', // ts(7027) - 'no-unsafe-negation': 'off', // ts(2365) & ts(2360) & ts(2358) - 'valid-typeof': 'off', // ts(2367) - - 'no-loss-of-precision': 'off', - '@typescript-eslint/no-loss-of-precision': 'error', - - 'no-use-before-define': 'off', - '@typescript-eslint/no-use-before-define': ['error', 'nofunc'], - - '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', - '@typescript-eslint/no-unsafe-argument': 'error', - '@typescript-eslint/no-unsafe-assignment': 'warn', // seems like an ok idea, but I don't have enough experience with TS yet. - '@typescript-eslint/no-unsafe-call': 'warn', // seems like an ok idea, but I don't have enough experience with TS yet. - '@typescript-eslint/no-unsafe-member-access': 'warn', // seems like an ok idea, but I don't have enough experience with TS yet. - '@typescript-eslint/no-unsafe-return': 'off', // seems like an ok idea, but it failed on a regular React Component - '@typescript-eslint/prefer-readonly-parameter-types': 'off', - }, - }, - ], -} diff --git a/react.js b/react.js index b704a14..77405a5 100644 --- a/react.js +++ b/react.js @@ -54,7 +54,7 @@ module.exports = { 'react/jsx-boolean-value': 'off', 'react/jsx-curly-brace-presence': [ 'warn', - {props: 'never', children: 'ignore'}, + {children: 'ignore', props: 'never'}, ], 'react/jsx-filename-extension': ['error', {extensions: ['.js']}], 'react/jsx-fragments': 'off', @@ -63,8 +63,8 @@ module.exports = { 'react/jsx-max-depth': 'off', 'react/jsx-newline': 'off', 'react/jsx-no-bind': 'off', - 'react/jsx-no-constructed-context-values': 'off', 'react/jsx-no-comment-textnodes': 'error', + 'react/jsx-no-constructed-context-values': 'off', 'react/jsx-no-duplicate-props': 'error', 'react/jsx-no-literals': 'off', 'react/jsx-no-script-url': 'error', diff --git a/stylistic.js b/stylistic.js deleted file mode 100644 index 33084c5..0000000 --- a/stylistic.js +++ /dev/null @@ -1,95 +0,0 @@ -module.exports = { - extends: ['./non-rules-config.js', 'prettier'], - rules: { - camelcase: 'off', // annoying to disable... - 'capitalized-comments': 'off', // wHO CaRes? - 'consistent-this': 'off', // Too many use-cases for reassigning "this" to different values - curly: ['error', 'multi-line'], - 'func-name-matching': 'error', - 'func-names': 'error', - 'func-style': 'off', - 'id-denylist': 'error', - 'id-length': 'off', // when using short composable functions, using single-letter variables is fine - 'id-match': [ - 'error', - // camelCase, PascalCase, __filename, CONST_VALUE, stream$, $el - '^\\$?(__)?(([A-Z]|[a-z]|[0-9]+)|([A-Z_]))*\\$?$', - ], - 'line-comment-position': 'off', - 'lines-between-class-members': 'off', - 'max-depth': ['error', 4], - 'max-lines': [ - 'error', - {max: 2500, skipBlankLines: false, skipComments: false}, - ], - - 'max-lines-per-function': 'off', // this becomes an obvious problem when it's actually a problem... - 'max-nested-callbacks': ['error', 7], - 'max-params': ['error', 7], - 'max-statements': 'off', // this becomes an obvious problem when it's actually a problem... - 'max-statements-per-line': ['error', {max: 1}], - 'multiline-comment-style': 'off', // this would be cool to get the fixer, but too strict. - 'new-cap': 'error', - 'no-array-constructor': 'error', - 'no-bitwise': 'error', - 'no-continue': 'off', - 'no-inline-comments': 'off', - 'no-lonely-if': 'error', - 'no-multi-assign': 'error', // it's handy, but harder to read - 'no-negated-condition': 'error', - 'no-nested-ternary': 'off', - 'no-new-object': 'error', - 'no-plusplus': 'off', - 'no-restricted-syntax': ['error', 'WithStatement'], - 'no-ternary': 'off', - 'no-underscore-dangle': 'off', - 'no-unneeded-ternary': 'error', - 'one-var': ['error', {uninitialized: 'always', initialized: 'never'}], - 'operator-assignment': 'off', // readability on a case-by-case basis - 'padding-line-between-statements': 'off', // meh... - 'prefer-exponentiation-operator': 'warn', - 'prefer-object-spread': 'warn', - 'sort-keys': 'off', - 'sort-vars': 'off', - 'spaced-comment': 'off', - - // variables - 'init-declarations': 'off', - }, - overrides: [ - { - files: ['**/*.ts?(x)'], - rules: { - 'lines-between-class-members': 'off', - '@typescript-eslint/lines-between-class-members': 'off', - - 'no-array-constructor': 'off', - '@typescript-eslint/no-array-constructor': 'error', - - 'init-declarations': 'off', - '@typescript-eslint/init-declarations': 'off', - - '@typescript-eslint/adjacent-overload-signatures': 'error', - '@typescript-eslint/ban-tslint-comment': 'error', - '@typescript-eslint/consistent-indexed-object-style': 'off', - '@typescript-eslint/consistent-type-definitions': 'off', - '@typescript-eslint/consistent-type-imports': 'off', // I think I prefer typed imports, but you can't always use them - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/member-delimiter-style': 'off', - '@typescript-eslint/member-ordering': 'off', - '@typescript-eslint/method-signature-style': 'off', - '@typescript-eslint/naming-convention': 'off', - '@typescript-eslint/no-confusing-non-null-assertion': 'off', // prettier reformats their "correct" example anyway 🤷‍♂️ - '@typescript-eslint/no-extra-non-null-assertion': 'error', - '@typescript-eslint/no-non-null-assertion': 'error', - '@typescript-eslint/no-parameter-properties': 'error', // yeah, I don't like this feature - '@typescript-eslint/no-type-alias': 'off', - '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn', - '@typescript-eslint/prefer-for-of': 'off', // I prefer for of, but I don't want to lint for it - '@typescript-eslint/sort-type-union-intersection-members': 'off', - '@typescript-eslint/typedef': 'off', - }, - }, - ], -}