1 | import type { CacheDurationSeconds, DebugLevel, JSDocParsingMode } from '@typescript-eslint/types';
|
2 | import type * as ts from 'typescript';
|
3 | import type { TSESTree, TSESTreeToTSNode, TSNode, TSToken } from './ts-estree';
|
4 | interface ParseOptions {
|
5 | |
6 |
|
7 |
|
8 |
|
9 | allowInvalidAST?: boolean;
|
10 | |
11 |
|
12 |
|
13 | comment?: boolean;
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | debugLevel?: DebugLevel;
|
25 | |
26 |
|
27 |
|
28 |
|
29 | errorOnUnknownASTType?: boolean;
|
30 | |
31 |
|
32 |
|
33 | filePath?: string;
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | jsDocParsingMode?: JSDocParsingMode;
|
45 | |
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | jsx?: boolean;
|
55 | |
56 |
|
57 |
|
58 |
|
59 |
|
60 | loc?: boolean;
|
61 | loggerFn?: false | ((message: string) => void);
|
62 | /**
|
63 | * Controls whether the `range` property is included on AST nodes.
|
64 | * The `range` property is a [number, number] which indicates the start/end index of the node in the file contents.
|
65 | * This is similar to the `loc` property, except this is the absolute index.
|
66 | */
|
67 | range?: boolean;
|
68 | /**
|
69 | * Set to true to create a top-level array containing all tokens from the file.
|
70 | */
|
71 | tokens?: boolean;
|
72 | /**
|
73 | * Whether deprecated AST properties should skip calling console.warn on accesses.
|
74 | */
|
75 | suppressDeprecatedPropertyWarnings?: boolean;
|
76 | }
|
77 | /**
|
78 | * Granular options to configure the project service.
|
79 | */
|
80 | export interface ProjectServiceOptions {
|
81 | /**
|
82 | * Globs of files to allow running with the default inferred project settings.
|
83 | */
|
84 | allowDefaultProjectForFiles?: string[];
|
85 | }
|
86 | interface ParseAndGenerateServicesOptions extends ParseOptions {
|
87 | /**
|
88 | * Causes the parser to error if the TypeScript compiler returns any unexpected syntax/semantic errors.
|
89 | */
|
90 | errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;
|
91 | /**
|
92 | * ***EXPERIMENTAL FLAG*** - Use this at your own risk.
|
93 | *
|
94 | * Whether to create a shared TypeScript server to power program creation.
|
95 | *
|
96 | * @see https://github.com/typescript-eslint/typescript-eslint/issues/6575
|
97 | */
|
98 | EXPERIMENTAL_useProjectService?: boolean | ProjectServiceOptions;
|
99 | /**
|
100 | * ***EXPERIMENTAL FLAG*** - Use this at your own risk.
|
101 | *
|
102 | * Causes TS to use the source files for referenced projects instead of the compiled .d.ts files.
|
103 | * This feature is not yet optimized, and is likely to cause OOMs for medium to large projects.
|
104 | *
|
105 | * This flag REQUIRES at least TS v3.9, otherwise it does nothing.
|
106 | *
|
107 | * @see https://github.com/typescript-eslint/typescript-eslint/issues/2094
|
108 | */
|
109 | EXPERIMENTAL_useSourceOfProjectReferenceRedirect?: boolean;
|
110 | /**
|
111 | * When `project` is provided, this controls the non-standard file extensions which will be parsed.
|
112 | * It accepts an array of file extensions, each preceded by a `.`.
|
113 | */
|
114 | extraFileExtensions?: string[];
|
115 | /**
|
116 | * Absolute (or relative to `tsconfigRootDir`) path to the file being parsed.
|
117 | * When `project` is provided, this is required, as it is used to fetch the file from the TypeScript compiler's cache.
|
118 | */
|
119 | filePath?: string;
|
120 | /**
|
121 | * Allows the user to control whether or not two-way AST node maps are preserved
|
122 | * during the AST conversion process.
|
123 | *
|
124 | * By default: the AST node maps are NOT preserved, unless `project` has been specified,
|
125 | * in which case the maps are made available on the returned `parserServices`.
|
126 | *
|
127 | * NOTE: If `preserveNodeMaps` is explicitly set by the user, it will be respected,
|
128 | * regardless of whether or not `project` is in use.
|
129 | */
|
130 | preserveNodeMaps?: boolean;
|
131 | /**
|
132 | * Absolute (or relative to `tsconfigRootDir`) paths to the tsconfig(s),
|
133 | * or `true` to find the nearest tsconfig.json to the file.
|
134 | * If this is provided, type information will be returned.
|
135 | *
|
136 | * If set to `false`, `null` or `undefined` type information will not be returned.
|
137 | */
|
138 | project?: string[] | string | boolean | null;
|
139 | /**
|
140 | * If you provide a glob (or globs) to the project option, you can use this option to ignore certain folders from
|
141 | * being matched by the globs.
|
142 | * This accepts an array of globs to ignore.
|
143 | *
|
144 | * By default, this is set to ["**\/node_modules/**"]
|
145 | */
|
146 | projectFolderIgnoreList?: string[];
|
147 | /**
|
148 | * The absolute path to the root directory for all provided `project`s.
|
149 | */
|
150 | tsconfigRootDir?: string;
|
151 | /**
|
152 | * An array of one or more instances of TypeScript Program objects to be used for type information.
|
153 | * This overrides any program or programs that would have been computed from the `project` option.
|
154 | * All linted files must be part of the provided program(s).
|
155 | */
|
156 | programs?: ts.Program[] | null;
|
157 | /**
|
158 | * @deprecated - this flag will be removed in the next major.
|
159 | * Do not rely on the behavior provided by this flag.
|
160 | */
|
161 | DEPRECATED__createDefaultProgram?: boolean;
|
162 | /**
|
163 | * ESLint (and therefore typescript-eslint) is used in both "single run"/one-time contexts,
|
164 | * such as an ESLint CLI invocation, and long-running sessions (such as continuous feedback
|
165 | * on a file in an IDE).
|
166 | *
|
167 | * When typescript-eslint handles TypeScript Program management behind the scenes, this distinction
|
168 | * is important because there is significant overhead to managing the so called Watch Programs
|
169 | * needed for the long-running use-case.
|
170 | *
|
171 | * When allowAutomaticSingleRunInference is enabled, we will use common heuristics to infer
|
172 | * whether or not ESLint is being used as part of a single run.
|
173 | */
|
174 | allowAutomaticSingleRunInference?: boolean;
|
175 | /**
|
176 | * Granular control of the expiry lifetime of our internal caches.
|
177 | * You can specify the number of seconds as an integer number, or the string
|
178 | * 'Infinity' if you never want the cache to expire.
|
179 | *
|
180 | * By default cache entries will be evicted after 30 seconds, or will persist
|
181 | * indefinitely if `allowAutomaticSingleRunInference = true` AND the parser
|
182 | * infers that it is a single run.
|
183 | */
|
184 | cacheLifetime?: {
|
185 | /**
|
186 | * Glob resolution for `parserOptions.project` values.
|
187 | */
|
188 | glob?: CacheDurationSeconds;
|
189 | };
|
190 | }
|
191 | export type TSESTreeOptions = ParseAndGenerateServicesOptions;
|
192 | export interface ParserWeakMap<Key, ValueBase> {
|
193 | get<Value extends ValueBase>(key: Key): Value;
|
194 | has(key: unknown): boolean;
|
195 | }
|
196 | export interface ParserWeakMapESTreeToTSNode<Key extends TSESTree.Node = TSESTree.Node> {
|
197 | get<KeyBase extends Key>(key: KeyBase): TSESTreeToTSNode<KeyBase>;
|
198 | has(key: unknown): boolean;
|
199 | }
|
200 | export interface ParserServicesNodeMaps {
|
201 | esTreeNodeToTSNodeMap: ParserWeakMapESTreeToTSNode;
|
202 | tsNodeToESTreeNodeMap: ParserWeakMap<TSNode | TSToken, TSESTree.Node>;
|
203 | }
|
204 | export interface ParserServicesWithTypeInformation extends ParserServicesNodeMaps {
|
205 | program: ts.Program;
|
206 | getSymbolAtLocation: (node: TSESTree.Node) => ts.Symbol | undefined;
|
207 | getTypeAtLocation: (node: TSESTree.Node) => ts.Type;
|
208 | }
|
209 | export interface ParserServicesWithoutTypeInformation extends ParserServicesNodeMaps {
|
210 | program: null;
|
211 | }
|
212 | export type ParserServices = ParserServicesWithoutTypeInformation | ParserServicesWithTypeInformation;
|
213 | export {};
|
214 |
|
\ | No newline at end of file |