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
4 changes: 4 additions & 0 deletions apps/oxlint/src/command/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ pub struct LintCommand {
#[bpaf(switch, hide_usage)]
pub type_aware: bool,

/// Enables JS plugins.
#[bpaf(switch, hide)]
pub experimental_js_plugins: bool,

#[bpaf(external)]
pub inline_config_options: InlineConfigOptions,

Expand Down
15 changes: 14 additions & 1 deletion apps/oxlint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ mod raw_fs;
#[global_allocator]
static GLOBAL: mimalloc_safe::MiMalloc = mimalloc_safe::MiMalloc;

pub fn lint(external_linter: Option<ExternalLinter>) -> CliRunResult {
/// Run the linter.
///
/// # Panics
/// Panics if `--experimental-js-plugins` CLI arg is present,
/// but this function is not called by `napi/oxlint2`.
pub fn lint(mut external_linter: Option<ExternalLinter>) -> CliRunResult {
init_tracing();
init_miette();

Expand All @@ -51,6 +56,14 @@ pub fn lint(external_linter: Option<ExternalLinter>) -> CliRunResult {
};

command.handle_threads();

if command.experimental_js_plugins {
// If this assertion fails, this function was not called by `napi/oxlint2`.
assert!(external_linter.is_some(), "JS plugins are not supported at present");
} else {
external_linter = None;
}

// stdio is blocked by LineWriter, use a BufWriter to reduce syscalls.
// See `https://github.com/rust-lang/rust/issues/60673`.
let mut stdout = BufWriter::new(std::io::stdout());
Expand Down
2 changes: 1 addition & 1 deletion napi/oxlint2/test/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const PACKAGE_ROOT_PATH = path.dirname(import.meta.dirname);
const ENTRY_POINT_PATH = path.join(PACKAGE_ROOT_PATH, 'dist/index.js');

async function runOxlint(cwd: string, args: string[] = []) {
return await execa('node', [ENTRY_POINT_PATH, ...args], {
return await execa('node', [ENTRY_POINT_PATH, '--experimental-js-plugins', ...args], {
cwd: path.join(PACKAGE_ROOT_PATH, cwd),
reject: false,
});
Expand Down
Loading