/
index.ts
161 lines (131 loc) · 3.83 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import type * as ts from 'typescript';
import type * as tsserverlibrary from 'typescript/lib/tsserverlibrary';
import type { CanonicalPath } from '../create-program/shared';
import type { TSESTree } from '../ts-estree';
import type { CacheLike } from './ExpiringCache';
type DebugModule = 'eslint' | 'typescript-eslint' | 'typescript';
// Workaround to support new TS version features for consumers on old TS versions
declare module 'typescript' {
// Added in TypeScript 5.3
enum JSDocParsingMode {}
}
/**
* Internal settings used by the parser to run on a file.
*/
export interface MutableParseSettings {
/**
* Prevents the parser from throwing an error if it receives an invalid AST from TypeScript.
*/
allowInvalidAST: boolean;
/**
* Code of the file being parsed, or raw source file containing it.
*/
code: ts.SourceFile | string;
/**
* Full text of the file being parsed.
*/
codeFullText: string;
/**
* Whether the `comment` parse option is enabled.
*/
comment: boolean;
/**
* If the `comment` parse option is enabled, retrieved comments.
*/
comments: TSESTree.Comment[];
/**
* @deprecated
* This is a legacy option that comes with severe performance penalties.
* Please do not use it.
*/
DEPRECATED__createDefaultProgram: boolean;
/**
* Which debug areas should be logged.
*/
debugLevel: Set<DebugModule>;
/**
* Whether to error if TypeScript reports a semantic or syntactic error diagnostic.
*/
errorOnTypeScriptSyntacticAndSemanticIssues: boolean;
/**
* Whether to error if an unknown AST node type is encountered.
*/
errorOnUnknownASTType: boolean;
/**
* Experimental: TypeScript server to power program creation.
*/
EXPERIMENTAL_projectService:
| tsserverlibrary.server.ProjectService
| undefined;
/**
* Whether TS should use the source files for referenced projects instead of the compiled .d.ts files.
*
* @remarks
* This feature is not yet optimized, and is likely to cause OOMs for medium to large projects.
* This flag REQUIRES at least TS v3.9, otherwise it does nothing.
*/
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: boolean;
/**
* Any non-standard file extensions which will be parsed.
*/
extraFileExtensions: string[];
/**
* Path of the file being parsed.
*/
filePath: string;
/**
* JSDoc parsing style to pass through to TypeScript
*/
jsDocParsingMode: ts.JSDocParsingMode;
/**
* Whether parsing of JSX is enabled.
*
* @remarks The applicable file extension is still required.
*/
jsx: boolean;
/**
* Whether to add `loc` information to each node.
*/
loc: boolean;
/**
* Log function, if not `console.log`.
*/
log: (message: string) => void;
/**
* Whether two-way AST node maps are preserved during the AST conversion process.
*/
preserveNodeMaps?: boolean;
/**
* One or more instances of TypeScript Program objects to be used for type information.
*/
programs: Iterable<ts.Program> | null;
/**
* Normalized paths to provided project paths.
*/
projects: readonly CanonicalPath[];
/**
* Whether to add the `range` property to AST nodes.
*/
range: boolean;
/**
* Whether this is part of a single run, rather than a long-running process.
*/
singleRun: boolean;
/**
* Whether deprecated AST properties should skip calling console.warn on accesses.
*/
suppressDeprecatedPropertyWarnings: boolean;
/**
* If the `tokens` parse option is enabled, retrieved tokens.
*/
tokens: TSESTree.Token[] | null;
/**
* Caches searches for TSConfigs from project directories.
*/
tsconfigMatchCache: CacheLike<string, string>;
/**
* The absolute path to the root directory for all provided `project`s.
*/
tsconfigRootDir: string;
}
export type ParseSettings = Readonly<MutableParseSettings>;