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

Bug with whitespace #2382

Closed
acrazing opened this issue Mar 21, 2017 · 3 comments
Closed

Bug with whitespace #2382

acrazing opened this issue Mar 21, 2017 · 3 comments

Comments

@acrazing
Copy link

Bug Report

  • TSLint version: 4.5.1
  • TypeScript version: 2.2.1
  • Running TSLint via: CLI

TypeScript code being linted

// code snippet
for (let i = 0; i < 1;) {
  console.log(i++)
}

with tslint.json configuration:

{
  "rules": {
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-module",
      "check-separator",
      "check-type"
    ]
  }
}

Actual behavior

Emit error:

src/__test__/tslint.ts[12, 23]: missing whitespace

Expected behavior

No error.

@MarkPieszak
Copy link

This bug is actually creating crazy issues in VSCode where you have to basically disable the whitepsace check, otherwise it throws random errors for lines all in the incorrect locations etc.

@sbj42
Copy link
Contributor

sbj42 commented Apr 22, 2017

I haven't seen this rule throw "random errors", but a related case I have seen is when using for (;;) to make an infinite loop (without triggering strict-boolean-expressions). TSLint warns about this code:

for (;;) {
    const c = peek();
    if (typeof c === 'undefined') {
        break;
    }
    handle(c);
}

And it is only appeased by:

for (; ; ) {

Which seems unnecessary to me. My recommendation is to make an exception for the "check-separator" case when the following element is empty/absent. That should cover both cases. It would also allow something like const [a,, b] = ignoreMiddleReturn() - I'm not sure if that's problematic.

@ajafff
Copy link
Contributor

ajafff commented Aug 15, 2017

Fixed by #3132

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

No branches or pull requests

4 participants