Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

[FIX][no-unused-vars] add EnumMember #236

Merged
merged 3 commits into from
Dec 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ module.exports = {
// just assume parameter properties are used
context.markVariableAsUsed(node.name);
},
"TSEnumMember Identifier"(node) {
context.markVariableAsUsed(node.name);
},
};
},
};
39 changes: 39 additions & 0 deletions tests/lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,30 @@ export class Baz<F = Foo & Bar> {}
// warning 'B' is defined but never used
export const a: Array<{b: B}> = []
`,
`
export enum FormFieldIds {
PHONE = 'phone',
EMAIL = 'email',
}
`,
`
enum FormFieldIds {
PHONE = 'phone',
EMAIL = 'email',
}
interface IFoo {
fieldName: FormFieldIds,
}
`,
`
enum FormFieldIds {
PHONE = 'phone',
EMAIL = 'email',
}
interface IFoo {
fieldName: FormFieldIds.EMAIL,
}
`,
],

invalid: [
Expand Down Expand Up @@ -709,5 +733,20 @@ new A();
},
],
},
{
code: `
enum FormFieldIds {
PHONE = 'phone',
EMAIL = 'email',
}
`,
errors: [
{
message: "'FormFieldIds' is defined but never used.",
line: 2,
column: 6,
},
],
},
],
});