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

feat(rome_js_analyze): noUselessSwitchCase #3912

Merged
merged 2 commits into from
Dec 9, 2022
Merged

feat(rome_js_analyze): noUselessSwitchCase #3912

merged 2 commits into from
Dec 9, 2022

Conversation

Conaclos
Copy link
Contributor

@Conaclos Conaclos commented Nov 30, 2022

Summary

This implements Unicorn's no-useless-switch-case with the difference that we also handle cases after default. This makes the Rome's rule more complete than Unicorn's one.

Impl choices

I chose to remove comments just before and after a useless case:

 switch (foo) {
-	  /* remove comment */ case 0: /* remove comment */
         // keep comment
	 default:
		 break;
   }

And to transfer the comment just before the statement list:

 switch (foo) {
-	default: /* keep comment */
-	/* remove comment */ case 0: /* transfer this comment */
+     default: /* keep comment *//* transfer this comment */
		break;
}

Test Plan

Unit test and doc-tests included.

@Conaclos Conaclos requested review from leops, ematipico, xunilrj and a team as code owners November 30, 2022 22:47
@netlify
Copy link

netlify bot commented Nov 30, 2022

Deploy Preview for docs-rometools ready!

Name Link
🔨 Latest commit d66349e
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/6393238e63a90e0009982652
😎 Deploy Preview https://deploy-preview-3912--docs-rometools.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Contributor

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. My only concern is around the applicability.

Copy link
Contributor

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to merge once the conflicts are resolved!

@MichaReiser MichaReiser added A-Linter Area: linter L-JavaScript Langauge: JavaScript labels Dec 9, 2022
@MichaReiser MichaReiser merged commit 88bc8e1 into rome:main Dec 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Linter Area: linter L-JavaScript Langauge: JavaScript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载