-
Notifications
You must be signed in to change notification settings - Fork 660
feat(rome_js_analyze): improvements to noUnusedVariables to consider catch, typescript and export #3004
feat(rome_js_analyze): improvements to noUnusedVariables to consider catch, typescript and export #3004
Conversation
Deploying with Cloudflare Pages
|
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.
Now that we have multiple files for the same rule, I think it will work better for to create a folder called noUnusedVariables/
and have there the files? We already do this for some other rule
Done. But now we strangely have a "noUnusedVariables" group. Not so sure I like that. |
Ah, I am not sure how things are set up, but I was referring to something like this: |
ac87f6d
to
a20d3e4
Compare
@@ -71,6 +72,43 @@ declare_rule! { | |||
} | |||
} | |||
|
|||
// It is ok in some Typescripts constructs for a parameter to be unused. | |||
fn is_typescript_unused_ok(binding: &JsIdentifierBinding) -> Option<()> { |
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.
Should this check be moved to the semantic model builder ? It could make sense to consider that identifiers in TypeScript declarations do not create a new binding in the semantic model
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.
Yes. It will as an "is_used" query. Or something like that.
@xunilrj could you please re-open the issue or create new issues to list what we are missing in order to make the rule stable? |
|
||
Some(JsRuleAction { | ||
category: ActionCategory::QuickFix, | ||
applicability: Applicability::Unspecified, |
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.
We should either choose Always
or MaybeIncorrect
. Using Unspecified
means that its applicability is unknown, which is not the case. Since the rule is still unstable, we should choose MaybeIncorrect
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.
Done.
a20d3e4
to
c0f2624
Compare
|
||
# Diagnostics | ||
``` | ||
warning[no_unused_variables/noUnusedVariables]: This variable is unused. |
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.
Out of curiosity, is this expected? The no_unused_variables/
part. (it should be js
)
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.
hum... I think this is part of the confusion with "groups". I will fix it.
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.
Done
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.
A suggestion: maybe we should not recommend this rule for the time being?
This is actually a very interesting issue: our lint rules are unstable, and some of them have a number of false positive issues due to the complexity of statically analyzing JavaScript code. |
Fortunately people can turn off rules via configuration now, so there's a good workaround in case of errors, and people won't be blocked. Less pressure for fixes. So yeah, I think it's worth turn them on and fix possible errors. |
df5fa3c
to
c6ce7e5
Compare
c6ce7e5
to
1e50f87
Compare
…catch, typescript and export (rome#3004) * improvements to noUnusedVariables to consider catch, typescript and export.
Summary
This expands #2979 with two extra cases:
Now we recommend removing the whole catch declaration:
and we don´t generate false positives to interfaces and abstract methods on Typescript and exported functions.
Test Plan