-
Notifications
You must be signed in to change notification settings - Fork 657
feat(rome_js_analyze): add noHeaderScope rule #3804
Conversation
✅ Deploy Preview for docs-rometools ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
fn action(ctx: &RuleContext<Self>, jsx_attr: &Self::State) -> Option<JsRuleAction> { | ||
let mut mutation = ctx.root().begin(); | ||
|
||
mutation.remove_node(jsx_attr.clone()); |
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 simple approach can leave some whitespaces in the JSX element, and I saw that we kinda handle it on the noAutoFocus rule, but I wonder if it's worth the effort here as the formatter can take care of 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.
Since users may opt-out of using the formatter and only enable the linter we try to ensure that code actions don't do something completely wrong with trivia like removing all whitespace, but it doesn't have to handle every edge case perfectly either.
fn action(ctx: &RuleContext<Self>, jsx_attr: &Self::State) -> Option<JsRuleAction> { | ||
let mut mutation = ctx.root().begin(); | ||
|
||
mutation.remove_node(jsx_attr.clone()); |
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.
Since users may opt-out of using the formatter and only enable the linter we try to ensure that code actions don't do something completely wrong with trivia like removing all whitespace, but it doesn't have to handle every edge case perfectly either.
crates/rome_js_analyze/src/analyzers/nursery/no_header_scope.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_header_scope.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_header_scope.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_header_scope.rs
Outdated
Show resolved
Hide resolved
2e63a54
to
755cb54
Compare
755cb54
to
8c655f2
Compare
Summary
Part of #3739
Closes #3815
Test Plan
Unit tests