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

Should TSLint run when there are syntactic errors in the file? #3808

Closed
Xarkam opened this issue Apr 4, 2018 · 9 comments
Closed

Should TSLint run when there are syntactic errors in the file? #3808

Xarkam opened this issue Apr 4, 2018 · 9 comments

Comments

@Xarkam
Copy link

Xarkam commented Apr 4, 2018

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

@grimly
Copy link

grimly commented Apr 5, 2018

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.

@Xarkam
Copy link
Author

Xarkam commented Apr 5, 2018

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 )

@grimly
Copy link

grimly commented Apr 8, 2018

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.

@JoshuaKGoldberg
Copy link
Contributor

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. 😆

@JoshuaKGoldberg JoshuaKGoldberg changed the title Trailing-comma or not trailing-comma. This is the question. Should TSLint run when there are syntactic errors in the file? Nov 5, 2018
@JoshuaKGoldberg
Copy link
Contributor

Per #3946: what about --fix?

@Xarkam
Copy link
Author

Xarkam commented Nov 5, 2018

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.

@MVrachev
Copy link

MVrachev commented Mar 24, 2019

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?

@JoshuaKGoldberg
Copy link
Contributor

💀 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!

@JoshuaKGoldberg
Copy link
Contributor

🤖 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! 👋

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

No branches or pull requests

4 participants