prettier-eslint: Error generating `parserServices` for eslint plugin `@typescript-eslint`
Versions:
prettier-eslint
version: 8.8.2node
version: 11.9.0yarn
version: 1.13.0
Have you followed the debugging tips?
Yes
Relevant code or config
.eslintrc.js
parser: `@typescript-eslint/parser`,
parserOptions: {
project: `./tsconfig.json`
},
rules: {
'@typescript-eslint/no-unnecessary-type-assertion': 2
}
What I did: Run prettier (via VSCode`s FormatOnSave hook).
What happened:
Error while loading rule '@typescript-eslint/no-unnecessary-type-assertion'/home/oskar/dev/hyperapp/hyper-parcel/src/bootstrap.ts:: You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Problem description:
Running prettier-eslint
I get the error above. Running eslint
directly gives no errors and works as expected. I have also tried it with an absolute path to my tsconfig.json
, but the error is the same.
Reproduction repository: https://github.com/r0skar/prettier-eslint-test
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 33
- Comments: 15 (4 by maintainers)
Commits related to this issue
- Ensure consistent type imports and exports This ensures types are imported and exported with `import type` and `export type`, which has various benefits such as providing extra assurance that TypeScr... — committed to ministryofjustice/hmpps-accredited-programmes-ui by yndajas a year ago
- Ensure consistent type imports and exports This ensures types are imported and exported with `import type` and `export type`, which has various benefits such as providing extra assurance that TypeScr... — committed to ministryofjustice/hmpps-accredited-programmes-ui by yndajas a year ago
- Ensure consistent type imports and exports This ensures types are imported and exported with `import type` and `export type`, which has various benefits such as providing extra assurance that TypeScr... — committed to ministryofjustice/hmpps-accredited-programmes-ui by yndajas a year ago
- Ensure consistent type imports and exports This ensures types are imported and exported with `import type` and `export type`, which has various benefits such as providing extra assurance that TypeScr... — committed to ministryofjustice/hmpps-accredited-programmes-ui by yndajas a year ago
- Ensure consistent type imports and exports This ensures types are imported and exported with `import type` and `export type`, which has various benefits such as providing extra assurance that TypeScr... — committed to ministryofjustice/hmpps-accredited-programmes-ui by yndajas a year ago
@ricardolpd I was able to fix this by adding
"project": ["tsconfig.json"],
:could anyone provide an example of a config that provides a work around for this? We are facing this issue with
'@typescript-eslint/require-await'
in our mono repo.update
typescript-eslint-parser
(Deprecated) to@typescript-eslint/parser
when i use
.eslintrc.js
withI directly remove code
it works fine
I’m looking into this today.
The main suggestion here seems to be to update from the old
typescript-eslint-parser
to the new@typescript-eslint/parser
.However, I would like to make another suggestion: make
prettier-eslint
respect any predefined TS parsers (via an existingparser
option in the ESLint RC).This way, users may use their own version of the TS parser, in much the same way that
prettier-eslint
allows users to use their own version of ESLint.@m-cat that didn’t work for me. We are also seeing this trying to add the same require-await rule as @ricardolpd. Are there any other suggestions on how to fix this?
I think this issue has been solved by the release of prettier-eslint v9.0.0.
Adding another solution since I found this thread via google. We also had a monorepo and the necessary parserOptions.project property was set correctly. The stack trace pointed to a
jest.config.js
file it was trying to lint, I explicitly ignored that file in my.eslintrc.js
:For me, the issue was that the parserOptions.project was not looking in the current project of a mono-repo. I had to specify it as if it was from the top of the repo.
packages/react-desktop/package.json
I’m not sure if that is a bug or not. It seems strange the . is the repo root, not the current project root. Now I can avoid those pesky falsyness in conditionals.
The requirement for the “parserOptions.project” property was seen after running
npx eslint . --ext .ts
I have created a quick test repo: https://github.com/r0skar/prettier-eslint-test
If you open it in VSCode with the prettier extension installed, you will get an error upon saving
index.ts
, but runningyarn eslint
will not show any error.