@@ -2,19 +2,20 @@ import type {
2
2
AnalyzeOptions ,
3
3
ScopeManager ,
4
4
} from '@typescript-eslint/scope-manager' ;
5
- import { analyze } from '@typescript-eslint/scope-manager' ;
6
5
import type { Lib , TSESTree } from '@typescript-eslint/types' ;
7
- import { ParserOptions } from '@typescript-eslint/types' ;
8
6
import type {
9
7
AST ,
10
8
ParserServices ,
11
9
TSESTreeOptions ,
12
10
} from '@typescript-eslint/typescript-estree' ;
13
- import { parseAndGenerateServices } from '@typescript-eslint/typescript-estree' ;
14
11
import type { VisitorKeys } from '@typescript-eslint/visitor-keys' ;
12
+ import type * as ts from 'typescript' ;
13
+
14
+ import { analyze } from '@typescript-eslint/scope-manager' ;
15
+ import { ParserOptions } from '@typescript-eslint/types' ;
16
+ import { parseAndGenerateServices } from '@typescript-eslint/typescript-estree' ;
15
17
import { visitorKeys } from '@typescript-eslint/visitor-keys' ;
16
18
import debug from 'debug' ;
17
- import type * as ts from 'typescript' ;
18
19
import { ScriptTarget } from 'typescript' ;
19
20
20
21
const log = debug ( 'typescript-eslint:parser:parser' ) ;
@@ -27,9 +28,9 @@ interface ESLintProgram extends AST<{ comment: true; tokens: true }> {
27
28
28
29
interface ParseForESLintResult {
29
30
ast : ESLintProgram ;
31
+ scopeManager : ScopeManager ;
30
32
services : ParserServices ;
31
33
visitorKeys : VisitorKeys ;
32
- scopeManager : ScopeManager ;
33
34
}
34
35
35
36
function validateBoolean (
@@ -58,24 +59,24 @@ function getLib(compilerOptions: ts.CompilerOptions): Lib[] {
58
59
const target = compilerOptions . target ?? ScriptTarget . ES5 ;
59
60
// https://github.com/microsoft/TypeScript/blob/ae582a22ee1bb052e19b7c1bc4cac60509b574e0/src/compiler/utilitiesPublic.ts#L13-L36
60
61
switch ( target ) {
61
- case ScriptTarget . ESNext :
62
- return [ 'esnext.full' ] ;
63
- case ScriptTarget . ES2022 :
64
- return [ 'es2022.full' ] ;
65
- case ScriptTarget . ES2021 :
66
- return [ 'es2021.full' ] ;
67
- case ScriptTarget . ES2020 :
68
- return [ 'es2020.full' ] ;
69
- case ScriptTarget . ES2019 :
70
- return [ 'es2019.full' ] ;
71
- case ScriptTarget . ES2018 :
72
- return [ 'es2018.full' ] ;
73
- case ScriptTarget . ES2017 :
74
- return [ 'es2017.full' ] ;
75
- case ScriptTarget . ES2016 :
76
- return [ 'es2016.full' ] ;
77
62
case ScriptTarget . ES2015 :
78
63
return [ 'es6' ] ;
64
+ case ScriptTarget . ES2016 :
65
+ return [ 'es2016.full' ] ;
66
+ case ScriptTarget . ES2017 :
67
+ return [ 'es2017.full' ] ;
68
+ case ScriptTarget . ES2018 :
69
+ return [ 'es2018.full' ] ;
70
+ case ScriptTarget . ES2019 :
71
+ return [ 'es2019.full' ] ;
72
+ case ScriptTarget . ES2020 :
73
+ return [ 'es2020.full' ] ;
74
+ case ScriptTarget . ES2021 :
75
+ return [ 'es2021.full' ] ;
76
+ case ScriptTarget . ES2022 :
77
+ return [ 'es2022.full' ] ;
78
+ case ScriptTarget . ESNext :
79
+ return [ 'esnext.full' ] ;
79
80
default :
80
81
return [ 'lib' ] ;
81
82
}
@@ -135,8 +136,8 @@ function parseForESLint(
135
136
136
137
const analyzeOptions : AnalyzeOptions = {
137
138
globalReturn : parserOptions . ecmaFeatures . globalReturn ,
138
- jsxPragma : parserOptions . jsxPragma ,
139
139
jsxFragmentName : parserOptions . jsxFragmentName ,
140
+ jsxPragma : parserOptions . jsxPragma ,
140
141
lib : parserOptions . lib ,
141
142
sourceType : parserOptions . sourceType ,
142
143
} ;
@@ -184,7 +185,7 @@ function parseForESLint(
184
185
services . experimentalDecorators ??=
185
186
parserOptions . experimentalDecorators === true ;
186
187
187
- return { ast, services , scopeManager , visitorKeys } ;
188
+ return { ast, scopeManager , services , visitorKeys } ;
188
189
}
189
190
190
191
export { parse , parseForESLint , ParserOptions } ;
0 commit comments