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
2 changes: 2 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
avoid-breaking-exported-api = false

ignore-interior-mutability = ["oxc_linter::rules::RuleEnum"]

disallowed-methods = [
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/miri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,5 @@ jobs:

- name: Test with Miri
run: |
cargo miri test -p oxc_ast --all-features
cargo miri test -p oxc_data_structures --all-features
cargo miri test -p oxc_parser
cargo miri test -p oxc_transformer
cargo miri test --doc --all-features -p oxc_ast -p oxc_data_structures
cargo miri test -p oxc_parser -p oxc_transformer
31 changes: 3 additions & 28 deletions apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,7 @@ impl Runner for LintRunner {
let mut options =
LintServiceOptions::new(self.cwd, paths).with_cross_module(use_cross_module);

let lint_config = match config_builder.build() {
Ok(config) => config,
Err(diagnostic) => {
print_and_flush_stdout(
stdout,
&format!(
"Failed to parse configuration file.\n{}\n",
render_report(&handler, &diagnostic)
),
);

return CliRunResult::InvalidOptionConfig;
}
};
let lint_config = config_builder.build();

let report_unused_directives = match inline_config_options.report_unused_directives {
ReportUnusedDirectives::WithoutSeverity(true) => Some(AllowWarnDeny::Warn),
Expand Down Expand Up @@ -439,20 +426,8 @@ impl LintRunner {
}
.with_filters(filters);

match builder.build() {
Ok(config) => nested_configs.insert(dir.to_path_buf(), config),
Err(diagnostic) => {
print_and_flush_stdout(
stdout,
&format!(
"Failed to parse configuration file.\n{}\n",
render_report(handler, &diagnostic)
),
);

return Err(CliRunResult::InvalidOptionConfig);
}
};
let config = builder.build();
nested_configs.insert(dir.to_path_buf(), config);
}

Ok(nested_configs)
Expand Down
6 changes: 5 additions & 1 deletion crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#![expect(missing_docs)] // FIXME
#![expect(
missing_docs, // FIXME
clippy::enum_variant_names,
clippy::struct_field_names,
)]

// NB: `#[span]`, `#[scope(...)]`,`#[visit(...)]` and `#[generate_derive(...)]` do NOT do anything to the code.
// They are purely markers for codegen used in `tasks/ast_tools` and `crates/oxc_traverse/scripts`. See docs in those crates.
Expand Down
5 changes: 4 additions & 1 deletion crates/oxc_ast/src/ast/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
//!
//! - [AST Spec](https://github.com/typescript-eslint/typescript-eslint/tree/v8.9.0/packages/ast-spec)
//! - [Archived TypeScript spec](https://github.com/microsoft/TypeScript/blob/3c99d50da5a579d9fa92d02664b1b66d4ff55944/doc/spec-ARCHIVED.md)
#![expect(missing_docs)] // FIXME
#![expect(
missing_docs, // FIXME
clippy::enum_variant_names,
)]

// NB: `#[span]`, `#[scope(...)]`,`#[visit(...)]` and `#[generate_derive(...)]` do NOT do anything to the code.
// They are purely markers for codegen used in `tasks/ast_tools` and `crates/oxc_traverse/scripts`. See docs in those crates.
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_ast/src/ast_builder_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{AstBuilder, ast::*};

/// Type that can be used in any AST builder method call which requires an `IntoIn<'a, Anything<'a>>`.
/// Pass `NONE` instead of `None::<Anything<'a>>`.
#[expect(clippy::upper_case_acronyms)]
pub struct NONE;

impl<'a, T> FromIn<'a, NONE> for Option<Box<'a, T>> {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ impl<'a> Function<'a> {

impl FunctionType {
/// Returns `true` if it is a [`FunctionType::TSDeclareFunction`] or [`FunctionType::TSEmptyBodyFunctionExpression`].
pub fn is_typescript_syntax(&self) -> bool {
pub fn is_typescript_syntax(self) -> bool {
matches!(self, Self::TSDeclareFunction | Self::TSEmptyBodyFunctionExpression)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast_impl/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl RegExpFlags {
/// Convert [`RegExpFlags`] to an [`InlineString`].
///
/// This performs the same role as `RegExpFlags::to_string`, but does not allocate.
pub fn to_inline_string(&self) -> InlineString<8, usize> {
pub fn to_inline_string(self) -> InlineString<8, usize> {
let mut str = InlineString::new();

// In alphabetical order.
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_ast/src/ast_impl/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl TSModuleDeclarationKind {

/// Declaration keyword as a string, identical to how it would appear in the
/// source code.
pub fn as_str(&self) -> &'static str {
pub fn as_str(self) -> &'static str {
match self {
Self::Global => "global",
Self::Module => "module",
Expand Down Expand Up @@ -295,12 +295,12 @@ impl<'a> Decorator<'a> {

impl ImportOrExportKind {
/// Returns `true` for "regular" imports and exports.
pub fn is_value(&self) -> bool {
pub fn is_value(self) -> bool {
matches!(self, Self::Value)
}

/// Returns `true` if this is an `import type` or `export type` statement.
pub fn is_type(&self) -> bool {
pub fn is_type(self) -> bool {
matches!(self, Self::Type)
}
}
Expand Down
6 changes: 5 additions & 1 deletion crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

//! AST node factories

#![expect(clippy::default_trait_access, clippy::inconsistent_struct_constructor)]
#![expect(
clippy::default_trait_access,
clippy::inconsistent_struct_constructor,
clippy::unused_self
)]

use std::cell::Cell;

Expand Down
3 changes: 2 additions & 1 deletion crates/oxc_ast_visit/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//! * [visitor pattern](https://rust-unofficial.github.io/patterns/patterns/behavioural/visitor.html)
//! * [rustc visitor](https://github.com/rust-lang/rust/blob/1.82.0/compiler/rustc_ast/src/visit.rs)

#![expect(unused_variables, clippy::semicolon_if_nothing_returned, clippy::match_same_arms)]
#![expect(unused_variables, clippy::match_same_arms, clippy::semicolon_if_nothing_returned)]
#![allow(clippy::needless_pass_by_ref_mut, clippy::trivially_copy_pass_by_ref)]

use std::cell::Cell;

Expand Down
3 changes: 2 additions & 1 deletion crates/oxc_ast_visit/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//! * [visitor pattern](https://rust-unofficial.github.io/patterns/patterns/behavioural/visitor.html)
//! * [rustc visitor](https://github.com/rust-lang/rust/blob/1.82.0/compiler/rustc_ast/src/visit.rs)

#![expect(unused_variables, clippy::semicolon_if_nothing_returned, clippy::match_same_arms)]
#![expect(unused_variables, clippy::match_same_arms, clippy::semicolon_if_nothing_returned)]
#![allow(clippy::needless_pass_by_ref_mut, clippy::trivially_copy_pass_by_ref)]

use std::cell::Cell;

Expand Down
1 change: 1 addition & 0 deletions crates/oxc_data_structures/src/stack/non_empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ impl<T> NonEmptyStack<T> {
}

/// Get if stack is empty. Always returns `false`.
#[expect(clippy::unused_self)]
#[inline]
pub fn is_empty(&self) -> bool {
// This method is pointless, as the stack is never empty. But provide it to override
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_formatter/src/formatter/token/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ pub enum Quote {
}

impl Quote {
pub fn as_char(&self) -> char {
pub fn as_char(self) -> char {
match self {
Quote::Double => '"',
Quote::Single => '\'',
}
}

pub fn as_byte(&self) -> u8 {
pub fn as_byte(self) -> u8 {
self.as_char() as u8
}

/// Given the current quote, it returns the other one
#[must_use]
pub fn other(&self) -> Self {
pub fn other(self) -> Self {
match self {
Quote::Double => Quote::Single,
Quote::Single => Quote::Double,
Expand Down
44 changes: 22 additions & 22 deletions crates/oxc_formatter/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ impl IndentStyle {
pub const DEFAULT_SPACES: u8 = 2;

/// Returns `true` if this is an [IndentStyle::Tab].
pub const fn is_tab(&self) -> bool {
pub const fn is_tab(self) -> bool {
matches!(self, IndentStyle::Tab)
}

/// Returns `true` if this is an [IndentStyle::Space].
pub const fn is_space(&self) -> bool {
pub const fn is_space(self) -> bool {
matches!(self, IndentStyle::Space)
}
}
Expand Down Expand Up @@ -163,7 +163,7 @@ pub enum LineEnding {

impl LineEnding {
#[inline]
pub const fn as_str(&self) -> &'static str {
pub const fn as_str(self) -> &'static str {
match self {
LineEnding::Lf => "\n",
LineEnding::Crlf => "\r\n",
Expand All @@ -172,17 +172,17 @@ impl LineEnding {
}

/// Returns `true` if this is a [LineEnding::Lf].
pub const fn is_line_feed(&self) -> bool {
pub const fn is_line_feed(self) -> bool {
matches!(self, LineEnding::Lf)
}

/// Returns `true` if this is a [LineEnding::Crlf].
pub const fn is_carriage_return_line_feed(&self) -> bool {
pub const fn is_carriage_return_line_feed(self) -> bool {
matches!(self, LineEnding::Crlf)
}

/// Returns `true` if this is a [LineEnding::Cr].
pub const fn is_carriage_return(&self) -> bool {
pub const fn is_carriage_return(self) -> bool {
matches!(self, LineEnding::Cr)
}
}
Expand Down Expand Up @@ -219,7 +219,7 @@ impl IndentWidth {
pub const MIN: u8 = 0;

/// Return the numeric value for this [IndentWidth]
pub fn value(&self) -> u8 {
pub fn value(self) -> u8 {
self.0
}
}
Expand Down Expand Up @@ -278,7 +278,7 @@ impl LineWidth {
pub const MIN: u16 = 1;

/// Return the numeric value for this [LineWidth]
pub fn value(&self) -> u16 {
pub fn value(self) -> u16 {
self.0
}
}
Expand Down Expand Up @@ -410,14 +410,14 @@ impl QuoteStyle {
}
}

pub fn as_char(&self) -> char {
pub fn as_char(self) -> char {
match self {
QuoteStyle::Double => '"',
QuoteStyle::Single => '\'',
}
}

pub fn as_byte(&self) -> u8 {
pub fn as_byte(self) -> u8 {
self.as_char() as u8
}

Expand All @@ -431,14 +431,14 @@ impl QuoteStyle {

/// Given the current quote, it returns the other one
#[must_use]
pub fn other(&self) -> Self {
pub fn other(self) -> Self {
match self {
QuoteStyle::Double => QuoteStyle::Single,
QuoteStyle::Single => QuoteStyle::Double,
}
}

pub const fn is_double(&self) -> bool {
pub const fn is_double(self) -> bool {
matches!(self, Self::Double)
}
}
Expand Down Expand Up @@ -527,11 +527,11 @@ pub enum Semicolons {
}

impl Semicolons {
pub const fn is_as_needed(&self) -> bool {
pub const fn is_as_needed(self) -> bool {
matches!(self, Self::AsNeeded)
}

pub const fn is_always(&self) -> bool {
pub const fn is_always(self) -> bool {
matches!(self, Self::Always)
}
}
Expand Down Expand Up @@ -568,11 +568,11 @@ pub enum ArrowParentheses {
}

impl ArrowParentheses {
pub const fn is_as_needed(&self) -> bool {
pub const fn is_as_needed(self) -> bool {
matches!(self, Self::AsNeeded)
}

pub const fn is_always(&self) -> bool {
pub const fn is_always(self) -> bool {
matches!(self, Self::Always)
}
}
Expand Down Expand Up @@ -629,7 +629,7 @@ pub enum TrailingSeparator {

impl FormatTrailingCommas {
/// This function returns corresponding [TrailingSeparator] for `format_separated` function.
pub fn trailing_separator(&self, options: &FormatOptions) -> TrailingSeparator {
pub fn trailing_separator(self, options: &FormatOptions) -> TrailingSeparator {
if options.trailing_commas.is_none() {
return TrailingSeparator::Omit;
}
Expand Down Expand Up @@ -674,15 +674,15 @@ pub enum TrailingCommas {
}

impl TrailingCommas {
pub const fn is_es5(&self) -> bool {
pub const fn is_es5(self) -> bool {
matches!(self, TrailingCommas::Es5)
}

pub const fn is_all(&self) -> bool {
pub const fn is_all(self) -> bool {
matches!(self, TrailingCommas::All)
}

pub const fn is_none(&self) -> bool {
pub const fn is_none(self) -> bool {
matches!(self, TrailingCommas::None)
}
}
Expand Down Expand Up @@ -748,7 +748,7 @@ pub struct BracketSpacing(bool);

impl BracketSpacing {
/// Return the boolean value for this [BracketSpacing]
pub fn value(&self) -> bool {
pub fn value(self) -> bool {
self.0
}
}
Expand Down Expand Up @@ -792,7 +792,7 @@ pub struct BracketSameLine(bool);

impl BracketSameLine {
/// Return the boolean value for this [BracketSameLine]
pub fn value(&self) -> bool {
pub fn value(self) -> bool {
self.0
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_isolated_declarations/src/declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<'a> IsolatedDeclarations<'a> {
}
Declaration::TSEnumDeclaration(enum_decl) => {
if !check_binding || self.scope.has_reference(&enum_decl.id.name) {
self.transform_ts_enum_declaration(enum_decl)
Some(self.transform_ts_enum_declaration(enum_decl))
} else {
None
}
Expand Down
Loading
Loading