Files
overlookmotel c6cbe42e17 refactor(linter/plugins): split TSDown plugins into separate files (#20304)
Pure refactor. TSDown config had got very large with the custom plugins to replace `debugAssert` calls, and hoist globals vars to top level. A PR to follow will make the situation worse, as it adds another plugin.

Move the plugins into separate files, to bring the TSDown config back to a manageable size.

This PR does not alter the plugin code, just moves it.
2026-03-12 19:22:57 +00:00

17 lines
471 B
TypeScript

import { parseSync } from "oxc-parser";
import type { Program } from "@oxc-project/types";
/**
* Parse code and return the AST.
* @param path - Path to file
* @param code - Source code
* @returns AST
* @throws Error if parsing fails
*/
export function parse(path: string, code: string): Program {
const { program, errors } = parseSync(path, code);
if (errors.length !== 0) throw new Error(`Failed to parse ${path}: ${errors[0].message}`);
return program;
}