From 5b03edb47e7f1ede556e69baadbe0b0f0304d8af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sun, 17 Oct 2021 16:00:56 +0200 Subject: [PATCH] feat: support ESLint v8 (#465) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: support ESLint 8.x * feat: support ESLint 8.x * chore: downgrade ESLint to v7 in dev deps * ci: force deps installation for running tests Co-authored-by: Mario Beltrán Alarcón --- .github/workflows/pipeline.yml | 6 ++++-- lib/rules/await-async-query.ts | 1 - lib/rules/await-async-utils.ts | 1 - lib/rules/await-fire-event.ts | 1 - lib/rules/consistent-data-testid.ts | 1 - lib/rules/no-await-sync-events.ts | 1 - lib/rules/no-await-sync-query.ts | 1 - lib/rules/no-container.ts | 1 - lib/rules/no-debugging-utils.ts | 1 - lib/rules/no-dom-import.ts | 1 - lib/rules/no-manual-cleanup.ts | 1 - lib/rules/no-node-access.ts | 1 - lib/rules/no-promise-in-fire-event.ts | 1 - lib/rules/no-render-in-setup.ts | 1 - lib/rules/no-unnecessary-act.ts | 1 - lib/rules/no-wait-for-empty-callback.ts | 1 - lib/rules/no-wait-for-multiple-assertions.ts | 1 - lib/rules/no-wait-for-side-effects.ts | 1 - lib/rules/no-wait-for-snapshot.ts | 1 - lib/rules/prefer-explicit-assert.ts | 1 - lib/rules/prefer-find-by.ts | 1 - lib/rules/prefer-presence-queries.ts | 1 - lib/rules/prefer-query-by-disappearance.ts | 1 - lib/rules/prefer-screen-queries.ts | 1 - lib/rules/prefer-user-event.ts | 1 - lib/rules/prefer-wait-for.ts | 1 - lib/rules/render-result-naming-convention.ts | 1 - package.json | 16 ++++++++-------- tests/fake-rule.ts | 1 - 29 files changed, 12 insertions(+), 37 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 893fcfe9..a1e12a94 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -52,7 +52,7 @@ jobs: strategy: matrix: node: [12.22.0, 12, 14.17.0, 14, '16.0', 16] - eslint: [7.5, 7] + eslint: [7.5, 7, 8] steps: - name: Cancel Previous Runs @@ -72,7 +72,9 @@ jobs: useLockFile: false - name: Install ESLint v${{ matrix.eslint }} - run: npm install --no-save eslint@${{ matrix.eslint }} + # force installation for now until we get ESLint and all plugins updated + # in dev dependencies + run: npm install --no-save --force eslint@${{ matrix.eslint }} - name: Run tests run: npm run test:ci diff --git a/lib/rules/await-async-query.ts b/lib/rules/await-async-query.ts index c3860452..90be4e9f 100644 --- a/lib/rules/await-async-query.ts +++ b/lib/rules/await-async-query.ts @@ -20,7 +20,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Enforce promises from async queries to be handled', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/await-async-utils.ts b/lib/rules/await-async-utils.ts index 6206fe1e..1f23e9fa 100644 --- a/lib/rules/await-async-utils.ts +++ b/lib/rules/await-async-utils.ts @@ -19,7 +19,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Enforce promises from async utils to be awaited properly', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/await-fire-event.ts b/lib/rules/await-fire-event.ts index 912086f2..e6a70568 100644 --- a/lib/rules/await-fire-event.ts +++ b/lib/rules/await-fire-event.ts @@ -19,7 +19,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Enforce promises from `fireEvent` methods to be handled', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/consistent-data-testid.ts b/lib/rules/consistent-data-testid.ts index e799acd0..ed462367 100644 --- a/lib/rules/consistent-data-testid.ts +++ b/lib/rules/consistent-data-testid.ts @@ -18,7 +18,6 @@ export default createTestingLibraryRule({ type: 'suggestion', docs: { description: 'Ensures consistent usage of `data-testid`', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/no-await-sync-events.ts b/lib/rules/no-await-sync-events.ts index bdb407ab..87753dc6 100644 --- a/lib/rules/no-await-sync-events.ts +++ b/lib/rules/no-await-sync-events.ts @@ -21,7 +21,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow unnecessary `await` for sync events', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/no-await-sync-query.ts b/lib/rules/no-await-sync-query.ts index 5e71c9fc..1797aa9d 100644 --- a/lib/rules/no-await-sync-query.ts +++ b/lib/rules/no-await-sync-query.ts @@ -13,7 +13,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow unnecessary `await` for sync queries', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/no-container.ts b/lib/rules/no-container.ts index 3da280b3..e64af6ca 100644 --- a/lib/rules/no-container.ts +++ b/lib/rules/no-container.ts @@ -20,7 +20,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow the use of `container` methods', - category: 'Best Practices', recommendedConfig: { dom: false, angular: 'error', diff --git a/lib/rules/no-debugging-utils.ts b/lib/rules/no-debugging-utils.ts index 3f382b5e..a6357cd5 100644 --- a/lib/rules/no-debugging-utils.ts +++ b/lib/rules/no-debugging-utils.ts @@ -31,7 +31,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow the use of debugging utilities like `debug`', - category: 'Best Practices', recommendedConfig: { dom: false, angular: 'error', diff --git a/lib/rules/no-dom-import.ts b/lib/rules/no-dom-import.ts index 5298eea2..9ae585ee 100644 --- a/lib/rules/no-dom-import.ts +++ b/lib/rules/no-dom-import.ts @@ -18,7 +18,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow importing from DOM Testing Library', - category: 'Best Practices', recommendedConfig: { dom: false, angular: ['error', 'angular'], diff --git a/lib/rules/no-manual-cleanup.ts b/lib/rules/no-manual-cleanup.ts index 506dc9c8..45d4a1c2 100644 --- a/lib/rules/no-manual-cleanup.ts +++ b/lib/rules/no-manual-cleanup.ts @@ -29,7 +29,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow the use of `cleanup`', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/no-node-access.ts b/lib/rules/no-node-access.ts index a9e4ce4e..36d232be 100644 --- a/lib/rules/no-node-access.ts +++ b/lib/rules/no-node-access.ts @@ -13,7 +13,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow direct Node access', - category: 'Best Practices', recommendedConfig: { dom: false, angular: 'error', diff --git a/lib/rules/no-promise-in-fire-event.ts b/lib/rules/no-promise-in-fire-event.ts index ea1c6f8b..01027201 100644 --- a/lib/rules/no-promise-in-fire-event.ts +++ b/lib/rules/no-promise-in-fire-event.ts @@ -20,7 +20,6 @@ export default createTestingLibraryRule({ docs: { description: 'Disallow the use of promises passed to a `fireEvent` method', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/no-render-in-setup.ts b/lib/rules/no-render-in-setup.ts index 89db8ef6..29f9a442 100644 --- a/lib/rules/no-render-in-setup.ts +++ b/lib/rules/no-render-in-setup.ts @@ -50,7 +50,6 @@ export default createTestingLibraryRule({ docs: { description: 'Disallow the use of `render` in testing frameworks setup functions', - category: 'Best Practices', recommendedConfig: { dom: false, angular: 'error', diff --git a/lib/rules/no-unnecessary-act.ts b/lib/rules/no-unnecessary-act.ts index 5bdf4fd2..5cd9f4b1 100644 --- a/lib/rules/no-unnecessary-act.ts +++ b/lib/rules/no-unnecessary-act.ts @@ -23,7 +23,6 @@ export default createTestingLibraryRule({ docs: { description: 'Disallow wrapping Testing Library utils or empty callbacks in `act`', - category: 'Possible Errors', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/no-wait-for-empty-callback.ts b/lib/rules/no-wait-for-empty-callback.ts index d731ecd7..7bbfef99 100644 --- a/lib/rules/no-wait-for-empty-callback.ts +++ b/lib/rules/no-wait-for-empty-callback.ts @@ -18,7 +18,6 @@ export default createTestingLibraryRule({ docs: { description: 'Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved`', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/no-wait-for-multiple-assertions.ts b/lib/rules/no-wait-for-multiple-assertions.ts index 171dd290..f3f23ebd 100644 --- a/lib/rules/no-wait-for-multiple-assertions.ts +++ b/lib/rules/no-wait-for-multiple-assertions.ts @@ -17,7 +17,6 @@ export default createTestingLibraryRule({ docs: { description: 'Disallow the use of multiple `expect` calls inside `waitFor`', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/no-wait-for-side-effects.ts b/lib/rules/no-wait-for-side-effects.ts index 2049f907..4c919245 100644 --- a/lib/rules/no-wait-for-side-effects.ts +++ b/lib/rules/no-wait-for-side-effects.ts @@ -20,7 +20,6 @@ export default createTestingLibraryRule({ type: 'suggestion', docs: { description: 'Disallow the use of side effects in `waitFor`', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/no-wait-for-snapshot.ts b/lib/rules/no-wait-for-snapshot.ts index 9b7ddd01..96450678 100644 --- a/lib/rules/no-wait-for-snapshot.ts +++ b/lib/rules/no-wait-for-snapshot.ts @@ -19,7 +19,6 @@ export default createTestingLibraryRule({ docs: { description: 'Ensures no snapshot is generated inside of a `waitFor` call', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/prefer-explicit-assert.ts b/lib/rules/prefer-explicit-assert.ts index 86e1f4ed..a8d376f0 100644 --- a/lib/rules/prefer-explicit-assert.ts +++ b/lib/rules/prefer-explicit-assert.ts @@ -69,7 +69,6 @@ export default createTestingLibraryRule({ docs: { description: 'Suggest using explicit assertions rather than standalone queries', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/prefer-find-by.ts b/lib/rules/prefer-find-by.ts index 40bb865a..460eab38 100644 --- a/lib/rules/prefer-find-by.ts +++ b/lib/rules/prefer-find-by.ts @@ -56,7 +56,6 @@ export default createTestingLibraryRule({ docs: { description: 'Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/prefer-presence-queries.ts b/lib/rules/prefer-presence-queries.ts index d07bf999..611cf5ed 100644 --- a/lib/rules/prefer-presence-queries.ts +++ b/lib/rules/prefer-presence-queries.ts @@ -11,7 +11,6 @@ export default createTestingLibraryRule({ name: RULE_NAME, meta: { docs: { - category: 'Best Practices', description: 'Ensure appropriate `get*`/`query*` queries are used with their respective matchers', recommendedConfig: { diff --git a/lib/rules/prefer-query-by-disappearance.ts b/lib/rules/prefer-query-by-disappearance.ts index cc2d6671..bbb2a9e6 100644 --- a/lib/rules/prefer-query-by-disappearance.ts +++ b/lib/rules/prefer-query-by-disappearance.ts @@ -23,7 +23,6 @@ export default createTestingLibraryRule({ docs: { description: 'Suggest using `queryBy*` queries when waiting for disappearance', - category: 'Possible Errors', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/prefer-screen-queries.ts b/lib/rules/prefer-screen-queries.ts index bca47eef..acca7c5a 100644 --- a/lib/rules/prefer-screen-queries.ts +++ b/lib/rules/prefer-screen-queries.ts @@ -40,7 +40,6 @@ export default createTestingLibraryRule({ type: 'suggestion', docs: { description: 'Suggest using `screen` while querying', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/prefer-user-event.ts b/lib/rules/prefer-user-event.ts index 76f37f93..2e0a8958 100644 --- a/lib/rules/prefer-user-event.ts +++ b/lib/rules/prefer-user-event.ts @@ -71,7 +71,6 @@ export default createTestingLibraryRule({ docs: { description: 'Suggest using `userEvent` over `fireEvent` for simulating user interactions', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/prefer-wait-for.ts b/lib/rules/prefer-wait-for.ts index fc8f654b..a302ee1c 100644 --- a/lib/rules/prefer-wait-for.ts +++ b/lib/rules/prefer-wait-for.ts @@ -26,7 +26,6 @@ export default createTestingLibraryRule({ type: 'suggestion', docs: { description: 'Use `waitFor` instead of deprecated wait methods', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/render-result-naming-convention.ts b/lib/rules/render-result-naming-convention.ts index 8e9d9e4f..046ce4ed 100644 --- a/lib/rules/render-result-naming-convention.ts +++ b/lib/rules/render-result-naming-convention.ts @@ -24,7 +24,6 @@ export default createTestingLibraryRule({ type: 'suggestion', docs: { description: 'Enforce a valid naming for return value from `render`', - category: 'Best Practices', recommendedConfig: { dom: false, angular: 'error', diff --git a/package.json b/package.json index e9edaadd..94f839e5 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "prepare": "is-ci || husky install" }, "dependencies": { - "@typescript-eslint/experimental-utils": "^4.30.0" + "@typescript-eslint/experimental-utils": "^5.0.0" }, "devDependencies": { "@babel/eslint-plugin": "^7.14.5", @@ -50,17 +50,17 @@ "@commitlint/config-conventional": "^13.2.0", "@types/jest": "^27.0.2", "@types/node": "^16.10.6", - "@typescript-eslint/eslint-plugin": "^4.30.0", - "@typescript-eslint/parser": "^4.30.0", + "@typescript-eslint/eslint-plugin": "^5.0.0", + "@typescript-eslint/parser": "^5.0.0", "cpy-cli": "^3.1.1", "eslint": "^7.32.0", - "eslint-config-kentcdodds": "^19.1.1", + "eslint-config-kentcdodds": "^19.2.0", "eslint-config-prettier": "^8.3.0", - "eslint-plugin-import": "^2.24.2", - "eslint-plugin-jest": "^24.4.0", + "eslint-plugin-import": "^2.25.2", + "eslint-plugin-jest": "^25.0.6", "eslint-plugin-jest-formatting": "^3.0.0", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^3.4.1", + "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-promise": "^5.1.0", "husky": "^7.0.2", "is-ci": "^3.0.0", @@ -73,7 +73,7 @@ "typescript": "^4.4.4" }, "peerDependencies": { - "eslint": "^7.5.0" + "eslint": "^7.5.0 || ^8.0.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0", diff --git a/tests/fake-rule.ts b/tests/fake-rule.ts index 70a8d5da..9f57493e 100644 --- a/tests/fake-rule.ts +++ b/tests/fake-rule.ts @@ -26,7 +26,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Fake rule to test rule maker and detection helpers', - category: 'Possible Errors', recommendedConfig: { dom: false, angular: false,