Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 8221d14

Browse files
committed
Improve ParserOptions
1 parent 4880d29 commit 8221d14

File tree

3 files changed

+155
-5
lines changed

3 files changed

+155
-5
lines changed

.eslintrc.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,34 @@ module.exports = defineConfig({
8282
skipWords: [
8383
'amd',
8484
'applescript',
85+
'asyncgenerator',
86+
'asynciterable',
8587
'atomtest',
8688
'backtick',
8789
'backticks',
8890
'browserify',
8991
'commonjs',
92+
'dom',
9093
'ecma',
9194
'embertest',
95+
'esnext',
9296
'globals',
9397
'greasemonkey',
9498
'jsdoc',
99+
'jsx',
100+
'loc',
95101
'multiline',
96102
'nashorn',
97103
'phantomjs',
104+
'pragma',
98105
'prototypejs',
99-
'webextensions'
106+
'scripthost',
107+
'sharedmemory',
108+
'tsconfig',
109+
'typedarrays',
110+
'webextensions',
111+
'webworker',
112+
'wellknown'
100113
]
101114
}
102115
],

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22
"cSpell.words": [
33
"Quadflieg",
44
"applescript",
5+
"asyncgenerator",
6+
"asynciterable",
57
"atomtest",
68
"backticks",
79
"embertest",
810
"greasemonkey",
11+
"importscripts",
12+
"linebreak",
913
"nashorn",
1014
"prototypejs",
1115
"qunit",
1216
"readonly",
17+
"scripthost",
1318
"serviceworker",
19+
"typedarrays",
1420
"typeof",
21+
"weakref",
1522
"webextensions"
1623
],
1724
"eslint.validate": ["javascript", "typescript"],

src/parser-options.d.ts

Lines changed: 134 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,140 @@
1+
import { LiteralUnion } from './utility-types';
2+
13
/**
4+
* Set to 3, 5 (default), 6, 7, 8, 9, 10, 11, or 12 to specify the version of ECMAScript syntax you want to use. You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), or 2021 (same as 12) to use the year-based naming.
25
*
6+
* @default 5
37
*/
4-
export interface ParserOptions {
5-
ecmaVersion?: 2020;
8+
export type EcmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021;
9+
10+
/**
11+
* Set to "script" (default) or "module" if your code is in ECMAScript modules.
12+
*/
13+
export type SourceType = 'script' | 'module';
14+
15+
/** Lib. */
16+
export type Lib = LiteralUnion<
17+
| 'es5'
18+
| 'es6'
19+
| 'es2015'
20+
| 'es7'
21+
| 'es2016'
22+
| 'es2017'
23+
| 'es2018'
24+
| 'es2019'
25+
| 'es2020'
26+
| 'esnext'
27+
| 'dom'
28+
| 'dom.iterable'
29+
| 'webworker'
30+
| 'webworker.importscripts'
31+
| 'webworker.iterable'
32+
| 'scripthost'
33+
| 'es2015.core'
34+
| 'es2015.collection'
35+
| 'es2015.generator'
36+
| 'es2015.iterable'
37+
| 'es2015.promise'
38+
| 'es2015.proxy'
39+
| 'es2015.reflect'
40+
| 'es2015.symbol'
41+
| 'es2015.symbol.wellknown'
42+
| 'es2016.array.include'
43+
| 'es2017.object'
44+
| 'es2017.sharedmemory'
45+
| 'es2017.string'
46+
| 'es2017.intl'
47+
| 'es2017.typedarrays'
48+
| 'es2018.asyncgenerator'
49+
| 'es2018.asynciterable'
50+
| 'es2018.intl'
51+
| 'es2018.promise'
52+
| 'es2018.regexp'
53+
| 'es2019.array'
54+
| 'es2019.object'
55+
| 'es2019.string'
56+
| 'es2019.symbol'
57+
| 'es2020.bigint'
58+
| 'es2020.promise'
59+
| 'es2020.sharedmemory'
60+
| 'es2020.string'
61+
| 'es2020.symbol.wellknown'
62+
| 'es2020.intl'
63+
| 'esnext.array'
64+
| 'esnext.symbol'
65+
| 'esnext.asynciterable'
66+
| 'esnext.intl'
67+
| 'esnext.bigint'
68+
| 'esnext.string'
69+
| 'esnext.promise'
70+
| 'esnext.weakref'
71+
| 'es2016.full'
72+
| 'es2017.full'
73+
| 'es2018.full'
74+
| 'es2019.full'
75+
| 'es2020.full'
76+
| 'esnext.full'
77+
| 'lib'
78+
>;
79+
80+
/** DebugLevel. */
81+
export type DebugLevel = boolean | Array<'eslint' | 'typescript' | 'typescript-eslint'>;
82+
83+
/**
84+
* Parser options.
85+
*
86+
* @see [Specifying Parser Options](https://eslint.org/docs/user-guide/configuring/language-options#specifying-parser-options)
87+
*/
88+
export interface ParserOptions extends Partial<Record<string, unknown>> {
89+
/**
90+
* Set to 3, 5 (default), 6, 7, 8, 9, 10, 11, or 12 to specify the version of ECMAScript syntax you want to use. You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), or 2021 (same as 12) to use the year-based naming.
91+
*
92+
* @default 5
93+
*/
94+
ecmaVersion?: EcmaVersion;
95+
/**
96+
* Set to "script" (default) or "module" if your code is in ECMAScript modules.
97+
*/
98+
sourceType?: SourceType;
99+
/**
100+
* An object indicating which additional language features you'd like to use.
101+
*/
102+
ecmaFeatures?: {
103+
/**
104+
* Allow `return` statements in the global scope.
105+
*/
106+
globalReturn?: boolean;
107+
/**
108+
* Enable global [strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) (if `ecmaVersion` is 5 or greater).
109+
*/
110+
impliedStrict?: boolean;
111+
/**
112+
* Enable [JSX](https://facebook.github.io/jsx/).
113+
*/
114+
jsx?: boolean;
115+
};
116+
jsxPragma?: string;
117+
jsxFragmentName?: string | null;
118+
lib?: Lib[];
119+
comment?: boolean;
120+
debugLevel?: DebugLevel;
121+
errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;
122+
errorOnUnknownASTType?: boolean;
123+
extraFileExtensions?: string[];
124+
filePath?: string;
125+
loc?: boolean;
126+
/**
127+
* Parser.
128+
*
129+
* @see [Working with Custom Parsers](https://eslint.org/docs/developer-guide/working-with-custom-parsers)
130+
* @see [Specifying Parser](https://eslint.org/docs/user-guide/configuring/plugins#specifying-parser)
131+
*/
6132
parser?: string;
7-
project?: any;
8-
sourceType?: 'module' | '...';
133+
project?: string | string[];
134+
projectFolderIgnoreList?: Array<string | RegExp>;
135+
range?: boolean;
136+
tokens?: boolean;
137+
tsconfigRootDir?: string;
138+
useJSXTextNode?: boolean;
9139
warnOnUnsupportedTypeScriptVersion?: boolean;
10140
}

0 commit comments

Comments
 (0)