From 6c2d27dbe311f9978a9d3c9a0bfeb38a436127cc Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Fri, 21 Mar 2025 11:57:10 +0000 Subject: [PATCH 1/3] chore: de-duplicate lint config This just simplifies the lint config slightly by doing the following: - Separate vitest and jest rules from regular rules, so we can declare the regular rules once for both - Change `vitestFiles` to be computed in preparation for us moving more packages to vitest (so we don't end up with a bunch of _very similar_ globs) --- eslint.config.mjs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index d95766112604..b74a33effb8a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -29,9 +29,11 @@ const restrictNamedDeclarations = { selector: 'ExportNamedDeclaration[declaration=null][source=null]', }; -const vitestFiles = [ - 'packages/eslint-plugin-internal/tests/**/*.test.{ts,tsx,cts,mts}', -]; +const vitestPackages = ['eslint-plugin-internal']; + +const vitestFiles = vitestPackages.map( + name => `packages/${name}/tests/**/*.test.{ts,tsx,cts,mts}`, +); export default tseslint.config( // register all of the plugins up-front @@ -392,7 +394,6 @@ export default tseslint.config( 'packages/integration-tests/tools/integration-test-base.ts', 'packages/integration-tests/tools/pack-packages.ts', ], - ignores: vitestFiles, rules: { '@typescript-eslint/no-empty-function': [ 'error', @@ -403,6 +404,18 @@ export default tseslint.config( '@typescript-eslint/no-unsafe-call': 'off', '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-return': 'off', + }, + }, + { + files: [ + 'packages/*/tests/**/*.test.{ts,tsx,cts,mts}', + 'packages/*/tests/**/test.{ts,tsx,cts,mts}', + 'packages/parser/tests/**/*.{ts,tsx,cts,mts}', + 'packages/integration-tests/tools/integration-test-base.ts', + 'packages/integration-tests/tools/pack-packages.ts', + ], + ignores: vitestFiles, + rules: { 'jest/no-alias-methods': 'error', 'jest/no-deprecated-functions': 'error', 'jest/no-disabled-tests': 'error', @@ -423,15 +436,6 @@ export default tseslint.config( { files: vitestFiles, rules: { - '@typescript-eslint/no-empty-function': [ - 'error', - { allow: ['arrowFunctions'] }, - ], - '@typescript-eslint/no-non-null-assertion': 'off', - '@typescript-eslint/no-unsafe-assignment': 'off', - '@typescript-eslint/no-unsafe-call': 'off', - '@typescript-eslint/no-unsafe-member-access': 'off', - '@typescript-eslint/no-unsafe-return': 'off', 'vitest/no-alias-methods': 'error', 'vitest/no-disabled-tests': 'error', 'vitest/no-focused-tests': 'error', From ec2e0ce060e9adb7ca2a0acc4e51038ce95e19cf Mon Sep 17 00:00:00 2001 From: Kirk Waiblinger <53019676+kirkwaiblinger@users.noreply.github.com> Date: Sat, 22 Mar 2025 14:02:06 -0600 Subject: [PATCH 2/3] Update eslint.config.mjs --- eslint.config.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/eslint.config.mjs b/eslint.config.mjs index b74a33effb8a..44ffcd35ce20 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -406,6 +406,7 @@ export default tseslint.config( '@typescript-eslint/no-unsafe-return': 'off', }, }, + // jest-specific config { files: [ 'packages/*/tests/**/*.test.{ts,tsx,cts,mts}', From 2a12bdd8dc8c8223fbba03a09a24f658c6dd09b9 Mon Sep 17 00:00:00 2001 From: Kirk Waiblinger <53019676+kirkwaiblinger@users.noreply.github.com> Date: Sat, 22 Mar 2025 14:11:57 -0600 Subject: [PATCH 3/3] fix up comment --- eslint.config.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 44ffcd35ce20..a923dbeae9ac 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -433,7 +433,7 @@ export default tseslint.config( 'jest/valid-expect': 'error', }, }, - // test file specific configuration + // vitest-specific configuration { files: vitestFiles, rules: {