diff --git a/apps/oxlint/src-js/cli.ts b/apps/oxlint/src-js/cli.ts index fd0d39f721ec1..0d6dfc638a8fe 100644 --- a/apps/oxlint/src-js/cli.ts +++ b/apps/oxlint/src-js/cli.ts @@ -6,7 +6,7 @@ import { lint } from './bindings.js'; let loadPlugin: typeof loadPluginWrapper | null = null; let lintFile: typeof lintFileWrapper | null = null; -function loadPluginWrapper(path: string, packageName?: string): Promise { +function loadPluginWrapper(path: string, packageName: string | null): Promise { if (loadPlugin === null) { const require = createRequire(import.meta.url); // `plugins.js` is in root of `dist`. See `tsdown.config.ts`. diff --git a/apps/oxlint/src-js/plugins/load.ts b/apps/oxlint/src-js/plugins/load.ts index 01746b042e4c5..59bf541b4053e 100644 --- a/apps/oxlint/src-js/plugins/load.ts +++ b/apps/oxlint/src-js/plugins/load.ts @@ -102,10 +102,10 @@ interface PluginDetails { * containing try/catch. * * @param path - Absolute path of plugin file - * @param packageName - Optional package name from package.json (fallback if plugin.meta.name is missing) + * @param packageName - Optional package name from `package.json` (fallback if `plugin.meta.name` is not defined) * @returns JSON result */ -export async function loadPlugin(path: string, packageName?: string): Promise { +export async function loadPlugin(path: string, packageName: string | null): Promise { try { const res = await loadPluginImpl(path, packageName); return JSON.stringify({ Success: res }); @@ -118,13 +118,15 @@ export async function loadPlugin(path: string, packageName?: string): Promise { +async function loadPluginImpl(path: string, packageName: string | null): Promise { if (registeredPluginPaths.has(path)) { throw new Error('This plugin has already been registered. This is a bug in Oxlint. Please report it.'); } @@ -134,13 +136,9 @@ async function loadPluginImpl(path: string, packageName?: string): Promise