diff --git a/lib/rules/id-match.js b/lib/rules/id-match.js index 977e66a26ad..8713a5f9f8b 100644 --- a/lib/rules/id-match.js +++ b/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; } diff --git a/tests/lib/rules/id-match.js b/tests/lib/rules/id-match.js index de66d8b8d55..7e469bd4d5b 100644 --- a/tests/lib/rules/id-match.js +++ b/tests/lib/rules/id-match.js @@ -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" + } + ] } ] });