Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: add fixer for prefer-numeric-literals #7205

Merged
merged 1 commit into from Sep 30, 2016

Conversation

not-an-aardvark
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[x] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

Please check each item to ensure your pull request is ready:

  • I've read the pull request guide
  • I've included tests for my change
  • I've updated documentation for my change (if appropriate)

What changes did you make? (Give an overview)

This adds a fixer for prefer-numeric-literals.

When given a function call such as parseInt('123', 16), the fixer replaces it with 0x123.

parseInt has some weird behavior; it accepts strings that look invalid. For example, parseInt('1 foo bar baz', 16) returns 1. The fixer only performs a fix if the literal in parseInt() would also be parseable as a regular number literal.

Is there anything you'd like reviewers to focus on?

Nothing in particular.

@mention-bot
Copy link

@not-an-aardvark, thanks for your PR! By analyzing the annotation information on this pull request, we identified @azhang496 to be a potential reviewer

@eslintbot
Copy link

LGTM

@platinumazure
Copy link
Member

Just one question about the very last invalid test-- it looks like an unquoted string is used for parseInt, is that just a rendering issue on GitHub?

@not-an-aardvark
Copy link
Member Author

I think it's just a rendering issue -- it looks fine for me. (screenshot)

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@platinumazure
Copy link
Member

Ah, when I highlighted individual characters I eventually saw the quotes. Firefox rendering issue indeed, thanks.

Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@mysticatea mysticatea added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Sep 23, 2016
@platinumazure platinumazure self-assigned this Sep 23, 2016
@platinumazure
Copy link
Member

I'll champion this one-- just need one more endorsement to accept.

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Sep 29, 2016
@nzakas nzakas merged commit c05a19c into eslint:master Sep 30, 2016
@not-an-aardvark not-an-aardvark deleted the prefer-numeric-literals-fixer branch September 30, 2016 18:15
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants