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

Closed
mdjermanovic opened this issue Oct 18, 2019 · 1 comment · May be fixed by rsumner868/librealsense2.1#1, rsumner868/librealsense#4, O330oei/node#4 or O330oei/node#11

Comments

@mdjermanovic
Copy link
Member

@mdjermanovic 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.

@kaicataldo kaicataldo added accepted rule and removed triage labels Nov 1, 2019
@kaicataldo
Copy link
Member

@kaicataldo kaicataldo commented Nov 1, 2019

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 eslint bot locked and limited conversation to collaborators May 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.