From 1575f46143ba3264b223af2a0c7eb803159ca9d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 4 Sep 2021 18:57:32 +0200 Subject: [PATCH] feat: support ESLint 8.x BREAKING CHANGE: Requires Node@^12.22.0 || ^14.17.0 || >=16.0.0 BREAKING CHANGE: Requires ESLint@^8.0.0 --- .github/workflows/validate.yml | 10 ++++---- README.md | 16 ++++++------- best-practices.js | 42 +++++++++++++++------------------- jest.js | 2 +- package.json | 34 +++++++++++++-------------- possible-errors.js | 4 +--- stylistic.js | 5 +--- 7 files changed, 50 insertions(+), 63 deletions(-) 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..1d0f4ab 100644 --- a/README.md +++ b/README.md @@ -97,17 +97,16 @@ 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 + ESLint doesn't support. It also 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. +- The default config actually is composed of several configurations which can be + used 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. The `import` config also has a `possible-errors.js`, + `best-practices.js`, and `stylistic.js` which it is composed of as well. #### Example of highly customized config @@ -116,7 +115,6 @@ module.exports = { extends: [ 'kentcdodds/possible-errors', 'kentcdodds/best-practices', - 'kentcdodds/es6/possible-errors', 'kentcdodds/import', 'kentcdodds/jest', ], diff --git a/best-practices.js b/best-practices.js index f7759ea..1e98b23 100644 --- a/best-practices.js +++ b/best-practices.js @@ -19,6 +19,7 @@ module.exports = { 'no-caller': 'error', 'no-case-declarations': 'error', 'no-constructor-return': 'error', + 'no-delete-var': 'error', 'no-div-regex': 'error', 'no-else-return': 'off', 'no-empty-function': 'off', // we're all grown ups here... @@ -35,6 +36,7 @@ module.exports = { 'no-implied-eval': 'error', 'no-invalid-this': 'error', 'no-iterator': 'error', + 'no-label-var': 'error', 'no-labels': 'error', 'no-lone-blocks': 'error', 'no-loop-func': 'error', @@ -49,6 +51,7 @@ module.exports = { 'no-param-reassign': 'off', 'no-proto': 'error', 'no-redeclare': 'error', + 'no-restricted-globals': ['error', 'event', 'fdescribe'], 'no-restricted-properties': 'off', // no ideas of what to disallow right now... 'no-return-assign': 'error', 'no-return-await': 'error', @@ -56,10 +59,24 @@ module.exports = { 'no-self-assign': 'error', 'no-self-compare': 'error', 'no-sequences': 'error', + 'no-shadow': 'error', + 'no-shadow-restricted-names': 'error', 'no-throw-literal': 'error', + 'no-undef': 'error', + 'no-undef-init': 'error', + 'no-undefined': 'off', 'no-unmodified-loop-condition': 'error', 'no-unused-expressions': 'off', 'no-unused-labels': 'error', + 'no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^ignored', + args: 'after-used', + ignoreRestSiblings: true, + }, + ], 'no-useless-call': 'error', 'no-useless-catch': 'error', 'no-useless-concat': 'error', @@ -74,30 +91,9 @@ module.exports = { radix: 'error', 'require-await': 'off', 'require-unicode-regexp': 'off', + strict: 'error', '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: [ { @@ -209,8 +205,6 @@ module.exports = { '@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/jest.js b/jest.js index 0caf55d..8f3e778 100644 --- a/jest.js +++ b/jest.js @@ -99,7 +99,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/package.json b/package.json index 0daef4b..876d6de 100644 --- a/package.json +++ b/package.json @@ -33,38 +33,38 @@ }, "homepage": "https://github.com/kentcdodds/eslint-config-kentcdodds#readme", "dependencies": { - "@babel/core": "^7.15.5", - "@babel/eslint-parser": "^7.15.4", + "@babel/core": "^7.16.0", + "@babel/eslint-parser": "^7.16.3", "@babel/eslint-plugin": "^7.14.5", - "@babel/preset-react": "^7.14.5", - "@typescript-eslint/eslint-plugin": "^4.30.0", - "@typescript-eslint/parser": "^4.30.0", + "@babel/preset-react": "^7.16.0", + "@typescript-eslint/eslint-plugin": "^5.3.1", + "@typescript-eslint/parser": "^5.3.1", "eslint-config-prettier": "^8.3.0", - "eslint-plugin-import": "^2.24.2", - "eslint-plugin-jest": "^24.4.0", - "eslint-plugin-jest-dom": "^3.9.0", - "eslint-plugin-jsx-a11y": "^6.4.1", - "eslint-plugin-react": "^7.25.1", - "eslint-plugin-react-hooks": "^4.2.0", - "eslint-plugin-testing-library": "^4.12.0", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-jest": "^25.2.4", + "eslint-plugin-jest-dom": "^3.9.2", + "eslint-plugin-jsx-a11y": "^6.5.1", + "eslint-plugin-react": "^7.27.0", + "eslint-plugin-react-hooks": "^4.3.0", + "eslint-plugin-testing-library": "^5.0.0", "read-pkg-up": "^7.0.1", "semver": "^7.3.5" }, "devDependencies": { "@testing-library/dom": "^7.31.2", "@testing-library/jest-dom": "^5.14.1", - "eslint": "^7.32.0", - "eslint-find-rules": "^3.6.1", + "eslint": "^8.2.0", + "eslint-find-rules": "^4.0.0", "husky": "^6.0.0", "jest": "^27.1.0", "npm-run-all": "^4.1.5", "prettier": "^2.3.2", "pretty-quick": "^3.1.1", "react": "^17.0.2", - "typescript": "^4.4.2" + "typescript": "^4.4.4" }, "peerDependencies": { - "eslint": "^7.5.0", + "eslint": "^8.0.0", "typescript": "^4.0.0" }, "peerDependenciesMeta": { @@ -81,7 +81,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 index cf2758c..79e6bc3 100644 --- a/possible-errors.js +++ b/possible-errors.js @@ -37,13 +37,11 @@ module.exports = { 'no-unreachable-loop': 'error', 'no-unsafe-finally': 'error', 'no-unsafe-negation': 'error', + 'no-use-before-define': ['error', 'nofunc'], 'no-useless-backreference': 'error', 'require-atomic-updates': 'off', 'use-isnan': 'error', 'valid-typeof': 'error', - - // variables - 'no-use-before-define': ['error', 'nofunc'], }, overrides: [ { diff --git a/stylistic.js b/stylistic.js index 33084c5..b98de64 100644 --- a/stylistic.js +++ b/stylistic.js @@ -15,6 +15,7 @@ module.exports = { // 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-depth': ['error', 4], @@ -22,7 +23,6 @@ module.exports = { '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], @@ -52,9 +52,6 @@ module.exports = { 'sort-keys': 'off', 'sort-vars': 'off', 'spaced-comment': 'off', - - // variables - 'init-declarations': 'off', }, overrides: [ {