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
5 changes: 2 additions & 3 deletions apps/oxlint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test = false
doctest = false

[dependencies]
oxc_allocator = { workspace = true }
oxc_allocator = { workspace = true, features = ["fixed_size"] }
oxc_diagnostics = { workspace = true }
oxc_linter = { workspace = true }
oxc_span = { workspace = true }
Expand All @@ -41,7 +41,7 @@ rayon = { workspace = true }
rustc-hash = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
simdutf8 = { workspace = true, optional = true }
simdutf8 = { workspace = true }
tempfile = { workspace = true }
tracing-subscriber = { workspace = true, features = [] } # Omit the `regex` feature

Expand All @@ -61,5 +61,4 @@ lazy-regex = { workspace = true }
[features]
default = []
allocator = ["dep:mimalloc-safe"]
oxlint2 = ["oxc_linter/oxlint2", "oxc_allocator/fixed_size", "dep:simdutf8"]
force_test_reporter = ["oxc_linter/force_test_reporter"]
4 changes: 1 addition & 3 deletions apps/oxlint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub use oxc_linter::{
mod command;
mod lint;
mod output_formatter;
mod raw_fs;
mod result;
mod tester;
mod walk;
Expand All @@ -18,9 +19,6 @@ pub mod cli {

use cli::{CliRunResult, LintRunner};

#[cfg(feature = "oxlint2")]
mod raw_fs;

#[cfg(all(feature = "allocator", not(miri), not(target_family = "wasm")))]
#[global_allocator]
static GLOBAL: mimalloc_safe::MiMalloc = mimalloc_safe::MiMalloc;
Expand Down
4 changes: 1 addition & 3 deletions apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,13 @@ impl LintRunner {

// Spawn linting in another thread so diagnostics can be printed immediately from diagnostic_service.run.
rayon::spawn(move || {
#[cfg(feature = "oxlint2")]
let has_external_linter = linter.has_external_linter();

let mut lint_service = LintService::new(linter, options);
lint_service.with_paths(files_to_lint);

// Use `RawTransferFileSystem` if `oxlint2` feature is enabled and `ExternalLinter` exists.
// Use `RawTransferFileSystem` if `ExternalLinter` exists.
// This reads the source text into start of allocator, instead of the end.
#[cfg(feature = "oxlint2")]
if has_external_linter {
use crate::raw_fs::RawTransferFileSystem;
lint_service.with_file_system(Box::new(RawTransferFileSystem));
Expand Down
7 changes: 3 additions & 4 deletions crates/oxc_linter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ description.workspace = true
default = []
ruledocs = ["oxc_macros/ruledocs"] # Enables the `ruledocs` feature for conditional compilation
language_server = ["oxc_data_structures/rope"] # For the Runtime to support needed information for the language server
oxlint2 = ["dep:oxc_ast_macros", "oxc_allocator/fixed_size", "oxc_ast_visit/serialize"]
force_test_reporter = []

[lints]
Expand All @@ -27,10 +26,10 @@ workspace = true
doctest = true

[dependencies]
oxc_allocator = { workspace = true, features = ["pool"] }
oxc_allocator = { workspace = true, features = ["fixed_size"] }
oxc_ast = { workspace = true }
oxc_ast_macros = { workspace = true, optional = true }
oxc_ast_visit = { workspace = true }
oxc_ast_macros = { workspace = true }
oxc_ast_visit = { workspace = true, features = ["serialize"] }
oxc_cfg = { workspace = true }
oxc_codegen = { workspace = true }
oxc_data_structures = { workspace = true, features = ["box_macros"] }
Expand Down
13 changes: 0 additions & 13 deletions crates/oxc_linter/src/config/config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,19 +494,6 @@ impl ConfigStoreBuilder {
serde_json::to_string_pretty(&oxlintrc).unwrap()
}

#[cfg(not(feature = "oxlint2"))]
#[expect(unused_variables, clippy::needless_pass_by_ref_mut)]
fn load_external_plugin(
oxlintrc_dir_path: &Path,
plugin_specifier: &str,
external_linter: &ExternalLinter,
resolver: &Resolver,
external_plugin_store: &mut ExternalPluginStore,
) -> Result<(), ConfigBuilderError> {
unreachable!()
}

#[cfg(feature = "oxlint2")]
fn load_external_plugin(
oxlintrc_dir_path: &Path,
plugin_specifier: &str,
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_linter/src/config/config_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ impl ConfigStore {
None
}

#[cfg_attr(not(feature = "oxlint2"), expect(dead_code))]
pub(crate) fn resolve_plugin_rule_names(
&self,
external_rule_id: ExternalRuleId,
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_linter/src/external_linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub struct Loc {
}

#[derive(Clone)]
#[cfg_attr(not(feature = "oxlint2"), expect(dead_code))]
pub struct ExternalLinter {
pub(crate) load_plugin: ExternalLinterLoadPluginCb,
pub(crate) lint_file: ExternalLinterLintFileCb,
Expand Down
20 changes: 4 additions & 16 deletions crates/oxc_linter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ use std::{path::Path, rc::Rc};

use oxc_allocator::Allocator;
use oxc_ast::ast_kind::AST_TYPE_MAX;
use oxc_data_structures::box_macros::boxed_array;
use oxc_semantic::AstNode;

#[cfg(feature = "oxlint2")]
use oxc_ast_macros::ast;
#[cfg(feature = "oxlint2")]
use oxc_ast_visit::utf8_to_utf16::Utf8ToUtf16;
use oxc_data_structures::box_macros::boxed_array;
use oxc_semantic::AstNode;

#[cfg(test)]
mod tester;
Expand Down Expand Up @@ -40,7 +37,7 @@ pub mod rules;
pub mod table;

mod generated {
#[cfg(all(feature = "oxlint2", debug_assertions))]
#[cfg(debug_assertions)]
mod assert_layouts;
mod rule_runner_impls;
}
Expand Down Expand Up @@ -255,13 +252,8 @@ impl Linter {
}
}

#[cfg(feature = "oxlint2")]
self.run_external_rules(&external_rules, path, &mut ctx_host, allocator);

// Stop clippy complaining about unused vars
#[cfg(not(feature = "oxlint2"))]
let (_, _, _) = (&external_rules, &mut ctx_host, allocator);

if let Some(severity) = self.options.report_unused_directive {
if severity.is_warn_deny() {
ctx_host.report_unused_directives(severity.into());
Expand All @@ -277,7 +269,6 @@ impl Linter {
ctx_host.take_diagnostics()
}

#[cfg(feature = "oxlint2")]
fn run_external_rules<'a>(
&self,
external_rules: &[(ExternalRuleId, AllowWarnDeny)],
Expand All @@ -300,7 +291,7 @@ impl Linter {
return;
}

// `external_linter` always exists when `oxlint2` feature is enabled
// `external_linter` always exists when `external_rules` is not empty
let external_linter = self.external_linter.as_ref().unwrap();

let (program_offset, span_converter) = {
Expand Down Expand Up @@ -395,7 +386,6 @@ impl Linter {
}
}

#[cfg(feature = "oxlint2")]
/// Metadata written to end of buffer.
///
/// Duplicate of `RawTransferMetadata` in `napi/parser/src/raw_transfer_types.rs`.
Expand All @@ -413,10 +403,8 @@ struct RawTransferMetadata2 {
pub(crate) _padding: u64,
}

#[cfg(feature = "oxlint2")]
use RawTransferMetadata2 as RawTransferMetadata;

#[cfg(feature = "oxlint2")]
impl RawTransferMetadata {
pub fn new(data_offset: u32) -> Self {
Self { data_offset, is_ts: false, _padding: 0 }
Expand Down
9 changes: 1 addition & 8 deletions crates/oxc_linter/src/service/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,7 @@ impl Runtime {
// If an external linter is used (JS plugins), we must use fixed-size allocators,
// for compatibility with raw transfer
let allocator_pool = if linter.has_external_linter() {
#[cfg(feature = "oxlint2")]
{
AllocatorPool::new_fixed_size(thread_count)
}
#[cfg(not(feature = "oxlint2"))]
{
panic!("`oxlint2` feature must be enabled when using external linters");
}
AllocatorPool::new_fixed_size(thread_count)
} else {
AllocatorPool::new(thread_count)
};
Expand Down
2 changes: 1 addition & 1 deletion napi/oxlint2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ doctest = false

[dependencies]
oxc_allocator = { workspace = true, features = ["fixed_size"] }
oxlint = { workspace = true, features = ["oxlint2", "allocator"] }
oxlint = { workspace = true, features = ["allocator"] }

napi = { workspace = true, features = ["async"] }
napi-derive = { workspace = true }
Expand Down
Loading