LINT_BUN_VERSIONconstno test imports itconst LINT_BUN_VERSION: "1.4.4-canary.20261115.1"The Bun whose lint runs ESLint plugins, until a release has it (FR-028).
A rule of a lint plugin run against code, in a test (commons lint 0001-lint FR-009): the files are written to a new folder and the real linter, bun lint of the pinned Bun, is run over them with the plugin loaded by --plugin and only the rule turned on by --rule, so that a test proves the rule and the way bun lint loads it. Its problems come back from its JSON report, decoded.
The linter is the Bun named by IFC_LINT_BUN (a path to a Bun whose lint runs plugins), else the pinned canary through bun x --no-install bun@<LINT_BUN_VERSION>, which is never fetched here: where it is not installed, linter() says so and the tests that need it are skipped with that reason (bun x bun@<LINT_BUN_VERSION> --version installs it).
import { lintFiles } from "./test-rule.ts";
const problems = await lintFiles({ rule: "no-registry-import", files: { "a.ts": 'import x from "npm:x";\nexport { x };\n' } });
// { kind: "ok", value: [{ file: "a.ts", rule: "no-registry-import", line: 1, column: 1, message: "..." }] }LINT_BUN_VERSIONconstno test imports itconst LINT_BUN_VERSION: "1.4.4-canary.20261115.1"The Bun whose lint runs ESLint plugins, until a release has it (FR-028).
PLUGIN_PATHconstno test imports itconst PLUGIN_PATH: stringThe plugin of this folder.
Problemtypetype Problem = {
readonly file: string;
readonly rule: string;
readonly line: number;
readonly column: number;
readonly message: string;
};A problem the linter reported: the file (as given), the rule without its prefix, the line and column from 1, and the message.
LintRuntypetype LintRun = {
readonly rule: string;
readonly options?: unknown;
readonly files: Readonly<Record<string, string>>;
readonly plugin?: string;
/** The plugin's name, the prefix of its rules (`ifc` by default). */
readonly prefix?: string;
};A rule to run: its name, its options object, the files (relative paths and their text), and the plugin (this folder's by default).
lintCommandfunctionno test imports itfunction lintCommand(): readonly string[]The command that runs bun lint, without lint: IFC_LINT_BUN, or the pinned canary through bun x --no-install.
linterfunctionfunction linter(): Promise<Result<readonly string[], string>>The linter's command where it runs and can load a plugin, or why not.
lintFilesfunctionfunction lintFiles(r: LintRun): Promise<Result<readonly Problem[], string>>The problems one rule of a plugin finds in the files given (0001-lint FR-009), by running bun lint over them in a new folder (its working folder, with a bunfig.toml of an empty [lint]), the rule set to error with its options. Problems of other rules (Bun's own defaults) are left out. An error where the linter fails (exit 2: a rule threw, or the plugin did not load).