feat(lint): implement noImplicitCoercion rule#6395
Conversation
CodSpeed Performance ReportMerging #6395 will degrade performances by 17.01%Comparing Summary
Benchmarks breakdown
|
arendjr
left a comment
There was a problem hiding this comment.
Nice work and solid implementation!
| trait ExpressionExt { | ||
| /// Returns the actual expression, i.e. in case of parenthesized expressions | ||
| /// it returns the inner expression. | ||
| fn actual_expression(&self) -> Option<AnyJsExpression>; |
There was a problem hiding this comment.
Suggestion:
| fn actual_expression(&self) -> Option<AnyJsExpression>; | |
| fn inner_expression(&self) -> Option<AnyJsExpression>; |
| 1 * a / 2; | ||
| (a * 1) / 2; | ||
| a * 1 / (b * 1); | ||
| /* test */ a * 1 + 2; |
There was a problem hiding this comment.
If possible, we could add another test with a trailing comment
/* test */ a /*comment*/ * 1 + 2;
🦋 Changeset detectedLatest commit: 37f852d The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@mdevils I changed the changeset to |
c32b034 to
38476da
Compare
|
Rebased. |
Summary
Added the new rule
noImplicitCoercion, which disallows shorthand type conversions in favor of explicit type conversion functions.Example (Invalid): Boolean conversion using double negation:
Example (Invalid): Number conversion using unary operators:
Example (Invalid): String conversion using concatenation:
Example (Invalid): Index checking using bitwise NOT:
Example (Valid): Using explicit type conversion functions:
Test Plan
Tests are included.
Closes #3935.