Enforce the amount of whitespace surrounding keywords.
See original GitHub issueGiven the following tab-indented source code:
function foo() {
if (true) {
try {
bar();
}
catch (err)
{
baz();
}
}
}
Using brace-style
to use "1tbs"
, we end up with tabs around the catch
keyword.
function foo() {
if (true) {
try {
bar();
} catch (err) {
baz();
}
}
}
It doesn’t seem possible to fix this with the existing eslint rules:
keyword-spacing
only asserts that there’s a non-zero amount of whitespace around keywordsno-multi-spaces
ignore tabsno-tabs
isn’t useful because we’re using tabs for indentation too
Possible solutions:
- add an option to
keyword-spacing
to enforce exactly one space (my suggestion) - add an option to
no-tabs
to only flag tabs that aren’t at the beginning of the line (suggested by @platinumazure) - generalise
no-multi-spaces
to work for arbitrary whitespace, not just spaces
Tested on eslint 3.10.2.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:8 (6 by maintainers)
Top Results From Across the Web
keyword-spacing - ESLint - Pluggable JavaScript Linter
This rule enforces consistent spacing around keywords and keyword-like tokens: as (in module declarations), async (of async functions), await (of await ...
Read more >Rules Reference — SQLFluff 1.4.5 documentation
Operators should be surrounded by a single whitespace. This rule is sqlfluff fix compatible. Groups: all , core. Anti ...
Read more >Adding White Space in Microsoft Word to Improve PDF ...
To add white space around an image using Paragraph Styles: In the Ribbon, select the Home tab, then in the Styles section select...
Read more >Search keywords in ElasticSearch 7.6 with whitespace
I am trying to implement in ElasticSearch 7.6 a search based on city names but I have a problem with those words containing...
Read more >Whitespace · Styleguide JavaScript
Indentation Character · Before Blocks · Around Keywords · Infix Operator Spacing · Newline · Chains · After Blocks · Padded Blocks.
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
Hi @bardware, the changes should be in this week’s release.
Seen it working in Alpha.2. Very nice, thanks alot!