eslint / typescript-eslint-parser

An ESLint custom parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.
Other
915 stars 92 forks source link

Possible wrong typescript version detected #528

Closed luisnaranjo733 closed 5 years ago

luisnaranjo733 commented 5 years ago

I'm using this module through madge, which uses the "dependency-tree" package, which uses the "precinct" package, which uses the "detective-typescript" package, which actually has "typescript-eslint-parser" as a dependency.

I am seeing the following warning, which I suspect is incorrect

WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-eslint-parser.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: ~3.0.1

YOUR TYPESCRIPT VERSION: 3.1.3 

My project's devDependencies in package.json looks like this "typescript": "^3.0.1", and if I go to node_modules/typescript/package.json, I can see "version": "3.0.1". So basically I'm pretty sure that I'm on 3.0.1, but typescript-eslint-parser is warning me that I'm on the wrong version.

Any idea why this might be happening?

kaicataldo commented 5 years ago

It sounds like you're running ESLint on your node_modules/ directory, which I'd strongly encourage you to not do! node_modules are ignored by default - are you linting them for a specific purpose?

Sorry - realizing I misunderstood. I thought this was being run in a linting step. It sounds like it might be pulling in a sub-dependency typescript module. Any chance you can check to see if that's the case?

luisnaranjo733 commented 5 years ago

Yeah, you're right. I just noticed that my yarn.lock has two top level entries for TS, and that detective-typescript references 3.0.3. So that is getting used instead of the version I'm declaring. Is this considered a bug in detective-typescript?

typescript@^3.0.1:
  version "3.0.1"

typescript@^3.0.3:
  version "3.1.3"

detective-typescript@^4.0.0:
  version "4.1.1"
  dependencies:
    node-source-walk "^4.0.0"
    typescript "^3.0.3"
    typescript-eslint-parser "^18.0.0"
kaicataldo commented 5 years ago

detective-typescript might be able to mitigate these errors by matching the version of TS specified exactly (i.e. ~3.0.1 should fix this, I believe), but that would most likely require changing the version of typescript-eslint-parser so that it doesn't update semver-minor versions automatically either. It's tricky with a project like this because changes in parsers are almost always breaking changes.

kaicataldo commented 5 years ago

That being said, now that the bulk of parsing is being done in typescript-estree, I imagine most non-ESLint dependencies would want to use that package directly.

JamesHenry commented 5 years ago

I think this issue was resolved, but feel free to open a new issue on the new project https://github.com/typescript-eslint/typescript-eslint at any time

Thanks!