@@ -85,25 +85,32 @@ export function parseForESLint(
85
85
options = Object . assign (
86
86
{
87
87
comment : true ,
88
- ecmaVersion : 2017 ,
89
88
loc : true ,
90
89
range : true ,
91
90
tokens : true ,
92
91
} ,
93
92
options || { } ,
94
93
)
95
94
95
+ const optionsWithEcmaVersion = {
96
+ ...options ,
97
+ ecmaVersion : options . ecmaVersion || 2017 ,
98
+ }
99
+
96
100
let result : AST . ESLintExtendedProgram
97
101
let document : AST . VDocumentFragment | null
98
102
let locationCalculator : LocationCalculatorForHtml | null
99
103
if ( ! isVueFile ( code , options ) ) {
100
- result = parseScript ( code , options )
104
+ result = parseScript ( code , optionsWithEcmaVersion )
101
105
document = null
102
106
locationCalculator = null
103
107
} else {
104
108
const skipParsingScript = options . parser === false
105
- const tokenizer = new HTMLTokenizer ( code , options )
106
- const rootAST = new HTMLParser ( tokenizer , options ) . parse ( )
109
+ const tokenizer = new HTMLTokenizer ( code , optionsWithEcmaVersion )
110
+ const rootAST = new HTMLParser (
111
+ tokenizer ,
112
+ optionsWithEcmaVersion ,
113
+ ) . parse ( )
107
114
108
115
locationCalculator = new LocationCalculatorForHtml (
109
116
tokenizer . gaps ,
@@ -124,7 +131,7 @@ export function parseForESLint(
124
131
125
132
let scriptSetup : VElement | undefined
126
133
if ( skipParsingScript || ! scripts . length ) {
127
- result = parseScript ( "" , options )
134
+ result = parseScript ( "" , optionsWithEcmaVersion )
128
135
} else if (
129
136
scripts . length === 2 &&
130
137
( scriptSetup = scripts . find ( isScriptSetup ) )
0 commit comments