@@ -49,15 +49,13 @@ export function parseForESLint(
49
49
code : string ,
50
50
parserOptions : any ,
51
51
) : AST . ESLintExtendedProgram {
52
- const options : ParserOptions = Object . assign (
53
- {
54
- comment : true ,
55
- loc : true ,
56
- range : true ,
57
- tokens : true ,
58
- } ,
59
- parserOptions || { } ,
60
- )
52
+ const options : ParserOptions = {
53
+ comment : true ,
54
+ loc : true ,
55
+ range : true ,
56
+ tokens : true ,
57
+ ...( parserOptions ?? { } ) ,
58
+ }
61
59
62
60
let result : AST . ESLintExtendedProgram
63
61
let document : AST . VDocumentFragment | null
@@ -70,12 +68,12 @@ export function parseForESLint(
70
68
; ( { result, document, locationCalculator } = parseAsSFC ( code , options ) )
71
69
}
72
70
73
- result . services = Object . assign (
74
- result . services || { } ,
75
- services . define ( code , result . ast , document , locationCalculator , {
71
+ result . services = {
72
+ ... ( result . services || { } ) ,
73
+ ... services . define ( code , result . ast , document , locationCalculator , {
76
74
parserOptions : options ,
77
75
} ) ,
78
- )
76
+ }
79
77
80
78
return result
81
79
}
@@ -96,7 +94,7 @@ export { AST }
96
94
function parseAsSFC ( code : string , options : ParserOptions ) {
97
95
const optionsForTemplate = {
98
96
...options ,
99
- ecmaVersion : options . ecmaVersion || DEFAULT_ECMA_VERSION ,
97
+ ecmaVersion : options . ecmaVersion ?? DEFAULT_ECMA_VERSION ,
100
98
}
101
99
const skipParsingScript = options . parser === false
102
100
const tokenizer = new HTMLTokenizer ( code , optionsForTemplate )
@@ -128,7 +126,7 @@ function parseAsSFC(code: string, options: ParserOptions) {
128
126
if ( skipParsingScript || ! scripts . length ) {
129
127
result = parseScript ( "" , {
130
128
...options ,
131
- ecmaVersion : options . ecmaVersion || DEFAULT_ECMA_VERSION ,
129
+ ecmaVersion : options . ecmaVersion ?? DEFAULT_ECMA_VERSION ,
132
130
parser : scriptParser ,
133
131
} )
134
132
} else if (
@@ -195,7 +193,7 @@ function parseAsSFC(code: string, options: ParserOptions) {
195
193
function parseAsScript ( code : string , options : ParserOptions ) {
196
194
return parseScript ( code , {
197
195
...options ,
198
- ecmaVersion : options . ecmaVersion || DEFAULT_ECMA_VERSION ,
196
+ ecmaVersion : options . ecmaVersion ?? DEFAULT_ECMA_VERSION ,
199
197
parser : getScriptParser ( options . parser , ( ) => {
200
198
const ext = (
201
199
path . extname ( options . filePath || "unknown.js" ) . toLowerCase ( ) ||
0 commit comments