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

max-len indented comments #6322

Closed
tbremer opened this issue Jun 4, 2016 · 4 comments
Closed

max-len indented comments #6322

tbremer opened this issue Jun 4, 2016 · 4 comments
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

@tbremer
Copy link

tbremer commented Jun 4, 2016

What version of ESLint are you using? 2.11.1 (from my package.json: ^2.11.1)

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

Please show your full configuration: full config piece concerned with:

"max-len": [
  2,
  {
    "code": Infinity,
    "comments": 80,
    "tabWidth": 2
  }
],

What did you do? Please include the actual source code causing the issue. I found the issues when a single line comment was indented but longer than my set comments length

function foo(something) {
  if (!something) throw new Error('something is reqquired');

  // this is a really long commnet this is a really long commnet this is a really long commnet this is a really long commnet
  return somethingDifferent;
}

actual code with issue:

export default class Maitre {
  set port(p) {
    if (this.__port__ !== undefined) throw new Error('Port should not be reassigned.');

    //this is a long comment this is a long comment this is a long comment this is a long comment this is a long commentthis is a long comment this is a long comment this is a long comment this is a long comment this is a long commentthis is a long comment this is a long comment this is a long comment this is a long comment this is a long comment
    this.__port__ = p;
  }
}

What did you expect to happen? max-len to throw an error

What actually happened? Please include the actual, raw output from ESLint. went a long like everything was cool.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jun 4, 2016
@tbremer
Copy link
Author

tbremer commented Jun 4, 2016

This is actually pretty easy to recreate:

function foo() {
  //this is a long comment this is a long comment this is a long comment this is a long comment this is a long commentthis is a long comment this is a long comment this is a long comment this is a long comment this is a long commentthis is a long comment this is a long comment this is a long comment this is a long comment this is a long comment
}

I could be making a bad assumption here, but this could be as simple as a check in isFullLineComment to trim whitespace?

@kaicataldo
Copy link
Member

Was able to recreate locally with the latest version of ESLint.

With the provided configuration,

function foo() {
//this is a long comment this is a long comment this is a long comment this is a long comment this is a long commentthis is a long comment this is a long comment this is a long comment this is a long comment this is a long commentthis is a long comment this is a long comment this is a long comment this is a long comment this is a long comment
}

errors, but

function foo() {
  //this is a long comment this is a long comment this is a long comment this is a long comment this is a long commentthis is a long comment this is a long comment this is a long comment this is a long comment this is a long commentthis is a long comment this is a long comment this is a long comment this is a long comment this is a long comment
}

does not.

@kaicataldo kaicataldo 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 and removed triage An ESLint team member will look at this issue soon labels Jun 5, 2016
@kaicataldo
Copy link
Member

kaicataldo commented Jun 5, 2016

In looking over it quickly, it looks to me like a bug in isFullLineComment - probably the start.column === 0 check. I can fix this tomorrow.

@tbremer
Copy link
Author

tbremer commented Jun 5, 2016

I wasn't sure about the === 0 because of multiline comments, but playing with the parser a bit I saw that multiline's were broken down as well.

Thanks @kaicataldo!

@nzakas nzakas closed this as completed in 2d63370 Jun 10, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@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 Feb 6, 2018
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 rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

3 participants