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
6 changes: 4 additions & 2 deletions crates/oxc_linter/src/config/config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,13 @@ impl Display for ConfigBuilderError {
write!(f, "invalid config file {file}: {reason}")
}
ConfigBuilderError::PluginLoadFailed { plugin_specifier, error } => {
write!(f, "Failed to load external plugin: {plugin_specifier}\n {error}")?;
write!(f, "Failed to load JS plugin: {plugin_specifier}\n {error}")?;
Ok(())
}
ConfigBuilderError::NoExternalLinterConfigured => {
f.write_str("Failed to load external plugin because no external linter was configured. This means the Oxlint binary was executed directly rather than via napi bindings.")?;
f.write_str(
"JS plugins are not supported without `--experimental-js-plugins` CLI option",
)?;
Ok(())
}
ConfigBuilderError::ExternalRuleLookupError(e) => std::fmt::Display::fmt(&e, f),
Expand Down
9 changes: 8 additions & 1 deletion napi/oxlint/test/__snapshots__/e2e.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,18 @@ exports[`oxlint CLI > should report an error if a a rule is not found within a c
exports[`oxlint CLI > should report an error if a custom plugin cannot be loaded 1`] = `
"Failed to parse configuration file.

x Failed to load external plugin: ./test_plugin
x Failed to load JS plugin: ./test_plugin
| Cannot find module './test_plugin'
"
`;

exports[`oxlint CLI > should report an error if a custom plugin in config but JS plugins are not enabled 1`] = `
"Failed to parse configuration file.

x JS plugins are not supported without \`--experimental-js-plugins\` CLI option
"
`;

exports[`oxlint CLI > should report an error if a rule is not found within a custom plugin 1`] = `
"Failed to parse configuration file.

Expand Down
6 changes: 6 additions & 0 deletions napi/oxlint/test/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ describe('oxlint CLI', () => {
expect(normalizeOutput(stdout)).toMatchSnapshot();
});

it('should report an error if a custom plugin in config but JS plugins are not enabled', async () => {
const { stdout, exitCode } = await runOxlintWithoutPlugins('test/fixtures/basic_custom_plugin');
expect(exitCode).toBe(1);
expect(normalizeOutput(stdout)).toMatchSnapshot();
});

it('should report an error if a custom plugin cannot be loaded', async () => {
const { stdout, exitCode } = await runOxlint('test/fixtures/missing_custom_plugin');
expect(exitCode).toBe(1);
Expand Down
Loading