Skip to content

Commit 7775c21

Browse files
committed
refactor(linter/plugins): remove oxlint2 Cargo feature (#13648)
Remove `oxlint2` Cargo feature from `oxlint` and `oxc_linter` crates. Now that enabling `fixed_size` Cargo feature of `oxc_allocator` doesn't change behavior, we don't need the feature gate. The incompatibility of `tokio` with WASM has been resolved by #13647.
1 parent 08cbd39 commit 7775c21

File tree

10 files changed

+13
-53
lines changed

10 files changed

+13
-53
lines changed

apps/oxlint/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test = false
2727
doctest = false
2828

2929
[dependencies]
30-
oxc_allocator = { workspace = true }
30+
oxc_allocator = { workspace = true, features = ["fixed_size"] }
3131
oxc_diagnostics = { workspace = true }
3232
oxc_linter = { workspace = true }
3333
oxc_span = { workspace = true }
@@ -41,7 +41,7 @@ rayon = { workspace = true }
4141
rustc-hash = { workspace = true }
4242
serde = { workspace = true }
4343
serde_json = { workspace = true }
44-
simdutf8 = { workspace = true, optional = true }
44+
simdutf8 = { workspace = true }
4545
tempfile = { workspace = true }
4646
tracing-subscriber = { workspace = true, features = [] } # Omit the `regex` feature
4747

@@ -61,5 +61,4 @@ lazy-regex = { workspace = true }
6161
[features]
6262
default = []
6363
allocator = ["dep:mimalloc-safe"]
64-
oxlint2 = ["oxc_linter/oxlint2", "oxc_allocator/fixed_size", "dep:simdutf8"]
6564
force_test_reporter = ["oxc_linter/force_test_reporter"]

apps/oxlint/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub use oxc_linter::{
88
mod command;
99
mod lint;
1010
mod output_formatter;
11+
mod raw_fs;
1112
mod result;
1213
mod tester;
1314
mod walk;
@@ -18,9 +19,6 @@ pub mod cli {
1819

1920
use cli::{CliRunResult, LintRunner};
2021

21-
#[cfg(feature = "oxlint2")]
22-
mod raw_fs;
23-
2422
#[cfg(all(feature = "allocator", not(miri), not(target_family = "wasm")))]
2523
#[global_allocator]
2624
static GLOBAL: mimalloc_safe::MiMalloc = mimalloc_safe::MiMalloc;

apps/oxlint/src/lint.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,13 @@ impl LintRunner {
359359

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

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

368-
// Use `RawTransferFileSystem` if `oxlint2` feature is enabled and `ExternalLinter` exists.
367+
// Use `RawTransferFileSystem` if `ExternalLinter` exists.
369368
// This reads the source text into start of allocator, instead of the end.
370-
#[cfg(feature = "oxlint2")]
371369
if has_external_linter {
372370
use crate::raw_fs::RawTransferFileSystem;
373371
lint_service.with_file_system(Box::new(RawTransferFileSystem));

crates/oxc_linter/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ description.workspace = true
1717
default = []
1818
ruledocs = ["oxc_macros/ruledocs"] # Enables the `ruledocs` feature for conditional compilation
1919
language_server = ["oxc_data_structures/rope"] # For the Runtime to support needed information for the language server
20-
oxlint2 = ["dep:oxc_ast_macros", "oxc_allocator/fixed_size", "oxc_ast_visit/serialize"]
2120
force_test_reporter = []
2221

2322
[lints]
@@ -27,10 +26,10 @@ workspace = true
2726
doctest = true
2827

2928
[dependencies]
30-
oxc_allocator = { workspace = true, features = ["pool"] }
29+
oxc_allocator = { workspace = true, features = ["fixed_size"] }
3130
oxc_ast = { workspace = true }
32-
oxc_ast_macros = { workspace = true, optional = true }
33-
oxc_ast_visit = { workspace = true }
31+
oxc_ast_macros = { workspace = true }
32+
oxc_ast_visit = { workspace = true, features = ["serialize"] }
3433
oxc_cfg = { workspace = true }
3534
oxc_codegen = { workspace = true }
3635
oxc_data_structures = { workspace = true, features = ["box_macros"] }

crates/oxc_linter/src/config/config_builder.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -494,19 +494,6 @@ impl ConfigStoreBuilder {
494494
serde_json::to_string_pretty(&oxlintrc).unwrap()
495495
}
496496

497-
#[cfg(not(feature = "oxlint2"))]
498-
#[expect(unused_variables, clippy::needless_pass_by_ref_mut)]
499-
fn load_external_plugin(
500-
oxlintrc_dir_path: &Path,
501-
plugin_specifier: &str,
502-
external_linter: &ExternalLinter,
503-
resolver: &Resolver,
504-
external_plugin_store: &mut ExternalPluginStore,
505-
) -> Result<(), ConfigBuilderError> {
506-
unreachable!()
507-
}
508-
509-
#[cfg(feature = "oxlint2")]
510497
fn load_external_plugin(
511498
oxlintrc_dir_path: &Path,
512499
plugin_specifier: &str,

crates/oxc_linter/src/config/config_store.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ impl ConfigStore {
343343
None
344344
}
345345

346-
#[cfg_attr(not(feature = "oxlint2"), expect(dead_code))]
347346
pub(crate) fn resolve_plugin_rule_names(
348347
&self,
349348
external_rule_id: ExternalRuleId,

crates/oxc_linter/src/external_linter.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pub struct Loc {
3939
}
4040

4141
#[derive(Clone)]
42-
#[cfg_attr(not(feature = "oxlint2"), expect(dead_code))]
4342
pub struct ExternalLinter {
4443
pub(crate) load_plugin: ExternalLinterLoadPluginCb,
4544
pub(crate) lint_file: ExternalLinterLintFileCb,

crates/oxc_linter/src/lib.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ use std::{path::Path, rc::Rc};
55

66
use oxc_allocator::Allocator;
77
use oxc_ast::ast_kind::AST_TYPE_MAX;
8-
use oxc_data_structures::box_macros::boxed_array;
9-
use oxc_semantic::AstNode;
10-
11-
#[cfg(feature = "oxlint2")]
128
use oxc_ast_macros::ast;
13-
#[cfg(feature = "oxlint2")]
149
use oxc_ast_visit::utf8_to_utf16::Utf8ToUtf16;
10+
use oxc_data_structures::box_macros::boxed_array;
11+
use oxc_semantic::AstNode;
1512

1613
#[cfg(test)]
1714
mod tester;
@@ -40,7 +37,7 @@ pub mod rules;
4037
pub mod table;
4138

4239
mod generated {
43-
#[cfg(all(feature = "oxlint2", debug_assertions))]
40+
#[cfg(debug_assertions)]
4441
mod assert_layouts;
4542
mod rule_runner_impls;
4643
}
@@ -255,13 +252,8 @@ impl Linter {
255252
}
256253
}
257254

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

261-
// Stop clippy complaining about unused vars
262-
#[cfg(not(feature = "oxlint2"))]
263-
let (_, _, _) = (&external_rules, &mut ctx_host, allocator);
264-
265257
if let Some(severity) = self.options.report_unused_directive {
266258
if severity.is_warn_deny() {
267259
ctx_host.report_unused_directives(severity.into());
@@ -277,7 +269,6 @@ impl Linter {
277269
ctx_host.take_diagnostics()
278270
}
279271

280-
#[cfg(feature = "oxlint2")]
281272
fn run_external_rules<'a>(
282273
&self,
283274
external_rules: &[(ExternalRuleId, AllowWarnDeny)],
@@ -300,7 +291,7 @@ impl Linter {
300291
return;
301292
}
302293

303-
// `external_linter` always exists when `oxlint2` feature is enabled
294+
// `external_linter` always exists when `external_rules` is not empty
304295
let external_linter = self.external_linter.as_ref().unwrap();
305296

306297
let (program_offset, span_converter) = {
@@ -395,7 +386,6 @@ impl Linter {
395386
}
396387
}
397388

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

416-
#[cfg(feature = "oxlint2")]
417406
use RawTransferMetadata2 as RawTransferMetadata;
418407

419-
#[cfg(feature = "oxlint2")]
420408
impl RawTransferMetadata {
421409
pub fn new(data_offset: u32) -> Self {
422410
Self { data_offset, is_ts: false, _padding: 0 }

crates/oxc_linter/src/service/runtime.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,7 @@ impl Runtime {
269269
// If an external linter is used (JS plugins), we must use fixed-size allocators,
270270
// for compatibility with raw transfer
271271
let allocator_pool = if linter.has_external_linter() {
272-
#[cfg(feature = "oxlint2")]
273-
{
274-
AllocatorPool::new_fixed_size(thread_count)
275-
}
276-
#[cfg(not(feature = "oxlint2"))]
277-
{
278-
panic!("`oxlint2` feature must be enabled when using external linters");
279-
}
272+
AllocatorPool::new_fixed_size(thread_count)
280273
} else {
281274
AllocatorPool::new(thread_count)
282275
};

napi/oxlint2/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ doctest = false
2323

2424
[dependencies]
2525
oxc_allocator = { workspace = true, features = ["fixed_size"] }
26-
oxlint = { workspace = true, features = ["oxlint2", "allocator"] }
26+
oxlint = { workspace = true, features = ["allocator"] }
2727

2828
napi = { workspace = true, features = ["async"] }
2929
napi-derive = { workspace = true }

0 commit comments

Comments
 (0)