@1stg/eslint-config 7.0.1 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/overrides.js CHANGED
@@ -1,37 +1,58 @@
1
- const path = require('node:path')
2
-
3
- const { jsoncFiles, nonJsonRcFiles, preferPrettier } = require('@1stg/config')
4
- const {
5
- isAngularAvailable,
6
- isReactAvailable,
7
- isPkgAvailable,
8
- isSvelteAvailable,
9
- isTsAvailable,
10
- isVueAvailable,
11
- tryFile,
12
- tryPkg,
13
- } = require('@pkgr/utils')
14
-
15
- const { magicNumbers, prettierExtends } = require('./_util')
1
+ // @ts-check
2
+
3
+ /**
4
+ * @import {Linter} from 'eslint'
5
+ */
6
+
7
+ import path from 'node:path'
8
+
9
+ import { jsoncFiles, nonJsonRcFiles, preferPrettier } from '@1stg/config'
10
+ import babelParser from '@babel/eslint-parser'
11
+ import babel from '@babel/eslint-plugin'
12
+ import react_ from '@eslint-react/eslint-plugin'
13
+ import { isPkgAvailable, tryFile, tryPkg } from '@pkgr/utils'
14
+ import angular_ from 'angular-eslint'
15
+ import angularTemplateParser from 'angular-eslint-template-parser'
16
+ import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
17
+ import eslintMdx from 'eslint-mdx'
18
+ import importX from 'eslint-plugin-import-x'
19
+ import jest_ from 'eslint-plugin-jest'
20
+ import jsdoc from 'eslint-plugin-jsdoc'
21
+ import jsonc_ from 'eslint-plugin-jsonc'
22
+ import * as mdx_ from 'eslint-plugin-mdx'
23
+ import * as reactHooks_ from 'eslint-plugin-react-hooks'
24
+ import toml_ from 'eslint-plugin-toml'
25
+ import vue_ from 'eslint-plugin-vue'
26
+ import yml_ from 'eslint-plugin-yml'
27
+ import tseslint from 'typescript-eslint'
28
+ import vueParser from 'vue-eslint-parser'
29
+
30
+ import { isTsAvailable, magicNumbers, prettierExtends } from './_util.js'
16
31
 
17
32
  const configFile =
18
33
  tryFile(path.resolve('babel.config.js')) ||
19
34
  tryFile(path.resolve('.babelrc.js')) ||
20
35
  tryPkg('@1stg/babel-preset/config')
21
36
 
37
+ /**
38
+ * @satisfies {Linter.Config}
39
+ */
22
40
  const jsBase = {
23
- files: ['*.cjs', '*.mjs', '*.js', '*.jsx'],
24
- parser: '@babel/eslint-parser',
25
- parserOptions: configFile
26
- ? {
27
- babelOptions: {
28
- configFile,
29
- },
30
- }
31
- : {
32
- requireConfigFile: false,
33
- },
34
- plugins: ['@babel'],
41
+ name: '@1stg/js-base',
42
+ files: ['**/*.cjs', '**/*.mjs', '**/*.js', '**/*.jsx'],
43
+ languageOptions: {
44
+ parser: babelParser,
45
+ parserOptions: configFile
46
+ ? {
47
+ babelOptions: {
48
+ configFile,
49
+ },
50
+ }
51
+ : { requireConfigFile: false },
52
+ },
53
+ plugins: {
54
+ '@babel': babel,
55
+ },
35
56
  rules: {
36
57
  camelcase: [
37
58
  2,
@@ -49,9 +70,12 @@ const jsBase = {
49
70
  },
50
71
  }
51
72
 
52
- exports.js = {
73
+ const jsdocConfig = jsdoc.configs['flat/recommended']
74
+
75
+ export const js = tseslint.config({
53
76
  ...jsBase,
54
- extends: ['plugin:jsdoc/recommended'],
77
+ name: '@1stg/js',
78
+ extends: [jsdocConfig],
55
79
  rules: {
56
80
  ...jsBase.rules,
57
81
  'jsdoc/require-jsdoc': 0,
@@ -71,7 +95,7 @@ exports.js = {
71
95
  },
72
96
  }
73
97
  : undefined,
74
- }
98
+ })
75
99
 
76
100
  const project =
77
101
  tryFile(path.resolve('tsconfig.eslint.json')) ||
@@ -80,29 +104,32 @@ const project =
80
104
  tryPkg('@1stg/tsconfig')
81
105
 
82
106
  const resolveSettings = {
83
- 'import/external-module-folders': [
107
+ 'import-x/external-module-folders': [
84
108
  'node_modules',
85
109
  'node_modules/@d-ts',
86
110
  'node_modules/@types',
87
111
  ],
88
- 'import/resolver': {
89
- typescript: {
112
+ 'import-x/resolver-next': [
113
+ createTypeScriptImportResolver({
90
114
  alwaysTryTypes: true,
91
115
  project,
92
- },
93
- },
116
+ }),
117
+ ],
94
118
  }
95
119
 
96
- const tsBase = {
97
- files: ['*.cts', '*.mts', '*.ts', '*.tsx'],
98
- parserOptions: {
99
- project,
120
+ const tsBase = tseslint.config({
121
+ name: '@1stg/ts-base',
122
+ files: ['**/*.cts', '**/*.mts', '**/*.ts', '**/*.tsx'],
123
+ languageOptions: {
124
+ parserOptions: {
125
+ project,
126
+ },
100
127
  },
101
128
  extends: [
102
- 'plugin:@typescript-eslint/eslint-recommended',
103
- 'plugin:@typescript-eslint/recommended',
104
- 'plugin:import/typescript',
105
- ...prettierExtends,
129
+ tseslint.configs.eslintRecommended,
130
+ tseslint.configs.recommended,
131
+ importX.flatConfigs.typescript,
132
+ prettierExtends,
106
133
  ],
107
134
  settings: resolveSettings,
108
135
  rules: {
@@ -114,14 +141,6 @@ const tsBase = {
114
141
  },
115
142
  ],
116
143
  '@typescript-eslint/ban-ts-comment': 0,
117
- '@typescript-eslint/ban-types': [
118
- 2,
119
- {
120
- types: {
121
- object: false,
122
- },
123
- },
124
- ],
125
144
  '@typescript-eslint/consistent-type-definitions': [2, 'interface'],
126
145
  '@typescript-eslint/explicit-function-return-type': 0,
127
146
  '@typescript-eslint/explicit-member-accessibility': [
@@ -135,7 +154,8 @@ const tsBase = {
135
154
  ],
136
155
  '@typescript-eslint/explicit-module-boundary-types': 0,
137
156
  '@typescript-eslint/member-ordering': 2,
138
- '@typescript-eslint/naming-convention': 0, // TODO: find better config
157
+ // eslint-disable-line sonarjs/todo-tag -- TODO: find better config
158
+ '@typescript-eslint/naming-convention': 0,
139
159
  '@typescript-eslint/no-empty-function': 2,
140
160
  '@typescript-eslint/no-extraneous-class': [
141
161
  2,
@@ -172,7 +192,7 @@ const tsBase = {
172
192
  '@typescript-eslint/prefer-for-of': 2,
173
193
  '@typescript-eslint/prefer-function-type': 2,
174
194
  '@typescript-eslint/prefer-ts-expect-error': 2,
175
- '@typescript-eslint/sort-type-union-intersection-members': 2,
195
+ '@typescript-eslint/sort-type-constituents': 2,
176
196
  '@typescript-eslint/triple-slash-reference': [
177
197
  2,
178
198
  {
@@ -183,12 +203,12 @@ const tsBase = {
183
203
  ],
184
204
  '@typescript-eslint/unified-signatures': 2,
185
205
  camelcase: 0,
186
- 'import/default': 0,
187
- 'import/named': 0,
188
- 'import/namespace': 0,
189
- 'import/no-duplicates': 2,
190
- 'import/no-named-as-default': 0,
191
- 'import/no-named-as-default-member': 0,
206
+ 'import-x/default': 0,
207
+ 'import-x/named': 0,
208
+ 'import-x/namespace': 0,
209
+ 'import-x/no-duplicates': 2,
210
+ 'import-x/no-named-as-default': 0,
211
+ 'import-x/no-named-as-default-member': 0,
192
212
  'no-empty-function': 0,
193
213
  'no-restricted-syntax': [
194
214
  2,
@@ -213,26 +233,31 @@ const tsBase = {
213
233
  // covered by @typescript-eslint/no-this-alias
214
234
  'unicorn/no-this-assignment': 0,
215
235
  },
216
- }
236
+ })
217
237
 
218
- exports.ts = [
238
+ export const ts = tseslint.config(
219
239
  tsBase,
220
240
  {
221
- files: '{bin,cli}.ts',
241
+ name: '@1stg/cli',
242
+ files: ['**/{bin,cli}.ts'],
222
243
  rules: {
223
244
  'n/shebang': 0,
224
245
  },
225
246
  },
226
247
  {
227
- files: '**/*.{md,mdx}/**/*.{cts,mts,ts,tsx}',
228
- parserOptions: {
229
- project: null,
248
+ name: '@1stg/code-block',
249
+ files: ['**/*.{md,mdx}/**/*.{cts,mts,ts,tsx}'],
250
+ languageOptions: {
251
+ parserOptions: {
252
+ project: null,
253
+ },
230
254
  },
231
255
  },
232
256
  {
233
- files: '*.{cts,mts,ts,tsx}',
234
- excludedFiles: ['**/*.{md,mdx}/**/*.{cts,mts,ts,tsx}', '*.d.{cts,mts,ts}'],
235
- extends: ['plugin:@typescript-eslint/recommended-requiring-type-checking'],
257
+ name: '@1stg/ts',
258
+ files: ['**/*.{cts,mts,ts,tsx}'],
259
+ ignores: ['**/*.{md,mdx}/**/*.{cts,mts,ts,tsx}', '*.d.{cts,mts,ts}'],
260
+ extends: [tseslint.configs.recommendedTypeChecked],
236
261
  rules: {
237
262
  '@typescript-eslint/no-floating-promises': [
238
263
  2,
@@ -269,100 +294,119 @@ exports.ts = [
269
294
  'no-magic-numbers': 0,
270
295
  },
271
296
  },
272
- ]
273
-
274
- exports.dTs = {
275
- files: ['*.d.cts', '*.d.mts', '*.d.ts'],
297
+ )
298
+
299
+ /**
300
+ * @type {Linter.Config}
301
+ */
302
+ export const dTs = {
303
+ name: '@1stg/d-ts',
304
+ files: ['**/*.d.cts', '**/*.d.mts', '**/*.d.ts'],
276
305
  rules: {
277
306
  '@typescript-eslint/no-explicit-any': 0,
278
307
  '@typescript-eslint/no-extraneous-class': 0,
279
308
  '@typescript-eslint/no-namespace': 0,
280
309
  '@typescript-eslint/no-unused-vars': 0,
281
- 'import/no-duplicates': 0,
282
- 'import/order': 0,
310
+ 'import-x/no-duplicates': 0,
311
+ 'import-x/order': 0,
283
312
  },
284
313
  }
285
314
 
286
- const reactJsx = {
287
- extends: ['standard-react', 'plugin:react/recommended', ...prettierExtends],
315
+ const reactJsx = tseslint.config({
316
+ name: '@1stg/react-jsx',
317
+ extends: [react_.configs.recommended, prettierExtends],
288
318
  settings: {
289
319
  react: {
290
320
  version: 'detect',
291
321
  },
292
322
  },
293
- }
323
+ })
294
324
 
295
- exports.react = [
325
+ export const react = tseslint.config(
296
326
  {
297
- files: '*.{js,jsx,tsx}',
327
+ name: '@1stg/react',
328
+ files: ['**/*.{js,jsx,tsx}'],
329
+ extends: [reactJsx],
298
330
  rules: {
299
- 'react/jsx-boolean-value': [2, 'always'],
300
- 'react/jsx-handler-names': [
301
- 2,
302
- {
303
- eventHandlerPrefix: false,
304
- eventHandlerPropPrefix: 'on',
305
- },
306
- ],
307
- 'sonar/function-name': isTsAvailable
308
- ? [2, { format: '^_?[a-zA-Z][a-zA-Z0-9]*\\$?$' }]
331
+ '@eslint-react/avoid-shorthand-boolean': 2,
332
+ // '@eslint-react/naming-convention/handler-prop': [
333
+ // 2,
334
+ // {
335
+ // eventHandlerPrefix: false,
336
+ // eventHandlerPropPrefix: 'on',
337
+ // },
338
+ // ],
339
+ 'sonarjs/function-name': isTsAvailable
340
+ ? [2, { format: String.raw`^_?[a-zA-Z][a-zA-Z0-9]*\$?$` }]
309
341
  : 0,
310
342
  },
311
- ...reactJsx,
312
343
  },
313
344
  {
314
- files: '*.tsx',
345
+ name: '@1stg/react-tsx',
346
+ files: ['**/*.tsx'],
315
347
  rules: {
316
- 'react/display-name': 0,
348
+ '@eslint-react/display-name': 0,
317
349
  },
318
350
  },
319
- ]
320
-
321
- exports.reactHooks = {
322
- files: '*.{js,jsx,ts,tsx}',
323
- plugins: ['react-hooks'],
324
- rules: {
325
- 'react-hooks/rules-of-hooks': 2,
326
- 'react-hooks/exhaustive-deps': 2,
351
+ {
352
+ name: '@1stg/react-hooks',
353
+ files: ['**/*.{js,jsx,ts,tsx}'],
354
+ plugins: { 'react-hooks': reactHooks_ },
355
+ rules: {
356
+ 'react-hooks/rules-of-hooks': 2,
357
+ 'react-hooks/exhaustive-deps': 2,
358
+ },
327
359
  },
328
- }
329
-
330
- exports.reactTs = {
331
- files: '*.{ts,tsx}',
332
- rules: {
333
- 'no-restricted-imports': [2, 'prop-types'],
334
- 'react/prop-types': 0,
360
+ {
361
+ name: '@1stg/react-ts',
362
+ files: ['**/*.{ts,tsx}'],
363
+ rules: {
364
+ 'no-restricted-imports': [2, 'prop-types'],
365
+ '@eslint-react/prop-types': 0,
366
+ },
335
367
  },
336
- }
368
+ )
337
369
 
338
- const vueExtends = ['plugin:vue/recommended', ...prettierExtends]
370
+ const vueExtends = tseslint.config(
371
+ vue_.configs['flat/recommended'],
372
+ prettierExtends,
373
+ )
339
374
 
340
- exports.vue = [
375
+ export const vue = tseslint.config(
341
376
  {
342
377
  ...jsBase,
343
- files: [...jsBase.files, !isTsAvailable && '*.vue'].filter(Boolean),
344
- parser: 'vue-eslint-parser',
345
- parserOptions: {
346
- ...jsBase.parserOptions,
347
- parser: jsBase.parser,
378
+ name: '@1stg/js-vue',
379
+ files: /** @type {string[]} */ (
380
+ [...jsBase.files, !isTsAvailable && '**/*.vue'].filter(Boolean)
381
+ ),
382
+ languageOptions: {
383
+ parser: vueParser,
384
+ parserOptions: {
385
+ parser: babelParser,
386
+ ...jsBase.languageOptions.parserOptions,
387
+ },
348
388
  },
349
389
  extends: vueExtends,
350
390
  },
351
- isTsAvailable && {
352
- ...tsBase,
353
- files: [...tsBase.files, '*.vue'],
354
- parser: 'vue-eslint-parser',
355
- parserOptions: {
356
- parser: '@typescript-eslint/parser',
357
- extraFileExtensions: ['.vue'],
358
- },
359
- extends: [...tsBase.extends, ...vueExtends],
360
- },
391
+ isTsAvailable
392
+ ? {
393
+ name: '@1stg/ts-vue',
394
+ extends: [...tsBase, ...vueExtends],
395
+ files: [.../** @type {string[]} */ (tsBase[0].files), '**/*.vue'],
396
+ languageOptions: {
397
+ parser: vueParser,
398
+ parserOptions: {
399
+ parser: tseslint.parser,
400
+ extraFileExtensions: ['.vue'],
401
+ },
402
+ },
403
+ }
404
+ : [],
361
405
  {
362
- files: '*.vue',
406
+ name: '@1stg/vue',
407
+ files: ['**/*.vue'],
363
408
  extends: [
364
- // eslint-disable-next-line sonarjs/no-duplicate-string
365
- 'plugin:markup/recommended',
409
+ // 'plugin:markup/recommended',
366
410
  ...vueExtends,
367
411
  ],
368
412
  rules: {
@@ -370,59 +414,33 @@ exports.vue = [
370
414
  '@typescript-eslint/no-unused-vars': 0,
371
415
  },
372
416
  },
373
- ].filter(Boolean)
374
-
375
- const svelteBase = {
376
- files: '*.svelte',
377
- extends: [
378
- 'plugin:markup/recommended',
379
- 'plugin:svelte/recommended',
380
- 'plugin:svelte/prettier',
381
- ...prettierExtends,
382
- ],
383
- rules: {
384
- 'sonar/label-position': 0,
385
- 'sonar/no-labels': 0,
386
- },
387
- }
417
+ )
388
418
 
389
- exports.svelte = isTsAvailable
390
- ? {
391
- ...tsBase,
392
- ...svelteBase,
419
+ export const angular = tseslint.config(
420
+ {
421
+ files: ['**/*.ts'],
422
+ ignores: ['**/*.d.ts'],
423
+ languageOptions: {
393
424
  parserOptions: {
394
- extraFileExtensions: ['.svelte'],
425
+ project,
395
426
  },
396
- }
397
- : {
398
- ...jsBase,
399
- ...svelteBase,
400
- }
401
-
402
- exports.angular = [
403
- {
404
- files: '*.ts',
405
- excludedFiles: '*.d.ts',
406
- parserOptions: {
407
- project,
408
427
  },
409
- extends: [
410
- 'plugin:@angular-eslint/recommended',
411
- 'plugin:@angular-eslint/template/process-inline-templates',
412
- ...prettierExtends,
413
- ],
428
+ extends: [angular_.configs.tsRecommended, prettierExtends],
429
+ processor: angular_.processInlineTemplates,
414
430
  rules: {
415
431
  '@angular-eslint/prefer-on-push-component-change-detection': 1,
416
432
  },
417
433
  },
418
434
  {
419
- files: '*.html',
435
+ files: ['**/*.html'],
420
436
  extends: [
421
- 'plugin:@angular-eslint/template/recommended',
422
- 'plugin:markup/recommended',
423
- ...prettierExtends,
437
+ angular_.configs.templateRecommended,
438
+ // 'plugin:markup/recommended',
439
+ prettierExtends,
424
440
  ],
425
- parser: 'angular-eslint-template-parser',
441
+ languageOptions: {
442
+ parser: angularTemplateParser,
443
+ },
426
444
  rules: {
427
445
  '@angular-eslint/template/eqeqeq': [
428
446
  2,
@@ -430,147 +448,187 @@ exports.angular = [
430
448
  allowNullOrUndefined: true,
431
449
  },
432
450
  ],
433
- 'prettier/prettier': [
434
- preferPrettier ? 0 : 2,
435
- {
436
- parser: 'angular',
437
- },
438
- ],
451
+ 'prettier/prettier': preferPrettier ? 0 : [2, { parser: 'angular' }],
439
452
  'spaced-comment': 0,
440
453
  },
441
454
  },
442
455
  {
443
- files: '*inline-template-*.component.html',
456
+ files: ['**/*inline-template-*.component.html'],
444
457
  rules: {
445
458
  'unicorn/no-empty-file': 0,
446
459
  },
447
460
  },
448
- ]
449
-
450
- exports.markup = [
461
+ )
462
+
463
+ /* eslint-disable sonarjs/no-commented-code */
464
+ // export const markup = [
465
+ // {
466
+ // files: '**/*.html',
467
+ // extends: 'plugin:markup/recommended',
468
+ // rules: {
469
+ // 'prettier/prettier': [
470
+ // preferPrettier ? 0 : 2,
471
+ // {
472
+ // parser: 'html',
473
+ // },
474
+ // ],
475
+ // },
476
+ // },
477
+ // {
478
+ // files: '**/*.pug',
479
+ // extends: ['plugin:markup/recommended', ...prettierExtends],
480
+ // },
481
+ // ]
482
+ /* eslint-enable sonarjs/no-commented-code */
483
+
484
+ export const md = tseslint.config(
451
485
  {
452
- files: '*.html',
453
- extends: 'plugin:markup/recommended',
486
+ name: '@1stg/md',
487
+ files: ['**/*.md'],
488
+ extends: [mdx_.configs.flat],
454
489
  rules: {
455
- 'prettier/prettier': [
456
- preferPrettier ? 0 : 2,
457
- {
458
- parser: 'html',
459
- },
460
- ],
490
+ 'prettier/prettier': preferPrettier ? 0 : 2,
461
491
  },
462
492
  },
463
- {
464
- files: '*.pug',
465
- extends: ['plugin:markup/recommended', ...prettierExtends],
466
- },
467
- ]
468
-
469
- exports.md = {
470
- files: '*.md',
471
- extends: ['plugin:mdx/recommended'],
472
- rules: {
473
- 'prettier/prettier': preferPrettier ? 0 : 2,
474
- },
475
- }
493
+ mdx_.configs.flatCodeBlocks,
494
+ )
476
495
 
477
- exports.mdx = {
478
- files: '*.mdx',
479
- extends: [...reactJsx.extends, 'plugin:mdx/recommended'],
480
- parserOptions: jsBase.parserOptions,
481
- settings: { ...reactJsx.settings, ...resolveSettings },
482
- rules: {
483
- 'prettier/prettier': preferPrettier ? 0 : 2,
496
+ export const mdx = tseslint.config(
497
+ {
498
+ name: '@1stg/mdx',
499
+ files: ['**/*.mdx'],
500
+ extends: [reactJsx, mdx_.configs.flat],
501
+ languageOptions: {
502
+ ...jsBase.languageOptions,
503
+ parser: eslintMdx,
504
+ },
505
+ settings: { ...reactJsx[0].settings, ...resolveSettings },
506
+ rules: {
507
+ 'prettier/prettier': preferPrettier ? 0 : 2,
508
+ },
484
509
  },
485
- }
510
+ mdx_.configs.flatCodeBlocks,
511
+ )
486
512
 
487
- const nonSourceRules = {
513
+ const nonSourceRules = /** @type {const} */ ({
488
514
  'n/no-extraneous-import': 0,
489
515
  'n/no-extraneous-require': 0,
490
516
  'n/no-unsupported-features/es-builtins': 0,
491
- }
492
-
493
- exports.test = {
494
- files: '**/{__test__,test,tests}/**/*',
517
+ })
518
+
519
+ /**
520
+ * @type {Linter.Config}
521
+ */
522
+ export const test = {
523
+ name: '@1stg/test',
524
+ files: ['**/{__test__,test,tests}/**/*'],
495
525
  rules: nonSourceRules,
496
526
  }
497
527
 
498
- exports.jest = {
499
- files: '*.{spec,test}.{js,jsx,ts,tsx}',
500
- extends: ['plugin:jest/recommended'],
501
- rules: exports.test.rules,
502
- }
503
-
504
- exports.script = exports.scripts = {
505
- files: '**/scripts/**/*',
528
+ export const tests = test
529
+
530
+ export const jest = tseslint.config({
531
+ name: '@1stg/jest',
532
+ files: ['**/*.{spec,test}.{js,jsx,ts,tsx}'],
533
+ extends: [jest_.configs['flat/recommended']],
534
+ rules: test.rules,
535
+ })
536
+
537
+ /**
538
+ * @type {Linter.Config}
539
+ */
540
+ export const script = {
541
+ name: '@1stg/script',
542
+ files: ['**/scripts/**/*'],
506
543
  rules: nonSourceRules,
507
544
  }
508
545
 
509
- exports.story = exports.stories = {
546
+ export const scripts = script
547
+
548
+ /**
549
+ * @type {Linter.Config}
550
+ */
551
+ export const story = {
552
+ name: '@1stg/story',
510
553
  files: ['**/.storybook/**/*', '**/stories/**/*'],
511
554
  rules: nonSourceRules,
512
555
  }
513
556
 
514
- exports.config = exports.configs = {
515
- files: ['.*.js', '*.config.{js,ts}'],
557
+ export const stories = story
558
+
559
+ /**
560
+ * @type {Linter.Config}
561
+ */
562
+ export const config = {
563
+ name: '@1stg/config',
564
+ files: ['**/.*.js', '**/*.config.{js,ts}'],
516
565
  rules: nonSourceRules,
517
566
  }
518
567
 
519
- exports.json = {
520
- files: ['.*rc', '*.json'],
521
- excludedFiles: [...nonJsonRcFiles, ...jsoncFiles],
568
+ export const configs = config
569
+
570
+ export const json = tseslint.config({
571
+ name: '@1stg/json',
572
+ files: ['**/.*rc', '**/*.json'],
573
+ ignores: [...nonJsonRcFiles, ...jsoncFiles],
522
574
  extends: [
523
- 'plugin:jsonc/recommended-with-json',
524
- // eslint-disable-next-line sonarjs/no-duplicate-string
525
- 'plugin:jsonc/prettier',
575
+ jsonc_.configs['flat/recommended-with-json'],
576
+ jsonc_.configs['flat/prettier'],
526
577
  ],
527
- }
578
+ })
528
579
 
529
- exports.jsonc = {
580
+ export const jsonc = tseslint.config({
581
+ name: '@1stg/jsonc',
530
582
  files: jsoncFiles,
531
- extends: ['plugin:jsonc/recommended-with-jsonc', 'plugin:jsonc/prettier'],
532
- }
533
-
534
- exports.json5 = {
535
- files: '*.json5',
536
- extends: ['plugin:jsonc/recommended-with-json5', 'plugin:jsonc/prettier'],
537
- }
538
-
539
- exports.toml = {
540
- files: '*.toml',
541
- extends: ['plugin:toml/recommended'],
542
- }
543
-
544
- exports.yml = exports.yaml = {
545
- files: ['*.yml', '*.yaml'],
546
- extends: ['plugin:yml/recommended', 'plugin:yml/prettier'],
547
- }
583
+ extends: [
584
+ jsonc_.configs['flat/recommended-with-jsonc'],
585
+ jsonc_.configs['flat/prettier'],
586
+ ],
587
+ })
548
588
 
549
- exports.overrides = []
550
- // eslint-disable-next-line unicorn/prefer-spread
551
- .concat(
552
- isPkgAvailable('@babel/core') && exports.js,
553
- isTsAvailable && exports.ts,
554
- isReactAvailable && exports.react,
555
- isReactAvailable && exports.reactHooks,
556
- isReactAvailable && exports.reactTs,
557
- // The order matters, the later should to be preferred
558
- exports.markup,
559
- isAngularAvailable && exports.angular,
560
- isVueAvailable && exports.vue,
561
- isSvelteAvailable && exports.svelte,
562
- exports.md,
563
- exports.mdx,
564
- isPkgAvailable('jest') && exports.jest,
565
- exports.test,
566
- exports.scripts,
567
- exports.stories,
568
- exports.configs,
569
- exports.dTs,
570
- exports.json,
571
- exports.jsonc,
572
- exports.json5,
573
- exports.toml,
574
- exports.yaml,
575
- )
576
- .filter(Boolean)
589
+ export const json5 = tseslint.config({
590
+ name: '@1stg/json5',
591
+ files: ['**/*.json5'],
592
+ extends: [
593
+ jsonc_.configs['flat/recommended-with-json5'],
594
+ jsonc_.configs['flat/prettier'],
595
+ ],
596
+ })
597
+
598
+ export const toml = tseslint.config({
599
+ name: '@1stg/toml',
600
+ files: ['**/*.toml'],
601
+ extends: [toml_.configs['flat/recommended']],
602
+ })
603
+
604
+ export const yaml = tseslint.config({
605
+ files: ['**/*.yml', '**/*.yaml'],
606
+ extends: [yml_.configs['flat/recommended'], yml_.configs['flat/prettier']],
607
+ })
608
+
609
+ export const yml = yaml
610
+
611
+ const isReactAvailable = isPkgAvailable('react')
612
+
613
+ export const overrides = tseslint.config(
614
+ isPkgAvailable('@babel/core') ? js : [],
615
+ isTsAvailable ? ts : [],
616
+ isReactAvailable ? react : [],
617
+ // The order matters, the later should to be preferred
618
+ // markup,
619
+ isPkgAvailable('vue') ? vue : [],
620
+ isPkgAvailable('@angular/core') ? angular : [],
621
+ md,
622
+ mdx,
623
+ isPkgAvailable('jest') ? jest : [],
624
+ test,
625
+ scripts,
626
+ stories,
627
+ configs,
628
+ dTs,
629
+ json,
630
+ jsonc,
631
+ json5,
632
+ toml,
633
+ yaml,
634
+ )