(code, userOptions = {})
| 12 | export const ecmaVersion = 2023; |
| 13 | |
| 14 | export function parseJS(code, userOptions = {}) { |
| 15 | // allowed options and their defaults |
| 16 | const options = { |
| 17 | comment: false, |
| 18 | ecmaVersion, |
| 19 | range: false, |
| 20 | sourceType: "script", |
| 21 | }; |
| 22 | |
| 23 | // validate and assign options |
| 24 | for (const [name, value] of Object.entries(userOptions)) { |
| 25 | if (!hasOwn(options, name)) { |
| 26 | throw new TypeError(`Allowed parser options are ${Object.keys(options)}, but not '${name}'`); |
| 27 | } |
| 28 | options[name] = value; |
| 29 | } |
| 30 | |
| 31 | return parse(code, options); |
| 32 | } |
| 33 | |
| 34 | export {Syntax, VisitorKeys} from "espree"; |
no test coverage detected