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
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);
});
});
0