Skip to content

Commit

Permalink
feat: false negative with property option in id-match (#15474)
Browse files Browse the repository at this point in the history
Fixes #15443
  • Loading branch information
snitin315 committed Jan 6, 2022
1 parent 359b2c1 commit 127f524
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/id-match.js
Expand Up @@ -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;
}

Expand Down
20 changes: 20 additions & 0 deletions tests/lib/rules/id-match.js
Expand Up @@ -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.