Skip to content

Commit

Permalink
fix(eslint-plugin): [no-magic-numbers] handle bigint in class props (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Jan 17, 2022
1 parent 253bfa3 commit c8e650f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-magic-numbers.ts
Expand Up @@ -69,7 +69,7 @@ export default util.createRule<Options, MessageIds>({

// Check if the node is a readonly class property
if (
typeof node.value === 'number' &&
(typeof node.value === 'number' || typeof node.value === 'bigint') &&
isParentTSReadonlyPropertyDefinition(node)
) {
if (options.ignoreReadonlyClassProperties) {
Expand Down
10 changes: 10 additions & 0 deletions packages/eslint-plugin/tests/rules/no-magic-numbers.test.ts
Expand Up @@ -53,6 +53,7 @@ class Foo {
static readonly D = 1;
readonly E = -1;
readonly F = +1;
private readonly G = 100n;
}
`,
options: [{ ignoreReadonlyClassProperties: true }],
Expand Down Expand Up @@ -204,6 +205,7 @@ class Foo {
static readonly D = 4;
readonly E = -5;
readonly F = +6;
private readonly G = 100n;
}
`,
options: [{ ignoreReadonlyClassProperties: false }],
Expand Down Expand Up @@ -256,6 +258,14 @@ class Foo {
line: 8,
column: 17,
},
{
messageId: 'noMagic',
data: {
raw: '100n',
},
line: 9,
column: 24,
},
],
},
],
Expand Down

0 comments on commit c8e650f

Please sign in to comment.