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 @@ -80,10 +80,10 @@ export function createParseSettings(
errorOnTypeScriptSyntacticAndSemanticIssues: false,
errorOnUnknownASTType: options.errorOnUnknownASTType === true,
EXPERIMENTAL_projectService:
(options.EXPERIMENTAL_useProjectService &&
process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER !== 'false') ||
(process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER === 'true' &&
options.EXPERIMENTAL_useProjectService !== false)
options.EXPERIMENTAL_useProjectService ||
(options.project &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @JoshuaKGoldberg , should we check it's non-empty?

I don't know this project options, asking this only because I use project:[] in prettier and eslint-plugin-unicorn, I don't remember why, maybe prevent search for tsconfig.json?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the docs, maybe I should use project: false?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yes, or project: null.

Copy link
Contributor

@fisker fisker Jan 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back to my question, should we treat [] as false here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question 🤔. My gut instinct is that it should probably be an error. I'm not sure though... Filed #8210.

options.EXPERIMENTAL_useProjectService !== false &&
process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER === 'true')
? (TSSERVER_PROJECT_SERVICE ??= createProjectService(
options.EXPERIMENTAL_useProjectService,
jsDocParsingMode,
Expand Down
50 changes: 50 additions & 0 deletions packages/typescript-estree/tests/lib/createParseSettings.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,56 @@
import { createParseSettings } from '../../src/parseSettings/createParseSettings';

const projectService = { service: true };

jest.mock('../../src/create-program/createProjectService', () => ({
createProjectService: (): typeof projectService => projectService,
}));

describe('createParseSettings', () => {
describe('EXPERIMENTAL_projectService', () => {
it('is created when options.EXPERIMENTAL_useProjectService is enabled', () => {
process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER = 'false';

const parseSettings = createParseSettings('', {
EXPERIMENTAL_useProjectService: true,
});

expect(parseSettings.EXPERIMENTAL_projectService).toBe(projectService);
});

it('is created when options.EXPERIMENTAL_useProjectService is undefined, options.project is true, and process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER is true', () => {
process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER = 'true';

const parseSettings = createParseSettings('', {
EXPERIMENTAL_useProjectService: undefined,
project: true,
});

expect(parseSettings.EXPERIMENTAL_projectService).toBe(projectService);
});

it('is not created when options.EXPERIMENTAL_useProjectService is undefined, options.project is falsy, and process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER is true', () => {
process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER = 'true';

const parseSettings = createParseSettings('', {
EXPERIMENTAL_useProjectService: undefined,
});

expect(parseSettings.EXPERIMENTAL_projectService).toBeUndefined();
});

it('is not created when options.EXPERIMENTAL_useProjectService is false, options.project is true, and process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER is true', () => {
process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER = 'true';

const parseSettings = createParseSettings('', {
EXPERIMENTAL_useProjectService: false,
project: true,
});

expect(parseSettings.EXPERIMENTAL_projectService).toBeUndefined();
});
});

describe('tsconfigMatchCache', () => {
it('reuses the TSConfig match cache when called a subsequent time', () => {
const parseSettings1 = createParseSettings('input.ts');
Expand Down