-
Notifications
You must be signed in to change notification settings - Fork 666
feat(rome_js_analyze): noInferrableTypes
#4083
Conversation
✅ Deploy Preview for docs-rometools canceled.Built without sensitive environment variables
|
crates/rome_js_analyze/src/analyzers/nursery/no_inferrable_types.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_inferrable_types.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_inferrable_types.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_inferrable_types.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_inferrable_types.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_inferrable_types.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_inferrable_types.rs
Outdated
Show resolved
Hide resolved
i Safe fix: Remove the type annotation. | ||
|
||
2 │ const·x:·/*before*/·/*inside*/·1·/*after*/·=·(1); | ||
│ ------------------------------------ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix of the rule can't be flagged as "safe" because it removes trivia, as we can see in this snapshot. If removing trivia is the intended behaviour, then the fix should be Applicability:MaybIncorrect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not interventional. I fixed the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, we can merge once rebased and conflicts are resolved
Done :) |
Summary
Closes #4084
This implements ESLint's no-inferrable-types with some change:
readonly
properties are supportedexport const C: number = 1
). This also looks more consistent (ESLint allowsconst x: 1 | 2 = 1
. Thus whyconst x: number = 1
should be rejected?)String(1)
,Number('1')
...):. They may be shadowedundefined
value is not supported (undefined
may be shadowed)RegExp
is not supported because it may be shadowedTest Plan
Includes a large set of unit tests.
Documentation