Skip to content

Commit 3bc69a6

Browse files
committed
fix: remove json configs from xo*
1 parent bbe158b commit 3bc69a6

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

index.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ export function addFilesIfNotSet(cfgs, files) {
6565
});
6666
}
6767

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+
6886
/**
6987
* @param {Linter.Config[]} cfgs
7088
*
@@ -361,19 +379,21 @@ export function buildConfig(options) {
361379
}
362380

363381
if (options.typescript) {
382+
const xoCfg = excludeByLanguagePrefix(xoTypescriptConfig, 'json/');
383+
364384
result.push(
365385
...addFilesIfNotSet(
366-
[importPlugin.flatConfigs.typescript, ...xoTypescriptConfig, {rules: tsRules}],
386+
[importPlugin.flatConfigs.typescript, ...xoCfg, {rules: tsRules}],
367387
[`**/*.{${tsExtensions.join(',')}}`]
368388
),
369389
...addFilesIfNotSet([{rules: jsRules}], filesDefault)
370390
);
371391
}
372392

373393
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));
377397
}
378398

379399
if (options.vitest) {

0 commit comments

Comments
 (0)