Tslint: "missing whitespace" warning is reported even with every whitespace rule turned off

Created on 10 Jan 2019  ยท  12Comments  ยท  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.12.0
  • __TypeScript version__: 3.1.6
  • __Running TSLint via__: Vue CLI

TypeScript code being linted

beforeDestroy(){
               ^
  window.removeEventListener('resize', this.handleWindowResize);
}

with tslint.json configuration:

{
  "defaultSeverity": "warning",
  "extends": [
    "tslint:recommended"
  ],
  "linterOptions": {
    "exclude": [
      "node_modules/**",
      "**/*.json"
    ]
  },
  "rules": {
    "quotemark": false,
    "indent": [true, "spaces", 2],
    "interface-name": false,
    "ordered-imports": false,
    "object-literal-sort-keys": false,
    "no-consecutive-blank-lines": false,
    "whitespace": false,
    "typedef-whitespace": false,
    "no-trailing-whitespace": false,
    "no-irregular-whitespace": false,
    "space-before-function-paren": false,
    "space-within-parens":false,
    "prefer-const":false,
    "max-line-length":false,
    "comment-format":false,
    "member-access":false,
    "arrow-parens":false
  }
}

Actual behavior

I still get the whitespace error, I'm assuming because of the "check-preblock" check in the whitespace rule. All the other rules are correctly being turned off by the configuration, but not this one

Expected behavior

No more whitespace errors

Formatting rule Bug ๐ŸŒน R.I.P. ๐ŸŒน

All 12 comments

I think this is a 5.12.0 regression in how tslint does configuration parsing / assigns default rule options. I can repro the bug in the tslint-playground and see a similar issue for "quotemark"

I also tried 5.11.0 too, same problem. Would there be a better candidate version to try and use?

I also get a bit strange warning for a question mark with 5.11.0

@Output()` onRemove? = new EventEmitter<void>();
                   ^---- missing whitespace
````

It goes away if I set the type as below or If I disable "check-preblock" rule

@Output() onRemove?: EventEmitter = new EventEmitter();


EDIT:  whitespace is set to this value in tslint.json:

"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-separator",
"check-rest-spread",
"check-type",
"check-preblock"
],

```
and we are extending "tslint-angular" set

I'm new to tslint, so I'm just checking here, should setting the entire whitespace rule to false like this:

"whitespace": false,

disable every whitespace check? Or do I need to list out the individual rules to disable them all?

Looks like the error I described before was introduced with 5.9.0 - so @chriszrc I would downgrade to 5.8.0 if you do not rely on new features

@FDIM huh, I tried downgrading all the way back to 5.6.0 but I still get the whitespace errors :(

If you want to see which rules are causing lint failures (so you can disable them), try using the "verbose" or "stylish" formatter. There are open issues to make this formatter the default (#3460) and group all formatting rules together (#3592).

+1 for it being the default, but actually I tried to change the formatter, but without luck, since it appears you can't change it from tslint.json, and I'm running tslint from the vue cli, which runs it from a webpack plugin that appears to not respect additional flags passed to it from the command line. And I haven't worked out how to run tslint from the command line, because it's a vue project, and the .vue files would need to be preprocessed first :(

But more importantly, are you saying that my tslint.json from the beginning of this issue could be missing rules or hasn't properly disabled some of the whitespace rules?

@chriszrc I'm not sure; it seems like you're correctly disabled all the right rules but I'm still seeing the lint failures reported in the tslint playground so this looks like a regression, but I haven't had time to dig into it yet:

image

@adidahiya ok, thanks for confirming. Not sure if this is just due to the formatter or not, but the warning I get locally is missing whitespace not the full Missing whitespace before function parens. Thanks for looking into this-

๐Ÿ’€ _It's time!_ ๐Ÿ’€

TSLint is being deprecated and no longer accepting pull requests for major new changes or features. See #4534. ๐Ÿ˜ฑ

If you'd like to see this change implemented, you have two choices:

  • Recommended: Check if this is available in ESLint + typescript-eslint โœ…
  • _Not Recommended: Fork TSLint locally_ ๐Ÿคทโ€โ™‚๏ธ

๐Ÿ‘‹ It was a pleasure open sourcing with you!

_If you believe this message was posted here in error, please comment so we can re-open the issue!_

๐Ÿค– Beep boop! ๐Ÿ‘‰ TSLint is deprecated ๐Ÿ‘ˆ _(#4534)_ and you should switch to typescript-eslint! ๐Ÿค–

๐Ÿ”’ This issue is being locked to prevent further unnecessary discussions. Thank you! ๐Ÿ‘‹

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajinder-yadav picture rajinder-yadav  ยท  3Comments

mrand01 picture mrand01  ยท  3Comments

ghost picture ghost  ยท  3Comments

avanderhoorn picture avanderhoorn  ยท  3Comments

adidahiya picture adidahiya  ยท  3Comments