Skip to content

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

Closed
@mdjermanovic

Description

@mdjermanovic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyruleRelates to ESLint's core rules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions