@typescript-eslint/project-service
Standalone TypeScript project service wrapper for linting ✨
The typescript-eslint Project Service is a wrapper around TypeScript's "project service" APIs. These APIs are what editors such as VS Code use to programmatically "open" files and generate TypeScript programs for type information.
See Announcing typescript-eslint v8 > Project Service for more details on how lint users interact with the Project Service.
import { createProjectService } from '@typescript-eslint/project-service';
const filePathAbsolute = '/path/to/your/project/index.ts';
const { service } = createProjectService();
service.openClientFile(filePathAbsolute);
const scriptInfo = service.getScriptInfo(filePathAbsolute)!;
const program = service
.getDefaultProjectForFile(scriptInfo.fileName, true)!
.getLanguageService(true)
.getProgram()!;
The following documentation is auto-generated from source code.
Functions
createProjectService()
function createProjectService(settings): ProjectServiceAndMetadata;
Defined in: createProjectService.ts:93
Creates a new Project Service instance, as well as metadata on its creation.
Parameters
Parameter | Type | Description |
---|---|---|
settings | CreateProjectServiceSettings | Settings to create a new Project Service instance. |
Returns
A new Project Service instance, as well as metadata on its creation.
Example
import { createProjectService } from '@typescript-eslint/project-service';
const { service } = createProjectService();
service.openClientFile('index.ts');
Interfaces
CreateProjectServiceSettings
Defined in: createProjectService.ts:63
Settings to create a new Project Service instance with createProjectService.
Properties
Property | Type | Description | Defined in |
---|---|---|---|
jsDocParsingMode? | JSDocParsingMode | How aggressively (and slowly) to parse JSDoc comments. | createProjectService.ts:72 |
options? | ProjectServiceOptions | Granular options to configure the project service. | createProjectService.ts:67 |
tsconfigRootDir? | string | Root directory for the tsconfig.json file, if not the current directory. | createProjectService.ts:77 |
ProjectServiceAndMetadata
Defined in: createProjectService.ts:38
A created Project Service instance, as well as metadata on its creation.
Properties
Property | Type | Description | Defined in |
---|---|---|---|
allowDefaultProject | undefined | string [] | Files allowed to be loaded from the default project, if any were specified. | createProjectService.ts:42 |
lastReloadTimestamp | number | The performance.now() timestamp of the last reload of the project service. | createProjectService.ts:47 |
maximumDefaultProjectFileMatchCount | number | The maximum number of files that can be matched by the default project. | createProjectService.ts:52 |
service | ProjectService | The created TypeScript Project Service instance. | createProjectService.ts:57 |
Type Aliases
TypeScriptProjectService
type TypeScriptProjectService = ts.server.ProjectService;
Defined in: createProjectService.ts:33
Shortcut type to refer to TypeScript's server ProjectService.