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
keyword-spacing
from merged space-before-keywords
and space-after-keywords
#3869
Comments
Are all the exceptions you list already implemented in the existing rules? |
@nzakas No, the first exception is not implemented. So But I'm not 100% sure this exception is proper. 2nd and 3rd exceptions is the same behavior as the existing rules. |
Can you explain the first exception some more? I'm not sure I understand what it would do. |
The first exception limits checking spacing to avoid conflicting with other spacing rules.
if (a)var b = 0; // missing a space.
if (a) {
}else {} // missing a space.
// I cannot found any `]` pattern...
//--------
let a;function b() { } // semi-spacing.
(0,function() { }); // comma-spacing.
() =>function() { }; // arrow-spacing.
(function() { }()); // space-in-parens
a[this.b] = 0; // array-bracket-spacing
{function a() { }} // block-spacing
var a = 100 *this.b; // space-infix-ops
var a = {foo:function() { }}; // key-spacing
if(a) { } // missing a space.
class A extends(b ? C : D) { } // missing a space.
class A extends[] { } // missing a space.
if (a) { }
else{ } // missing a space.
class A extends{name: "a"} { } // missing a space.
return(a + b);
return[];
return{a: 0};
return!foo;
return~foo;
return+foo;
return-foo;
return++foo;
return--foo; // missing a space (space-return-throw-case)
//------------
var a = this; // semi-spacing
var a = () => (foo(), this); // space-in-parens
var a = {b: 0, c: this}; // object-curly-spacing |
Ah, I see. Thanks for explaining. @eslint/eslint-team thoughts? |
@eslint/eslint-team we need to come to consensus on this proposal. Thoughts? |
Changing rules can be confusing for some folks, so without a bit more clear added value, I'm not overly enthused about it. Does this fit in with other efforts to combine rules? In general I've seen rules go the other way. Obviously a lot of thought has been put into it, so maybe there's more to it than that. |
👍 from me- I like how many of the other whitespace rules are symmetrical and I appreciate the thought that went into ensuring this new rule wouldn't conflict with existing rules. |
I don't see any problem with merging those two rules. Should be a bit easier to configure for new users. |
@xjamundx we've generally been merging If we want to do this, then it would be good to get into 2.0.0, otherwise we'd need to wait until 3.0.0. |
Makes sense 👍 |
And may I merge |
What would configuration for this new rule be with all these options? |
My plan for options of this rule: {
"keyword-spacing": [2, {"before": true, "after": true, "overrides": null}]
}
|
Sounds good, let's try to get this into 2.0.0. |
Sounds like this would also fix: #4006 |
I'm working on this. |
I'm writing tests to check that it doesn't conflict with
Which is intentional behavior of |
@michaelficarra Do you remember what was intended for |
@ilyavolodin Speaking as an end user, I would expect any infix operators (punctuation or word) to be checked. That said, how common is that anyway? |
Related discussion: #3587 |
Also refs eslint#1338, fixes eslint#3878, fixes eslint#4006, fixes eslint#4585. This commit creates a new rule: `keyword-spacing` (merged from `space-after-keywords`, `space-before-keywords`, and `space-return-throw-case`). - `keyword-spacing` rule ignores usage of spacing at some places to not conflict other spacing rules. - `keyword-spacing` rule has `"overrides"` option to configure more preference.
Also refs eslint#1338, fixes eslint#3878, fixes eslint#4006, fixes eslint#4585. This commit creates a new rule: `keyword-spacing` (merged from `space-after-keywords`, `space-before-keywords`, and `space-return-throw-case`). - `keyword-spacing` rule ignores usage of spacing at some places to not conflict other spacing rules. - `keyword-spacing` rule has `"overrides"` option to configure more preference.
Also refs eslint#1338, fixes eslint#3878, fixes eslint#4006, fixes eslint#4585. This commit creates a new rule: `keyword-spacing` (merged from `space-after-keywords`, `space-before-keywords`, and `space-return-throw-case`). - `keyword-spacing` rule ignores usage of spacing at some places to not conflict other spacing rules. - `keyword-spacing` rule has `"overrides"` option to configure more preference.
I thought the way of detecting keywords is the same in space-before-keywords and space-after-keywords, so I made an idea that merges two.
This rule is similar to semi-spacing, comma-spacing, and arrow-spacing.
Note:
)
,]
,}
) and spacing which is followed by a opening parenthesis ((
,[
,{
). This is to avoid conflicts with semi-spacing, comma-spacing, arrow-spacing, space-in-parens, array-bracket-spacing, object-curly-spacing, block-spacing, space-infix-ops, and key-spacing.function
,return
,throw
,case
,new
,delete
,typeof
,void
, oryield
. It's checked by space-before-function-paren, space-return-throw-case, and space-unary-ops.super
and(
. It's checked by no-spaced-func.Perhaps space-return-throw-case can be merged if there is an
overrides
option that is similar to operator-linebreak's.Original rules are marked deprecated and will be removed at 2.0.0.
Could I get your opinion?
I'm happy to work on this if accepted.
The text was updated successfully, but these errors were encountered: