Tslint: Should TSLint run when there are syntactic errors in the file?

Created on 4 Apr 2018  ยท  9Comments  ยท  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.9.1
  • __TypeScript version__: 2.8.1
  • __Running TSLint via__: Visual Studio

TypeScript code being linted

@NgModule({
  exports: [ RouterModule ],
  imports: [ RouterModule.forRoot(
    routes,
    { enableTracing: true },
  ],
})

with tslint.json configuration:

{
  "extends": "tslint:recommended",
  "rules": {
    "no-duplicate-variable": true,
    "no-unused-variable": [
      true
    ],
    "linebreak-style":false,
    "max-line-length":false,
    "no-console":false,
    "no-shadowed-variable":false,
    "variable-name": [
      true,
      "check-format",
      "allow-leading-underscore",
      "allow-trailing-underscore"
    ]
  },
  "rulesDirectory": [
    "node_modules/tslint-eslint-rules/dist/rules"
  ]
}

Actual behavior

Because a picture is better than a long speech :
image

Expected behavior

Give good choice ;)

ps: yes, he misses one ) in snippet

In Discussion Needs Proposal Question ๐ŸŒน R.I.P. ๐ŸŒน

Most helpful comment

Hello, I think TSLint can stop on misconfiguration.
But, it needs a clear message that TSLint is stopped because of a bad configuration.

Developers can then narrow their search field to tslint configuration on errors.

All 9 comments

You have two errors at different places. Try validating this :

@NgModule({
  exports: [ RouterModule ],
  imports: [ RouterModule.forRoot(
    routes,
    { enableTracing: true, }
  )],
})

I switched , and } to add the trailing comma in the object literal and remove the one in the forRoot function call.

And I added the ) back in the end of the forRoot function call.

Yes, I have specified the missing one )
With the final ) I've not error.

But it's disturbing to have this message with just a missing )

This is odd, but when it come to parsing, the missing closing parenthesis may have seen something completely different to what we may think.

It might have back-tracked to something that is not the RouterModule.forRoot function call.

I don't think the linter can do a lot here, or maybe shut the linter errors if there is a compilation error.

The root issue here is, as suggested, that TSLint should have a better strategy for providing failures when there's a syntax problem. Modifying the title to make that more clear; I must have rediscovered this issue a half dozen times by now. ๐Ÿ˜†

Per #3946: what about --fix?

Hello, I think TSLint can stop on misconfiguration.
But, it needs a clear message that TSLint is stopped because of a bad configuration.

Developers can then narrow their search field to tslint configuration on errors.

Hi, I just read through the discussion here and it's little unclear for me what decision was made.

Is there a way ESLint reports for syntax errors? I imagine that syntax errors will prevent the correct analysis of a file so it makes sense to report those problems.

The way I saw Gosec (Golang static code analysis tool) handles the syntax errors is by giving Golang syntax errors at the beginning of the output.

Text:
image

JSON:
image

Is there a similiar feature in TSLint?

๐Ÿ’€ _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

SwintDC picture SwintDC  ยท  3Comments

CSchulz picture CSchulz  ยท  3Comments

zewa666 picture zewa666  ยท  3Comments

allbto picture allbto  ยท  3Comments

ypresto picture ypresto  ยท  3Comments