question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[no-magic-numbers] - Add an option to omit numbers check in array declaration

See original GitHub issue

What rule do you want to change? no-magic-numbers Does this change cause the rule to produce more or fewer warnings? less How will the change be implemented? (New option, new default behavior, etc.)? new option to skip showing error Please provide some example code that this change will affect:

const arr = [0, 1, 2];

also here - https://github.com/eslint/eslint/issues/11383 What does the rule currently do for this code? shows error What will the rule do after it’s changed? not show error Are you willing to submit a pull request to implement this change? nope

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
avalanche1commented, Feb 8, 2020

Still me and my team would like to have an option for arrays as I initially requested.

1reaction
kaicataldocommented, Feb 6, 2020
const [widht, height] = [10, 20];

This case being reported does feel like a bug to me, because these are named. I agree it would be nice to update this rule to check for hard-coded numbers that are assigned using destructuring (both array and object).

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-magic-numbers - ESLint - Pluggable JavaScript Linter
'Magic numbers' are numbers that occur multiple times in code without an explicit meaning. They should preferably be replaced by named constants.
Read more >
no-magic-numbers - TypeScript ESLint
See eslint/no-magic-numbers options. This rule adds the following options: interface Options extends BaseNoMagicNumbersOptions { ignoreEnums?: boolean;
Read more >
eslint no-magic-numbers rule can't ignore checking number ...
I'm new to eslint. With "no-magic-numbers" rule turned on, declare an array with number literal can't be ignored.eg. let array = [1, 2,...
Read more >
no-magic-numbers - Rule
Rule: no-magic-numbers​​ Disallows the use constant number values outside of variable assignments. When no list of allowed values is specified, -1, 0 and...
Read more >
Replace Magic Number with Symbolic Constant
Declare a constant and assign the value of the magic number to it. · Find all mentions of the magic number. · For...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found