diff --git a/crates/oxc_linter/src/config/config_builder.rs b/crates/oxc_linter/src/config/config_builder.rs index e17eb63008140..0dd01f6e7a117 100644 --- a/crates/oxc_linter/src/config/config_builder.rs +++ b/crates/oxc_linter/src/config/config_builder.rs @@ -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), diff --git a/napi/oxlint/test/__snapshots__/e2e.test.ts.snap b/napi/oxlint/test/__snapshots__/e2e.test.ts.snap index 81c9c2d647421..03c8b1fa6fdf8 100644 --- a/napi/oxlint/test/__snapshots__/e2e.test.ts.snap +++ b/napi/oxlint/test/__snapshots__/e2e.test.ts.snap @@ -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. diff --git a/napi/oxlint/test/e2e.test.ts b/napi/oxlint/test/e2e.test.ts index 4fdafd70e7469..9817faf98bf64 100644 --- a/napi/oxlint/test/e2e.test.ts +++ b/napi/oxlint/test/e2e.test.ts @@ -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);