10000 chore: clean up ESLint config post `vitest` migration (#11135) · coreyward/typescript-eslint@ff2a785 · GitHub
[go: up one dir, main page]

Skip to content

Commit ff2a785

Browse files
authored
chore: clean up ESLint config post vitest migration (typescript-eslint#11135)
* chore: cleanup ESLint config file * remove `jiti`
1 parent f06fd3e commit ff2a785

File tree

5 files changed

+92
-67
lines changed

5 files changed

+92
-67
lines changed

eslint.config.mjs

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const restrictNamedDeclarations = {
3131
export default tseslint.config(
3232
// register all of the plugins up-front
3333
{
34+
name: 'register-all-plugins',
3435
// note - intentionally uses computed syntax to make it easy to sort the keys
3536
/* eslint-disable no-useless-computed-key */
3637
plugins: {
@@ -85,11 +86,12 @@ export default tseslint.config(
8586
// see the file header in eslint-base.test.js for more info
8687
'packages/rule-tester/tests/eslint-base/',
8788
],
89+
name: 'global-ignores',
8890
},
8991

9092
// extends ...
9193
eslintCommentsPlugin.recommended,
92-
eslint.configs.recommended,
94+
{ name: `${eslint.meta.name}/recommended`, ...eslint.configs.recommended },
9395
tseslint.configs.strictTypeChecked,
9496
tseslint.configs.stylisticTypeChecked,
9597
jsdocPlugin.configs['flat/recommended-typescript-error'],
@@ -108,6 +110,7 @@ export default tseslint.config(
108110
},
109111
},
110112
linterOptions: { reportUnusedDisableDirectives: 'error' },
113+
name: 'base-config',
111114
rules: {
112115
//
113116
// our plugin :D
@@ -345,6 +348,7 @@ export default tseslint.config(
345348
{
346349
extends: [tseslint.configs.disableTypeChecked],
347350
files: ['**/*.js'],
351+
name: 'js-files-only',
348352
rules: {
349353
// turn off other type-aware rules
350354
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
@@ -361,7 +365,7 @@ export default tseslint.config(
361365
// test file specific configuration
362366
{
363367
files: [
364-
'packages/*/tests/**/*.{ts,tsx,cts,mts}',
368+
'packages/*/tests/**/*.?(m|c)ts?(x)',
365369
'packages/integration-tests/tools/**/*.ts',
366370
],
367371
...vitestPlugin.configs.env,
@@ -406,11 +410,11 @@ export default tseslint.config(
406410
// plugin rule tests
407411
{
408412
files: [
409-
'packages/eslint-plugin-internal/tests/rules/**/*.test.{ts,tsx,cts,mts}',
410-
'packages/eslint-plugin-tslint/tests/rules/**/*.test.{ts,tsx,cts,mts}',
411-
'packages/eslint-plugin/tests/rules/**/*.test.{ts,tsx,cts,mts}',
412-
'packages/eslint-plugin/tests/eslint-rules/**/*.test.{ts,tsx,cts,mts}',
413+
'packages/eslint-plugin-internal/tests/rules/**/*.test.?(m|c)ts?(x)',
414+
'packages/eslint-plugin/tests/rules/**/*.test.?(m|c)ts?(x)',
415+
'packages/eslint-plugin/tests/eslint-rules/**/*.test.?(m|c)ts?(x)',
413416
],
417+
name: 'eslint-plugin-and-eslint-plugin-internal/test-files/rules',
414418
rules: {
415419
'@typescript-eslint/internal/plugin-test-formatting': 'error',
416420
},
@@ -421,23 +425,25 @@ export default tseslint.config(
421425
//
422426
{
423427
files: [
424-
'**/tools/**/*.{ts,tsx,cts,mts}',
425-
'**/tests/**/*.{ts,tsx,cts,mts}',
426-
'packages/integration-tests/**/*.{ts,tsx,cts,mts}',
428+
'**/tools/**/*.?(m|c)ts?(x)',
429+
'**/tests/**/*.?(m|c)ts?(x)',
430+
'packages/integration-tests/**/*.?(m|c)ts?(x)',
427431
],
432+
name: 'tools-and-test-files',
428433
rules: {
429434
// allow console logs in tools and tests
430435
'no-console': 'off',
431436
},
432437
},
433438
{
434439
files: [
435-
'eslint.config.{js,cjs,mjs}',
440+
'eslint.config.mjs',
436441
'knip.ts',
437442
'packages/*/src/index.ts',
438443
'vitest.config.mts',
439444
'packages/*/vitest.config.mts',
440445
],
446+
name: 'no-default-export',
441447
rules: {
442448
// requirement
443449
'import/no-default-export': 'off',
@@ -451,24 +457,23 @@ export default tseslint.config(
451457
{
452458
extends: [eslintPluginPlugin.configs['flat/recommended']],
453459
files: [
454-
'packages/eslint-plugin-internal/**/*.{ts,tsx,cts,mts}',
455-
'packages/eslint-plugin-tslint/**/*.{ts,tsx,cts,mts}',
456-
'packages/eslint-plugin/**/*.{ts,tsx,cts,mts}',
460+
'packages/eslint-plugin-internal/**/*.?(m|c)ts?(x)',
461+
'packages/eslint-plugin/**/*.?(m|c)ts?(x)',
457462
],
463+
name: 'eslint-plugin-and-eslint-plugin-internal',
458464

459465
rules: {
460466
'@typescript-eslint/internal/no-typescript-estree-import': 'error',
461467
},
462468
},
463469
{
464470
files: [
465-
'packages/eslint-plugin-internal/src/rules/**/*.{ts,tsx,cts,mts}',
466-
'packages/eslint-plugin-tslint/src/rules/**/*.{ts,tsx,cts,mts}',
467-
'packages/eslint-plugin/src/configs/**/*.{ts,tsx,cts,mts}',
468-
'packages/typescript-eslint/src/configs/**/*.{ts,tsx,cts,mts}',
469-
'packages/core/src/configs/**/*.{ts,tsx,cts,mts}',
470-
'packages/eslint-plugin/src/rules/**/*.{ts,tsx,cts,mts}',
471+
'packages/eslint-plugin-internal/src/rules/**/*.?(m|c)ts?(x)',
472+
'packages/eslint-plugin/src/configs/**/*.?(m|c)ts?(x)',
473+
'packages/typescript-eslint/src/configs/**/*.?(m|c)ts?(x)',
474+
'packages/eslint-plugin/src/rules/**/*.?(m|c)ts?(x)',
471475
],
476+
name: 'configs-and-rules',
472477
rules: {
473478
'eslint-plugin/no-property-in-node': [
474479
'error',
@@ -500,6 +505,7 @@ export default tseslint.config(
500505
},
501506
{
502507
files: ['packages/eslint-plugin/src/rules/index.ts'],
508+
name: 'eslint-plugin/source-files/rules-index-file',
503509
rules: {
504510
// enforce alphabetical ordering
505511
'import/order': ['error', { alphabetize: { order: 'asc' } }],
@@ -513,10 +519,10 @@ export default tseslint.config(
513519

514520
{
515521
files: [
516-
'packages/scope-manager/src/lib/*.{ts,tsx,cts,mts}',
517-
'packages/eslint-plugin/src/configs/*.{ts,tsx,cts,mts}',
518-
'packages/core/src/configs/*.{ts,tsx,cts,mts}',
522+
'packages/scope-manager/src/lib/*.?(m|c)ts?(x)',
523+
'packages/eslint-plugin/src/configs/*.?(m|c)ts?(x)',
519524
],
525+
name: 'generated-files',
520526
rules: {
521527
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
522528
'@typescript-eslint/internal/no-typescript-default-import': 'off',
@@ -529,15 +535,27 @@ export default tseslint.config(
529535
//
530536

531537
{
532-
files: ['packages/ast-spec/src/**/*.{ts,tsx,cts,mts}'],
538+
files: ['packages/ast-spec/src/**/*.?(m|c)ts?(x)'],
539+
name: 'ast-spec/source-files',
533540
rules: {
534541
// disallow ALL unused vars
535542
'@typescript-eslint/no-unused-vars': ['error', { caughtErrors: 'all' }],
536543
'@typescript-eslint/sort-type-constituents': 'error',
544+
545+
'perfectionist/sort-interfaces': [
546+
'error',
547+
{
548+
customGroups: {
549+
first: ['type'],
550+
},
551+
groups: ['first', 'unknown'],
552+
},
553+
],
537554
},
538555
},
539556
{
540-
files: ['packages/ast-spec/**/*.{ts,tsx,cts,mts}'],
557+
files: ['packages/ast-spec/**/*.?(m|c)ts?(x)'],
558+
name: 'ast-spec',
541559
rules: {
542560
'no-restricted-imports': [
543561
'error',
@@ -559,12 +577,18 @@ export default tseslint.config(
559577
jsxA11yPlugin.flatConfigs.recommended,
560578
// https://github.com/facebook/react/pull/30774
561579
// @ts-expect-error -- Temporary types incompatibility pending flat config support
562-
reactPlugin.configs.flat.recommended,
563-
// https://github.com/facebook/react/pull/30774
564-
// @ts-expect-error -- Temporary types incompatibility pending flat config support
565-
fixupConfigRules(compat.config(reactHooksPlugin.configs.recommended)),
580+
{ name: 'react/recommended', ...reactPlugin.configs.flat.recommended },
581+
fixupConfigRules([
582+
{
583+
name: 'react-hooks/recommended',
584+
// https://github.com/facebook/react/pull/30774
585+
// @ts-expect-error -- Temporary types incompatibility pending flat config support
586+
...compat.config(reactHooksPlugin.configs.recommended)[0],
587+
},
588+
]),
566589
],
567-
files: ['packages/website/**/*.{ts,tsx,mts,cts,js,jsx}'],
590+
files: ['packages/website/**/*.?(c|m)[tj]s?(x)'],
591+
name: 'website',
568592
rules: {
569593
'@typescript-eslint/internal/prefer-ast-types-enum': 'off',
570594
'import/no-default-export': 'off',
@@ -580,18 +604,17 @@ export default tseslint.config(
580604
},
581605
},
582606
{
583-
files: ['packages/website/src/**/*.{ts,tsx,cts,mts}'],
607+
files: ['packages/website/src/**/*.?(m|c)ts?(x)'],
608+
name: 'website/source-files',
584609
rules: {
585610
'import/no-default-export': 'off',
586611
// allow console logs in the website to help with debugging things in production
587612
'no-console': 'off',
588613
},
589614
},
590615
{
591-
files: [
592-
'packages/website-eslint/src/mock/**/*.js',
593-
'**/*.d.{ts,tsx,cts,mts}',
594-
],
616+
files: ['packages/website-eslint/src/mock/**/*.js', '**/*.d.?(m|c)ts?(x)'],
617+
name: 'website/source-files/mocks-and-declaration-files',
595618
rules: {
596619
// mocks and declaration files have to mirror their original package
597620
'import/no-default-export': 'off',
@@ -604,6 +627,7 @@ export default tseslint.config(
604627
'packages/eslint-plugin/src/configs/flat/*',
605628
'packages/scope-manager/src/configs/*',
606629
],
630+
name: 'all-files',
607631
rules: {
608632
'@typescript-eslint/sort-type-constituents': 'off',
609633
'perfectionist/sort-classes': 'error',
@@ -618,25 +642,12 @@ export default tseslint.config(
618642
],
619643
},
620644
},
621-
{
622-
files: ['packages/ast-spec/src/**/*.ts'],
623-
rules: {
624-
'perfectionist/sort-interfaces': [
625-
'error',
626-
{
627-
customGroups: {
628-
first: ['type'],
629-
},
630-
groups: ['first', 'unknown'],
631-
},
632-
],
633-
},
634-
},
635645
{
636646
files: [
637647
'packages/eslint-plugin/src/rules/*.ts',
638648
'packages/eslint-plugin-internal/src/rules/*.ts',
639649
],
650+
name: 'eslint-plugin-and-eslint-plugin-internal/source-files/rules',
640651
rules: {
641652
'perfectionist/sort-objects': [
642653
'error',
@@ -654,6 +665,7 @@ export default tseslint.config(
654665
},
655666
{
656667
files: ['packages/eslint-plugin/tests/rules/*.test.ts'],
668+
name: 'eslint-plugin-rules-test-files',
657669
rules: {
658670
'perfectionist/sort-objects': [
659671
'error',
@@ -666,6 +678,7 @@ export default tseslint.config(
666678
},
667679
{
668680
files: ['packages/typescript-estree/src/**/*.ts'],
681+
name: 'typescript-estree/source-files',
669682
rules: {
670683
'perfectionist/sort-objects': [
671684
'error',

nx.json

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
"buildDepsTargetName": "vite:build-deps",
3030
"watchDepsTargetName": "vite:watch-deps"
3131
}
32+
},
33+
{
34+
"plugin": "@nx/eslint/plugin",
35+
"include": ["packages/*"],
36+
"options": {
37+
"targetName": "lint"
38+
}
3239
}
3340
],
3441
"release": {
@@ -82,16 +89,20 @@
8289
"watch": false
8390
}
8491
},
92+
"@nx/eslint:lint": {
93+
"dependsOn": ["eslint-plugin-internal:build", "typescript-eslint:build"],
94+
"options": {
95+
"noEslintrc": true,
96+
"cache": true,
97+
"eslintConfig": "{workspaceRoot}/eslint.config.mjs"
98+
},
99+
"outputs": ["{options.outputFile}"],
100+
"cache": true
101+
},
85102
"lint": {
86-
"executor": "@nx/eslint:lint",
87-
"dependsOn": [
88-
"eslint-plugin:build",
89-
"eslint-plugin-internal:build",
90-
"typescript-eslint:build"
91-
],
103+
"dependsOn": ["eslint-plugin-internal:build", "typescript-eslint:build"],
92104
"inputs": [
93105
"default",
94-
"{workspaceRoot}/eslint.config.js",
95106
"{workspaceRoot}/eslint.config.mjs",
96107
{
97108
"dependentTasksOutputFiles": "**/*.js",

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
"execa": "7.2.0",
9393
"globals": "^16.0.0",
9494
"husky": "^9.1.4",
95-
"jiti": "2.4.2",
9695
"knip": "^5.41.1",
9796
"lint-staged": "^15.2.2",
9897
"make-dir": "^4.0.0",

project.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
"outputs": ["{workspaceRoot}/dist"]
1010
},
1111
"lint": {
12-
"command": "eslint . --ignore-pattern=packages --cache"
12+
"executor": "@nx/eslint:lint",
13+
"options": {
14+
"lintFilePatterns": ["{workspaceRoot}/!packages"]
15+
}
1316
},
1417
"generate-configs": {
1518
"command": "tsx tools/scripts/generate-configs.mts"

yarn.lock

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5733,7 +5733,6 @@ __metadata:
57335733
execa: 7.2.0
57345734
globals: ^16.0.0
57355735
husky: ^9.1.4
5736-
jiti: 2.4.2
57375736
knip: ^5.41.1
57385737
lint-staged: ^15.2.2
57395738
make-dir: ^4.0.0
@@ -12549,15 +12548,6 @@ __metadata:
1254912548
languageName: node
1255012549
linkType: hard
1255112550

12552-
"jiti@npm:2.4.2, jiti@npm:^2.4.2":
12553-
version: 2.4.2
12554-
resolution: "jiti@npm:2.4.2"
12555-
bin:
12556-
jiti: lib/jiti-cli.mjs
12557-
checksum: c6c30c7b6b293e9f26addfb332b63d964a9f143cdd2cf5e946dbe5143db89f7c1b50ad9223b77fb1f6ddb0b9c5ecef995fea024ecf7d2861d285d779cde66e1e
12558-
languageName: node
12559-
linkType: hard
12560-
1256112551
"jiti@npm:^1.20.0":
1256212552
version: 1.21.6
1256312553
resolution: "jiti@npm:1.21.6"
@@ -12567,6 +12557,15 @@ __metadata:
1256712557
languageName: node
1256812558
linkType: hard
1256912559

12560+
"jiti@npm:^2.4.2":
12561+
version: 2.4.2
12562+
resolution: "jiti@npm:2.4.2"
12563+
bin:
12564+
jiti: lib/jiti-cli.mjs
12565+
checksum: c6c30c7b6b293e9f26addfb332b63d964a9f143cdd2cf5e946dbe5143db89f7c1b50ad9223b77fb1f6ddb0b9c5ecef995fea024ecf7d2861d285d779cde66e1e
12566+
languageName: node
12567+
linkType: hard
12568+
1257012569
"jju@npm:~1.4.0":
1257112570
version: 1.4.0
1257212571
resolution: "jju@npm:1.4.0"

0 commit comments

Comments
 (0)
0