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.

The radix rule should provide fixers

See original GitHub issue

What rule do you want to change? radix

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

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

Please provide some example code that this change will affect:

/*eslint radix: "error"*/

var num = parseInt("071");

/*eslint radix: ["error", "as-needed"]*/

var num = parseInt("071", 10);

What does the rule currently do for this code? it reports problems in both cases, but requires fixing manually

What will the rule do after it’s changed? It should at least be able to fix the Redundant radix error, as there is only one valid way to perform it (removing the second argument).

For the missing radix (when using the default always configuration), I think it would also be fine to implement a fix adding a second argument with value 10, as that’s the expected behavior.

Are you willing to submit a pull request to implement this change? I might try, but I have no experience writing rules and fixers for them.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
stofcommented, Dec 6, 2019

Well, the Invalid radix might have multiple ways to fix it, but I don’t think any of them could be suggested (as the cause is a bug in the code that probably require a dev to look at it). The case of having no argument at all won’t be fixable either. But I think it is fine to have 2 fixable problems and 2 non-fixable problems in the rule rather than 4 non-fixable problems.

1reaction
kaicataldocommented, Dec 7, 2019

Given what @mdjermanovic listed above, I think suggestions might be the best course of action for both these cases.

We don’t want to make any assumptions in autofixing, because many users run auto fixing on save or as a pre-commit hook.

Read more comments on GitHub >

github_iconTop Results From Across the Web

radix - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
JSLint says "missing radix parameter" - Stack Overflow
It always a good practice to pass radix with parseInt - parseInt(string, radix). For decimal - parseInt(id.substring(id.length - 1), 10).
Read more >
Fixed-Point Number - an overview | ScienceDirect Topics
Fixed point numbers are stored as integers, and integer operations are performed on them. However, the programmer assigns a radix point location to...
Read more >
radix - Rule
Rule : radix ... Requires the radix parameter to be specified when calling parseInt . Rationale. From MDN: Always specify this parameter to...
Read more >
Radix Sort Algorithm, Examples & Problems - Interview Kickstart
Radix Sort Example: LSD to MSD · This array consists of integers in the decimal number system — so the digits will range...
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