+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

fix(rome_js_analyze): improve the handling of trivia in useBlockStatements #2981

Merged
merged 2 commits into from
Aug 2, 2022

Conversation

leops
Copy link
Contributor

@leops leops commented Aug 1, 2022

Summary

This PR fixes #2943 by introducing additional logic in the code generating the auto-fix for the rule to inspect the tokens and nodes being modified, and move or add trivia pieces accordingly.

I also fixed the query used by the rule to ensure it would trigger separately for if statements and else clauses, ensuring both the consequent and alternate statements would have a diagnostic and code action emitted, and not only the first one visited by the rule.

Test Plan

I added a number of additional test cases in the snapshot tests for the rule to verify the handling of empty statements in if-else chains and indentation

@leops leops requested a review from xunilrj as a code owner August 1, 2022 13:13
Base automatically changed from fix/mutation-remove-list to main August 2, 2022 08:44
@leops leops requested a review from MichaReiser as a code owner August 2, 2022 08:44
@leops leops requested a review from a team August 2, 2022 08:44
@leops leops force-pushed the fix/use-block-statements branch from 0397a9d to eb9aed0 Compare August 2, 2022 08:46
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 2, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3046015
Status: ✅  Deploy successful!
Preview URL: https://3d25172d.tools-8rn.pages.dev
Branch Preview URL: https://fix-use-block-statements.tools-8rn.pages.dev

View logs

@leops leops temporarily deployed to aws August 2, 2022 08:46 Inactive
@github-actions
Copy link

github-actions bot commented Aug 2, 2022

@leops leops temporarily deployed to aws August 2, 2022 08:53 Inactive
@leops leops merged commit 9c7cc07 into main Aug 2, 2022
@leops leops deleted the fix/use-block-statements branch August 2, 2022 15:09
IWANABETHATGUY pushed a commit to IWANABETHATGUY/tools that referenced this pull request Aug 22, 2022
…ements` (rome#2981)

* fix(rome_js_analyze): improve the handling of trivia in `useBlockStatements`

* run lintdoc
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Misaligned code fix for js/useBlockStatements
2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载