8000 fix(typescript-estree): don't add in-project files to defaultProjectMatchedFiles by ehoogeveen-medweb · Pull Request #9097 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

fix(typescript-estree): don't add in-project files to defaultProjectMatchedFiles #9097

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 @@ -83,7 +83,9 @@ export function useProgramFromProjectService(
return undefined;
}

defaultProjectMatchedFiles.add(filePathAbsolute);
if (!opened.configFileName) {
defaultProjectMatchedFiles.add(filePathAbsolute);
}
if (defaultProjectMatchedFiles.size > maximumDefaultProjectFileMatchCount) {
throw new Error(
`Too many files (>${maximumDefaultProjectFileMatchCount}) have matched the default project.${DEFAULT_PROJECT_FILES_ERROR_EXPLANATION}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,29 @@ If you absolutely need more files included, set parserOptions.EXPERIMENTAL_usePr

expect(actual).toBe(program);
});

it('returns a created program when hasFullTypeInformation is disabled, the file is in the project service, the service has a matching program, and no out-of-project files are allowed', () => {
const { service } = createMockProjectService();
const program = { getSourceFile: jest.fn() };

mockGetProgram.mockReturnValueOnce(program);

service.openClientFile.mockReturnValueOnce({
configFileName: 'tsconfig.json',
});
mockCreateProjectProgram.mockReturnValueOnce(program);

const actual = useProgramFromProjectService(
createProjectServiceSettings({
allowDefaultProjectForFiles: [],
maximumDefaultProjectFileMatchCount: 0,
service,
}),
mockParseSettings,
false,
new Set(),
);

expect(actual).toBe(program);
});
});
Loading
0