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

Conversation

denbezrukov
Copy link
Contributor

Summary

Fix #3969

Test Plan

cargo test

@netlify
Copy link

netlify bot commented Dec 11, 2022

Deploy Preview for docs-rometools ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 5330fa3
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/63a177b7059265000807729f
😎 Deploy Preview https://deploy-preview-4039--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.

for case in node.cases() {
if let AnyJsSwitchClause::JsCaseClause(case) = case {
if let Ok(test) = case.test() {
let text = test.text();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is it enough to compare text? Or we need to travers expression tree?
Can we get text without inner comment?
For example:

switch (a) {
	case f(
		a + 1 // comment
	).p1:
		break;
	case f(a + 1).p1:
		break;
	default:
		break;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This is similar to the check being performed in #4031, maybe there's an opportunity to move this comparison in a shared utility for these two rules

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to do that?

It seems to me this would be case for another lint rule: to only allow constants as the case.

This will fall into the same cases as the binary: these expression can have side effects (or throw) and we will be changing the application behaviour.

Copy link
Contributor Author

@denbezrukov denbezrukov Dec 17, 2022

Choose a reason for hiding this comment

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

I took test cases from the eslint rule.
https://github.com/eslint/eslint/blob/main/tests/lib/rules/no-duplicate-case.js
It has this test case.

@denbezrukov denbezrukov force-pushed the feat/no-duplicate-case branch from 0bff894 to 74aca10 Compare December 11, 2022 20:29
@ematipico
Copy link
Contributor

@denbezrukov could you please comment on #3969 so I can assign the issue to you?

# Conflicts:
#	crates/rome_js_analyze/src/analyzers/nursery.rs
#	crates/rome_service/src/configuration/linter/rules.rs
@denbezrukov denbezrukov force-pushed the feat/no-duplicate-case branch from 95b88f1 to 419d1b8 Compare December 17, 2022 14:43
@denbezrukov denbezrukov force-pushed the feat/no-duplicate-case branch from 3563f0c to 55f7b79 Compare December 20, 2022 08:46
# Conflicts:
#	crates/rome_js_analyze/src/analyzers/nursery.rs
#	crates/rome_service/src/configuration/linter/rules.rs
@xunilrj xunilrj merged commit bae94ac into rome:main Dec 20, 2022
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.

noDuplicateCase, no-duplicate-case

4 participants

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