@@ -65,6 +65,24 @@ export function addFilesIfNotSet(cfgs, files) {
65
65
} ) ;
66
66
}
67
67
68
+ /**
69
+ * Excludes configs that's language are prefixed with the given prefix.
70
+ *
71
+ * @param {Linter.Config[] } cfgs
72
+ * @param {string } prefix
73
+ *
74
+ * @returns {Linter.Config[] }
75
+ */
76
+ function excludeByLanguagePrefix ( cfgs , prefix ) {
77
+ return cfgs . filter ( ( cfg ) => {
78
+ if ( cfg . language === undefined ) {
79
+ return true ;
80
+ }
81
+
82
+ return ! cfg . language . startsWith ( prefix ) ;
83
+ } ) ;
84
+ }
85
+
68
86
/**
69
87
* @param {Linter.Config[] } cfgs
70
88
*
@@ -361,19 +379,21 @@ export function buildConfig(options) {
361
379
}
362
380
363
381
if ( options . typescript ) {
382
+ const xoCfg = excludeByLanguagePrefix ( xoTypescriptConfig , 'json/' ) ;
383
+
364
384
result . push (
365
385
...addFilesIfNotSet (
366
- [ importPlugin . flatConfigs . typescript , ...xoTypescriptConfig , { rules : tsRules } ] ,
386
+ [ importPlugin . flatConfigs . typescript , ...xoCfg , { rules : tsRules } ] ,
367
387
[ `**/*.{${ tsExtensions . join ( ',' ) } }` ]
368
388
) ,
369
389
...addFilesIfNotSet ( [ { rules : jsRules } ] , filesDefault )
370
390
) ;
371
391
}
372
392
373
393
if ( options . react ) {
374
- result . push (
375
- ... addFilesIfNotSet ( [ importPlugin . flatConfigs . react , ... xoReactConfig , { rules : reactRules } ] , filesDefault )
376
- ) ;
394
+ const xoCfg = excludeByLanguagePrefix ( xoReactConfig , 'json/' ) ;
395
+
396
+ result . push ( ... addFilesIfNotSet ( [ importPlugin . flatConfigs . react , ... xoCfg , { rules : reactRules } ] , filesDefault ) ) ;
377
397
}
378
398
379
399
if ( options . vitest ) {
0 commit comments