diff --git a/.config/husky/.gitignore b/.config/husky/.gitignore deleted file mode 100644 index 31354ec..0000000 --- a/.config/husky/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_ diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 6ea95e6..aed0cdb 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -16,11 +16,11 @@ jobs: if: ${{ !contains(github.head_ref, 'all-contributors') }} strategy: matrix: - node: [10, 12, 14, 16] + node: [12.22.0, 12, 14.17.0, 14, 16.0.0, 16] runs-on: ubuntu-latest steps: - name: 🛑 Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.9.0 + uses: styfle/cancel-workflow-action@0.9.1 - name: ⬇️ Checkout repo uses: actions/checkout@v2 @@ -50,7 +50,7 @@ jobs: github.ref) && github.event_name == 'push' }} steps: - name: 🛑 Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.9.0 + uses: styfle/cancel-workflow-action@0.9.1 - name: ⬇️ Checkout repo uses: actions/checkout@v2 @@ -58,7 +58,7 @@ jobs: - name: ⎔ Setup node uses: actions/setup-node@v2 with: - node-version: 14 + node-version: 16 - name: 📥 Download deps uses: bahmutov/npm-install@v1 @@ -68,7 +68,7 @@ jobs: - name: 🚀 Release uses: cycjimmy/semantic-release-action@v2 with: - semantic_version: 17 + semantic_version: 18 branches: | [ '+([0-9])?(.{+([0-9]),x}).x', diff --git a/README.md b/README.md index 468705e..12089b6 100644 --- a/README.md +++ b/README.md @@ -96,30 +96,17 @@ for it. ### Things to know -- The default config uses `@babel/eslint-parser` to support stage features that - ESLint doesn't support and it opts to use the `@babel/eslint-plugin` rules - over the ESLint rules to support rules for these features as well. - 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/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/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..cf17884 --- /dev/null +++ b/import.js @@ -0,0 +1,82 @@ +module.exports = { + env: { + es6: true, + }, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + plugins: ['import'], + settings: { + 'import/ignore': ['node_modules', '.json$', '.(scss|less|css|styl)$'], + }, + rules: { + '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..1473f30 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,424 @@ +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, + es6: true, + node: true, + }, + extends: ['prettier', './import.js'], + rules: { + 'accessor-pairs': 'error', + 'array-callback-return': 'error', + 'arrow-body-style': 'off', + '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 + 'constructor-super': 'error', + 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-class-assign': 'error', + 'no-compare-neg-zero': 'error', + 'no-cond-assign': 'error', + 'no-console': 'off', + 'no-const-assign': 'error', + '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-class-members': 'error', + 'no-dupe-else-if': 'error', + 'no-dupe-keys': 'error', + 'no-duplicate-case': 'error', + 'no-duplicate-imports': '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-symbol': '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-exports': 'off', // not applicable for a config preset (should be configured only in projects) + 'no-restricted-globals': ['error', 'event', 'fdescribe'], + 'no-restricted-imports': 'off', // not applicable for a config preset (should be configured only in projects) + '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-this-before-super': 'error', + '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-unsafe-optional-chaining': 'error', + 'no-unused-expressions': 'off', + 'no-unused-labels': 'error', + 'no-unused-private-class-members': '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-computed-key': 'error', + 'no-useless-concat': 'error', + 'no-useless-constructor': 'error', + 'no-useless-escape': 'error', + 'no-useless-rename': 'error', + 'no-useless-return': 'error', + 'no-var': 'error', + 'no-void': 'off', + 'no-warning-comments': ['error', {location: 'anywhere', terms: ['fixme']}], + 'no-with': 'off', + 'object-shorthand': ['error', 'properties'], // methods are optional so you can specify a name if you want + 'one-var': ['error', {initialized: 'never', uninitialized: 'always'}], + 'operator-assignment': 'off', // readability on a case-by-case basis + 'padding-line-between-statements': 'off', // meh... + 'prefer-arrow-callback': [ + 'error', + {allowNamedFunctions: true, allowUnboundThis: true}, + ], + 'prefer-const': 'error', + 'prefer-destructuring': 'off', // nah, I like it, but not that much... + 'prefer-exponentiation-operator': 'warn', + 'prefer-named-capture-group': 'off', // maybe one day... But I'm not used to it yet. + 'prefer-numeric-literals': 'error', + 'prefer-object-has-own': 'error', + 'prefer-object-spread': 'warn', + 'prefer-promise-reject-errors': 'off', // maybe one day... Not sure I'm in... + 'prefer-regex-literals': 'off', + 'prefer-rest-params': 'error', + 'prefer-spread': 'error', + 'prefer-template': 'error', + radix: 'error', + 'require-atomic-updates': 'off', + 'require-await': 'off', + 'require-unicode-regexp': 'off', + 'require-yield': 'error', + 'sort-imports': 'off', + 'sort-keys': 'off', + 'sort-vars': 'off', + 'spaced-comment': 'off', + strict: 'error', + 'symbol-description': '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: { + 'constructor-super': 'off', // ts(2335) & ts(2377) + 'getter-return': 'off', // ts(2378) + 'no-const-assign': 'off', // ts(2588) + '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-new-symbol': 'off', // ts(2588) + 'no-obj-calls': 'off', // ts(2349) + 'no-setter-return': 'off', // ts(2408) + 'no-this-before-super': 'off', // ts(2376) + '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 + '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 + + '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-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-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', + }, + ], + + 'no-useless-constructor': 'off', + '@typescript-eslint/no-useless-constructor': 'error', + + '@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..982c393 100644 --- a/jest.js +++ b/jest.js @@ -1,6 +1,13 @@ const readPkgUp = require('read-pkg-up') -const {disableRules, mapDeprecatedRules} = require('./utils') +const disableRules = deprecatedRules => + deprecatedRules.reduce( + (allRules, rule) => ({ + ...allRules, + [rule]: 'off', + }), + {}, + ) let hasJestDom = false let hasTestingLibrary = false @@ -27,10 +34,8 @@ try { const rules = { 'react/display-name': 'off', // we don't need a display name in test files - ...mapDeprecatedRules(['jest/no-expect-resolves']), 'jest/consistent-test-it': 'off', 'jest/expect-expect': 'off', - 'jest/lowercase-name': 'off', 'jest/max-nested-describe': 'error', 'jest/no-alias-methods': 'off', 'jest/no-commented-out-tests': 'warn', @@ -53,17 +58,13 @@ const rules = { 'jest/no-standalone-expect': 'off', 'jest/no-test-prefixes': 'error', 'jest/no-test-return-statement': 'off', - 'jest/no-truthy-falsy': 'off', - 'jest/no-try-expect': 'error', 'jest/prefer-called-with': 'error', 'jest/prefer-expect-assertions': 'off', 'jest/prefer-expect-resolves': 'off', 'jest/prefer-hooks-on-top': 'error', - 'jest/prefer-inline-snapshots': 'off', + 'jest/prefer-lowercase-title': 'off', 'jest/prefer-spy-on': 'off', 'jest/prefer-strict-equal': 'off', - 'jest/prefer-to-be-null': 'off', - 'jest/prefer-to-be-undefined': 'off', 'jest/prefer-to-be': 'off', 'jest/prefer-to-contain': 'warn', 'jest/prefer-to-have-length': 'warn', @@ -72,7 +73,7 @@ const rules = { 'jest/require-to-throw-message': 'off', 'jest/require-top-level-describe': 'off', 'jest/unbound-method': 'off', - 'jest/valid-describe': 'error', + 'jest/valid-describe-callback': 'error', 'jest/valid-expect': 'error', 'jest/valid-expect-in-promise': 'error', 'jest/valid-title': 'warn', @@ -80,16 +81,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), @@ -102,7 +103,7 @@ const rules = { 'testing-library/no-await-sync-events': 'error', 'testing-library/no-await-sync-query': 'error', 'testing-library/no-container': 'error', - 'testing-library/no-debug': 'error', + 'testing-library/no-debugging-utils': 'error', 'testing-library/no-dom-import': ['error', 'react'], 'testing-library/no-manual-cleanup': 'error', 'testing-library/no-node-access': 'error', diff --git a/jsx-a11y.js b/jsx-a11y.js index bf12f99..d2e7edf 100644 --- a/jsx-a11y.js +++ b/jsx-a11y.js @@ -1,5 +1,3 @@ -const {mapDeprecatedRules} = require('./utils') - module.exports = { env: { browser: true, @@ -11,9 +9,6 @@ module.exports = { }, plugins: ['jsx-a11y'], rules: { - ...mapDeprecatedRules([ - 'jsx-a11y/label-has-for', // see label-has-associated-control - ]), 'jsx-a11y/accessible-emoji': 'error', 'jsx-a11y/alt-text': 'warn', 'jsx-a11y/anchor-has-content': 'error', 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/package.json b/package.json index 4c621fc..1878c04 100644 --- a/package.json +++ b/package.json @@ -33,30 +33,26 @@ }, "homepage": "https://github.com/kentcdodds/eslint-config-kentcdodds#readme", "dependencies": { - "@babel/core": "^7.16.5", - "@babel/eslint-parser": "^7.16.5", - "@babel/eslint-plugin": "^7.16.5", - "@babel/preset-react": "^7.16.5", - "@typescript-eslint/eslint-plugin": "^4.33.0", - "@typescript-eslint/parser": "^4.33.0", + "@typescript-eslint/eslint-plugin": "^5.9.0", + "@typescript-eslint/parser": "^5.9.0", "eslint-config-prettier": "^8.3.0", - "eslint-plugin-import": "^2.25.3", - "eslint-plugin-jest": "^24.7.0", - "eslint-plugin-jest-dom": "^3.9.4", + "eslint-plugin-import": "^2.25.4", + "eslint-plugin-jest": "^25.3.4", + "eslint-plugin-jest-dom": "^4.0.1", "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-react": "^7.28.0", "eslint-plugin-react-hooks": "^4.3.0", - "eslint-plugin-testing-library": "^4.12.4", + "eslint-plugin-testing-library": "^5.0.1", "read-pkg-up": "^7.0.1", "semver": "^7.3.5" }, "devDependencies": { - "@testing-library/dom": "^7.31.2", + "@testing-library/dom": "^8.11.1", "@testing-library/jest-dom": "^5.16.1", - "eslint": "^7.32.0", - "eslint-find-rules": "^3.6.1", - "husky": "^6.0.0", - "jest": "^27.4.5", + "eslint": "^8.6.0", + "eslint-find-rules": "^4.1.0", + "husky": "^7.0.4", + "jest": "^27.4.7", "npm-run-all": "^4.1.5", "prettier": "^2.5.1", "pretty-quick": "^3.1.3", @@ -64,7 +60,7 @@ "typescript": "^4.5.4" }, "peerDependencies": { - "eslint": "^7.5.0", + "eslint": "^8.0.0", "typescript": "^4.0.0" }, "peerDependenciesMeta": { @@ -81,7 +77,7 @@ "dist" ], "engines": { - "node": "^10.12.0 || >=12.0.0", + "node": "^12.22.0 || ^14.17.0 || >=16.0.0", "npm": ">=6", "yarn": ">=1" } 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', - }, - }, - ], -} diff --git a/utils.js b/utils.js deleted file mode 100644 index 611cd7d..0000000 --- a/utils.js +++ /dev/null @@ -1,12 +0,0 @@ -const disableRules = deprecatedRules => - deprecatedRules.reduce( - (allRules, rule) => ({ - ...allRules, - [rule]: 'off', - }), - {}, - ) - -const mapDeprecatedRules = disableRules - -module.exports = {disableRules, mapDeprecatedRules}