prefer-math-trunc
: Use suggestion instead of fix for x | 0
#1014
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use a suggestion rather than an autofix for the
| 0
case, to prevent incorrectly transforming Int32's casts.I've only done it for
| 0
but I can do it for all the cases too (~~x
,x >> 0
,x << 0
,x ^ 0
).I've not updated the test because I have no idea how to do so with the "visual tester". Does it support suggestions? If no, do I have to move all tests containing| 0
to the invalid array?I've already done something like this, taking inspiration from the
prefer-node-remove
rule ; but I don't know if I should really move all of them, if this is the right thing to do, and mostly, how to deal with the "multiple-in-one" tests, such asconst foo = ~~(bar| 0);
With the new suggestion support to the visuazizetester, this is no longer applicable
Fixes #911