Skip to content

max-len does not properly ignore trailing comments #11838

Description

@OliverSieweke

Tell us about your environment

  • ESLint Version: 5.16.0
  • Node Version: 10.16.0 (current LTS)
  • npm Version: 6.9.0

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

Please show your full configuration:

Configuration

Minimal working example for .eslintrc.json:

{
    "rules": {
        "max-len": [
            "error",
            {
                "code": 20,
                "ignoreTrailingComments": true
            }
        ]
    }
}

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

test.js:

"this is fine"; // Some comment... bla bla bla
"this is fine"; /* Some inline comment... */
"this isn't"; /* inline */ // Some other comment
eslint test.js

What did you expect to happen?
No error, as trailing comments should be ignored.

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

  2:1  error  Line 2 exceeds the maximum line length of 20  max-len

Comments

This happens when the trailing comments include an inline as well as a line comment.

I'm happy to submit a pull request if this is recognized as a bug.

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

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions