1
- const eslintPluginUnicorn = { // as of [email protected]
1
+ const rules = [ { // as of [email protected]
2
2
optout : {
3
3
'unicorn/no-null' : 'off' ,
4
4
'unicorn/no-array-callback-reference' : 'off' ,
14
14
'unicorn/numeric-separators-style' : [ 'error' , { onlyIfContainsSeparator : true } ] ,
15
15
'unicorn/switch-case-braces' : [ 'error' , 'avoid' ] ,
16
16
} ,
17
- } ;
18
- const eslintPluginImport = { // as of [email protected]
17
+
19
18
optout : {
20
19
'import-x/namespace' : 'off' , // https://github.com/import-js/eslint-plugin-import/issues/2340
21
20
} ,
50
49
warnOnUnassignedImports : true ,
51
50
} ] ,
52
51
} ,
53
- } ;
54
- const stylisticPlus = { // as of @stylistic /[email protected]
52
+ } , { // as of @stylistic /[email protected]
55
53
optin : {
56
54
// '@stylistic/indent-binary-ops': ['error', 4],
57
55
'@stylistic/type-generic-spacing' : 'error' ,
58
56
'@stylistic/type-named-tuple-spacing' : 'error' ,
59
57
} ,
60
- } ;
61
- const stylisticMigrate = { // as of @stylistic /[email protected]
58
+ } , { // as of @stylistic /[email protected]
62
59
optin : {
63
60
'@stylistic/dot-location' : [ 'error' , 'property' ] ,
64
61
'@stylistic/no-floating-decimal' : 'error' ,
164
161
// https://github.com/eslint-stylistic/eslint-stylistic/issues/249
165
162
// '@stylistic/type-annotation-spacing': 'error',
166
163
} ,
167
- } ;
168
- const eslint = { // as of [email protected]
164
+
169
165
optout : {
170
166
camelcase : 'off' ,
171
167
} ,
261
257
'no-empty-static-block' : 'error' ,
262
258
'no-new-native-nonconstructor' : 'error' ,
263
259
} ,
264
- } ;
265
- const typescriptESLint = { // as of @typescript [email protected]
260
+ } , { // as of @typescript [email protected]
266
261
override : {
267
262
'no-empty-function' : 'off' ,
268
263
'@typescript-eslint/no-empty-function' : 'error' ,
389
384
'@typescript-eslint/no-unsafe-unary-minus' : 'error' ,
390
385
'@typescript-eslint/parameter-properties' : [ 'error' , { prefer : 'parameter-property' } ] ,
391
386
} ,
392
- } ;
393
- const eslintPluginVue = { // as of [email protected]
387
+
394
388
optout : {
395
389
'vue/max-attributes-per-line' : 'off' ,
396
390
'vue/singleline-html-element-content-newline' : 'off' ,
525
519
'vue/no-unused-emit-declarations' : 'error' ,
526
520
'vue/no-ref-object-reactivity-loss' : 'error' ,
527
521
} ,
528
- } ;
522
+ } ] ;
529
523
530
- // eslint-disable-next-line no-undef
531
- module . exports = {
532
- root : true ,
533
- reportUnusedDisableDirectives : true ,
534
- parserOptions : {
535
- project : [ './tsconfig.json' , './tsconfig.node.json' ] ,
536
- // eslint-disable-next-line no-undef
537
- tsconfigRootDir : __dirname ,
524
+ import viteConfig from './vite.config.ts' ;
525
+ import { fixupConfigRules } from '@eslint/compat' ;
526
+ import { FlatCompat } from '@eslint/eslintrc' ;
527
+ import eslintJs from '@eslint/js' ;
528
+ import * as vueESLintParser from 'vue-eslint-parser' ;
529
+ import pluginVue from 'eslint-plugin-vue'
530
+ import vueESLintConfigTypescriptRecommendedExtends from '@vue/eslint-config-typescript/recommended.js'
531
+ import * as typescriptESLintParserForExtraFiles from 'typescript-eslint-parser-for-extra-files' ;
532
+ import pluginStylistic from '@stylistic/eslint-plugin' ;
533
+ import stylisticMigrate from '@stylistic/eslint-plugin-migrate' ;
534
+ import pluginImportX from 'eslint-plugin-import-x' ;
535
+ import pluginUnicorn from 'eslint-plugin-unicorn' ;
536
+ import * as _ from 'lodash-es' ;
537
+
538
+ // https://github.com/eslint/eslint/issues/18093
539
+ // https://github.com/eslint/eslint/issues/18391
540
+ const compat = new FlatCompat ( ) ;
541
+
542
+ export default [
543
+ eslintJs . configs . recommended ,
544
+ ...pluginVue . configs [ 'flat/recommended' ] ,
545
+ ...compat . config ( vueESLintConfigTypescriptRecommendedExtends ) , // https://github.com/vuejs/eslint-config-typescript/issues/76#issuecomment-2051234597
546
+ ...compat . extends ( // https://github.com/ota-meshi/typescript-eslint-parser-for-extra-files/issues/95#issuecomment-2148604881
547
+ 'plugin:@typescript-eslint/strict-type-checked' ,
548
+ 'plugin:@typescript-eslint/stylistic-type-checked' ,
549
+ ) ,
550
+ ...compat . config ( pluginImportX . configs . recommended ) , // https://github.com/un-ts/eslint-plugin-import-x/issues/29#issuecomment-2148843214
551
+ ...compat . config ( pluginImportX . configs . typescript ) ,
552
+ ...fixupConfigRules ( ...compat . extends (
553
+ 'plugin:@tanstack/eslint-plugin-query/recommended' , // https://github.com/TanStack/query/pull/7253
554
+ ) ) ,
555
+ pluginUnicorn . configs [ 'flat/recommended' ] ,
556
+ { linterOptions : { reportUnusedDisableDirectives : 'error' } } ,
557
+ {
558
+ languageOptions : {
559
+ parserOptions : {
560
+ project : [ './tsconfig.json' , './tsconfig.node.json' ] ,
561
+ tsconfigRootDir : import . meta. dirname ,
562
+ } ,
563
+ } ,
564
+ plugins : { '@stylistic' : pluginStylistic } ,
565
+
566
+ // https://stackoverflow.com/questions/30221286/how-to-convert-an-array-of-objects-to-an-object-in-lodash/36692117#36692117
567
+ rules : Object . assign ( { } , ..._ . flatten ( _ . map ( rules , Object . values ) ) ) ,
538
568
} ,
539
- overrides : [ { // https://stackoverflow.com/questions/57107800/eslint-disable-extends-in-override
540
- files : '* .ts',
541
- parser : 'typescript-eslint- parser-for-extra-files' ,
569
+ {
570
+ files : [ '**/* .ts'] ,
571
+ languageOptions : { parser : typescriptESLintParserForExtraFiles } ,
542
572
settings : { 'import-x/resolver' : { typescript : true } } ,
543
- } , {
544
- files : '*.vue' ,
545
- parser : 'vue-eslint-parser' ,
546
- parserOptions : {
547
- parser : 'typescript-eslint-parser-for-extra-files' ,
548
- project : [ './tsconfig.json' , './tsconfig.node.json' ] ,
549
- // eslint-disable-next-line no-undef
550
- tsconfigRootDir : __dirname ,
573
+ } ,
574
+ {
575
+ files : [ '**/*.vue' ] ,
576
+ languageOptions : {
577
+ parser : vueESLintParser ,
578
+ parserOptions : {
579
+ parser : typescriptESLintParserForExtraFiles ,
580
+ project : [ './tsconfig.json' , './tsconfig.node.json' ] ,
581
+ tsconfigRootDir : import . meta. dirname ,
582
+ } ,
551
583
} ,
552
584
settings : {
553
585
'import-x/resolver' : {
@@ -557,40 +589,15 @@ module.exports = {
557
589
vite : { viteConfig : import ( './vite.config' ) } ,
558
590
} ,
559
591
} ,
560
- } , {
561
- files : '.eslintrc.cjs' ,
562
- plugins : [ '@stylistic' , '@stylistic/migrate' ] ,
592
+ } ,
593
+ {
594
+ files : [ 'eslint.config.js' ] ,
595
+ plugins : { '@stylistic' : pluginStylistic , '@stylistic/migrate' : stylisticMigrate } ,
563
596
rules : {
564
597
'@stylistic/migrate/migrate-js' : 'error' ,
565
598
'@stylistic/migrate/migrate-ts' : 'error' ,
566
599
'@stylistic/comma-dangle' : [ 'error' , 'always-multiline' ] ,
567
600
'@typescript-eslint/naming-convention' : 'off' ,
568
601
} ,
569
- } ] ,
570
- plugins : [ '@stylistic' ] ,
571
- extends : [
572
- 'eslint:recommended' ,
573
- 'plugin:vue/vue3-recommended' ,
574
- '@vue/typescript/recommended' ,
575
- 'plugin:@typescript-eslint/strict-type-checked' ,
576
- 'plugin:@typescript-eslint/stylistic-type-checked' ,
577
- 'plugin:import-x/recommended' ,
578
- 'plugin:import-x/typescript' ,
579
- 'plugin:unicorn/recommended' ,
580
- 'plugin:@tanstack/eslint-plugin-query/recommended' ,
581
- ] ,
582
- rules : {
583
- ...eslintPluginUnicorn . optout ,
584
- ...eslintPluginUnicorn . optin ,
585
- ...eslintPluginImport . optout ,
586
- ...eslintPluginImport . optin ,
587
- ...stylisticPlus . optin ,
588
- ...stylisticMigrate . optin ,
589
- ...eslint . optout ,
590
- ...eslint . optin ,
591
- ...typescriptESLint . override ,
592
- ...typescriptESLint . optin ,
593
- ...eslintPluginVue . optout ,
594
- ...eslintPluginVue . optin ,
595
602
} ,
596
- } ;
603
+ ] ;
0 commit comments