Skip to content

Commit 15d0960

Browse files
authored
fix(eslint-plugin): [no-unused-vars] never report the naming of an enum member (#10117)
do the thing
1 parent 2fa6e4c commit 15d0960

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎packages/eslint-plugin/src/rules/no-unused-vars.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,13 @@ export default createRule<Options, MessageIds>({
522522
def.name.type === AST_NODE_TYPES.Identifier &&
523523
options.varsIgnorePattern?.test(def.name.name)
524524
) {
525-
if (options.reportUsedIgnorePattern && used) {
525+
if (
526+
options.reportUsedIgnorePattern &&
527+
used &&
528+
/* enum members are always marked as 'used' by `collectVariables`, but in reality they may be used or
529+
unused. either way, don't complain about their naming. */
530+
def.type !== TSESLint.Scope.DefinitionType.TSEnumMember
531+
) {
526532
context.report({
527533
node: def.name,
528534
messageId: 'usedIgnoredVar',

‎packages/eslint-plugin/tests/rules/no-unused-vars/no-unused-vars.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,5 +2266,13 @@ import { foo } from 'foo';
22662266
22672267
export type Bar = typeof foo;
22682268
`,
2269+
{
2270+
code: `
2271+
export enum Foo {
2272+
_A,
2273+
}
2274+
`,
2275+
options: [{ reportUsedIgnorePattern: true, varsIgnorePattern: '_' }],
2276+
},
22692277
],
22702278
});

0 commit comments

Comments
 (0)