8000 [Error] Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser · Issue #954 · microsoft/vscode-eslint · GitHub
[go: up one dir, main page]

Skip to content
[Error] Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser #954
@six-ponies

Description

@six-ponies

Hi~ I found an error descibed above, and my versions are listed below:

package version
vscode-eslint 2.1.5
@typescript-eslint/parser 2.27.0
TypeScript 3.7.2
ESLint 6.8.0
vscode 1.44.1
Node.js 12.8.1
V8 7.8.279.23-electron.0
OS Linux x64 4.13.0-36-generic

eslint configs:

module.exports = {
    parser: '@typescript-eslint/parser',
    parserOptions: {
        warnOnUnsupportedTypeScriptVersion: false,
        ecmaVersion: 6,
        sourceType: 'module',
        project: 'tsconfig.json',
    }
}

This error happens when I use symlink as my workspace dir, e.g.
/home/xxx/workspace/ -> /workspace

I tried to div into source code and found languageServer use symlink uri when file changed, e.g.
/home/xxx/workspace/src/index.js
but typescript-estree use extra.tsconfigRootDir = '/workspace' to createProjectProgram.

I also found a way to solve this problem:

function getFileSystemPath(uri: URI): string {
	const result = uri.fsPath;
	if (process.platform === 'win32' && result.length >= 2 && result[1] === ':') {
		// Node by default uses an upper case drive letter and ESLint uses
		// === to compare paths which results in the equal check failing
		// if the drive letter is lower case in th URI. Ensure upper case.
		return result[0].toUpperCase() + result.substr(1);
	} else {
		return fs.realpathSync(result); // I added fs.realpathSync to solve this problem
	}
}

Let me know if this solution is correct, thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    info-neededIssue requires more information from poster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0