-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
parser-options.d.ts
342 lines (308 loc) · 10.7 KB
/
parser-options.d.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
import type { LiteralUnion } from './utility-types';
// Some types copied from `@types/eslint` `Linter.ParserOptions`
/**
* Any valid ECMAScript version number or 'latest':
*
* - A version: es3, es5, es6, es7, es8, es9, es10, es11, es12, es13, es14, ...
* - A year: es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, ...
* - 'latest'
*
* @see https://typescript-eslint.io/architecture/parser/#ecmaversion
*/
export type EcmaVersion =
| 3
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| 13
| 14
| 2015
| 2016
| 2017
| 2018
| 2019
| 2020
| 2021
| 2022
| 2023
| 'latest';
/**
* Set to "script" (default) or "module" if your code is in ECMAScript modules.
*/
export type SourceType = 'script' | 'module';
/**
* An object indicating which additional language features you'd like to use.
*
* @see https://eslint.org/docs/latest/user-guide/configuring/language-options#specifying-parser-options
* @see https://typescript-eslint.io/architecture/parser#ecmafeatures
*/
export interface EcmaFeatures extends Partial<Record<string, boolean>> {
/**
* Allow `return` statements in the global scope.
*/
globalReturn?: boolean;
/**
* Enable global [strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) (if `ecmaVersion` is 5 or greater).
*/
impliedStrict?: boolean;
/**
* Enable [JSX](https://facebook.github.io/jsx).
*/
jsx?: boolean;
}
/** Lib. */
export type Lib = LiteralUnion<
| 'es5'
| 'es6'
| 'es2015'
| 'es7'
| 'es2016'
| 'es2017'
| 'es2018'
| 'es2019'
| 'es2020'
| 'esnext'
| 'dom'
| 'dom.iterable'
| 'webworker'
| 'webworker.importscripts'
| 'webworker.iterable'
| 'scripthost'
| 'es2015.core'
| 'es2015.collection'
| 'es2015.generator'
| 'es2015.iterable'
| 'es2015.promise'
| 'es2015.proxy'
| 'es2015.reflect'
| 'es2015.symbol'
| 'es2015.symbol.wellknown'
| 'es2016.array.include'
| 'es2017.object'
| 'es2017.sharedmemory'
| 'es2017.string'
| 'es2017.intl'
| 'es2017.typedarrays'
| 'es2018.asyncgenerator'
| 'es2018.asynciterable'
| 'es2018.intl'
| 'es2018.promise'
| 'es2018.regexp'
| 'es2019.array'
| 'es2019.object'
| 'es2019.string'
| 'es2019.symbol'
| 'es2020.bigint'
| 'es2020.promise'
| 'es2020.sharedmemory'
| 'es2020.string'
| 'es2020.symbol.wellknown'
| 'es2020.intl'
| 'esnext.array'
| 'esnext.symbol'
| 'esnext.asynciterable'
| 'esnext.intl'
| 'esnext.bigint'
| 'esnext.string'
| 'esnext.promise'
| 'esnext.weakref'
| 'es2016.full'
| 'es2017.full'
| 'es2018.full'
| 'es2019.full'
| 'es2020.full'
| 'esnext.full'
| 'lib'
>;
/** DebugLevel. */
export type DebugLevel =
| boolean
| Array<'eslint' | 'typescript' | 'typescript-eslint'>;
/** Parser. */
export type Parser = LiteralUnion<
| 'babel-eslint'
| '@typescript-eslint/parser'
| 'jsonc-eslint-parser'
| 'vue-eslint-parser'
>;
/**
* Parser options.
*
* @see [Specifying Parser Options](https://eslint.org/docs/user-guide/configuring/language-options#specifying-parser-options)
*/
export interface ParserOptions extends Partial<Record<string, unknown>> {
/**
* Accepts any valid ECMAScript version number or `'latest'`:
*
* - A version: es3, es5, es6, es7, es8, es9, es10, es11, es12, es13, es14, ..., or
* - A year: es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, ..., or
* - `'latest'`
*
* When it's a version or a year, the value must be a number - so do not include the `es` prefix.
*
* Specifies the version of ECMAScript syntax you want to use. This is used by the parser to determine how to perform scope analysis, and it affects the default
*
* @default 2018
*
* @see https://typescript-eslint.io/architecture/parser/#ecmaversion
*/
ecmaVersion?: EcmaVersion;
/**
* Set to "script" (default) or "module" if your code is in ECMAScript modules.
*
* @default 'script'
*
* @see https://eslint.org/docs/latest/user-guide/configuring/language-options#specifying-parser-options
*/
sourceType?: SourceType;
/**
* An object indicating which additional language features you'd like to use.
*
* @see https://eslint.org/docs/latest/user-guide/configuring/language-options#specifying-parser-options
* @see https://typescript-eslint.io/architecture/parser#ecmafeatures
*/
ecmaFeatures?: EcmaFeatures;
/**
* The identifier that's used for JSX Elements creation (after transpilation).
* If you're using a library other than React (like `preact`), then you should change this value.
* If you are using the [new JSX transform](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) you can set this to `null`.
*
* This should not be a member expression - just the root identifier (i.e. use `"React"` instead of `"React.createElement"`).
*
* If you provide `parserOptions.project`, you do not need to set this, as it will automatically detected from the compiler.
*
* @default 'React'
*
* @see [jsxPragma](https://typescript-eslint.io/architecture/parser#jsxpragma)
*/
jsxPragma?: string;
/**
* The identifier that's used for JSX fragment elements (after transpilation).
* If `null`, assumes transpilation will always use a member of the configured `jsxPragma`.
* This should not be a member expression - just the root identifier (i.e. use `"h"` instead of `"h.Fragment"`).
*
* If you provide `parserOptions.project`, you do not need to set this, as it will automatically detected from the compiler.
*
* @default null
*
* @see [jsxFragmentName](https://typescript-eslint.io/architecture/parser#jsxfragmentname)
*/
jsxFragmentName?: string | null;
/**
* For valid options, see the [TypeScript compiler options](https://www.typescriptlang.org/tsconfig#lib).
*
* Specifies the TypeScript `libs` that are available.
* This is used by the scope analyser to ensure there are global variables declared for the types exposed by TypeScript.
*
* If you provide `parserOptions.project`, you do not need to set this, as it will automatically detected from the compiler.
*
* @default ['es2018']
*
* @see [lib](https://typescript-eslint.io/architecture/parser/#lib)
*/
lib?: Lib[];
comment?: boolean;
debugLevel?: DebugLevel;
errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;
errorOnUnknownASTType?: boolean;
/**
* This option allows you to provide one or more additional file extensions which should be considered in the TypeScript Program compilation.
*
* The default extensions are `.ts`, `.tsx`, `.js`, and `.jsx`. Add extensions starting with `.`, followed by the file extension.
* E.g. for a `.vue` file use `"extraFileExtensions: [".vue"]`.
*
* @see [extraFileExtensions](https://typescript-eslint.io/architecture/parser/#extrafileextensions)
*/
extraFileExtensions?: string[];
filePath?: string;
loc?: boolean;
/**
* Parser.
*
* @see [Working with Custom Parsers](https://eslint.org/docs/developer-guide/working-with-custom-parsers)
* @see [Specifying Parser](https://eslint.org/docs/user-guide/configuring/plugins#specifying-parser)
*/
parser?: Parser;
/**
* This option allows you to provide a path to your project's `tsconfig.json`.
* **This setting is required if you want to use rules which require type information.**
* Relative paths are interpreted relative to the current working directory if `tsconfigRootDir` is not set.
* If you intend on running ESLint from directories other than the project root, you should consider using `tsconfigRootDir`.
*
* @default undefined
*
* @see [project](https://typescript-eslint.io/architecture/parser/#project)
*/
project?: string | string[];
/**
* This option allows you to ignore folders from being included in your provided list of `project`s.
* This is useful if you have configured glob patterns, but want to make sure you ignore certain folders.
*
* It accepts an array of globs to exclude from the `project` globs.
*
* For example, by default it will ensure that a glob like `./**/tsconfig.json` will not match any `tsconfigs` within your `node_modules` folder (some npm packages do not exclude their source files from their published packages).
*
* @default ['**/node_modules/**']
*
* @see [projectFolderIgnoreList](https://typescript-eslint.io/architecture/parser/#projectfolderignorelist)
*/
projectFolderIgnoreList?: Array<string | RegExp>;
range?: boolean;
tokens?: boolean;
/**
* This option allows you to provide the root directory for relative tsconfig paths specified in the `project` option above.
*
* @see [tsconfigRootDir](https://typescript-eslint.io/architecture/parser/#tsconfigrootdir)
*/
tsconfigRootDir?: string;
useJSXTextNode?: boolean;
/**
* This option allows you to toggle the warning that the parser will give you if you use a version of TypeScript which is not explicitly supported.
*
* @default true
*
* @see [warnOnUnsupportedTypeScriptVersion](https://typescript-eslint.io/architecture/parser/#warnonunsupportedtypescriptversion)
*/
warnOnUnsupportedTypeScriptVersion?: boolean;
/**
* This option allow you to tell parser to act as if `emitDecoratorMetadata: true` is set in `tsconfig.json`, but without [type-aware linting](https://typescript-eslint.io/linting/typed-linting).
* In other words, you don't have to specify `parserOptions.project` in this case, making the linting process faster.
*
* @default undefined
*
* @see [emitDecoratorMetadata](https://typescript-eslint.io/architecture/parser/#emitdecoratormetadata)
*/
emitDecoratorMetadata?: boolean;
/**
* @see [vueFeatures](https://github.com/vuejs/vue-eslint-parser#parseroptionsvuefeatures)
*/
vueFeatures?: {
/**
* You can use `parserOptions.vueFeatures.filter` property to specify whether to parse the Vue2 filter.
*
* If you specify `false`, the parser does not parse `|` as a filter.
*
* @see [filter](https://github.com/vuejs/vue-eslint-parser#parseroptionsvuefeaturesfilter)
*/
filter?: boolean;
/**
* You can use `parserOptions.vueFeatures.interpolationAsNonHTML` property to specify whether to parse the interpolation as HTML.
*
* If you specify `true`, the parser handles the interpolation as non-HTML (However, you can use HTML escaping in the interpolation).
*
* @see [interpolationAsNonHTML](https://github.com/vuejs/vue-eslint-parser#parseroptionsvuefeaturesinterpolationasnonhtml)
*/
interpolationAsNonHTML?: boolean;
};
/**
* @see [templateTokenizer](https://github.com/rashfael/eslint-plugin-vue-pug#usage)
*/
templateTokenizer?: {
pug?: LiteralUnion<'vue-eslint-parser-template-tokenizer-pug'>;
};
}