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

function-call-argument-newline invalid autofix with a line comment #12454

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 rule Relates to ESLint's core rules

Comments

@mdjermanovic
Copy link
Member

mdjermanovic commented Oct 18, 2019

Tell us about your environment

  • ESLint Version: 6.5.1
  • Node Version: 10.16.0
  • npm Version: 6.9.0

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

default

Please show your full configuration:

Configuration
module.exports = {
  parserOptions: {
    ecmaVersion: 2015,
  }
};

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

Online Demo Link

/* eslint function-call-argument-newline: ["error", "never"] */

f(a, // comment
  b);
eslint index.js --fix

What did you expect to happen?

I'm not sure, maybe an error without autofix.

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

/* eslint function-call-argument-newline: ["error", "never"] */

f(a, // comment b);

Are you willing to submit a pull request to fix this bug?

Yes. #12280 should be probably merged first.

Autofix also doesn't work quite well when a comment or the comma , is on the same line with the argument that shouldn't have a linebreak before - Demo Link

The reported locations are wrong and autofix just removes whitespace (or even inserts a new space in some cases), but the linebreak and the error are still there.

Maybe we could do here the same as with array-element-newline - Demo Link

From this demo, it looks like the logic is as the following:

  • If there is a comment anywhere between two elements, just report error without any autofixes.
  • If there are no comments, then fix the code. If the comma is on the same line as the second element, remove the range between the first element and the comma, instead of between the comma and the second element.

Reported locations are also not correct.

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Oct 18, 2019
@kaicataldo kaicataldo added accepted There is consensus among the team that this change 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 Nov 1, 2019
@kaicataldo
Copy link
Member

This is definitely a bug, since the autofix changes code execution here.

yangmingshan added a commit to yangmingshan/eslint-config-silent that referenced this issue Nov 23, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators May 10, 2020
@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 May 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.