Skip to content
Merged
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
11 changes: 11 additions & 0 deletions apps/oxlint/test/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const NODE_BIN_PATH = process.execPath;
* - `files` as the only argument (so only lints the files in the fixture's `files` directory).
*
* Fixtures with an `options.json` file containing `"fix": true` are also run with `--fix` CLI option.
* Fixtures with an `options.json` file containing `"fixSuggestions": true` are also run with `--fix-suggestions` CLI option.
* The files' contents after fixes are recorded in the snapshot.
*
* Fixtures with an `options.json` file containing `"oxlint": false` are skipped.
Expand Down Expand Up @@ -62,4 +63,14 @@ async function runFixture(fixture: Fixture, expect: ExpectStatic): Promise<void>
const fixArgs = [args[0], "--fix", ...args.slice(1)];
await testFixtureWithCommand({ ...testOptions, args: fixArgs, snapshotName: "fix" });
}

// Run Oxlint with `--fix-suggestions` option
if (options.fixSuggestions) {
const fixArgs = [args[0], "--fix-suggestions", ...args.slice(1)];
await testFixtureWithCommand({
...testOptions,
args: fixArgs,
snapshotName: "fix-suggestions",
});
}
}
6 changes: 5 additions & 1 deletion apps/oxlint/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export interface Fixture {
eslint: boolean;
// Run Oxlint with fixes. Default: `false`.
fix: boolean;
// Run Oxlint with fix-suggestions. Default: `false`.
fixSuggestions: boolean;
// Run Oxlint single-threaded. Default: `false`.
singleThread: boolean;
// Run Oxlint/ESLint in a specific working directory.
Expand All @@ -40,6 +42,7 @@ const DEFAULT_OPTIONS: Fixture["options"] = {
oxlint: true,
eslint: false,
fix: false,
fixSuggestions: false,
singleThread: false,
cwd: null,
};
Expand Down Expand Up @@ -76,10 +79,11 @@ export function getFixtures(): Fixture[] {
typeof options.oxlint !== "boolean" ||
typeof options.eslint !== "boolean" ||
typeof options.fix !== "boolean" ||
typeof options.fixSuggestions !== "boolean" ||
typeof options.singleThread !== "boolean"
) {
throw new TypeError(
"`oxlint`, `eslint`, `fix`, and `singleThread` properties in `options.json` must be booleans",
"`oxlint`, `eslint`, `fix`, `fixSuggestions`, and `singleThread` properties in `options.json` must be booleans",
);
}
if (options.cwd !== null && typeof options.cwd !== "string") {
Expand Down
Loading