-
-
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
New spaced-comment rule to only enforce space after // #2897
Comments
Can you elaborate by giving an example and stating what do you expect to happen and what is currently happening? |
I think what @doberkofler means is that |
@mathieumg Exactly! |
we dont have an option like that. right now that rule runs on both (line and block) by default. |
@gyandeeps Having transitioned from jshint/jscs to eslint, I originally wrote the spaced-line-comment rule as we only want to enforce this rule for line comments and jscs allowed me to do this with the requireSpaceAfterLineComment rule. I would no longer be able to enforce this style rule, once the depreciated space-line-comment rule gets removed and I would clearly prefer to either have two separate rules, split the new one into two configurations or keep the old one. |
I think I would support the notion of having that option. |
Let's just add options to specify line:true, block: true, so people can choose. |
And by default both are true? |
Yes, we need to keep rule defaults the same to avoid breaking people's linting. |
Sounds good to me as this would solve my problem but more generally speaking I think that splitting the rule might be the better option. It seems to me, as if people would use the two comment styles rather differently and maybe they should also be configured independently. |
I don't see splitting the rule as an option. We just combined this rule to handle both block and line comments, reverting that change would be unnecessarily disruptive to people. |
Is there any reason behind that merge? |
Because the logic is exactly the same. You can always go dig up the commit and issue to see the discussion. |
I understand the rationale of avoiding code duplication, but if the logic is exactly the same couldn't it be put in a 3rd file which is leveraged by the rule for each comment flavor? Another way would be to have the |
Having a third file becomes a maintenance issue - where do we put file-specific code? Do we end up with "third" files for a lot of rules then? It's much cleaner to have one spot. In any event, whether we keep one rule or not isn't up for debate here. We can add options to handle the case where line comments should be handled separate from block comments. I think maybe it should be more like:
|
I understand, regarding the "third file"/file structure. I think the config example you showed would be good, it only sacrifices the ability to warn/error based on the comment type, and that's not really a problem. At least it allows to enforce different things based on the comment type, as opposed to the |
@nzakas Having separate options for line and block command sounds like a good solution. |
I'll throw up a proposed solution to this problem and am happy to work on it as I'm running into similar issues. |
So the suggestion is the following? Current options:
Proposed Options:
The only question for me is what happens in cases like this:
Do the exceptions get applied into the |
Agreed |
I'm working on this. |
How would you formulate "only apply the rule for line comments, not block" in the current spec? The following does not work because it is expecting an object instead of "false." "spaced-comment": [2, "always", { block: false }] |
@mccord like this
|
This doesn't seem to work anymore (version 4.16.0). The config @doberkofler suggested fails with error
which I assume means that the With config
and code
gives an error
Is there still a way to only enforce space after |
@noppa Please open a new issue and we'll investigate, thanks! |
Is it no longer possible to only enforce space after // but not after /* ?
The text was updated successfully, but these errors were encountered: