tools icon indicating copy to clipboard operation
tools copied to clipboard

chore(rome_js_analyze): `noSwitchDeclarations`

Open Conaclos opened this issue 3 years ago • 2 comments

Summary

This implements ESLint's no-case-declarations under the name noSwitchDeclarations.

In contrast to ESLint, this rule handles TypeScript declarations (enum, ...).

Test Plan

Uni test and doc-tests included.

Conaclos avatar Dec 01 '22 18:12 Conaclos

Deploy Preview for docs-rometools canceled.

Built without sensitive environment variables

Name Link
Latest commit 2c49a0a5e858196875a8df44d8799cac15be16ba
Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/63ea9e24bcfa930008c18c8f

netlify[bot] avatar Dec 01 '22 18:12 netlify[bot]

@MichaReiser

This rule has overlaps with the UseSingleCaseStatement. What's your recommendation on how these rules should (or should not) co-exist?

I could suggest removing useSingleCaseStatement of the recommended rule set, moving the rule to style. The rule has already some negative user feedbacks.

I could also propose to eventually make useSingleCaseStatement obsolete, and adding an option (disabled by default) to useBlock for requiring a block for every non-empty case/default clause.

Conaclos avatar Dec 05 '22 10:12 Conaclos

I could also propose to eventually make useSingleCaseStatement obsolete

We could deprecate useSingleCaseStatement in this release cycle and suggest this new rule. This won't create breaking changes.

ematipico avatar Dec 19 '22 11:12 ematipico

I could also propose to eventually make useSingleCaseStatement obsolete

We could deprecate useSingleCaseStatement in this release cycle and suggest this new rule. This won't create breaking changes.

The useSingleCaseStatement rule has already been moved to the style group and removed from the recommended set in 11.0.0. I don't think we should go as far as deprecating it since its use case (enforce that case clause are wrapped in a block) is somewhat different from what noSwitchDeclaration is enforcing (disallow declarations in case clause), and some users may want to keep both rules enabled.

leops avatar Dec 21 '22 10:12 leops