curly: Allow to filter affected keywords and pass keywords-exceptions
See original GitHub issueJSCS has rules disallowCurlyBraces
and requireCurlyBraces
that allows to pass keywords: ["if", "else", "for", "while", "do", "try", "catch", "default"]
.
More over requireCurlyBraces
has allExcept
option that works like exception for passed keywords:
- `'allExcept'`
- Array of keywords inside of the block that would allow curly braces
- Ex: ["return" , "continue", "break"]
E.g. for:
"allExcept": ["return", "continue", "break"]
it works like:
// Here we need curlies
if (true) {
// Dummy
} else {
// Another one
}
// And here we don't
if (true) return false;
else if (false) break;
else continue;
The current curly
options and the first suggestion:
"curly": [2, "all"]
"curly": [2, "multi"]
"curly": [2, "multi-line"]
"curly": [2, "multi-or-nest"]
"curly": [2, "multi", "consistent"]
I suggest to pass an Object
with keywords and exceptions as the last parameter:
"curly": [2, { "keywords": ["if", "else"], "except": ["return", "break"] }]
"curly": [2, "multi", { "keywords": … }]
// or even:
"curly": [2, { "schema": "multi", "consistent": true, "keywords": … }]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:8
- Comments:13 (13 by maintainers)
Top Results From Across the Web
Exception Handling in Spring MVC
Exceptions thrown outside the Spring MVC framework, such as from a servlet Filter, are still reported by the Spring Boot fallback error page ......
Read more >Exceptional C# Exception Filtering - Pluralsight
The exception handling features of C# help you deal with unexpected or exceptional situations with three keywords: "try", "catch", ...
Read more >Query and filter context | Elasticsearch Guide [8.5] | Elastic
Use query clauses in query context for conditions which should affect the score of matching documents (i.e. how well does the document match),...
Read more >Robot Framework User Guide
If keyword needs to accept and pass forward any named arguments, it must be changed to accept free named arguments. See free named...
Read more >Template Designer Documentation - Jinja
Filters that accept arguments have parentheses around the arguments, ... All unconsumed keyword arguments are stored in this special variable.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Some ESLint’s rules have
overrides
option: keyword-spacing, space-unary-ops, and operator-linebreak. So, how about theoverrides
option for consistency?For example:
I’m willing to implement this.