Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-magic-numbers should ignore various Number methods' params #3653

Closed
mateuszwitkowski opened this issue Jan 15, 2018 · 4 comments
Closed

Comments

@mateuszwitkowski
Copy link
Contributor

Bug Report

Since linter now ingores radix param in parseInt method maybe it should be good to standardize how params are handled in those Number methods:

  • toFixed()
  • toExponential()
  • toPrecision()

TypeScript code being linted

someNumber.toFixed(2);
someNumber.toExponential(4);
someNumber.toPrecision(2);

with tslint.json configuration:

{
  "no-magic-number": true
}

Actual behavior

[tslint] 'magic numbers' are not allowed (no-magic-numbers)

Expected behavior

No error.

@mateuszwitkowski
Copy link
Contributor Author

If it's OK I'd like to take care of this but I need some hint: how to get the name of called method?

@aervin
Copy link
Contributor

aervin commented Jan 20, 2018

@mateuszwitkowski You should paste these snippets

someNumber.toFixed(2);
someNumber.toExponential(4);
someNumber.toPrecision(2);

into ast-explorer to get a better idea of the AST nodes you'll be parsing.

@mateuszwitkowski
Copy link
Contributor Author

@aervin That's great tool. Thanks!

@JoshuaKGoldberg
Copy link
Contributor

This was fixed by #3668 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants