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

Breaking: make radix rule stricter #12608

Merged
merged 6 commits into from Jan 20, 2020
Merged

Conversation

fisker
Copy link
Contributor

@fisker fisker commented Nov 27, 2019

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

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

What changes did you make? (Give an overview)

What rule do you want to change?

radix

Does this change cause the rule to produce more or fewer warnings?
more warnings

How will the change be implemented? (New option, new default behavior, etc.)?

new default behavior

Please provide some example code that this change will affect:

before, radix only check second param is number , this PR only allow integer between 2 and 36 ref: parseInt Syntax

var num = parseInt("071", 37); // valid before, invalid now

What does the rule currently do for this code?

What will the rule do after it's changed?

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

@jsf-clabot
Copy link

jsf-clabot commented Nov 27, 2019

CLA assistant check
All committers have signed the CLA.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Nov 27, 2019
@fisker
Copy link
Contributor Author

fisker commented Dec 21, 2019

Any chance this get merged?

@kaicataldo kaicataldo added breaking This change is backwards-incompatible evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Dec 21, 2019
Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

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

Apologies for the delay in reviewing this. I'm personally not against this change, though I do think we either need to put it behind an option or release it in the next major release.

Can we update the documentation to make this behavior more transparent for end users?

Finally, we'll need a three more supporters from the team before we can mark this as accepted.

@kaicataldo kaicataldo self-assigned this Dec 21, 2019
@kaicataldo
Copy link
Member

I'll champion this.

@platinumazure
Copy link
Member

I'll support this, but as @kaicataldo said, this either needs to be flagged as a breaking change or needs to be put behind an option.

@fisker
Copy link
Contributor Author

fisker commented Dec 23, 2019

Thank you guys, any further work should I do?

@kaicataldo
Copy link
Member

Nope! We just need one more 👍 for the team. Since we're now prepping our next release, I think it's fine to make this a breaking change.

@btmills btmills 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 Jan 17, 2020
@btmills
Copy link
Member

btmills commented Jan 17, 2020

Nice enhancement! I've added my 👍 and marked this as accepted.

Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

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

Nice work on this! It'll be a nice enhancement. The implementation looks good as-is, though if you're willing to add it, reporting a separate message for an out-of-bounds radix might be helpful. For example, "Radix must be an integer between 2 and 36 inclusive" or something like that.

Can you also add a test with a non-integer radix so that we don't accidentally allow e.g. 10.5 in a future code change? LGTM once that's done.

@kaicataldo kaicataldo changed the title Update: make radix rule stricter Breaking: make radix rule stricter Jan 17, 2020
@fisker
Copy link
Contributor Author

fisker commented Jan 18, 2020

Changed message to Invalid radix parameter, must be an integer between 2 and 36.

Add tests, including 10.0 1.6e1 0x10 and 10.5

@btmills

Copy link
Member

@btmills btmills 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 for contributing!

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

It would be nice to add tests for boundary values: valid 2 and 36 and invalid 1 (37 is already tested).

@fisker
Copy link
Contributor Author

fisker commented Jan 19, 2020

@mdjermanovic Done 72ef36f

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

Thanks 👍

LGTM!

@kaicataldo kaicataldo merged commit c2217c0 into eslint:master Jan 20, 2020
@kaicataldo
Copy link
Member

Thanks for contributing to ESLint!

@fisker fisker deleted the strict-radix branch January 20, 2020 05:23
montmanu pushed a commit to montmanu/eslint that referenced this pull request Mar 4, 2020
* Update: make `radix` rule stricter

* style: remove extra blank line

* Update message, more tests

* Variable name & exponential notation test

* test `10.0`

* Add tests `1` `2` `36`
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 20, 2020
@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 Jul 20, 2020
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 breaking This change is backwards-incompatible rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants