The radix rule should provide fixers
See original GitHub issueWhat 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:
- Created 4 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
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.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.