Skip to content

fix(typescript-estree): factor tsconfigRootDir into allowDefaultProject #9675

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,12 @@ export function useProgramFromProjectService(
filePathAbsolute,
);

const filePathRelative = path.relative(
parseSettings.tsconfigRootDir,
filePathAbsolute,
);
const isDefaultProjectAllowed = filePathMatchedBy(
parseSettings.filePath,
filePathRelative,
serviceSettings.allowDefaultProject,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const mockFileName = 'camelCaseFile.ts';
const mockParseSettings = {
filePath: `path/PascalCaseDirectory/${mockFileName}`,
extraFileExtensions: [] as readonly string[],
tsconfigRootDir: currentDirectory,
} as ParseSettings;

const createProjectServiceSettings = <
Expand Down Expand Up @@ -106,10 +107,12 @@ describe('useProgramFromProjectService', () => {
);

expect(service.openClientFile).toHaveBeenCalledWith(
path.normalize('/repos/repo/path/PascalCaseDirectory/camelCaseFile.ts'),
undefined,
path.normalize(
`${currentDirectory}/path/PascalCaseDirectory/camelCaseFile.ts`,
),
undefined,
undefined,
currentDirectory,
);
});

Expand Down Expand Up @@ -184,7 +187,7 @@ See https://typescript-eslint.io/troubleshooting/typed-linting#allowdefaultproje
Matching files:
- a
- b
- ${path.normalize('/repos/repo/path/PascalCaseDirectory/camelCaseFile.ts')}
- ${path.normalize(`${currentDirectory}/path/PascalCaseDirectory/camelCaseFile.ts`)}

If you absolutely need more files included, set parserOptions.projectService.maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING to a larger value.
`);
Expand Down
Loading