You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
xo attempts to check if a given file that it's linting matches a tsconfig.json passed into parserOptions.project. If the file being checked does not match the tsconfig (according to minimatch), a temporary tsconfig will be created.
However, options.filePath here is an absolute filepath, and the includes glob of a given tsconfig.json may be specified as a relative path from the config file itself. If the tsconfig in question is not in the current working directory, this check will erroneously fail.
I noticed this issue due to xojs/vscode-linter-xo#110. I thought I had given xo a good parserOptions.project path, but xo and the vscode-linter-xo started generating competing (and different!) temporary tsconfigs in the cache, eventually causing the editor extension to start choking on parser errors.
/path/to/my-project/src/some-file.ts does not match the glob ../src/**/*, so a temporary tsconfig is created in node_modules/.cache/xo-linter, even though tsc would recognize the config as matching that file.
Before passing options.filePath to micromatch, I think it should be made relative to options.tsConfigPath if it exists. If this is an acceptable solution, I'm happy open a PR!
This issue is pretty straightforward to workaround by placing the tsconfig given to parserOptions.project in the project root rather than a subdirectory, so that a glob like src/**/* will match an absolute path.
The text was updated successfully, but these errors were encountered:
Overview
xo attempts to check if a given file that it's linting matches a
tsconfig.json
passed intoparserOptions.project
. If the file being checked does not match the tsconfig (according to minimatch), a temporary tsconfig will be created.xo/lib/options-manager.js
Lines 178 to 181 in 352f20c
However,
options.filePath
here is an absolute filepath, and theincludes
glob of a giventsconfig.json
may be specified as a relative path from the config file itself. If the tsconfig in question is not in the current working directory, this check will erroneously fail.I noticed this issue due to xojs/vscode-linter-xo#110. I thought I had given
xo
a goodparserOptions.project
path, butxo
and thevscode-linter-xo
started generating competing (and different!) temporary tsconfigs in the cache, eventually causing the editor extension to start choking on parser errors.Reproduction
Project structure
tsconfig.lint.json
Behavior
/path/to/my-project/src/some-file.ts
does not match the glob../src/**/*
, so a temporary tsconfig is created innode_modules/.cache/xo-linter
, even thoughtsc
would recognize the config as matching that file.Proposal
Before passing
options.filePath
tomicromatch
, I think it should be made relative tooptions.tsConfigPath
if it exists. If this is an acceptable solution, I'm happy open a PR!Workaround
This issue is pretty straightforward to workaround by placing the tsconfig given to
parserOptions.project
in the project root rather than a subdirectory, so that a glob likesrc/**/*
will match an absolute path.The text was updated successfully, but these errors were encountered: