Skip to content

Commit

Permalink
Fix jsonc/auto detection of rules being "off" (#188)
Browse files Browse the repository at this point in the history
Co-authored-by: Clement Yan <clement.yan@acqra.com>
  • Loading branch information
clemyan and Clement Yan committed Aug 16, 2022
1 parent 7de41de commit 6dd88e4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/utils/get-auto-jsonc-rules-config.ts
Expand Up @@ -134,8 +134,11 @@ export function getAutoConfig(filename: string): {
const jsoncName = getJsoncRule(ruleName)
if (jsoncName && !config.rules[jsoncName]) {
const entry = config.rules[ruleName]
if (entry && entry !== "off") {
autoConfig[jsoncName] = entry
if (entry) {
const severity = Array.isArray(entry) ? entry[0] : entry
if (severity !== "off" && severity !== 0) {
autoConfig[jsoncName] = entry
}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/auto/test03/.eslintrc.json
@@ -0,0 +1,7 @@
{
"root": true,
"extends": ["eslint:all"],
"rules": {
"indent": ["off", 4]
}
}
6 changes: 6 additions & 0 deletions tests/lib/rules/auto.ts
Expand Up @@ -24,6 +24,12 @@ tester.run("auto", rule as any, {
</i18n>`,
parser: require.resolve("vue-eslint-parser"),
},
{
filename: path.join(ROOT_DIR, "test03", "test.json"),
code: `{
"foo": "bar"
}`,
},
],
invalid: [
{
Expand Down

0 comments on commit 6dd88e4

Please sign in to comment.