diff --git a/tests/lib/rules/id-match.js b/tests/lib/rules/id-match.js index cb21e5d8f0b..5a1f75812f4 100644 --- a/tests/lib/rules/id-match.js +++ b/tests/lib/rules/id-match.js @@ -197,6 +197,46 @@ ruleTester.run("id-match", rule, { }], parserOptions: { ecmaVersion: 2022 } }, + { + code: ` + const foo = { + foo_one: 1, + bar_one: 2, + fooBar: 3 + }; + `, + options: ["^[^_]+$", { + properties: false + }], + parserOptions: { ecmaVersion: 2022 } + }, + { + code: ` + const foo = { + foo_one: 1, + bar_one: 2, + fooBar: 3 + }; + `, + options: ["^[^_]+$", { + onlyDeclarations: true + }], + parserOptions: { ecmaVersion: 2022 } + }, + { + code: ` + const foo = { + foo_one: 1, + bar_one: 2, + fooBar: 3 + }; + `, + options: ["^[^_]+$", { + properties: false, + onlyDeclarations: false + }], + parserOptions: { ecmaVersion: 2022 } + }, // Class Methods { @@ -800,6 +840,30 @@ ruleTester.run("id-match", rule, { type: "Identifier" } ] + }, + { + code: ` + const foo = { + foo_one: 1, + bar_one: 2, + fooBar: 3 + }; + `, + options: ["^[^_]+$", { + properties: true, + onlyDeclarations: false + }], + parserOptions: { ecmaVersion: 2022 }, + errors: [ + { + message: "Identifier 'foo_one' does not match the pattern '^[^_]+$'.", + type: "Identifier" + }, + { + message: "Identifier 'bar_one' does not match the pattern '^[^_]+$'.", + type: "Identifier" + } + ] } ] });