-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce the amount of whitespace surrounding keywords. #7621
Comments
One of the reasons I favor augmenting if (foo) { // Tab between condition close paren and open brace
} The above example wouldn't be enforced by keyword-spacing because there isn't a keyword on either side of the hypothetical tab. So this implies that On the other hand, |
I would prefer the option of generalizing I don't think adding a "prohibit multiple whitespace characters" option to Adding an option to To expand on that, try {
} catch (err) { // same as above, but with spaces
} I think it would be unexpected to handle that case with a different rule depending on whether the gap contains spaces or tabs. |
@not-an-aardvark @Wilfred What should happen in the case where two tokens are separated by one tab? @Wilfred Would you want that case flagged? @not-an-aardvark If we wanted to flag that particular case, which rule should be responsible? |
I think the rule should not report an error. An alternative would be to update rules such as
I'm not sure I understand what you mean by "that particular case". If you're referring to the code sample in my comment above, I think |
@not-an-aardvark Sorry, "that particular case" was "the case where two tokens are separated by one tab". If you believe that shouldn't be an error at all, then the question is moot. |
Previously, the brace-style autofixer would leave any existing whitesapce between tokens when removing newlines. This would result in a large amount of extra whitespace on a line when fixing indented code. Users generally don't expect indentation whitespace to be preserved inline when fixing brace styling, so this commit updates the fixer to always output a single space between tokens when removing newlines.
Hi, in what version will these changes take effect? I pulled
still becomes
|
Hi @bardware, the changes should be in this week's release. |
Seen it working in Alpha.2. Very nice, thanks alot! |
Given the following tab-indented source code:
Using
brace-style
to use"1tbs"
, we end up with tabs around thecatch
keyword.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 tooPossible solutions:
keyword-spacing
to enforce exactly one space (my suggestion)no-tabs
to only flag tabs that aren't at the beginning of the line (suggested by @platinumazure)no-multi-spaces
to work for arbitrary whitespace, not just spacesTested on eslint 3.10.2.
The text was updated successfully, but these errors were encountered: