Skip to content
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-comment ES2015 classes in new allowClassStart option #8564

Closed
Mardak opened this issue May 8, 2017 · 15 comments · Fixed by #8565
Closed

lines-around-comment ES2015 classes in new allowClassStart option #8564

Mardak opened this issue May 8, 2017 · 15 comments · Fixed by #8565
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules

Comments

@Mardak
Copy link
Contributor

Mardak commented May 8, 2017

Tell us about your environment

  • ESLint Version: v4.0.0-alpha.2
  • Node Version: v7.10.0
  • npm Version: 4.5.0

What parser (default, Babel-ESLint, etc.) are you using?
default

Please show your full configuration:
--env es6 --rule lines-around-comment:["error",{allowObjectStart:true}]

What did you do? Please include the actual source code causing the issue.

class A {
  /* test */
  constructor() {}
}

What did you expect to happen?
No errors.

What actually happened? Please include the actual, raw output from ESLint.
2:3 error Expected line before comment lines-around-comment

For #2894 @gyandeeps added ES2015 classes to "allowBlockStart" via 9a2dcc2 disallowing an empty line before a comment block just within a class, but it seems like it would be more appropriate as part of its own "allowClassStart".

This proposed change would better match the breaking change in #7879 by @alberto in e232464 where classes are treated differently than block statements. In particular, if someone had --rule padded-blocks:["error","never"] in addition to the above --rule lines-around-comment:["error",{allowObjectStart:true}], neither rule would be happy with a line or without a line, but if the code was using let A = { instead of a class, it would be fine.

I would think that moving class from allowBlockStart would also be a breaking change.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label May 8, 2017
Mardak added a commit to Mardak/eslint that referenced this issue May 8, 2017
Mardak added a commit to Mardak/eslint that referenced this issue May 8, 2017
@not-an-aardvark
Copy link
Member

Thanks for the issue.

Hmm, I'm unconvinced that this is worth changing. Technically, classes are neither object literals nor blocks, but I don't see how treating them as objects is more valid than treating them as blocks. In fact, the change in #7879 that you linked has the effect of treating classes more like blocks in the padded-blocks rule, since they are treated now like blocks by default in that rule.

@ljharb
Copy link
Sponsor Contributor

ljharb commented May 14, 2017

Perhaps an allowClassStart option would be more appropriate, since class is neither a block nor an object?

Mardak added a commit to Mardak/eslint that referenced this issue May 17, 2017
@Mardak Mardak changed the title lines-around-comment ES2015 classes in allowObjectStart instead of allowBlockStart lines-around-comment ES2015 classes in allowClassStart instead of allowBlockStart May 17, 2017
@Mardak
Copy link
Contributor Author

Mardak commented May 17, 2017

Updated issue and PR to move class checks as part of allowClassStart from allowBlockStart.

To be clear, we started running into this issue with v4 because padded-blocks now handles classes, which is desired, but a comment block just inside the class conflicts with lines-around-comment unless allowBlockStart is set, which would also allow lines inside actual blocks, which is undesired.

In regards to classes being different than objects or blocks, that's true, but it's relatively natural to switch from an object (for a function/constructor prototype) to a class when "upgrading" to classes.

@ilyavolodin
Copy link
Member

I'm unconvinced that naming change is important enough to create a breaking change. While technically, classes are not blocks, they are treated as blocks by scoping. Block scoping in ES6 includes classes, so argument can be made that people might think of them as blocks. If it wouldn't be a breaking change, I wouldn't have a problem with this, though.
P.S. Last version we release was a beta, so we will try to avoid any new breaking changes until version 5.

@Mardak Mardak changed the title lines-around-comment ES2015 classes in allowClassStart instead of allowBlockStart lines-around-comment ES2015 classes in new allowClassStart option May 21, 2017
Mardak added a commit to Mardak/eslint that referenced this issue May 21, 2017
@Mardak
Copy link
Contributor Author

Mardak commented May 21, 2017

I've updated the issue and PR to not be a breaking change by not altering the behavior of allowBlockStart and instead just adds the new option allowing just class "blocks" without including other blocks.

@platinumazure platinumazure added enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Jun 26, 2017
@platinumazure
Copy link
Member

@Mardak @not-an-aardvark @ilyavolodin @ljharb Apologies, seems we've lost track of this.

Can anyone please summarize where we're at and what our next steps should be? Thanks!

@not-an-aardvark
Copy link
Member

To clarify, with the current proposal are classes included in both allowBlockStart and allowClassStart? If so, what happens if the options are something like {allowBlockStart: true, allowClassStart: false}?

@ljharb
Copy link
Sponsor Contributor

ljharb commented Jun 26, 2017

I would expect allowClassStart set to false to disable the class behavior in allowBlockStart as well - since that's a new option, it wouldn't be a breaking change.

In other words, allowBlockStart would continue to look at class, which would overlap with allowClassStart - thus allowClassStart: true, allowBlockStart: false would still check class.

In a later semver-major, perhaps, the class behavior should be removed from allowBlockStart.

Mardak added a commit to Mardak/eslint that referenced this issue Jun 27, 2017
@Mardak
Copy link
Contributor Author

Mardak commented Jun 27, 2017

I updated the PR #8565 with the desired explicit allowClass{Start,End}: false behavior of overriding allowBlock: true (to act as if there were not an allowBlock: true for class "blocks") and added positive class tests for Block, Class and !Block+Class for classes and negative tests for default and Block+!Class.

Mardak added a commit to Mardak/eslint that referenced this issue Jun 28, 2017
@Mardak
Copy link
Contributor Author

Mardak commented Jul 15, 2017

Does the evaluating tag need to be removed to finish up this issue?

@not-an-aardvark
Copy link
Member

Hi, sorry about the delayed response. We generally accept enhancements only if the team reaches consensus that they should be added (by having 3 👍s from team members on the issue, and having one team member willing to champion the proposal). This is a high bar by design -- we can't realistically accept and maintain every feature request in the long term, so we only accept feature requests which are useful enough that there is consensus among the team that they're worth adding.

In this case, it seems like this issue hasn't reached consensus yet. I'll ping @eslint/eslint-team to see if anyone else is willing to support/champion this proposal. If the issue gets one more 👍 and someone willing to champion it, then we'll mark it as accepted; otherwise, unfortunately we'll have to close the issue and PR.

@kaicataldo
Copy link
Member

Just need a champion now :)

@Mardak
Copy link
Contributor Author

Mardak commented Oct 13, 2017

@not-an-aardvark we've been holding off on upgrading to ESLint 4 because of this, but I guess we'll just turn off rules to get things working: mozilla/activity-stream#3705

I see there's 3 👍s, and this is just looking for a champion, so anything I can do to help get this marked as accepted?

@kaicataldo
Copy link
Member

kaicataldo commented Oct 13, 2017

Sorry for the delay here. I'll champion this. That being said, we need another thumb now (I can't both be a thumb and a champion!) @eslint/eslint-team

@not-an-aardvark
Copy link
Member

👍

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Oct 13, 2017
Mardak added a commit to Mardak/eslint that referenced this issue Oct 13, 2017
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 13, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Apr 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants