Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-trailing-whitespace ignores trailing whitespace in comments #2049

Closed
ajafff opened this issue Jan 16, 2017 · 4 comments · Fixed by singapore/lint-condo#223
Closed

no-trailing-whitespace ignores trailing whitespace in comments #2049

ajafff opened this issue Jan 16, 2017 · 4 comments · Fixed by singapore/lint-condo#223

Comments

@ajafff
Copy link
Contributor

ajafff commented Jan 16, 2017

Bug Report

  • TSLint version: current master
  • TypeScript version: 2.1.4
  • Running TSLint via: cli

TypeScript code being linted

// comment with trailing spaces    
/* multiline comment 
    with trailing whitespace in first line */

with tslint.json configuration:

"no-trailing-whitespace": true

Actual behavior

no error

Expected behavior

// comment with trailing spaces    
                               ~~~~ [trailing whitespace]
/* multiline comment 
                    ~ [trailing whitespace]
   with trailing whitespace in first line */

Is this intended or can this be fixed? And should this be configurable with a config option?

The fix would not be difficult. I'd like to fix this if you want it

@nchen63
Copy link
Contributor

nchen63 commented Jan 16, 2017

Is there ever a valid reason for that? I'd prefer not to add an option if not, and just fix it

@Martinspire
Copy link

Martinspire commented Jan 27, 2017

Why would you want to notify trailing whitespace in comments? Isn't the whole point of comments to not run any validations on it other than it being opened/closed properly?
I'd rather suggest to use a new rule like

"no-trailing-whitespace-comments": true

for that.

Sidenote, seems this does force you to use multi-line comments this will be reported as an error:

// some comment
// 
// some more comments

Though it shows up sometimes but not in others. Will investigate some more

@adidahiya
Copy link
Contributor

Isn't the whole point of comments to not run any validations on it other than it being opened/closed properly?

I guess this is open to interpretation, but no, I don't think that's the whole point of comments. I don't see why you would want trailing whitespace in some part of your code and not others. If you and others feel strongly about it, you could send a PR to allow the rule to ignore comments.

@JoshuaKGoldberg
Copy link
Contributor

^ this. I like having trailing whitespace in my TSDoc comments, but otherwise it's a waste.

/**
 *.{description}
 *.
 *.{params,etc}
 */

Config for the rule might want to include whether all comments are ignored or just TSDoc comments.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants