UNPKG

eslint-plugin-exception-handling

Version:

💣 Lints unhandled functions that might throw errors. For JavaScript/TypeScript eslint.

21 lines (20 loc) • 626 B
import { exploreChildren } from "./explore-children.js"; function omitNullish(obj) { return Object.fromEntries(Object.entries(obj).filter(([, value]) => value != null)); } export function parse(source, context) { const opts = context.languageOptions; const parsed = opts.parser.parseForESLint(source.text, omitNullish({ parser: opts.parserOptions, filePath: source.fileName, loc: true, range: true, tokens: true, comment: true, })); const ast = parsed.ast; exploreChildren(ast, (node, parent) => { node.parent = parent; }); return ast; }