Skip to content

Commit fb8894b

Browse files
committed
Refactor code-style
1 parent 528265f commit fb8894b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/index.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,34 @@ import {VFileMessage} from 'vfile-message'
5252
/**
5353
* @param {Value} value
5454
* Serialized JavaScript to parse.
55-
* @param {Options} [options={}]
55+
* @param {Options | null | undefined} [options={}]
5656
* Configuration (optional).
5757
* @returns {Program}
5858
* Program node (as esast).
5959
*/
60-
export function fromJs(value, options = {}) {
60+
export function fromJs(value, options) {
61+
const options_ = options || {}
6162
/** @type {ParserClass} */
6263
let parser = Parser
6364
/** @type {Array<Comment>} */
6465
const comments = []
6566
/** @type {Program} */
6667
let tree
6768

68-
if (options.plugins) {
69-
parser = parser.extend(...options.plugins)
69+
if (options_.plugins) {
70+
parser = parser.extend(...options_.plugins)
7071
}
7172

7273
try {
7374
// @ts-expect-error: Acorn looks enough like estree.
7475
tree = parser.parse(value, {
75-
ecmaVersion: options.version || 'latest',
76-
sourceType: options.module ? 'module' : 'script',
77-
allowReturnOutsideFunction: options.allowReturnOutsideFunction,
78-
allowImportExportEverywhere: options.allowImportExportEverywhere,
79-
allowAwaitOutsideFunction: options.allowAwaitOutsideFunction,
80-
allowHashBang: options.allowHashBang,
81-
allowSuperOutsideMethod: options.allowSuperOutsideMethod,
76+
ecmaVersion: options_.version || 'latest',
77+
sourceType: options_.module ? 'module' : 'script',
78+
allowReturnOutsideFunction: options_.allowReturnOutsideFunction,
79+
allowImportExportEverywhere: options_.allowImportExportEverywhere,
80+
allowAwaitOutsideFunction: options_.allowAwaitOutsideFunction,
81+
allowHashBang: options_.allowHashBang,
82+
allowSuperOutsideMethod: options_.allowSuperOutsideMethod,
8283
locations: true,
8384
onComment: comments
8485
})

0 commit comments

Comments
 (0)