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