Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.0 Parsing Issues #890

Closed
2 of 3 tasks
bradzacher opened this issue Aug 20, 2019 · 8 comments
Closed
2 of 3 tasks

2.0.0 Parsing Issues #890

bradzacher opened this issue Aug 20, 2019 · 8 comments
Labels
question Questions! (i.e. not a bug / enhancment / documentation)

Comments

@bradzacher
Copy link
Member

bradzacher commented Aug 20, 2019

Known Issues


This issue will serve as a mega-thread of sorts for parsing issues.
There's a lot of people posting in various issues about the same problems, and people mixing up which issue is which.

In v2 we released a breaking change which causes the parser to hard fail for files that are not properly included within your project's tsconfig(s). This was done because we noticed that we had a huge performance issue - when we attempted to parse a file that wasn't included in an existing tsconfig, then we would have to parse that file as if it were a brand new project - including all of its dependencies. This was slow, and educating users about the correct configs was near impossible because we can only do it via looking at copy pasted configs in issue threads.

We throw an error so that you can see what files have not been included by typescript based on the config that you have provided. Chances are that you need to reconfigure your tsconfig's include so that it properly encapsulates all of the files you want to lint. The best way to do this is written in the 2.0.0 release notes, but I'll copy it here to colocate the information:

Steps to fix this

  1. Upgrade to the latest canary version on npm.

  2. Create a new config - tsconfig.eslint.json - which you pass into parserOptions.project. This new tsconfig should include all of the files you want to lint, e.g.:

{
  // extend your base config so you don't have to redefine your compilerOptions
  "extends": "./tsconfig.json",
  "include": [
    "src/**/*.ts",
    "test/**/*.ts",
    "typings/**/*.ts",
    // etc
    
    // if you are going to parse JS files
    "src/**/*/.js"
    // etc
  ]
}

If you are using non standard file extensions (i.e. .vue files), you should setup your config something like the following:

{
  "parserOptions": {
    "extraFileExtensions": [".vue"]
  }
}

FAQ

I upgraded to v2 and now I have parsing errors that I didn't have before, why?

See above. If you attempt the above steps, and it doesn't fix the errors, please respond to this post using this issue template. Comments asking for help without this template will be deleted. Please, help us to help you.

I am getting errors in my IDE (VSCode, WebStorm, etc).

First, check to make sure you can do a lint run for your entire project from the CLI (i.e. yarn eslint). If you get errors here, then stop, and see above.

If you get no errors, then you've hit a known issue. Sit tight, we're working on a fix.

If and only if you have no errors in the CLI, and it's causing you too many headaches in your IDE, then consider adding createDefaultProgram to your config. See the parser docs for more info. PLEASE NOTE THAT THIS IS A TEMPORARY FIX THAT SHOULD ONLY BE USED ONCE YOU HAVE NO PARSING ISSUES FROM THE CLI.

My project uses Vue SFC's, and I can't seem to get it working.

Have a look at our example for Vue SFC that we're testing against. Check that your config is the same.

If you're still seeing issues, please respond to this post using this issue template. Comments asking for help without this template will be deleted. Please, help us to help you.

@bradzacher bradzacher changed the title 2. 2.0.0 Parsing Issues Aug 20, 2019
@bradzacher bradzacher pinned this issue Aug 20, 2019
arcticicestudio added a commit to svengreb/styleguide-javascript that referenced this issue Aug 20, 2019
To support projects build with TypeScript (1), a new
`@arcticicestudio/eslint-config-typescript` package has been implemented
using the awesome @typescript-eslint (2) project. It will mainly extend
`@typescript-eslint/eslint-plugin`'s already provided and recommended
configurations (3) in order to adapt best practices:

1. `plugin:@typescript-eslint/eslint-recommended`
2. `plugin:@typescript-eslint/recommended`
3. `plugin:@typescript-eslint/recommended-requiring-type-checking`

The `@typescript-eslint/parser` (4) is set as ESLint parser.
Also as of `@typescript-eslint/parser` version `2.0.0` (5) (also see
typescript-eslint/typescript-eslint#890 (6)), the parser will panic when
parsing files that are not included within the provided tsconfig(s).
The package documentation contains instructions and a quick setup and
usage guide to inform about the required `tsconfig` configurations (7)
and the corresponding `eslintrc` changes.

Next to the support for TypeScript, the package also modifies some React
and import related rules in order to prevent conflicts, like the
adaption of the `.ts` and `.tsx` extensions for all JS and JSX files as
well as removing `.jsx` to force the usage of `.tsx`.
There are other rules that have been disabled like the check for valid
React `prop-types` since these and not necessary anymore when working
with TypeScript.

The new package provides two entry points, available as
`@arcticicestudio/eslint-config-typescript` (main) and
`@arcticicestudio/eslint-config-typescript/prettier` that can both be
composed with all other available entry points (8) to inherit their
rules.

This package mainly depends on the
`@typescript-eslint/eslint-plugin@^2.0.0` and
`@typescript-eslint/parser@^2.0.0` packages as peer dependencies.

References:
  (1) https://www.typescriptlang.org
  (2) https://github.com/typescript-eslint/typescript-eslint
  (3) https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/configs
  (4) https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser
  (5) https://github.com/typescript-eslint/typescript-eslint/releases/tag/v2.0.0
  (6) typescript-eslint/typescript-eslint#890
  (7) https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#configuration
  (8)  https://github.com/arcticicestudio/styleguide-javascript/blob/develop/packages/%40arcticicestudio/eslint-config/README.md#entry-points

GH-19
arcticicestudio added a commit to svengreb/styleguide-javascript that referenced this issue Aug 20, 2019
To support projects build with TypeScript (1), a new
`@arcticicestudio/eslint-config-typescript` package has been implemented
using the awesome @typescript-eslint (2) project. It will mainly extend
`@typescript-eslint/eslint-plugin`'s already provided and recommended
configurations (3) in order to adapt best practices:

1. `plugin:@typescript-eslint/eslint-recommended`
2. `plugin:@typescript-eslint/recommended`
3. `plugin:@typescript-eslint/recommended-requiring-type-checking`

The `@typescript-eslint/parser` (4) is set as ESLint parser.
Also as of `@typescript-eslint/parser` version `2.0.0` (5) (also see
typescript-eslint/typescript-eslint#890 (6)), the parser will panic when
parsing files that are not included within the provided tsconfig(s).
The package documentation contains instructions and a quick setup and
usage guide to inform about the required `tsconfig` configurations (7)
and the corresponding `eslintrc` changes.

Next to the support for TypeScript, the package also modifies some React
and import related rules in order to prevent conflicts, like the
adaption of the `.ts` and `.tsx` extensions for all JS and JSX files as
well as removing `.jsx` to force the usage of `.tsx`.
There are other rules that have been disabled like the check for valid
React `prop-types` since these and not necessary anymore when working
with TypeScript.

The new package provides two entry points, available as
`@arcticicestudio/eslint-config-typescript` (main) and
`@arcticicestudio/eslint-config-typescript/prettier` that can both be
composed with all other available entry points (8) to inherit their
rules.

This package mainly depends on the
`@typescript-eslint/eslint-plugin@^2.0.0` and
`@typescript-eslint/parser@^2.0.0` packages as peer dependencies.

References:
  (1) https://www.typescriptlang.org
  (2) https://github.com/typescript-eslint/typescript-eslint
  (3) https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/configs
  (4) https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser
  (5) https://github.com/typescript-eslint/typescript-eslint/releases/tag/v2.0.0
  (6) typescript-eslint/typescript-eslint#890
  (7) https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#configuration
  (8)  https://github.com/arcticicestudio/styleguide-javascript/blob/develop/packages/%40arcticicestudio/eslint-config/README.md#entry-points

Resolves GH-19
@toddbluhm
Copy link

toddbluhm commented Aug 30, 2019

Moved comment to new issue - #955

@bradzacher

This comment has been minimized.

@typescript-eslint typescript-eslint deleted a comment from saostad Aug 30, 2019
@toddbluhm

This comment has been minimized.

@typescript-eslint typescript-eslint deleted a comment from fregante Sep 5, 2019
@typescript-eslint typescript-eslint deleted a comment from fregante Sep 5, 2019
@bradzacher

This comment has been minimized.

@ahuglajbclajep

This comment has been minimized.

@munierujp

This comment has been minimized.

munierujp added a commit to gasunit/GASUnit that referenced this issue Sep 19, 2019
munierujp added a commit to gasunit/GASUnit that referenced this issue Sep 19, 2019
* Add eslint-config-standard-with-typescript package

`npm i -D eslint-config-standard-with-typescript`

* Update eslint package

`ncu -u eslint && npm update eslint`

* Update @typescript-eslint/eslint-plugin package

`ncu -u @typescript-eslint/eslint-plugin && npm update 
@typescript-eslint/eslint-plugin`

* Update @typescript-eslint/parser package

`ncu -u @typescript-eslint/parser && npm update 
@typescript-eslint/parser`

* Update eslint-plugin-node package

`ncu -u eslint-plugin-node && npm update eslint-plugin-node`

* Update eslint-plugin-standard package

`ncu -u eslint-plugin-standard && npm update eslint-plugin-standard`

* Update packages

`npm update`

* Update package-lock.json

* Add isFalsy_.ts

* Add isTruthy_.ts

* Add tsconfig.eslint.json

typescript-eslint/typescript-eslint#890

* Add test/**/*.ts to target of linting

* Use standard-with-typescript

* Apply lint

* Remove globals

* Remove eslint-config-standard package

`npm rm eslint-config-standard`
@bradzacher

This comment has been minimized.

@JoshuaKGoldberg

This comment has been minimized.

@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Questions! (i.e. not a bug / enhancment / documentation)
Projects
None yet
Development

No branches or pull requests

5 participants