-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
error: Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. #967
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
Comments
Could you please provide some more information about your environment? Help me to help you |
@bradzacher I experienced this problem in my (pretty complex) development environment after updating the typescript compiler and the @typescript-eslint components to the latest version and did not yet manage to distill this problem down to a reasonable simple example. I experience the problem from within VSCode but also when invoking esling from the command line using: The key configuration files are: tsconfig.json {
"extends": "./configs/tsconfig_base",
"compilerOptions": {
"paths": {
"Source_Data/*": ["./src/data/*"],
"Source_Framework/*": ["./src/framework/*"],
"Source_Modules/*": ["./src/modules/*"],
"Source_Vendor/*": ["./vendor/*"]
}
},
"include": [
"src",
"test/unittest"
]
} tsconfig_base.json {
"compilerOptions": {
"noEmit": true,
"downlevelIteration": true,
"allowJs": true,
"checkJs": false,
"sourceMap": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": false,
"noUnusedLocals": true,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"declaration": false,
"importHelpers": true,
"moduleResolution": "node",
"target": "es2015",
"module": "es2015",
"jsx": "react",
"baseUrl": "../",
"outDir": "../temp",
"typeRoots": [
"../node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
},
"compileOnSave": false,
"exclude": [
"node_modules"
]
} .eslintrc.js module.exports = {
parserOptions: {
ecmaVersion: 2017,
sourceType: 'script',
},
env: {
'es6': true,
},
extends: [
'./configs/eslint_baserules.js',
'../configs/eslint_typescript.js',
'../configs/eslint_import.js',
'../configs/eslint_promise.js',
'../configs/eslint_react.js',
'../configs/eslint_jsdoc.js',
],
}; eslint_typescript.js module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json'
},
extends: [
'plugin:@typescript-eslint/recommended',
],
rules: {
'@typescript-eslint/array-type': ['warn', {default: 'generic'}],
'@typescript-eslint/await-thenable': 'warn',
'@typescript-eslint/ban-ts-ignore': 'off',
'brace-style': 'off',
'@typescript-eslint/brace-style': ['warn', '1tbs'],
'camelcase': 'off',
'@typescript-eslint/camelcase': ['warn', {'properties': 'never'}],
'@typescript-eslint/explicit-function-return-type': 'off', // should probably be on
'@typescript-eslint/explicit-member-accessibility': 'off',
'indent': 'off',
'@typescript-eslint/indent': ['warn', 'tab', {'SwitchCase': 1}],
'@typescript-eslint/member-delimiter-style': ['warn',
{
singleline: {
delimiter: 'comma',
requireLast: false
},
multiline: {
delimiter: 'comma',
requireLast: true
}
}
],
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'no-extra-parens': 'off',
'@typescript-eslint/no-extra-parens': 'warn',
'@typescript-eslint/no-extraneous-class': 'warn',
'@typescript-eslint/no-for-in-array': 'warn',
'@typescript-eslint/no-inferrable-types': ['warn', {'ignoreParameters': true}],
'@typescript-eslint/no-misused-promises': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-unnecessary-qualifier': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/no-useless-constructor': 'warn',
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/no-this-alias': [
'warn',
{
allowDestructuring: true,
allowedNames: ['that']
}
],
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/prefer-function-type': 'warn',
'@typescript-eslint/prefer-includes': 'off',
'@typescript-eslint/prefer-interface': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/prefer-readonly': 'warn',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/require-array-sort-compare': 'warn',
'@typescript-eslint/require-await': 'warn',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/unbound-method': 'warn',
}
}; |
@bradzacher I now isolated the issue in this sample project |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@calumpeak Unfortunately this is not possible in my environment as we use several different |
There's a whole section on it in the readme...
Additionally, the error message that the parser gives you pretty explicitly states it as well:
Please let me know if any of the documentation is not clear enough.
We're working to fix this #864 |
@doberkofler - looking at your zip repro, it's all working as intended. Your tsconfig has the following includes:
Which means that You have to ensure all files are included within the tsconfig. "include": [
+ "src/util",
"src/core"
], I made this change, ran If you have many tsconfigs, you can provide as many or as few of them to the parser as you want, can see more information on this in the parser readme. Alternately, you should create a separate |
This comment has been minimized.
This comment has been minimized.
@bradzacher Thank you for your feedback. I understand how to setup the configuration files but must admit that on a large (I have about 30 TypeScript configuration files) project this new requirement makes things a lot more complicated. I was wondering why this new required is needed and was not in earlier versions? |
More information on why is located in the 2.0.0 release notes: TL;DR is because if you don't include the linted files within the tsconfigs you provide us, then it will cause a serious performance impact, which is If you've got many tsconfig files, you can either:
My recommendation is to just do a new {
"compilerOptions": { "strict": true },
"include": [
"**/src/**/*.ts",
"**/test/**/*.ts",
// etc
]
} I'm going to close this for housekeeping purposes, because it looks like there's no bug here. |
@bradzacher Thank you very much for your extensive feedback and all the work you are doing on this project! |
Resarting VSCode solved this for me 🤔 |
Perhaps I am being thick right now but is there a way to glob any So, "recursively get any and all .ts files from here down" essentially. |
@r-bman - #864, we're working on it and should have a fix out soon. @tsujp - the typescript compiler apis we utilise do not work this way; you have to pass it the path to a tsconfig. We can't really create a temporary tsconfig file in your project during lint, because we don't know the structure of your folders (it's also not a great practice to create temporary files in the project folder). Additionally, whilst globs are reasonably fast, for some larger/deeply nested projects, providing such wide-reaching globs can cause perf issues. |
Using
|
@JeffGuKang - a solution to what exactly? This is how the parser works now. Either you configure it to include all your files, or you get parsing errors. Failing to do so, and turning on
|
@bradzacher Thank you for feedback. I've fixed some misunderstandings and it was related to #864, not this. |
What code were you trying to parse?
any kind of sub module that is currently not used by any other module
What did you expect to happen?
What actually happened?
When using eslint on a sub module that is currently not used by any other module, the following type of error message is shown:
If I import the file in another module the error disappears.
This error message is relatively new and previous version of the
@typescript-eslint/parser
did not complain.Versions
@typescript-eslint/parser
2.2.0
TypeScript
3.6.3
ESLint
6.3.0
node
12.10.0
npm
6.11.2
The text was updated successfully, but these errors were encountered: