-
-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(linter): tree_shaking/no_side_effects_in_initialization
handle JSX correctly
#5450
fix(linter): tree_shaking/no_side_effects_in_initialization
handle JSX correctly
#5450
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @overlookmotel and the rest of your teammates on Graphite |
CodSpeed Performance ReportMerging #5450 will not alter performanceComparing Summary
|
Your org has enabled the Graphite merge queue for merging into mainAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
I am actually not sure this is quite correct. Please see the snapshot change. The old error But is the new error correct?? I am not familiar with this rule (or the linter in general), so am having difficulty in determining if this is correct or not. @DonIsaac or @camc314 can you please advise? |
I unfortunately have no context into this, but I can handle it if @camc314 is unable to. |
b04ca3a
to
1ea1431
Compare
Merge activity
|
…JSX correctly (#5450) #5223 altered `JSXElementName` so `JSXElementName::Identifier` is used only for non-reference JSX names (e.g. `<div>`). `JSXElementName::IdentifierReference` is used where the name is a reference (e.g. `<Foo>`). Similarly `JSXMemberExpressionObject`'s `object` is always an `IdentifierReference` now. So, the net result is that `JSXIdentifier` is now never a reference, it's just the JSX equivalent of `IdentifierName`. So I don't think `JSXIdentifier` can ever have side-effects. This PR: 1. Removes `impl ListenerMap for JSXIdentifier` 2. Adds `impl ListenerMap for JSXMemberExpression` and makes sure the root `IdentifierReference` (`Foo` in `<Foo.bar.qux>`) is visited.
1ea1431
to
82c0a16
Compare
We only merged because we wanted to get the upstack PR merged. The question of whether the error is correct or not is still open. @Boshen Git blame says you wrote this code. Sounds like DonIsaac is not familiar with this lint rule, so it's hard for him to answer my query. Can you please take a look? |
@mysteryven Can you double check whether the code is correct or not? |
Follow up #5450. [eslint-plugin-tree-shaking](https://github.com/lukastaegert/eslint-plugin-tree-shaking/blob/463fa1f0bef7caa2b231a38b9c3557051f506c92/src/rules/no-side-effects-in-initialization.ts#L673-L677) just report on `JSXMemberExpression.property` ![CleanShot 2024-09-06 at 22 34 55@2x](https://github.com/user-attachments/assets/a8dbfe43-daf8-4b96-b812-8afff5939b34)
## [0.9.3] - 2024-09-07 ### Features - be3a432 linter: Implement typescript/no-magic-numbers (#4745) (Alexander S.) - 09aa86d linter/eslint: Implement `sort-vars` rule (#5430) (Jelle van der Waa) - 2ec2f7d linter/eslint: Implement no-alert (#5535) (Edwin Lim) - a786acf linter/import: Add no-dynamic-require rule (#5389) (Jelle van der Waa) - 4473779 linter/node: Implement no-exports-assign (#5370) (dalaoshu) - b846432 linter/oxc: Add fixer for `erasing-op` (#5377) (camc314) - aff2c71 linter/react: Implement `self-closing-comp` (#5415) (Jelle van der Waa) ### Bug Fixes - 0df1d9d ast, codegen, linter: Panics in fixers. (#5431) (rzvxa) - cdd1a91 linter: Typescript/no-magic-numbers: remove double minus for reporting negative bigint numbers (#5565) (Alexander S.) - ff88c1f linter: Don't mark binding rest elements as unused in TS function overloads (#5470) (Cam McHenry) - 088733b linter: Handle loops in `getter-return` rule (#5517) (Cam McHenry) - 82c0a16 linter: `tree_shaking/no_side_effects_in_initialization` handle JSX correctly (#5450) (overlookmotel) - 6285a02 linter: `eslint/radix` rule correctly check for unbound symbols (#5446) (overlookmotel) - c8ab353 linter/tree-shaking: Align JSXMemberExpression's report (#5548) (mysteryven) - 5187f38 linter/tree-shaking: Detect the correct export symbol resolution (#5467) (mysteryven) ### Performance - 8170954 linter/react: Add should_run conditions for react rules (#5402) (Jelle van der Waa) ### Documentation - a540215 linter: Update docs `Examples` for linter rules (#5513) (dalaoshu) - 7414190 linter: Update docs `Example` for linter rules (#5479) (heygsc) ### Refactor - 0ac420d linter: Use meaningful names for diagnostic parameters (#5564) (Don Isaac) - 81a394d linter: Deduplicate code in `oxc/no-async-await` (#5549) (DonIsaac) - 979c16c linter: Reduce nested if statements in eslint/no_this_before_super (#5485) (IWANABETHATGUY) - 1d3e973 linter: Simplify `eslint/radix` rule (#5445) (overlookmotel) - fdb8857 linter: Use "parsed pattern" in `no_div_regex` rule. (#5417) (rzvxa) - 2ccbd93 linter: `react/jsx_no_undef` rule `get_member_ident` do not return Option (#5411) (overlookmotel) ### Styling - 2a43fa4 linter: Introduce the writing style from PR #5491 and reduce the if nesting (#5512) (dalaoshu)- d8b29e7 Add trailing line breaks to JSON files (#5544) (overlookmotel)- 694f032 Add trailing line breaks to `package.json` files (#5542) (overlookmotel) ### Testing - 340b535 linter/no-unused-vars: Arrow functions in tagged templates (#5510) (Don Isaac) - af69393 linter/no-useless-spread: Ensure spreads on identifiers pass (#5561) (DonIsaac)- dc92489 Add trailing line breaks to conformance fixtures (#5541) (overlookmotel) Co-authored-by: Boshen <[email protected]>
#5223 altered
JSXElementName
soJSXElementName::Identifier
is used only for non-reference JSX names (e.g.<div>
).JSXElementName::IdentifierReference
is used where the name is a reference (e.g.<Foo>
). SimilarlyJSXMemberExpressionObject
'sobject
is always anIdentifierReference
now.So, the net result is that
JSXIdentifier
is now never a reference, it's just the JSX equivalent ofIdentifierName
. So I don't thinkJSXIdentifier
can ever have side-effects.This PR:
impl ListenerMap for JSXIdentifier
impl ListenerMap for JSXMemberExpression
and makes sure the rootIdentifierReference
(Foo
in<Foo.bar.qux>
) is visited.