Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cli-checks-one-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"diagnostics-webpack-plugin": patch
---

Hand Biome and oxlint every file at once when webpack is done building them, rather than in batches while it builds: each batch was a process of its own reading the configuration, and for Biome the project, again.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,10 @@ new DiagnosticsPlugin({ checks: ["biome"] });
Like the oxlint check this runs a binary and reads the JSON it answers with,
which Biome calls an experimental reporter — a release of its own may move the
shape, and it is the only reporter carrying the severities this check needs.
A build hands it every file at once when webpack is done building them, one
run for each 500, rather than in batches while webpack builds: each run reads
the configuration and the project again. Over 1,500 files that took the CPU of
the processes from 2.9 s to 2.2 s, and for oxlint from 1.2–1.7 s to 0.3 s.

Biome's project and types rules — `noImportCycles`, `noFloatingPromises` —
answer for a file from the files it imports, and which rules those are is not
Expand Down
4 changes: 4 additions & 0 deletions src/checks/biome.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,9 @@ export default {
// read for the answer the way oxlint's can. A rebuild lints again what a
// change reaches, which a run of Biome barely notices; a project using none
// of those rules can write `readsAcrossFiles: false`.
// Each run is a process of its own that reads the configuration and, for
// Biome, the project again: handed every file at once, a build starts one
// for each 500 files rather than one for each batch webpack builds.
lintsOnce: () => true,
readsAcrossFiles: () => true,
};
4 changes: 4 additions & 0 deletions src/checks/oxlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ export default {
create,
resultPath: (/** @type {EXPECTED_ANY} */ result) =>
/** @type {FileResult} */ (result).filename,
// Each run is a process of its own that reads the configuration and, for
// Biome, the project again: handed every file at once, a build starts one
// for each 500 files rather than one for each batch webpack builds.
lintsOnce: () => true,
readsAcrossFiles,
};

Expand Down
7 changes: 7 additions & 0 deletions test/lints-once.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import { afterEach, describe, it } from "node:test";

import webpack from "webpack";

import biome from "../src/checks/biome.js";
import eslint from "../src/checks/eslint.js";
import oxlint from "../src/checks/oxlint.js";
import DiagnosticsPlugin from "../src/index.js";
import { countThreads } from "../src/threads.js";

Expand Down Expand Up @@ -50,6 +52,11 @@ describe("linting once", () => {
});
});

it("should hand Biome and oxlint every file at once, each run being a process", () => {
assert.strictEqual(biome.lintsOnce && biome.lintsOnce(), true);
assert.strictEqual(oxlint.lintsOnce && oxlint.lintsOnce(), true);
});

describe("a check that lints once", () => {
/** @type {string | undefined} */
let project;
Expand Down
1 change: 1 addition & 0 deletions types/checks/biome.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare namespace _default {
export function defaultExclude(): string;
export { create };
export function resultPath(result: EXPECTED_ANY): string;
export function lintsOnce(): boolean;
export function readsAcrossFiles(): boolean;
}
export default _default;
Expand Down
1 change: 1 addition & 0 deletions types/checks/oxlint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare namespace _default {
export function defaultExclude(): string;
export { create };
export function resultPath(result: EXPECTED_ANY): string;
export function lintsOnce(): boolean;
export { readsAcrossFiles };
}
export default _default;
Expand Down
Loading