Skip to content

Commit

Permalink
fix(eslint-plugin): test falsy values and fix some metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
aifreedom committed Apr 23, 2022
1 parent 44afc2d commit 84db88d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
5 changes: 2 additions & 3 deletions packages/eslint-plugin/src/rules/no-duplicate-enum-values.ts
Expand Up @@ -8,11 +8,10 @@ export default util.createRule({
docs: {
description: 'Disallow duplicate enum member values',
recommended: false,
suggestion: true,
},
hasSuggestions: true,
messages: {
duplicateMember: 'Duplicate enum member with value {{value}}.',
duplicateValue: 'Duplicate enum member value {{value}}.',
},
schema: [],
},
Expand Down Expand Up @@ -58,7 +57,7 @@ export default util.createRule({
if (seenValues.has(value)) {
context.report({
node: member,
messageId: 'duplicateMember',
messageId: 'duplicateValue',
data: {
value,
},
Expand Down
Expand Up @@ -59,6 +59,17 @@ enum E {
B = 'B',
C = 2,
D = foo(),
}
`,
`
enum E {
A = false,
B = 0,
C = -0,
D = 0n,
E = null,
F = undefined,
G = NaN,
}
`,
],
Expand All @@ -74,7 +85,7 @@ enum E {
{
line: 4,
column: 3,
messageId: 'duplicateMember',
messageId: 'duplicateValue',
data: { value: 1 },
},
],
Expand All @@ -90,7 +101,7 @@ enum E {
{
line: 4,
column: 3,
messageId: 'duplicateMember',
messageId: 'duplicateValue',
data: { value: 'A' },
},
],
Expand All @@ -108,13 +119,13 @@ enum E {
{
line: 4,
column: 3,
messageId: 'duplicateMember',
messageId: 'duplicateValue',
data: { value: 'A' },
},
{
line: 6,
column: 3,
messageId: 'duplicateMember',
messageId: 'duplicateValue',
data: { value: 1 },
},
],
Expand Down

0 comments on commit 84db88d

Please sign in to comment.