From aaf62cd0da1ada072101d4d84b6a66a35d82425c Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 7 Jun 2025 11:15:38 +1200 Subject: [PATCH 01/13] feat: drop support for Node v16 BREAKING CHANGE: dropped support for Node v16 --- .github/workflows/nodejs.yml | 11 +---------- package.json | 6 +++--- tsconfig.json | 2 +- yarn.lock | 29 +++++++++++++++++++---------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 222b2f8ff..44d5841c5 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -72,19 +72,10 @@ jobs: strategy: fail-fast: false matrix: - node-version: [16.x, 18.x, 20.x, 21.x, 22.x, 23.x, 24.x] + node-version: [18.x, 20.x, 21.x, 22.x, 23.x, 24.x] eslint-version: [7, 8, 9] ts-eslint-plugin-version: [6, 7, 8] exclude: - # ts-eslint/plugin@7 doesn't support node@16 - - node-version: 16.x - ts-eslint-plugin-version: 7 - # ts-eslint/plugin@8 doesn't support node@16 - - node-version: 16.x - ts-eslint-plugin-version: 8 - # eslint@9 doesn't support node@16 - - node-version: 16.x - eslint-version: 9 # ts-eslint/plugin@7 doesn't support eslint@7 - eslint-version: 7 ts-eslint-plugin-version: 7 diff --git a/package.json b/package.json index 06b32b635..3ccd4c0c4 100644 --- a/package.json +++ b/package.json @@ -80,10 +80,10 @@ "@schemastore/package": "^0.0.10", "@semantic-release/changelog": "^6.0.0", "@semantic-release/git": "^10.0.0", - "@tsconfig/node16": "^16.0.0", + "@tsconfig/node18": "^18.0.0", "@types/eslint": "^8.4.6", "@types/jest": "^29.0.0", - "@types/node": "^16.0.0", + "@types/node": "^18.0.0", "@types/semver": "^7.5.8", "@typescript-eslint/eslint-plugin": "^8.0.0", "@typescript-eslint/parser": "^8.0.0", @@ -129,7 +129,7 @@ }, "packageManager": "yarn@3.8.7", "engines": { - "node": "^16.10.0 || ^18.12.0 || >=20.0.0" + "node": "^18.12.0 || >=20.0.0" }, "publishConfig": { "provenance": true diff --git a/tsconfig.json b/tsconfig.json index bf3a1fbf5..e9138bb39 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "@tsconfig/node16/tsconfig.json", + "extends": "@tsconfig/node18/tsconfig.json", "compilerOptions": { "noEmit": true, "stripInternal": true, diff --git a/yarn.lock b/yarn.lock index a89a3780a..fa2aa6894 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2667,10 +2667,10 @@ __metadata: languageName: node linkType: hard -"@tsconfig/node16@npm:^16.0.0": - version: 16.1.4 - resolution: "@tsconfig/node16@npm:16.1.4" - checksum: 99ed9232899f6e92b2c05cd7c7d16bae7dd9250d14d1af5d8f280023a47960c14c1ba4184e600231a21d70f02c2b2dba3ceb92e643b57aede1eaee2232a732c4 +"@tsconfig/node18@npm:^18.0.0": + version: 18.2.4 + resolution: "@tsconfig/node18@npm:18.2.4" + checksum: 80623cb9c129c78d51fe6c4a256ba986f12f02ff02dc2a1e5b33dd13a7983f767b6792cfcd51b3dd1c8256ea105f1fea31f64a2070564e37787ab3d9a1a1e7e3 languageName: node linkType: hard @@ -2830,10 +2830,12 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^16.0.0": - version: 16.18.126 - resolution: "@types/node@npm:16.18.126" - checksum: 86112e7499f8a4d1bb60696cab0bf464adf3c141fca4bc5451e8f3aba5736529b76d4b4396edb21e5d7c19592852f7d6cb81ee70074fd13bde2db2d0db720467 +"@types/node@npm:^18.0.0": + version: 18.19.111 + resolution: "@types/node@npm:18.19.111" + dependencies: + undici-types: ~5.26.4 + checksum: 0696f422bf8c70e01255397767cea2938287d819e5ac92242f0e5629ab69f25ac22c811d0f4f3ae727c6b4f678f88737aa568b17404047cfcf3ea2b1f47786b3 languageName: node linkType: hard @@ -5146,10 +5148,10 @@ __metadata: "@schemastore/package": ^0.0.10 "@semantic-release/changelog": ^6.0.0 "@semantic-release/git": ^10.0.0 - "@tsconfig/node16": ^16.0.0 + "@tsconfig/node18": ^18.0.0 "@types/eslint": ^8.4.6 "@types/jest": ^29.0.0 - "@types/node": ^16.0.0 + "@types/node": ^18.0.0 "@types/semver": ^7.5.8 "@typescript-eslint/eslint-plugin": ^8.0.0 "@typescript-eslint/parser": ^8.0.0 @@ -11399,6 +11401,13 @@ __metadata: languageName: node linkType: hard +"undici-types@npm:~5.26.4": + version: 5.26.5 + resolution: "undici-types@npm:5.26.5" + checksum: 3192ef6f3fd5df652f2dc1cd782b49d6ff14dc98e5dced492aa8a8c65425227da5da6aafe22523c67f035a272c599bb89cfe803c1db6311e44bed3042fc25487 + languageName: node + linkType: hard + "undici-types@npm:~7.8.0": version: 7.8.0 resolution: "undici-types@npm:7.8.0" From a366393fb38a55c91d0200791315e727fcfe3e90 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 7 Jun 2025 11:17:04 +1200 Subject: [PATCH 02/13] feat: drop support for Node v21 BREAKING CHANGE: dropped support for Node v21 --- .github/workflows/nodejs.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 44d5841c5..35e7e42ad 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -72,7 +72,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [18.x, 20.x, 21.x, 22.x, 23.x, 24.x] + node-version: [18.x, 20.x, 22.x, 23.x, 24.x] eslint-version: [7, 8, 9] ts-eslint-plugin-version: [6, 7, 8] exclude: diff --git a/package.json b/package.json index 3ccd4c0c4..587f23f14 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,7 @@ }, "packageManager": "yarn@3.8.7", "engines": { - "node": "^18.12.0 || >=20.0.0" + "node": "^18.12.0 || ^20.0.0 || >=22.0.0" }, "publishConfig": { "provenance": true From b06e7d000fd730c24c7eb7a21d34e5cf92b30835 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 7 Jun 2025 11:23:04 +1200 Subject: [PATCH 03/13] feat: drop support for ESLint v7 BREAKING CHANGE: dropped support for ESLint v7 --- .github/workflows/nodejs.yml | 9 +------ package.json | 4 +-- src/rules/__tests__/test-utils.ts | 45 +++---------------------------- yarn.lock | 6 ++--- 4 files changed, 9 insertions(+), 55 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 35e7e42ad..9006c84ac 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -73,15 +73,8 @@ jobs: fail-fast: false matrix: node-version: [18.x, 20.x, 22.x, 23.x, 24.x] - eslint-version: [7, 8, 9] + eslint-version: [8, 9] ts-eslint-plugin-version: [6, 7, 8] - exclude: - # ts-eslint/plugin@7 doesn't support eslint@7 - - eslint-version: 7 - ts-eslint-plugin-version: 7 - # ts-eslint/plugin@8 doesn't support eslint@7 - - eslint-version: 7 - ts-eslint-plugin-version: 8 runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index 587f23f14..50ee4227f 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "babel-jest": "^29.0.0", "babel-plugin-replace-ts-export-assignment": "^0.0.2", "dedent": "^1.5.0", - "eslint": "^7.0.0 || ^8.0.0", + "eslint": "^8.0.0", "eslint-config-prettier": "^10.0.0", "eslint-doc-generator": "^2.0.0", "eslint-plugin-eslint-plugin": "^6.0.0", @@ -116,7 +116,7 @@ }, "peerDependencies": { "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0", - "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0", + "eslint": "^8.0.0 || ^9.0.0", "jest": "*" }, "peerDependenciesMeta": { diff --git a/src/rules/__tests__/test-utils.ts b/src/rules/__tests__/test-utils.ts index e4fe80132..2acaeb51c 100644 --- a/src/rules/__tests__/test-utils.ts +++ b/src/rules/__tests__/test-utils.ts @@ -8,8 +8,7 @@ const eslintRequire = createRequire(require.resolve('eslint')); export const espreeParser = eslintRequire.resolve('espree'); -export const eslintMajorVersion = semver.major(eslintVersion); -export const usingFlatConfig = eslintMajorVersion >= 9; +export const usingFlatConfig = semver.major(eslintVersion) >= 9; export class FlatCompatRuleTester extends TSESLint.RuleTester { public constructor(testerConfig?: TSESLint.RuleTesterConfig) { @@ -25,49 +24,11 @@ export class FlatCompatRuleTester extends TSESLint.RuleTester { tests: TSESLint.RunTests, ) { super.run(ruleName, rule, { - valid: FlatCompatRuleTester._filterCases( - tests.valid.map(t => FlatCompatRuleTester._flatCompat(t)), - ), - invalid: FlatCompatRuleTester._filterCases( - tests.invalid.map(t => FlatCompatRuleTester._flatCompat(t)), - ), + valid: tests.valid.map(t => FlatCompatRuleTester._flatCompat(t)), + invalid: tests.invalid.map(t => FlatCompatRuleTester._flatCompat(t)), }); } - /* istanbul ignore next */ - /** - * Filters out test cases that are using ecma version 2022 or higher when running - * on ESLint v7 - * @private - */ - private static _filterCases< - T extends - | string - | TSESLint.ValidTestCase - | TSESLint.InvalidTestCase, - >(tests: T[]): T[] { - if (semver.major(eslintVersion) > 7) { - return tests; - } - - const filtered = tests.filter( - t => - typeof t === 'string' || - !t.parserOptions?.ecmaVersion || - t.parserOptions.ecmaVersion === 'latest' || - t.parserOptions.ecmaVersion < 2022, - ); - - // print the number of tests that were filtered - if (filtered.length !== tests.length) { - console.warn( - `Filtered ${tests.length - filtered.length} tests due to unsupported parser options.`, - ); - } - - return filtered; - } - /* istanbul ignore next */ private static _flatCompat< T extends diff --git a/yarn.lock b/yarn.lock index fa2aa6894..7d5592cad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5159,7 +5159,7 @@ __metadata: babel-jest: ^29.0.0 babel-plugin-replace-ts-export-assignment: ^0.0.2 dedent: ^1.5.0 - eslint: ^7.0.0 || ^8.0.0 + eslint: ^8.0.0 eslint-config-prettier: ^10.0.0 eslint-doc-generator: ^2.0.0 eslint-plugin-eslint-plugin: ^6.0.0 @@ -5183,7 +5183,7 @@ __metadata: typescript: ^5.0.4 peerDependencies: "@typescript-eslint/eslint-plugin": ^6.0.0 || ^7.0.0 || ^8.0.0 - eslint: ^7.0.0 || ^8.0.0 || ^9.0.0 + eslint: ^8.0.0 || ^9.0.0 jest: "*" peerDependenciesMeta: "@typescript-eslint/eslint-plugin": @@ -5287,7 +5287,7 @@ __metadata: languageName: node linkType: hard -"eslint@npm:^7.0.0 || ^8.0.0": +"eslint@npm:^8.0.0": version: 8.57.1 resolution: "eslint@npm:8.57.1" dependencies: From d3bf1dcec9322304a37fe45e6a5cdeee7775c543 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Sat, 7 Jun 2025 11:34:26 +1200 Subject: [PATCH 04/13] fix: remove `jest/no-alias-methods` from `styles` config BREAKING CHANGE: `jest/no-alias-methods` has been removed from the `styles` config as its already in the `recommended` config --- README.md | 2 +- docs/rules/no-alias-methods.md | 4 +--- src/__tests__/__snapshots__/rules.test.ts.snap | 2 -- src/index.ts | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7687b1cb3..79064c319 100644 --- a/README.md +++ b/README.md @@ -329,7 +329,7 @@ Manually fixable by | [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | | ✅ | | | | [max-expects](docs/rules/max-expects.md) | Enforces a maximum number assertion calls in a test body | | | | | | [max-nested-describe](docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | | | | | -| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ✅ | 🎨 | 🔧 | | +| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ✅ | | 🔧 | | | [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | | ✅ | | | | [no-conditional-expect](docs/rules/no-conditional-expect.md) | Disallow calling `expect` conditionally | ✅ | | | | | [no-conditional-in-test](docs/rules/no-conditional-in-test.md) | Disallow conditional logic in tests | | | | | diff --git a/docs/rules/no-alias-methods.md b/docs/rules/no-alias-methods.md index 0df4fcb32..6796de373 100644 --- a/docs/rules/no-alias-methods.md +++ b/docs/rules/no-alias-methods.md @@ -1,8 +1,6 @@ # Disallow alias methods (`no-alias-methods`) -💼⚠️ This rule is enabled in the ✅ `recommended` -[config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations). -This rule _warns_ in the 🎨 `style` +💼 This rule is enabled in the ✅ `recommended` [config](https://github.com/jest-community/eslint-plugin-jest/blob/main/README.md#shareable-configurations). 🔧 This rule is automatically fixable by the diff --git a/src/__tests__/__snapshots__/rules.test.ts.snap b/src/__tests__/__snapshots__/rules.test.ts.snap index 06883704c..9e436ad59 100644 --- a/src/__tests__/__snapshots__/rules.test.ts.snap +++ b/src/__tests__/__snapshots__/rules.test.ts.snap @@ -242,7 +242,6 @@ exports[`rules should export configs that refer to actual rules 1`] = ` }, }, "rules": { - "jest/no-alias-methods": "warn", "jest/prefer-to-be": "error", "jest/prefer-to-contain": "error", "jest/prefer-to-have-length": "error", @@ -285,7 +284,6 @@ exports[`rules should export configs that refer to actual rules 1`] = ` "jest", ], "rules": { - "jest/no-alias-methods": "warn", "jest/prefer-to-be": "error", "jest/prefer-to-contain": "error", "jest/prefer-to-have-length": "error", diff --git a/src/index.ts b/src/index.ts index 52b142983..e32f97b52 100644 --- a/src/index.ts +++ b/src/index.ts @@ -53,7 +53,6 @@ const recommendedRules = { } satisfies Record; const styleRules = { - 'jest/no-alias-methods': 'warn', 'jest/prefer-to-be': 'error', 'jest/prefer-to-contain': 'error', 'jest/prefer-to-have-length': 'error', From fe61a409d41ef4e7ab8137b8b3d3f66cee6d40a6 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Sat, 7 Jun 2025 11:36:55 +1200 Subject: [PATCH 05/13] feat: drop support for `@typescript-eslint` v6 BREAKING CHANGE: dropped support for `@typescript-eslint` v6 --- .github/workflows/nodejs.yml | 2 +- package.json | 4 ++-- yarn.lock | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 9006c84ac..5f97b0554 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -74,7 +74,7 @@ jobs: matrix: node-version: [18.x, 20.x, 22.x, 23.x, 24.x] eslint-version: [8, 9] - ts-eslint-plugin-version: [6, 7, 8] + ts-eslint-plugin-version: [7, 8] runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index 50ee4227f..4d2dc78a3 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ ] }, "dependencies": { - "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0" + "@typescript-eslint/utils": "^7.0.0 || ^8.0.0" }, "devDependencies": { "@babel/cli": "^7.4.4", @@ -115,7 +115,7 @@ "typescript": "^5.0.4" }, "peerDependencies": { - "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0", + "@typescript-eslint/eslint-plugin": "^7.0.0 || ^8.0.0", "eslint": "^8.0.0 || ^9.0.0", "jest": "*" }, diff --git a/yarn.lock b/yarn.lock index 7d5592cad..35cc2d268 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5182,7 +5182,7 @@ __metadata: ts-node: ^10.2.1 typescript: ^5.0.4 peerDependencies: - "@typescript-eslint/eslint-plugin": ^6.0.0 || ^7.0.0 || ^8.0.0 + "@typescript-eslint/eslint-plugin": ^7.0.0 || ^8.0.0 eslint: ^8.0.0 || ^9.0.0 jest: "*" peerDependenciesMeta: From 5ca65d3f941e5c0684876c20f251e2d467fc5a15 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Sat, 7 Jun 2025 11:53:57 +1200 Subject: [PATCH 06/13] feat: drop support for `@typescript-eslint` v7 BREAKING CHANGE: dropped support for `@typescript-eslint` v7 --- .github/workflows/nodejs.yml | 2 +- package.json | 4 +- yarn.lock | 130 ++++++++++++++++++++++++++++------- 3 files changed, 110 insertions(+), 26 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 5f97b0554..b2eb0b7ee 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -74,7 +74,7 @@ jobs: matrix: node-version: [18.x, 20.x, 22.x, 23.x, 24.x] eslint-version: [8, 9] - ts-eslint-plugin-version: [7, 8] + ts-eslint-plugin-version: [8] runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index 4d2dc78a3..5f7d6e0b3 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ ] }, "dependencies": { - "@typescript-eslint/utils": "^7.0.0 || ^8.0.0" + "@typescript-eslint/utils": "^8.0.0" }, "devDependencies": { "@babel/cli": "^7.4.4", @@ -115,7 +115,7 @@ "typescript": "^5.0.4" }, "peerDependencies": { - "@typescript-eslint/eslint-plugin": "^7.0.0 || ^8.0.0", + "@typescript-eslint/eslint-plugin": "^8.0.0", "eslint": "^8.0.0 || ^9.0.0", "jest": "*" }, diff --git a/yarn.lock b/yarn.lock index 35cc2d268..aec5c7732 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2891,39 +2891,52 @@ __metadata: linkType: hard "@typescript-eslint/eslint-plugin@npm:^8.0.0": - version: 8.34.0 - resolution: "@typescript-eslint/eslint-plugin@npm:8.34.0" + version: 8.33.1 + resolution: "@typescript-eslint/eslint-plugin@npm:8.33.1" dependencies: "@eslint-community/regexpp": ^4.10.0 - "@typescript-eslint/scope-manager": 8.34.0 - "@typescript-eslint/type-utils": 8.34.0 - "@typescript-eslint/utils": 8.34.0 - "@typescript-eslint/visitor-keys": 8.34.0 + "@typescript-eslint/scope-manager": 8.33.1 + "@typescript-eslint/type-utils": 8.33.1 + "@typescript-eslint/utils": 8.33.1 + "@typescript-eslint/visitor-keys": 8.33.1 graphemer: ^1.4.0 ignore: ^7.0.0 natural-compare: ^1.4.0 ts-api-utils: ^2.1.0 peerDependencies: - "@typescript-eslint/parser": ^8.34.0 + "@typescript-eslint/parser": ^8.33.1 eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.9.0" - checksum: f5d4a57d0661bea3b15b8842abeae3327828647540e8127c882d44cbf793e84d4c9e33b6740f682891ddf20ca664a634b7016289e1bc98ae21f02808498a28ec + checksum: 8732c42790728335c7f07947892302b5454340f0d4d80b2afaca33d1612e4ac8ad8c46b123337c207fe16b80964bd860992fc63b74addf8495bc6a61f7b9a18c languageName: node linkType: hard "@typescript-eslint/parser@npm:^8.0.0": - version: 8.34.0 - resolution: "@typescript-eslint/parser@npm:8.34.0" + version: 8.33.1 + resolution: "@typescript-eslint/parser@npm:8.33.1" dependencies: - "@typescript-eslint/scope-manager": 8.34.0 - "@typescript-eslint/types": 8.34.0 - "@typescript-eslint/typescript-estree": 8.34.0 - "@typescript-eslint/visitor-keys": 8.34.0 + "@typescript-eslint/scope-manager": 8.33.1 + "@typescript-eslint/types": 8.33.1 + "@typescript-eslint/typescript-estree": 8.33.1 + "@typescript-eslint/visitor-keys": 8.33.1 debug: ^4.3.4 peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.9.0" - checksum: 7b6797c4d87e8b2e24f99bd2e9c4102366b8f77f4a2912f810df01d7b655524304859e0adef12c21dbbe986bacc7e45d35845d8c4439193350c38d8a14bb7ef7 + checksum: 2b527529a11738001a85494ceb56352a902d02989394ad480311fc273aa06ac282c039649433ed6396008a93c37b5d4d1c9bb5598b1526674e4d08dc2fccabe2 + languageName: node + linkType: hard + +"@typescript-eslint/project-service@npm:8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/project-service@npm:8.33.1" + dependencies: + "@typescript-eslint/tsconfig-utils": ^8.33.1 + "@typescript-eslint/types": ^8.33.1 + debug: ^4.3.4 + peerDependencies: + typescript: ">=4.8.4 <5.9.0" + checksum: 237618a025c11587d079ce82c289a43579c422ff134a32b08ef3804e5bac7632c692f7acd49d1e6520c55f41edfdabf54069c9d460d1a5e05e051027657c96b0 languageName: node linkType: hard @@ -2940,6 +2953,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/scope-manager@npm:8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/scope-manager@npm:8.33.1" + dependencies: + "@typescript-eslint/types": 8.33.1 + "@typescript-eslint/visitor-keys": 8.33.1 + checksum: fbc3ec340f4a0a9541f5898e44137ce1cb10678a8347ebce9b216342e50041c54d59515e34335fb3869db56ec3c2807408894d19a4aee53fd4ca183316008ffb + languageName: node + linkType: hard + "@typescript-eslint/scope-manager@npm:8.34.0": version: 8.34.0 resolution: "@typescript-eslint/scope-manager@npm:8.34.0" @@ -2950,6 +2973,15 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/tsconfig-utils@npm:8.33.1, @typescript-eslint/tsconfig-utils@npm:^8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/tsconfig-utils@npm:8.33.1" + peerDependencies: + typescript: ">=4.8.4 <5.9.0" + checksum: 9e0e348af4d54b7e42a015bf36e08965c8fa389ac7b179c2ccf2bec5fce4b31e951397394dcbaea6fb0ddf782f4f2f2ee71df108173742f756705f82d653cc9d + languageName: node + linkType: hard + "@typescript-eslint/tsconfig-utils@npm:8.34.0, @typescript-eslint/tsconfig-utils@npm:^8.34.0": version: 8.34.0 resolution: "@typescript-eslint/tsconfig-utils@npm:8.34.0" @@ -2959,18 +2991,25 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:8.34.0": - version: 8.34.0 - resolution: "@typescript-eslint/type-utils@npm:8.34.0" +"@typescript-eslint/type-utils@npm:8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/type-utils@npm:8.33.1" dependencies: - "@typescript-eslint/typescript-estree": 8.34.0 - "@typescript-eslint/utils": 8.34.0 + "@typescript-eslint/typescript-estree": 8.33.1 + "@typescript-eslint/utils": 8.33.1 debug: ^4.3.4 ts-api-utils: ^2.1.0 peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.9.0" - checksum: 97046c06edc6d15363f9a1e08ace2f774def8b903b42bf32db6e7f944f0f308273583b0ddd86c013e3f945bc15862d11625ff0d63578cc0b6f94a881f7337cef + checksum: 54099177a52d69fdb19bf12006c3ef543f54dde0772166e7986d085b11acc03eec7cc321450b3d98808c860b555b63476c1739409a4ca36c2635452c1f941cf2 + languageName: node + linkType: hard + +"@typescript-eslint/types@npm:8.33.1, @typescript-eslint/types@npm:^8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/types@npm:8.33.1" + checksum: 80ad8b857324da1778e0dd7af213b18ff18abb0a4fd600a80379e68fdec17c1f0dc2e2bb29667b0c4d9f1a113978d0bef71eb380fe95d239247f4b58d24af32f languageName: node linkType: hard @@ -2981,6 +3020,26 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/typescript-estree@npm:8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/typescript-estree@npm:8.33.1" + dependencies: + "@typescript-eslint/project-service": 8.33.1 + "@typescript-eslint/tsconfig-utils": 8.33.1 + "@typescript-eslint/types": 8.33.1 + "@typescript-eslint/visitor-keys": 8.33.1 + debug: ^4.3.4 + fast-glob: ^3.3.2 + is-glob: ^4.0.3 + minimatch: ^9.0.4 + semver: ^7.6.0 + ts-api-utils: ^2.1.0 + peerDependencies: + typescript: ">=4.8.4 <5.9.0" + checksum: aacb9252572be7079252dd3798e99ec0f8b7eee6875ab431fe2f646705ea1f9f968d26a0611b9d02080ed1da1986280f3b9df5ad15e9a7b54026ae274fc435fd + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:8.34.0": version: 8.34.0 resolution: "@typescript-eslint/typescript-estree@npm:8.34.0" @@ -3001,7 +3060,22 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/utils@npm:8.34.0, @typescript-eslint/utils@npm:^8.0.0, @typescript-eslint/utils@npm:^8.26.1": +"@typescript-eslint/utils@npm:8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/utils@npm:8.33.1" + dependencies: + "@eslint-community/eslint-utils": ^4.7.0 + "@typescript-eslint/scope-manager": 8.33.1 + "@typescript-eslint/types": 8.33.1 + "@typescript-eslint/typescript-estree": 8.33.1 + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: ">=4.8.4 <5.9.0" + checksum: aef41fe93d7137336cd8bcc05ea56b55dfa86e2616a86176f51ee867607263a33eee025a2130d586a6a27d7e0564c9593bb3786073425dccd82b910e43984fae + languageName: node + linkType: hard + +"@typescript-eslint/utils@npm:^8.0.0, @typescript-eslint/utils@npm:^8.26.1": version: 8.34.0 resolution: "@typescript-eslint/utils@npm:8.34.0" dependencies: @@ -3016,6 +3090,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/visitor-keys@npm:8.33.1" + dependencies: + "@typescript-eslint/types": 8.33.1 + eslint-visitor-keys: ^4.2.0 + checksum: d8bbb35ff28aaa11313d1bf6871efe343862836a0ca1083d833227a7426be7c8c791a4abc1cd0e3d86c5c0ad371fd72a3ef018e92c73e17fc75a789ca40a2e41 + languageName: node + linkType: hard + "@typescript-eslint/visitor-keys@npm:8.34.0": version: 8.34.0 resolution: "@typescript-eslint/visitor-keys@npm:8.34.0" @@ -5182,7 +5266,7 @@ __metadata: ts-node: ^10.2.1 typescript: ^5.0.4 peerDependencies: - "@typescript-eslint/eslint-plugin": ^7.0.0 || ^8.0.0 + "@typescript-eslint/eslint-plugin": ^8.0.0 eslint: ^8.0.0 || ^9.0.0 jest: "*" peerDependenciesMeta: From 945651c36c471f424b743f0aae3ccca6271f21ba Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 13 Jun 2025 16:35:11 +1200 Subject: [PATCH 07/13] feat(unbound-method): remove `docs.recommended` and `docs.requiresTypeChecking` properties BREAKING CHANGE: removed `docs.recommend` and `docs.requiresTypeChecking` from `unbound-method` --- src/rules/unbound-method.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/rules/unbound-method.ts b/src/rules/unbound-method.ts index 862c66df1..ddb7587e4 100644 --- a/src/rules/unbound-method.ts +++ b/src/rules/unbound-method.ts @@ -48,16 +48,6 @@ export type MessageIds = 'unbound' | 'unboundWithoutThisAnnotation'; const DEFAULT_MESSAGE = 'This rule requires `@typescript-eslint/eslint-plugin`'; -// todo: remove these along with the actual runtime properties below in new major -declare module '@typescript-eslint/utils/ts-eslint' { - interface RuleMetaDataDocs { - /** @deprecated */ - requiresTypeChecking?: boolean; - /** @deprecated */ - recommended?: unknown; - } -} - export default createRule({ defaultOptions: [{ ignoreStatic: false }], ...baseRule, @@ -73,12 +63,7 @@ export default createRule({ docs: { description: 'Enforce unbound methods are called with their expected scope', - /** @deprecated */ - requiresTypeChecking: true, ...baseRule?.meta.docs, - // mark this as not recommended - /** @deprecated */ - recommended: undefined, }, }, create(context) { From 598880c4cb26eed177d1efdf3f8d4293956b58ac Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 13 Jun 2025 16:40:48 +1200 Subject: [PATCH 08/13] feat: drop support for Node v18 BREAKING CHANGE: dropped support for Node v18 --- .github/workflows/nodejs.yml | 2 +- package.json | 6 +++--- tsconfig.json | 2 +- yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index b2eb0b7ee..306ce51f6 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -72,7 +72,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [18.x, 20.x, 22.x, 23.x, 24.x] + node-version: [20.x, 22.x, 23.x, 24.x] eslint-version: [8, 9] ts-eslint-plugin-version: [8] runs-on: ubuntu-latest diff --git a/package.json b/package.json index 5f7d6e0b3..f0d745e98 100644 --- a/package.json +++ b/package.json @@ -80,10 +80,10 @@ "@schemastore/package": "^0.0.10", "@semantic-release/changelog": "^6.0.0", "@semantic-release/git": "^10.0.0", - "@tsconfig/node18": "^18.0.0", + "@tsconfig/node20": "^20.0.0", "@types/eslint": "^8.4.6", "@types/jest": "^29.0.0", - "@types/node": "^18.0.0", + "@types/node": "^20.0.0", "@types/semver": "^7.5.8", "@typescript-eslint/eslint-plugin": "^8.0.0", "@typescript-eslint/parser": "^8.0.0", @@ -129,7 +129,7 @@ }, "packageManager": "yarn@3.8.7", "engines": { - "node": "^18.12.0 || ^20.0.0 || >=22.0.0" + "node": "^20.0.0 || >=22.0.0" }, "publishConfig": { "provenance": true diff --git a/tsconfig.json b/tsconfig.json index e9138bb39..57a4175f0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "@tsconfig/node18/tsconfig.json", + "extends": "@tsconfig/node20/tsconfig.json", "compilerOptions": { "noEmit": true, "stripInternal": true, diff --git a/yarn.lock b/yarn.lock index aec5c7732..f2b592e42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2667,10 +2667,10 @@ __metadata: languageName: node linkType: hard -"@tsconfig/node18@npm:^18.0.0": - version: 18.2.4 - resolution: "@tsconfig/node18@npm:18.2.4" - checksum: 80623cb9c129c78d51fe6c4a256ba986f12f02ff02dc2a1e5b33dd13a7983f767b6792cfcd51b3dd1c8256ea105f1fea31f64a2070564e37787ab3d9a1a1e7e3 +"@tsconfig/node20@npm:^20.0.0": + version: 20.1.5 + resolution: "@tsconfig/node20@npm:20.1.5" + checksum: 6d689785f7b6ffd09d2cd0565290235ddc650932f6c110701dd38732b3c0b57ba039a3663268ae4a16b855d55ec2fbd48a53910e5a5fc7f196caaa4074dd0a53 languageName: node linkType: hard @@ -2830,12 +2830,12 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^18.0.0": - version: 18.19.111 - resolution: "@types/node@npm:18.19.111" +"@types/node@npm:^20.0.0": + version: 20.19.1 + resolution: "@types/node@npm:20.19.1" dependencies: - undici-types: ~5.26.4 - checksum: 0696f422bf8c70e01255397767cea2938287d819e5ac92242f0e5629ab69f25ac22c811d0f4f3ae727c6b4f678f88737aa568b17404047cfcf3ea2b1f47786b3 + undici-types: ~6.21.0 + checksum: f2883d8e2325af18424c625cc01ba2276c933ae8fc7aba93042fb757da075eabef0d2e22775e5706a74b67687d3cb06d6d42248d966c1e6bf8a2755457e537c7 languageName: node linkType: hard @@ -5232,10 +5232,10 @@ __metadata: "@schemastore/package": ^0.0.10 "@semantic-release/changelog": ^6.0.0 "@semantic-release/git": ^10.0.0 - "@tsconfig/node18": ^18.0.0 + "@tsconfig/node20": ^20.0.0 "@types/eslint": ^8.4.6 "@types/jest": ^29.0.0 - "@types/node": ^18.0.0 + "@types/node": ^20.0.0 "@types/semver": ^7.5.8 "@typescript-eslint/eslint-plugin": ^8.0.0 "@typescript-eslint/parser": ^8.0.0 @@ -11485,10 +11485,10 @@ __metadata: languageName: node linkType: hard -"undici-types@npm:~5.26.4": - version: 5.26.5 - resolution: "undici-types@npm:5.26.5" - checksum: 3192ef6f3fd5df652f2dc1cd782b49d6ff14dc98e5dced492aa8a8c65425227da5da6aafe22523c67f035a272c599bb89cfe803c1db6311e44bed3042fc25487 +"undici-types@npm:~6.21.0": + version: 6.21.0 + resolution: "undici-types@npm:6.21.0" + checksum: 46331c7d6016bf85b3e8f20c159d62f5ae471aba1eb3dc52fff35a0259d58dcc7d592d4cc4f00c5f9243fa738a11cfa48bd20203040d4a9e6bc25e807fab7ab3 languageName: node linkType: hard From 1fb1a6747ed0f15ce4532624715c2b2a079e18f2 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 13 Jun 2025 16:42:17 +1200 Subject: [PATCH 09/13] feat: drop support for Node v23 BREAKING CHANGE: dropped support for Node v23 --- .github/workflows/nodejs.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 306ce51f6..20bf68d8d 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -72,7 +72,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [20.x, 22.x, 23.x, 24.x] + node-version: [20.x, 22.x, 24.x] eslint-version: [8, 9] ts-eslint-plugin-version: [8] runs-on: ubuntu-latest diff --git a/package.json b/package.json index f0d745e98..efbf3ad32 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,7 @@ }, "packageManager": "yarn@3.8.7", "engines": { - "node": "^20.0.0 || >=22.0.0" + "node": "^20.0.0 || ^22.0.0 || >=24.0.0" }, "publishConfig": { "provenance": true From 2f2fb68db315388230fe5bcefbcafcc2716e07e4 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 13 Jun 2025 16:43:30 +1200 Subject: [PATCH 10/13] feat: drop support for Node v20.x prior to v20.12.0 BREAKING CHANGE: dropped support for Node v20.x prior to v20.12.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index efbf3ad32..d5bcd2c87 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,7 @@ }, "packageManager": "yarn@3.8.7", "engines": { - "node": "^20.0.0 || ^22.0.0 || >=24.0.0" + "node": "^20.12.0 || ^22.0.0 || >=24.0.0" }, "publishConfig": { "provenance": true From d79765af01e67db6646d3416cbf26df6bab414e7 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 13 Jun 2025 17:03:47 +1200 Subject: [PATCH 11/13] feat: drop support for ESLint v8.x prior to v8.57.0 BREAKING CHANGE: dropped support for ESLint v8.x prior to v8.57.0 --- package.json | 4 ++-- yarn.lock | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d5bcd2c87..9defcec7f 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "babel-jest": "^29.0.0", "babel-plugin-replace-ts-export-assignment": "^0.0.2", "dedent": "^1.5.0", - "eslint": "^8.0.0", + "eslint": "^8.57.0", "eslint-config-prettier": "^10.0.0", "eslint-doc-generator": "^2.0.0", "eslint-plugin-eslint-plugin": "^6.0.0", @@ -116,7 +116,7 @@ }, "peerDependencies": { "@typescript-eslint/eslint-plugin": "^8.0.0", - "eslint": "^8.0.0 || ^9.0.0", + "eslint": "^8.57.0 || ^9.0.0", "jest": "*" }, "peerDependenciesMeta": { diff --git a/yarn.lock b/yarn.lock index f2b592e42..7ae0f1f07 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5243,7 +5243,7 @@ __metadata: babel-jest: ^29.0.0 babel-plugin-replace-ts-export-assignment: ^0.0.2 dedent: ^1.5.0 - eslint: ^8.0.0 + eslint: ^8.57.0 eslint-config-prettier: ^10.0.0 eslint-doc-generator: ^2.0.0 eslint-plugin-eslint-plugin: ^6.0.0 @@ -5267,7 +5267,7 @@ __metadata: typescript: ^5.0.4 peerDependencies: "@typescript-eslint/eslint-plugin": ^8.0.0 - eslint: ^8.0.0 || ^9.0.0 + eslint: ^8.57.0 || ^9.0.0 jest: "*" peerDependenciesMeta: "@typescript-eslint/eslint-plugin": @@ -5371,7 +5371,7 @@ __metadata: languageName: node linkType: hard -"eslint@npm:^8.0.0": +"eslint@npm:^8.57.0": version: 8.57.1 resolution: "eslint@npm:8.57.1" dependencies: From 8d1053e4f64959bb38e0687976a35510712413e9 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 13 Jun 2025 17:06:21 +1200 Subject: [PATCH 12/13] refactor: remove ESLint context fallbacks --- src/rules/expect-expect.ts | 7 ++-- src/rules/no-commented-out-tests.ts | 4 +- src/rules/no-conditional-expect.ts | 3 +- src/rules/no-confusing-set-timeout.ts | 5 ++- src/rules/no-disabled-tests.ts | 3 +- src/rules/no-done-callback.ts | 13 ++----- src/rules/no-jasmine-globals.ts | 3 +- src/rules/no-large-snapshots.ts | 5 +-- src/rules/no-test-return-statement.ts | 3 +- src/rules/prefer-comparison-matcher.ts | 3 +- src/rules/prefer-equality-matcher.ts | 3 +- src/rules/prefer-importing-jest-globals.ts | 3 +- src/rules/prefer-jest-mocked.ts | 4 +- src/rules/prefer-mock-promise-shorthand.ts | 3 +- src/rules/prefer-spy-on.ts | 4 +- src/rules/prefer-to-contain.ts | 3 +- src/rules/utils/misc.ts | 43 +--------------------- src/rules/utils/padding.ts | 4 +- src/rules/utils/parseJestFnCall.ts | 6 ++- src/rules/valid-expect.ts | 3 +- 20 files changed, 34 insertions(+), 91 deletions(-) diff --git a/src/rules/expect-expect.ts b/src/rules/expect-expect.ts index 73f097889..94145bfc2 100644 --- a/src/rules/expect-expect.ts +++ b/src/rules/expect-expect.ts @@ -6,8 +6,6 @@ import { AST_NODE_TYPES, type TSESTree } from '@typescript-eslint/utils'; import { createRule, - getAncestors, - getDeclaredVariables, getNodeName, getTestCallExpressionsFromDeclaredVariables, isSupportedAccessor, @@ -94,7 +92,8 @@ export default createRule< : -1; if (node.type === AST_NODE_TYPES.FunctionDeclaration) { - const declaredVariables = getDeclaredVariables(context, node); + const declaredVariables = + context.sourceCode.getDeclaredVariables(node); const testCallExpressions = getTestCallExpressionsFromDeclaredVariables( declaredVariables, @@ -129,7 +128,7 @@ export default createRule< unchecked.push(node); } else if (matchesAssertFunctionName(name, assertFunctionNames)) { // Return early in case of nested `it` statements. - checkCallExpressionUsed(getAncestors(context, node)); + checkCallExpressionUsed(context.sourceCode.getAncestors(node)); } }, 'Program:exit'() { diff --git a/src/rules/no-commented-out-tests.ts b/src/rules/no-commented-out-tests.ts index 5b8cd9a50..39428ac72 100644 --- a/src/rules/no-commented-out-tests.ts +++ b/src/rules/no-commented-out-tests.ts @@ -1,5 +1,5 @@ import type { TSESTree } from '@typescript-eslint/utils'; -import { createRule, getSourceCode } from './utils'; +import { createRule } from './utils'; function hasTests(node: TSESTree.Comment) { return /^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\(/mu.test( @@ -21,7 +21,7 @@ export default createRule({ }, defaultOptions: [], create(context) { - const sourceCode = getSourceCode(context); + const { sourceCode } = context; function checkNode(node: TSESTree.Comment) { if (!hasTests(node)) { diff --git a/src/rules/no-conditional-expect.ts b/src/rules/no-conditional-expect.ts index 31e7d3ada..0281467d3 100644 --- a/src/rules/no-conditional-expect.ts +++ b/src/rules/no-conditional-expect.ts @@ -2,7 +2,6 @@ import { AST_NODE_TYPES, type TSESTree } from '@typescript-eslint/utils'; import { type KnownCallExpression, createRule, - getDeclaredVariables, getTestCallExpressionsFromDeclaredVariables, isSupportedAccessor, isTypeOfJestFnCall, @@ -38,7 +37,7 @@ export default createRule({ return { FunctionDeclaration(node) { - const declaredVariables = getDeclaredVariables(context, node); + const declaredVariables = context.sourceCode.getDeclaredVariables(node); const testCallExpressions = getTestCallExpressionsFromDeclaredVariables( declaredVariables, context, diff --git a/src/rules/no-confusing-set-timeout.ts b/src/rules/no-confusing-set-timeout.ts index f295a36fb..e67d1721f 100644 --- a/src/rules/no-confusing-set-timeout.ts +++ b/src/rules/no-confusing-set-timeout.ts @@ -1,7 +1,6 @@ import { type ParsedJestFnCall, createRule, - getScope, isIdentifier, parseJestFnCall, } from './utils'; @@ -49,7 +48,9 @@ export default createRule({ return; } - if (!['global', 'module'].includes(getScope(context, node).type)) { + if ( + !['global', 'module'].includes(context.sourceCode.getScope(node).type) + ) { context.report({ messageId: 'globalSetTimeout', node }); } diff --git a/src/rules/no-disabled-tests.ts b/src/rules/no-disabled-tests.ts index cfce626b0..093db7812 100644 --- a/src/rules/no-disabled-tests.ts +++ b/src/rules/no-disabled-tests.ts @@ -1,7 +1,6 @@ import { createRule, getAccessorValue, - getScope, parseJestFnCall, resolveScope, } from './utils'; @@ -50,7 +49,7 @@ export default createRule({ } }, 'CallExpression[callee.name="pending"]'(node) { - if (resolveScope(getScope(context, node), 'pending')) { + if (resolveScope(context.sourceCode.getScope(node), 'pending')) { return; } diff --git a/src/rules/no-done-callback.ts b/src/rules/no-done-callback.ts index c7a43d34e..0806eaafe 100644 --- a/src/rules/no-done-callback.ts +++ b/src/rules/no-done-callback.ts @@ -3,14 +3,7 @@ import { type TSESLint, type TSESTree, } from '@typescript-eslint/utils'; -import { - createRule, - getFilename, - getNodeName, - getSourceCode, - isFunction, - parseJestFnCall, -} from './utils'; +import { createRule, getNodeName, isFunction, parseJestFnCall } from './utils'; const findCallbackArg = ( node: TSESTree.CallExpression, @@ -109,7 +102,7 @@ export default createRule({ fix(fixer) { const { body, params } = callback; - const sourceCode = getSourceCode(context); + const { sourceCode } = context; const firstBodyToken = sourceCode.getFirstToken(body); const lastBodyToken = sourceCode.getLastToken(body); @@ -133,7 +126,7 @@ export default createRule({ !tokenAfterLastParam ) { throw new Error( - `Unexpected null when attempting to fix ${getFilename(context)} - please file a github issue at https://github.com/jest-community/eslint-plugin-jest`, + `Unexpected null when attempting to fix ${context.filename} - please file a github issue at https://github.com/jest-community/eslint-plugin-jest`, ); } diff --git a/src/rules/no-jasmine-globals.ts b/src/rules/no-jasmine-globals.ts index 6d0d122dd..59be150d4 100644 --- a/src/rules/no-jasmine-globals.ts +++ b/src/rules/no-jasmine-globals.ts @@ -2,7 +2,6 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils'; import { createRule, getNodeName, - getScope, isSupportedAccessor, resolveScope, } from './utils'; @@ -45,7 +44,7 @@ export default createRule({ calleeName === 'fail' || calleeName === 'pending' ) { - if (resolveScope(getScope(context, node), calleeName)) { + if (resolveScope(context.sourceCode.getScope(node), calleeName)) { // It's a local variable, not a jasmine global. return; } diff --git a/src/rules/no-large-snapshots.ts b/src/rules/no-large-snapshots.ts index c9aee9b87..3d7c89630 100644 --- a/src/rules/no-large-snapshots.ts +++ b/src/rules/no-large-snapshots.ts @@ -7,7 +7,6 @@ import { import { createRule, getAccessorValue, - getFilename, isSupportedAccessor, parseJestFnCall, } from './utils'; @@ -47,7 +46,7 @@ const reportOnViolation = ( node.expression.left.type === AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.expression.left.property) ) { - const fileName = getFilename(context); + const fileName = context.filename; const allowedSnapshotsInFile = allowedSnapshots[fileName]; if (allowedSnapshotsInFile) { @@ -106,7 +105,7 @@ export default createRule<[RuleOptions], MessageId>({ }, defaultOptions: [{}], create(context, [options]) { - if (getFilename(context).endsWith('.snap')) { + if (context.filename.endsWith('.snap')) { return { ExpressionStatement(node) { reportOnViolation(context, node, options); diff --git a/src/rules/no-test-return-statement.ts b/src/rules/no-test-return-statement.ts index 6cde8e75d..759290283 100644 --- a/src/rules/no-test-return-statement.ts +++ b/src/rules/no-test-return-statement.ts @@ -1,7 +1,6 @@ import { AST_NODE_TYPES, type TSESTree } from '@typescript-eslint/utils'; import { createRule, - getDeclaredVariables, getTestCallExpressionsFromDeclaredVariables, isFunction, isTypeOfJestFnCall, @@ -53,7 +52,7 @@ export default createRule({ context.report({ messageId: 'noReturnValue', node: returnStmt }); }, FunctionDeclaration(node) { - const declaredVariables = getDeclaredVariables(context, node); + const declaredVariables = context.sourceCode.getDeclaredVariables(node); const testCallExpressions = getTestCallExpressionsFromDeclaredVariables( declaredVariables, context, diff --git a/src/rules/prefer-comparison-matcher.ts b/src/rules/prefer-comparison-matcher.ts index ec356f656..a303d019f 100644 --- a/src/rules/prefer-comparison-matcher.ts +++ b/src/rules/prefer-comparison-matcher.ts @@ -4,7 +4,6 @@ import { createRule, getAccessorValue, getFirstMatcherArg, - getSourceCode, isBooleanLiteral, isStringNode, parseJestFnCall, @@ -115,7 +114,7 @@ export default createRule({ context.report({ fix(fixer) { - const sourceCode = getSourceCode(context); + const { sourceCode } = context; // preserve the existing modifier if it's not a negation const modifierText = diff --git a/src/rules/prefer-equality-matcher.ts b/src/rules/prefer-equality-matcher.ts index 02932692e..4b482801a 100644 --- a/src/rules/prefer-equality-matcher.ts +++ b/src/rules/prefer-equality-matcher.ts @@ -5,7 +5,6 @@ import { createRule, getAccessorValue, getFirstMatcherArg, - getSourceCode, isBooleanLiteral, parseJestFnCall, } from './utils'; @@ -73,7 +72,7 @@ export default createRule({ const buildFixer = (equalityMatcher: string): TSESLint.ReportFixFunction => fixer => { - const sourceCode = getSourceCode(context); + const { sourceCode } = context; // preserve the existing modifier if it's not a negation let modifierText = diff --git a/src/rules/prefer-importing-jest-globals.ts b/src/rules/prefer-importing-jest-globals.ts index 862a7d5fb..836c7fbc3 100644 --- a/src/rules/prefer-importing-jest-globals.ts +++ b/src/rules/prefer-importing-jest-globals.ts @@ -3,7 +3,6 @@ import { type JestFnType, createRule, getAccessorValue, - getSourceCode, isIdentifier, isStringNode, isSupportedAccessor, @@ -94,7 +93,7 @@ export default createRule({ messageId: 'preferImportingJestGlobal', data: { jestFunctions: Array.from(functionsToImport).join(', ') }, fix(fixer) { - const sourceCode = getSourceCode(context); + const { sourceCode } = context; const [firstNode] = sourceCode.ast.body; // check if "use strict" directive exists diff --git a/src/rules/prefer-jest-mocked.ts b/src/rules/prefer-jest-mocked.ts index 6389871a5..d462a696c 100644 --- a/src/rules/prefer-jest-mocked.ts +++ b/src/rules/prefer-jest-mocked.ts @@ -1,5 +1,5 @@ import { AST_NODE_TYPES, type TSESTree } from '@typescript-eslint/utils'; -import { createRule, followTypeAssertionChain, getSourceCode } from './utils'; +import { createRule, followTypeAssertionChain } from './utils'; const mockTypes = ['Mock', 'MockedFunction', 'MockedClass', 'MockedObject']; @@ -42,7 +42,7 @@ export default createRule({ return; } - const fnName = getSourceCode(context).text.slice( + const fnName = context.sourceCode.text.slice( ...followTypeAssertionChain(node.expression).range, ); diff --git a/src/rules/prefer-mock-promise-shorthand.ts b/src/rules/prefer-mock-promise-shorthand.ts index c32a456b7..008d276aa 100644 --- a/src/rules/prefer-mock-promise-shorthand.ts +++ b/src/rules/prefer-mock-promise-shorthand.ts @@ -5,7 +5,6 @@ import { createRule, getAccessorValue, getNodeName, - getSourceCode, isFunction, isSupportedAccessor, } from './utils'; @@ -69,7 +68,7 @@ export default createRule({ messageId: 'useMockShorthand', data: { replacement }, fix(fixer) { - const sourceCode = getSourceCode(context); + const { sourceCode } = context; // there shouldn't be more than one argument, but if there is don't try // fixing since we have no idea what to do with the extra arguments diff --git a/src/rules/prefer-spy-on.ts b/src/rules/prefer-spy-on.ts index c01ae1157..98b14a529 100644 --- a/src/rules/prefer-spy-on.ts +++ b/src/rules/prefer-spy-on.ts @@ -3,7 +3,7 @@ import { type TSESLint, type TSESTree, } from '@typescript-eslint/utils'; -import { createRule, getNodeName, getSourceCode } from './utils'; +import { createRule, getNodeName } from './utils'; const findNodeObject = ( node: TSESTree.CallExpression | TSESTree.MemberExpression, @@ -57,7 +57,7 @@ const getAutoFixMockImplementation = ( } const [arg] = jestFnCall.arguments; - const argSource = arg && getSourceCode(context).getText(arg); + const argSource = arg && context.sourceCode.getText(arg); return argSource ? `.mockImplementation(${argSource})` diff --git a/src/rules/prefer-to-contain.ts b/src/rules/prefer-to-contain.ts index b062e1f8b..c31e967aa 100644 --- a/src/rules/prefer-to-contain.ts +++ b/src/rules/prefer-to-contain.ts @@ -7,7 +7,6 @@ import { createRule, getAccessorValue, getFirstMatcherArg, - getSourceCode, hasOnlyOneArgument, isBooleanLiteral, isSupportedAccessor, @@ -88,7 +87,7 @@ export default createRule({ context.report({ fix(fixer) { - const sourceCode = getSourceCode(context); + const { sourceCode } = context; // we need to negate the expectation if the current expected // value is itself negated by the "not" modifier diff --git a/src/rules/utils/misc.ts b/src/rules/utils/misc.ts index 15c886487..71c8c91e1 100644 --- a/src/rules/utils/misc.ts +++ b/src/rules/utils/misc.ts @@ -174,7 +174,7 @@ export const removeExtraArgumentsFixer = ( const firstArg = func.arguments[from]; const lastArg = func.arguments[func.arguments.length - 1]; - const sourceCode = getSourceCode(context); + const { sourceCode } = context; let tokenAfterLastParam = sourceCode.getTokenAfter(lastArg)!; if (tokenAfterLastParam.value === ',') { @@ -225,44 +225,3 @@ export const getFirstMatcherArg = ( return followTypeAssertionChain(firstArg); }; - -/* istanbul ignore next */ -export const getFilename = ( - context: TSESLint.RuleContext, -) => { - return context.filename ?? context.getFilename(); -}; - -/* istanbul ignore next */ -export const getSourceCode = ( - context: TSESLint.RuleContext, -) => { - return context.sourceCode ?? context.getSourceCode(); -}; - -/* istanbul ignore next */ -export const getScope = ( - context: TSESLint.RuleContext, - node: TSESTree.Node, -) => { - return getSourceCode(context).getScope?.(node) ?? context.getScope(); -}; - -/* istanbul ignore next */ -export const getAncestors = ( - context: TSESLint.RuleContext, - node: TSESTree.Node, -) => { - return getSourceCode(context).getAncestors?.(node) ?? context.getAncestors(); -}; - -/* istanbul ignore next */ -export const getDeclaredVariables = ( - context: TSESLint.RuleContext, - node: TSESTree.Node, -) => { - return ( - getSourceCode(context).getDeclaredVariables?.(node) ?? - context.getDeclaredVariables(node) - ); -}; diff --git a/src/rules/utils/padding.ts b/src/rules/utils/padding.ts index edd071b05..43fb9a130 100644 --- a/src/rules/utils/padding.ts +++ b/src/rules/utils/padding.ts @@ -15,7 +15,7 @@ import { type TSESTree, } from '@typescript-eslint/utils'; import * as astUtils from './ast-utils'; -import { createRule, getSourceCode } from './misc'; +import { createRule } from './misc'; // Statement types we'll respond to export const enum StatementType { @@ -353,7 +353,7 @@ export const createPaddingRule = ( create(context) { const paddingContext = { ruleContext: context, - sourceCode: getSourceCode(context), + sourceCode: context.sourceCode, scopeInfo: createScopeInfo(), configs, }; diff --git a/src/rules/utils/parseJestFnCall.ts b/src/rules/utils/parseJestFnCall.ts index 720907d7d..c74ea1426 100644 --- a/src/rules/utils/parseJestFnCall.ts +++ b/src/rules/utils/parseJestFnCall.ts @@ -12,7 +12,6 @@ import { TestCaseName, findTopMostCallExpression, getAccessorValue, - getScope, getStringValue, isIdentifier, isStringNode, @@ -578,7 +577,10 @@ const resolveToJestFn = ( accessor: AccessorNode, ): ResolvedJestFn | null => { const identifier = getAccessorValue(accessor); - const maybeImport = resolveScope(getScope(context, accessor), identifier); + const maybeImport = resolveScope( + context.sourceCode.getScope(accessor), + identifier, + ); // the identifier was found as a local variable or function declaration // meaning it's not a function from jest diff --git a/src/rules/valid-expect.ts b/src/rules/valid-expect.ts index b31496411..a643467aa 100644 --- a/src/rules/valid-expect.ts +++ b/src/rules/valid-expect.ts @@ -13,7 +13,6 @@ import { ModifierName, createRule, getAccessorValue, - getSourceCode, isFunction, isSupportedAccessor, parseJestFnCallWithReason, @@ -416,7 +415,7 @@ export default createRule<[Options], MessageIds>({ if (alwaysAwait && returnStatement) { const sourceCodeText = - getSourceCode(context).getText(returnStatement); + context.sourceCode.getText(returnStatement); const replacedText = sourceCodeText.replace('return', 'await'); fixes.push(fixer.replaceText(returnStatement, replacedText)); From 04ee2609afdfd82f55845d7ed91ed7223b35fe7a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 18 Jun 2025 02:26:42 +0000 Subject: [PATCH 13/13] chore(release): 29.0.0 [skip ci] # [29.0.0](https://github.com/jest-community/eslint-plugin-jest/compare/v28.14.0...v29.0.0) (2025-06-18) ### Bug Fixes * remove `jest/no-alias-methods` from `styles` config ([d3bf1dc](https://github.com/jest-community/eslint-plugin-jest/commit/d3bf1dcec9322304a37fe45e6a5cdeee7775c543)) ### Features * drop support for `[@typescript-eslint](https://github.com/typescript-eslint)` v6 ([fe61a40](https://github.com/jest-community/eslint-plugin-jest/commit/fe61a409d41ef4e7ab8137b8b3d3f66cee6d40a6)) * drop support for `[@typescript-eslint](https://github.com/typescript-eslint)` v7 ([5ca65d3](https://github.com/jest-community/eslint-plugin-jest/commit/5ca65d3f941e5c0684876c20f251e2d467fc5a15)) * drop support for ESLint v7 ([b06e7d0](https://github.com/jest-community/eslint-plugin-jest/commit/b06e7d000fd730c24c7eb7a21d34e5cf92b30835)) * drop support for ESLint v8.x prior to v8.57.0 ([d79765a](https://github.com/jest-community/eslint-plugin-jest/commit/d79765af01e67db6646d3416cbf26df6bab414e7)) * drop support for Node v16 ([aaf62cd](https://github.com/jest-community/eslint-plugin-jest/commit/aaf62cd0da1ada072101d4d84b6a66a35d82425c)) * drop support for Node v18 ([598880c](https://github.com/jest-community/eslint-plugin-jest/commit/598880c4cb26eed177d1efdf3f8d4293956b58ac)) * drop support for Node v20.x prior to v20.12.0 ([2f2fb68](https://github.com/jest-community/eslint-plugin-jest/commit/2f2fb68db315388230fe5bcefbcafcc2716e07e4)) * drop support for Node v21 ([a366393](https://github.com/jest-community/eslint-plugin-jest/commit/a366393fb38a55c91d0200791315e727fcfe3e90)) * drop support for Node v23 ([1fb1a67](https://github.com/jest-community/eslint-plugin-jest/commit/1fb1a6747ed0f15ce4532624715c2b2a079e18f2)) * **unbound-method:** remove `docs.recommended` and `docs.requiresTypeChecking` properties ([945651c](https://github.com/jest-community/eslint-plugin-jest/commit/945651c36c471f424b743f0aae3ccca6271f21ba)) ### BREAKING CHANGES * dropped support for ESLint v8.x prior to v8.57.0 * dropped support for Node v20.x prior to v20.12.0 * dropped support for Node v23 * dropped support for Node v18 * **unbound-method:** removed `docs.recommend` and `docs.requiresTypeChecking` from `unbound-method` * dropped support for `@typescript-eslint` v7 * dropped support for `@typescript-eslint` v6 * `jest/no-alias-methods` has been removed from the `styles` config as its already in the `recommended` config * dropped support for ESLint v7 * dropped support for Node v21 * dropped support for Node v16 --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8a0a9c11..933e9dc91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,40 @@ +# [29.0.0](https://github.com/jest-community/eslint-plugin-jest/compare/v28.14.0...v29.0.0) (2025-06-18) + + +### Bug Fixes + +* remove `jest/no-alias-methods` from `styles` config ([d3bf1dc](https://github.com/jest-community/eslint-plugin-jest/commit/d3bf1dcec9322304a37fe45e6a5cdeee7775c543)) + + +### Features + +* drop support for `[@typescript-eslint](https://github.com/typescript-eslint)` v6 ([fe61a40](https://github.com/jest-community/eslint-plugin-jest/commit/fe61a409d41ef4e7ab8137b8b3d3f66cee6d40a6)) +* drop support for `[@typescript-eslint](https://github.com/typescript-eslint)` v7 ([5ca65d3](https://github.com/jest-community/eslint-plugin-jest/commit/5ca65d3f941e5c0684876c20f251e2d467fc5a15)) +* drop support for ESLint v7 ([b06e7d0](https://github.com/jest-community/eslint-plugin-jest/commit/b06e7d000fd730c24c7eb7a21d34e5cf92b30835)) +* drop support for ESLint v8.x prior to v8.57.0 ([d79765a](https://github.com/jest-community/eslint-plugin-jest/commit/d79765af01e67db6646d3416cbf26df6bab414e7)) +* drop support for Node v16 ([aaf62cd](https://github.com/jest-community/eslint-plugin-jest/commit/aaf62cd0da1ada072101d4d84b6a66a35d82425c)) +* drop support for Node v18 ([598880c](https://github.com/jest-community/eslint-plugin-jest/commit/598880c4cb26eed177d1efdf3f8d4293956b58ac)) +* drop support for Node v20.x prior to v20.12.0 ([2f2fb68](https://github.com/jest-community/eslint-plugin-jest/commit/2f2fb68db315388230fe5bcefbcafcc2716e07e4)) +* drop support for Node v21 ([a366393](https://github.com/jest-community/eslint-plugin-jest/commit/a366393fb38a55c91d0200791315e727fcfe3e90)) +* drop support for Node v23 ([1fb1a67](https://github.com/jest-community/eslint-plugin-jest/commit/1fb1a6747ed0f15ce4532624715c2b2a079e18f2)) +* **unbound-method:** remove `docs.recommended` and `docs.requiresTypeChecking` properties ([945651c](https://github.com/jest-community/eslint-plugin-jest/commit/945651c36c471f424b743f0aae3ccca6271f21ba)) + + +### BREAKING CHANGES + +* dropped support for ESLint v8.x prior to v8.57.0 +* dropped support for Node v20.x prior to v20.12.0 +* dropped support for Node v23 +* dropped support for Node v18 +* **unbound-method:** removed `docs.recommend` and `docs.requiresTypeChecking` from `unbound-method` +* dropped support for `@typescript-eslint` v7 +* dropped support for `@typescript-eslint` v6 +* `jest/no-alias-methods` has been removed from the `styles` config as its already in + the `recommended` config +* dropped support for ESLint v7 +* dropped support for Node v21 +* dropped support for Node v16 + # [28.14.0](https://github.com/jest-community/eslint-plugin-jest/compare/v28.13.5...v28.14.0) (2025-06-15) diff --git a/package.json b/package.json index 9defcec7f..ee3eff794 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-jest", - "version": "28.14.0", + "version": "29.0.0", "description": "ESLint rules for Jest", "keywords": [ "eslint",