Skip to content
Permalink
Browse files
feat: false negative with property option in id-match (#15474)
Fixes #15443
  • Loading branch information
snitin315 committed Jan 6, 2022
1 parent 359b2c1 commit 127f524337f92dd72d36e71e646c91c9715ad444
Showing with 21 additions and 1 deletion.
  1. +1 −1 lib/rules/id-match.js
  2. +20 −0 tests/lib/rules/id-match.js
@@ -250,7 +250,7 @@ module.exports = {
}

// never check properties or always ignore destructuring
if (!checkProperties || (ignoreDestructuring && isInsideObjectPattern(node))) {
if ((!checkProperties && !parent.computed) || (ignoreDestructuring && isInsideObjectPattern(node))) {
return;
}

@@ -894,6 +894,26 @@ ruleTester.run("id-match", rule, {
type: "Identifier"
}
]
},

// https://github.com/eslint/eslint/issues/15443
{
code: `
const foo = {
[a]: 1,
};
`,
options: ["^[^a]", {
properties: false,
onlyDeclarations: false
}],
parserOptions: { ecmaVersion: 2022 },
errors: [
{
message: "Identifier 'a' does not match the pattern '^[^a]'.",
type: "Identifier"
}
]
}
]
});

0 comments on commit 127f524

Please sign in to comment.