Skip to content

Commit 0ade564

Browse files
committed
refactor(linter/plugins): replace ! with assertIsNonNull (#15947)
After #15946, we're now free to use `assertIsNonNull` in `cli.ts` without breaking dead code removal. So use it instead of unchecked `!` assertions. In debug build it becomes a real runtime assertion.
1 parent 619a226 commit 0ade564

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

apps/oxlint/src-js/cli.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { lint } from './bindings.js';
2+
import { assertIsNonNull } from './utils/asserts.js';
23

34
// Lazy-loaded JS plugin-related functions.
45
// Using `typeof wrapper` here makes TS check that the function signatures of `loadPlugin` and `loadPluginWrapper`
@@ -24,7 +25,8 @@ function loadPluginWrapper(path: string, packageName: string | null): Promise<st
2425
return loadPlugin(path, packageName);
2526
});
2627
}
27-
return loadPlugin!(path, packageName);
28+
assertIsNonNull(loadPlugin);
29+
return loadPlugin(path, packageName);
2830
}
2931

3032
/**
@@ -48,7 +50,8 @@ function lintFileWrapper(
4850
): string {
4951
// `lintFileWrapper` is never called without `loadPluginWrapper` being called first,
5052
// so `lintFile` must be defined here
51-
return lintFile!(filePath, bufferId, buffer, ruleIds, settingsJSON);
53+
assertIsNonNull(lintFile);
54+
return lintFile(filePath, bufferId, buffer, ruleIds, settingsJSON);
5255
}
5356

5457
// Get command line arguments, skipping first 2 (node binary and script path)

0 commit comments

Comments
 (0)