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
9 changes: 5 additions & 4 deletions apps/oxlint/conformance/src/capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,14 @@ export function it(code: string, fn: () => void): void {
if (currentTest === null) throw new Error("Test case was not run with `RuleTester`");

testResult.isPassed = true;
} catch (err) {
} catch (_err) {
let err: Error;
if (currentTest === null) {
// oxlint-disable-next-line no-ex-assign
err = new Error("Test case was not run with `RuleTester`");
currentTest = { code };
} else if (!(err instanceof Error)) {
// oxlint-disable-next-line no-ex-assign
} else if (_err instanceof Error) {
err = _err;
} else {
err = new Error("Unknown error");
}

Expand Down
4 changes: 3 additions & 1 deletion apps/oxlint/src-js/package/rule_tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,9 @@ function setupOptions(test: TestCase, cwd: string): number {
workspaceUri: null,
});
} catch (err) {
throw new Error(`Failed to serialize options: ${err}`);
throw new Error(
`Failed to serialize options: ${err as (typeof globalThis)["Error"]["prototype"]}`,
);
}
setOptions(allOptionsJson);

Expand Down
4 changes: 2 additions & 2 deletions apps/oxlint/test/fixtures/createOnce/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ const plugin: Plugin = {

export default plugin;

function tryCatch(fn: () => unknown) {
function tryCatch(fn: () => unknown): Error {
try {
fn();
} catch (err) {
return err;
return err as Error;
}
throw new Error("Expected function to throw");
}
4 changes: 2 additions & 2 deletions apps/oxlint/test/rule_tester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ RuleTester.it = itHook;
* @returns Array containing errors for each test case
*/
function runCases(): (Error | null)[] {
const errors = [];
const errors: (Error | null)[] = [];
for (const testCase of cases) {
let error = null;
try {
testCase.fn();
} catch (err) {
error = err;
error = err as Error;
}
errors.push(error);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function getFixtures(): Fixture[] {
try {
options = JSON.parse(readFileSync(pathJoin(dirPath, "options.json"), "utf8"));
} catch (err) {
if (err?.code !== "ENOENT") throw err;
if ((err as NodeJS.ErrnoException)?.code !== "ENOENT") throw err;
options = DEFAULT_OPTIONS;
}

Expand Down
3 changes: 2 additions & 1 deletion apps/oxlint/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"noImplicitAny": true,
"strictNullChecks": true,
"skipLibCheck": true,
"noUnusedLocals": true
"noUnusedLocals": true,
"useUnknownInCatchVariables": true
},
"exclude": ["node_modules", "fixtures", "test/fixtures/*/files", "conformance/submodules"]
}
Loading