tools
tools copied to clipboard
feat(rome_js_analyze): `useDefaultSwitchClauseLast`
Deploy Preview for docs-rometools ready!
Built without sensitive environment variables
| Name | Link |
|---|---|
| Latest commit | 12d448899832b800131c58aa9e206e9b3011a018 |
| Latest deploy log | https://app.netlify.com/sites/docs-rometools/deploys/637e92c3184866000879140a |
| Deploy Preview | https://deploy-preview-3791--docs-rometools.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
@ematipico
I think we can also provide a code action that moves the
defaultstatement to the last position. We can add the code action in another PR.
The difficulty is when a fallthrough is present. Like in the following code:
switch (foo) {
default:
doSomethingIfNotZero();
case 0:
doSomethingAnyway();
}
This requires some logic to know whether the block return/break. Have you an idea how to implement this without exploring all descendants? Or we could just handle the case where a block statement ends with return or break. This looks fair.
In fact I - in constrast to ESLint - we could allow code with default clause that fallthrough (as the previous code). Another rule (noFallthrough) could reject this code. This could make useDefaultCaseLast less restrictive.
Also, I wonder if we should rename the rule "useDefaultCaseLast" to "useDefaultClauseLast" or "useDefaultSwitchClauseLast".
!bench_analyzer
Also, I wonder if we should rename the rule "useDefaultCaseLast" to "useDefaultClauseLast" or "useDefaultSwitchClauseLast".
I'm in favor of renaming Case to Clause as this aligns with the terminology used in the diagnostics and useDefaultSwitchClauseLast goes well with our philosophy;
Utilize verbosity when naming commands and flags. No unnecessary and confusing abbreviations.
Analyzer Benchmark Results
group main pr
----- ---- --
analyzer/css.js 1.17 2.5±0.01ms 4.7 MB/sec 1.00 2.1±0.02ms 5.5 MB/sec
analyzer/index.js 1.08 6.6±0.12ms 5.0 MB/sec 1.00 6.1±0.03ms 5.3 MB/sec
analyzer/lint.ts 1.04 3.2±0.01ms 13.1 MB/sec 1.00 3.1±0.01ms 13.6 MB/sec
analyzer/parser.ts 1.08 7.8±0.24ms 6.3 MB/sec 1.00 7.2±0.11ms 6.8 MB/sec
analyzer/router.ts 1.08 5.4±0.03ms 11.6 MB/sec 1.00 5.0±0.01ms 12.5 MB/sec
analyzer/statement.ts 1.05 7.3±0.12ms 4.8 MB/sec 1.00 7.0±0.04ms 5.1 MB/sec
analyzer/typescript.ts 1.03 10.9±0.18ms 5.0 MB/sec 1.00 10.5±0.03ms 5.2 MB/sec
@ematipico @MichaReiser Ready for merging.
I will open a new PR for the code action. This allows discussing that in details.
Unfortunately, a commit in main causes a failure on the format check. Indeed, ./crates/rome_js_analyze/src/semantic_analyzers/nursery/use_exhaustive_dependencies.rs was not formatted with rustfmt.
Unfortunately, a commit in
maincauses a failure on the format check. Indeed,./crates/rome_js_analyze/src/semantic_analyzers/nursery/use_exhaustive_dependencies.rswas not formatted with rustfmt.
Fixed in https://github.com/rome/tools/pull/3840