eslint-config-xo
Version:
ESLint shareable config for XO
53 lines (48 loc) • 1.02 kB
JavaScript
import json from '@eslint/json';
const jsonRules = {
'json/no-duplicate-keys': 'error',
'json/no-empty-keys': 'error',
'json/no-unsafe-values': 'error',
'json/no-unnormalized-keys': 'error',
};
// `jsonConfig` must come before `jsoncConfig` so that files matching both (e.g. `tsconfig.json`) end up with `language: 'json/jsonc'` instead of `'json/json'`, which would reject the JSONC-only `allowTrailingCommas` option.
export const jsonConfig = {
name: 'xo/json',
plugins: {
json,
},
files: [
'**/*.json',
],
language: 'json/json',
rules: jsonRules,
};
export const jsoncConfig = {
name: 'xo/jsonc',
plugins: {
json,
},
files: [
'**/*.jsonc',
'**/{ts,js}config.json',
'**/{ts,js}config.*.json',
'**/{,.}dprint.json',
'.vscode/*.json',
],
language: 'json/jsonc',
languageOptions: {
allowTrailingCommas: true,
},
rules: jsonRules,
};
export const json5Config = {
name: 'xo/json5',
plugins: {
json,
},
files: [
'**/*.json5',
],
language: 'json/json5',
rules: jsonRules,
};