-
-
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
Lines-around-comments: allowBlockStart has issue with return block #2965
Comments
From that description (from the docs for |
Took me a few times, but I think @btmills may be right. That's not really a block, it's just an object literal. |
Is this now a proposal for |
Frankly speaking I am not sure. |
I believe this is a work of I'm not happy to add more options for every syntax, such as |
👎 I don't think we need more options here. It's behaving as intended. |
I'm also 👎 unless someone comes along to say they really need this. |
closing based on the above discussion. |
👍 At first I thought as well the the option included object literals. Basically comments preceded by const foo = {
// this property is important
important: 3.1415
}; and I would rather write const foo = {
// this property is important
important: 3.1415
}; |
I agree with @Cellule. My hope is that (My true hope is to remove |
Object literals don't define blocks, so while they look the same, they are completely different. So we should not expand the existing options to include this case. We could add two new options per @btmills suggestion. |
I don't particularly mind adding options, I already do for blocks, might as well do it for anything block-like |
What about a generic |
No. These should not be treated as the same thing (see my previous comment). |
The two ways out of this seem to be:
I personally would have been content with either the second one, or both of them. (i.e. second one overrides former one), but it seems it's a no go for the second option as per @nzakas, so I imagine it'll be the first one? A list of node types against which to validate, a bit like in |
👍 I'm with @Cellule and @mysticatea on this. And while I acknowledge that an object literal is not a code block, per se, as pointed out by @btmills, @mysticatea is correct that a class body is not a block either yet it's treated by the allowBlockStart exception. It seems to me that the object literal and the class body should be treated equivalently by this rule (but that's my opinion). It doesn't help that the rule and the exceptions use two different definitions of the term |
@nzakas Has a resolution path been decided for this? (See my previous reply) Thanks! |
See my previous reply: #2965 (comment) |
… and "allowArrayEnd" options to `lines-around-comment` rule. (fixes eslint#2965)
My stab at this: mathieumg@3c4df61 I didn't update the documentation or provide many tests, yet, because of some hurdles related to the discussion above. Should The commit I linked to implements the first approach to simplify things. However, let me bring something new to the discussion: I realized that the exception case is always when the line above is less indented (with Thanks. |
@nzakas What is missing to mark this as accepted? I want to help this move forward but from the lack of discussion it might mean I'm the only party interested by that change? |
@mathieumg I'm also interested in the change but lack the experience in the eslint code base to contribute meaningfully to your implementation ideas. |
@mathieumg just forgot, thanks for the nudge. |
… and "allowArrayEnd" options to `lines-around-comment` rule. (fixes eslint#2965)
Any update on this? It seems that everybody is in agreement about the right way to fix it, and the code has already been committed by @mathieumg. Will this fix be included in the next version of ESLint? |
I still have to add tests, update the documentation and get it reviewed by collaborators. (Plus rebase my changes on top of master, they were made on ESLint 1.3) School has started again so I'm really busy with that nowadays, but perhaps I can put in some time to move this past the finish line during "reading week" in a week and a half. Of course, if it's more urgent I wouldn't mind if anyone took what I started and finished it. |
I might do what I can to help push this along but doubt I can find enough time. As much I dislike +1-ing things, based on this conv I feel it's important to say I'd really appreciate this feature. |
… and "allowArrayEnd" options to `lines-around-comment` rule. (fixes eslint#2965)
… and "allowArrayEnd" options to `lines-around-comment` rule. (fixes eslint#2965)
…arrays Update: added exceptions for objects and arrays in `lines-around-comment` rule (fixes #2965)
…t#2965) Added the following exceptions to the `lines-around-comment` rule: * `allowObjectStart` * `allowObjectEnd` * `allowArrayStart` * `allowArrayEnd` See eslint#2965
Eslint: v0.24.1
Praser: default
Rule config:
Code:
Actual:
$ eslint --reset index.js index.js 4:2 error Expected line before comment lines-around-comment ? 1 problem (1 error, 0 warnings)
Expected:
No errors.
The text was updated successfully, but these errors were encountered: