How do I enable the recommendedTypeChecked config in typescript-eslint?
The config below works for recommended, but when I uncomment ...tseslint.configs.recommendedTypeChecked, I get the error below
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
export default tseslint.config(
eslint.configs.recommended,
// ...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
parser: "@typescript-eslint/parser",
project: true,
},
},
files: ["src/**/*.ts"],
},
);
ESLint: 8.57.0
Error: Error while loading rule '@typescript-eslint/await-thenable': 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. Note: detected a parser other than @typescript-eslint/parser. Make sure the parser is configured to forward "parserOptions.project" to @typescript-eslint/parser.
Occurred while linting /workspaces/eslint-error/eslint.config.js
at throwError (/workspaces/eslint-error/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:33:11)
parserOptions.project is already set. Not sure what the next step is.
I pared-down the package.json to the below. I pushed a repo as well
{
"devDependencies": {
"@types/node": "^18.16.19",
"esbuild": "^0.17.3",
"eslint": "^8.57.0",
"ts-node": "^10.9.1",
"typescript": "~4.9.5",
"typescript-eslint": "^7.1.1"
},
"dependencies": {
"typescript": "~4.9.5"
}
}
How do I get the linter to stop trying to lint it's own config file?
The only solution I have found is to comment out the files array, and instead pass in a path when linting. How can I specify this in the config file?
./node_modules/.bin/eslint **/*.ts
Ignoring the error message component about the parser...
How do I get the linter to stop trying to lint it's own config file?
This is a known common issue when using typed linting. The tl;dr is that type linting relies on TypeScript to generate type info, but if the TypeScript project doesn't include the file, then type info can't be generated for the file.
This is all documented in the typescript-eslint FAQs. Your main stable choices are:
allowJs
to your tsconfig.json
, or use a separate tsconfig.eslint.json
with allowJs
& configure that as your parserOptions.project