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

comma-style: Autofix can lead to parse error when line comment on preceding line and block comment on same line as solo comma #10632

Closed
platinumazure opened this issue Jul 20, 2018 · 3 comments · Fixed by #11154
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 bug ESLint is working incorrectly help wanted The team would welcome a contribution from the community for this issue rule Relates to ESLint's core rules

Comments

@platinumazure
Copy link
Member

platinumazure commented Jul 20, 2018

Tell us about your environment

  • ESLint Version: master
  • Node Version: 8.11.3
  • npm Version: 5.6.0

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

Default

Please show your full configuration:

(See ESLint command)

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

[
    ...one /* block comment 1 */ // line comment
    , /* block comment 2
    foo bar */
];
node bin/eslint ./file.js --no-eslintrc --rule "comma-style: error" --parser-options "ecmaVersion: 2015" --fix

What did you expect to happen?

Autofix to work with no syntax error afterwards; or no fix applied

What actually happened? Please include the actual, raw output from ESLint.

First pass autofix results in the following:

[

    ...one, /* block comment 1 */ // line comment /* block comment 2
    foo bar */
];

The line comment results in the opening of block comment 2 not taking effect, so the foo bar on the next line is not commented. This results in a parser error since foo bar is not a valid expression.


This example is a simplified version of a test case generated by the ESLint fuzz tool.

@platinumazure platinumazure added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion labels Jul 20, 2018
@kaicataldo kaicataldo added help wanted The team would welcome a contribution from the community for this issue Hacktoberfest Recommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/ labels Oct 15, 2018
@serbanghita
Copy link

Hi, I started working on this.
I'm looking into both variants:

  • Autofix to work with no syntax error afterwards
  • no fix applied

@jouncealimb
Copy link

Hi @serbanghita I see you started working on this. Are you still working on this one?

@serbanghita
Copy link

@jouncealimb no, I failed to find time to address it :(

@kaicataldo kaicataldo removed Hacktoberfest Recommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/ labels Nov 13, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jun 7, 2019
@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 Jun 7, 2019
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 bug ESLint is working incorrectly help wanted The team would welcome a contribution from the community for this issue rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants