Comments (2)
Hi @mike-lischke, thanks for the issue!
This works as intended because you have the following configuration for the no-restricted-syntax
rule:
"no-restricted-syntax": [ "error", "WithStatement", { "selector": "SwitchCase:has(*.consequent[type!=\"BlockStatement\"])", "message": "Switch cases without blocks are disallowed." } ],
The SwitchCase:has(*.consequent[type!=\"BlockStatement\"])
selector finds consequent
of simpleView ? "" : ""
(ConditionalExpression
) and thus this rule reports Switch cases without blocks are disallowed.
. This is probably not what was intended to be disallowed, but it works as specified.
If you don't want to disallow switch cases without blocks, you can just remove this config entry.
If you want to disallow switch cases without blocks (i.e., enforce that code in switch cases is always wrapped in blocks), you can fix the selector like this:
SwitchCase:matches([consequent.length>1], [consequent.length=1][consequent.0.type!='BlockStatement'])
from eslint.
Wow, that sounds a bit weird. What by all means is a "consequent" in this context? Also that selector syntax is totally greek to me 🤣
But many thanks for figuring this out for me. Great and quick help from your side - much appreciated!
from eslint.
Related Issues (20)
- Change Request: Rule Tester omit specific properties for duplicate test case detection HOT 2
- Change Request: Update strip-ansi to version 7 HOT 1
- Rule Change: no-fallthrough should not permit "falls through" comment when code will not fall through. HOT 4
- Repo: 'documentation' label added and removed quickly on PRs HOT 6
- Bug: `flat config global ignores` should support `git-ignore-alike-syntax` to negate pattern HOT 1
- Rule Change: no-extra-boolean-cast should check final expression in comma operator expressions HOT 5
- Docs: Page does not update when prefers-color-scheme changes HOT 3
- Docs: Option to use system preference for light/dark theme HOT 6
- Scheduled release for March 22nd, 2024 HOT 3
- Bug: cannot override no-unused-vars HOT 4
- Bug: Random error on line 1 column 1 Parsing error: Cannot read properties of undefined (reading 'map') eslint HOT 2
- Bug: Flat config file not found when run with `CWD` outside of source directory HOT 5
- Bug: Flat config doesn't work when `files` refers to a sibling directory. HOT 2
- Change Request: Lazy import and initialize Linter HOT 1
- Bug: no-lone-blocks emits an error with `using` keyword HOT 10
- `--print-config` ignore the old `overrides` field and flat config overrides HOT 1
- Rule Change: User-defined replacements as autofix for no-restricted-syntax HOT 3
- Change Request: Allow flat config file at non-standard location HOT 2
- Bug: using nested `.files` and `.folders` with ignore-pattern doesn't work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint.