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

Adding comment line length enforcement #4665

Closed
nevir opened this Issue Dec 11, 2015 · 5 comments

Comments

Projects
None yet
5 participants
@nevir
Copy link
Contributor

nevir commented Dec 11, 2015

I'd like to propose some additional options to the max-len rule, so that we can specify independent max lengths for source and comments:

A style that I have grown to prefer is a maximum line length of 80 characters for comments (to enforce readable paragraphs), but something a bit longer than that for code (100, or 120, frequently).

It seems best to fold this log into the max-len rule (as opposed to a separate max-comment-len rule), due to shared behavior - particularly tab size configuration.

Adding two new options to the max-len rule can satisfy this:

commentLength: would allow the user to specify their independent line length for comment lines.

ignoreTrailingComments: preserves the ability to ignore trailing comments, while still supporting max lengths for full line comments.

Similar to jscs-dev/node-jscs#1348

@eslintbot

This comment has been minimized.

Copy link

eslintbot commented Dec 11, 2015

@nevir Thanks for the issue! If you're reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

@eslintbot eslintbot added the triage label Dec 11, 2015

nevir added a commit to nevir/eslint that referenced this issue Dec 11, 2015

New: Add a commentLength option to the max-len rule (fixes eslint#4665)
This allows for separate line length restrictions for source and comments.
For example, allowing source lines to be up to 100 characters wide, while
restricting comments to 80 for readability.
@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Dec 12, 2015

If we add options, then we should switch to something like:

max-len: [2, {
    code: 80,
    comments: 100,
    ignoreTrailingComments: true
}]

That makes it clear what's going on and still allows your use cases. Would you mind updating your PR to match?

@nzakas nzakas added accepted and removed evaluating labels Dec 12, 2015

nevir added a commit to nevir/eslint that referenced this issue Dec 14, 2015

New: Add a commentLength option to the max-len rule (fixes eslint#4665)
This allows for separate line length restrictions for source and comments.
For example, allowing source lines to be up to 100 characters wide, while
restricting comments to 80 for readability.

nevir added a commit to nevir/eslint that referenced this issue Dec 18, 2015

New: Add a comment length option to the max-len rule (fixes eslint#4665)
This allows for separate line length restrictions for source and comments.
For example, allowing source lines to be up to 100 characters wide, while
restricting comments to 80 for readability.
@nevir

This comment has been minimized.

Copy link
Contributor Author

nevir commented Dec 18, 2015

Done! Supports both options styles for backwards compat

@nzakas nzakas closed this in 62b4d91 Dec 18, 2015

@rafaeleyng

This comment has been minimized.

Copy link

rafaeleyng commented Mar 3, 2016

I'm using it like:

    'max-len': [2, {
      'code': 120,
      'tabWidth': 2,
      'comments': 80
    }],

The comment lines are being validated with the 120 instead of the 80, but if I delete the 'code': 120 then the 80 is applied.

Am I doing something wrong here?

@platinumazure

This comment has been minimized.

Copy link
Member

platinumazure commented Mar 3, 2016

@rafaeleyng Could you please open a new issue? Thanks!

@eslint eslint bot locked and limited conversation to collaborators Feb 6, 2018

@eslint eslint bot added the archived due to age label Feb 6, 2018

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.