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
12 changes: 7 additions & 5 deletions apps/oxlint/src-js/plugins/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ function lintFileImpl(
}
assertIs<BufferWithArrays>(buffer);

if (typeof filePath !== 'string' || filePath.length === 0) {
throw new Error('expected filePath to be a non-zero length string');
}
if (!Array.isArray(ruleIds) || ruleIds.length === 0) {
throw new Error('Expected `ruleIds` to be a non-zero len array');
if (DEBUG) {
if (typeof filePath !== 'string' || filePath.length === 0) {
throw new Error('Expected filePath to be a non-zero length string');
}
if (!Array.isArray(ruleIds) || ruleIds.length === 0) {
throw new Error('Expected `ruleIds` to be a non-zero length array');
}
}

// Pass file path to context module, so `Context`s know what file is being linted
Expand Down
7 changes: 3 additions & 4 deletions apps/oxlint/src-js/plugins/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,13 @@ export async function loadPlugin(path: string, packageName: string | null): Prom
* @throws {*} If plugin throws an error during import
*/
async function loadPluginImpl(path: string, packageName: string | null): Promise<PluginDetails> {
if (registeredPluginPaths.has(path)) {
throw new Error('This plugin has already been registered. This is a bug in Oxlint. Please report it.');
if (DEBUG) {
if (registeredPluginPaths.has(path)) throw new Error('This plugin has already been registered');
registeredPluginPaths.add(path);
}

const { default: plugin } = (await import(pathToFileURL(path).href)) as { default: Plugin };

registeredPluginPaths.add(path);

// TODO: Use a validation library to assert the shape of the plugin, and of rules

const pluginName = getPluginName(plugin, packageName);
Expand Down
Loading