question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule: no-trailing-spaces in comments

See original GitHub issue

When trailing spaces are present in comments (illustrated as underscore):

/* eslint no-trailing-spaces: 1 */
// trailing space _

ESLint produces the same warning as for lines of code: Trailing spaces not allowed no-trailing-spaces

I believe this rule should be relaxed for comments, or at least there should be an option to configure this.

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
mik-jozefcommented, May 23, 2016

I’d also welcome this. Sometimes I do:

/**
 * A long comment with multiple paragraphs.
 *     <- empty line, trailing space
 * Blabla
 */
exports.myWonderfulMethod(needs, long, documentation) { ...
2reactions
pdehaancommented, Sep 10, 2014

@nzakas Both, I guess… 🤷 I have worked on systems in the past that used Markdown flavored JSDocs. We weren’t using ESLint at the time and it was a custom Ruby-based doc system, IIRC.

I’d be happy with two separate rules, or maybe just an option on no-trailing-spaces for “ignore-comments” which defaults to true (which would match JSLint/JSHint behavior if I’m understanding @asapach’s https://github.com/eslint/eslint/issues/1229#issuecomment-55011448 correctly). If for some reason I wanted ESLint to tell me that my doc comments had trailing spaces, I could always pref it on using something like:

rules:
  no-trailing-spaces: [1, {ignore-comments: false}]

So I can think of places I probably wouldn’t want spaces in doc comments, as well as the use case above where trailing spaces are required (unless you want to manually throw in
tags into your JSDoc comments).

Or not, what do I know. (Spoiler alert: Nothing. I don’t know nothing.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-trailing-spaces - ESLint - Pluggable JavaScript Linter
This rule disallows trailing whitespace (spaces, tabs, and other Unicode whitespace characters) at the end of lines. Examples of incorrect code for this...
Read more >
no-trailing-whitespace - Rule
Disallows trailing whitespace at the end of a line. Rationale. Keeps version control diffs clean as it prevents accidental whitespace from being committed....
Read more >
Always Getting an Error of "Trailing Spaces not Allowed" in ...
In settings search bar type "trim trailing whitespace"; Underneath check "trim trailing whitespace" option. Restart vscode. Now whenever you ...
Read more >
No-trailing-spaces - ESLint - W3cubDocs
This rule disallows trailing whitespace (spaces, tabs, and other Unicode whitespace characters) at the end of lines. Examples of incorrect code for this...
Read more >
ESLint / no-trailing-spaces | Spec-Zone.ru
This rule disallows trailing whitespace (spaces, tabs, and other Unicode whitespace characters) at the end of lines. Examples of incorrect code for this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found