eslint-plugin-exception-handling
Version:
💣 Lints unhandled functions that might throw errors. For JavaScript/TypeScript eslint.
18 lines (17 loc) • 534 B
JavaScript
import { isFunctionDeclaration } from "../../src/utils/ast-guards.js";
import { resolveId } from "./resolve-id.js";
import { findInParent } from "./find-in-parent.js";
export function resolveFunc(id, context) {
const resolved = resolveId(id, context);
if (!resolved?.id)
return;
const func = findInParent(resolved.id, isFunctionDeclaration);
if (!func)
return;
return {
func,
module: resolved.module,
protocol: resolved.protocol,
context: resolved.context,
};
}