Skip to content

Commit 127f524

Browse files
authored
feat: false negative with property option in id-match (#15474)
Fixes #15443
1 parent 359b2c1 commit 127f524

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/rules/id-match.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ module.exports = {
250250
}
251251

252252
// never check properties or always ignore destructuring
253-
if (!checkProperties || (ignoreDestructuring && isInsideObjectPattern(node))) {
253+
if ((!checkProperties && !parent.computed) || (ignoreDestructuring && isInsideObjectPattern(node))) {
254254
return;
255255
}
256256

tests/lib/rules/id-match.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,26 @@ ruleTester.run("id-match", rule, {
894894
type: "Identifier"
895895
}
896896
]
897+
},
898+
899+
// https://github.com/eslint/eslint/issues/15443
900+
{
901+
code: `
902+
const foo = {
903+
[a]: 1,
904+
};
905+
`,
906+
options: ["^[^a]", {
907+
properties: false,
908+
onlyDeclarations: false
909+
}],
910+
parserOptions: { ecmaVersion: 2022 },
911+
errors: [
912+
{
913+
message: "Identifier 'a' does not match the pattern '^[^a]'.",
914+
type: "Identifier"
915+
}
916+
]
897917
}
898918
]
899919
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy