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: 2 additions & 2 deletions apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Runner for LintRunner {
}) {
stdout.write_all(end.as_bytes()).or_else(Self::check_for_writer_error).unwrap();
stdout.flush().unwrap();
};
}

return CliRunResult::LintNoFilesFound;
}
Expand Down Expand Up @@ -391,7 +391,7 @@ impl Runner for LintRunner {
}) {
stdout.write_all(end.as_bytes()).or_else(Self::check_for_writer_error).unwrap();
stdout.flush().unwrap();
};
}

if diagnostic_result.errors_count() > 0 {
CliRunResult::LintFoundErrors
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 @@ -89,7 +89,7 @@ impl StringLiteral<'_> {
if (0xd800..=0xdfff).contains(&hex) {
return false;
}
};
}
}
}
true
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_cfg/src/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl DisplayDot for ControlFlowGraph {
attrs += ("style", "dotted");
} else if matches!(weight, EdgeType::Error(_)) {
attrs += ("color", "red");
};
}

format!("{attrs:?}")
},
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ impl Gen for ImportAttribute<'_> {
ImportAttributeKey::StringLiteral(literal) => {
p.print_string_literal(literal, false);
}
};
}
p.print_colon();
p.print_soft_space();
p.print_string_literal(&self.value, false);
Expand Down Expand Up @@ -1105,7 +1105,7 @@ impl Gen for ModuleExportName<'_> {
Self::IdentifierName(ident) => ident.print(p, ctx),
Self::IdentifierReference(ident) => ident.print(p, ctx),
Self::StringLiteral(literal) => p.print_string_literal(literal, false),
};
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_codegen/src/sourcemap_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl SourcemapBuilder {

break 'lines;
}
};
}

// Line break found.
// `byte_offset_from_line_start` is now the length of line *including* line break.
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_diagnostics/src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Info {

if let Some(name) = span_content.name() {
filename = name.to_string();
};
}
if matches!(diagnostic.severity(), Some(Severity::Error)) {
severity = Severity::Error;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_formatter/src/formatter/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ fn clean_interned(
most_flat.iter().rev().for_each(|element| element_stack.push(element));
}
element => cleaned.push(element.clone()),
};
}
}

Interned::new(cleaned)
Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_formatter/src/formatter/printer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<'a> Printer<'a> {
match mode {
DedentMode::Level => indent_stack.start_dedent(),
DedentMode::Root => indent_stack.reset_indent(),
};
}
stack.push(TagKind::Dedent, args);
}

Expand Down Expand Up @@ -281,10 +281,10 @@ impl<'a> Printer<'a> {
match mode {
DedentMode::Level => indent_stack.end_dedent(),
DedentMode::Root => indent_stack.pop(),
};
}
stack.pop(tag.kind())?;
}
};
}

Ok(())
}
Expand Down Expand Up @@ -1102,7 +1102,7 @@ impl<'a, 'print> FitsMeasurer<'a, 'print> {
match mode {
DedentMode::Level => self.indent_stack.start_dedent(),
DedentMode::Root => self.indent_stack.reset_indent(),
};
}
self.stack.push(TagKind::Dedent, args);
}

Expand Down
38 changes: 18 additions & 20 deletions crates/oxc_formatter/src/formatter/trivia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,24 @@ impl Format<'_> for FormatLeadingComments<'_> {
write!(f, [comment])?;

match comment.kind() {
CommentKind::Block | CommentKind::InlineBlock => {
match comment.lines_after() {
0 => {
let should_nestle =
leading_comments_iter.peek().is_some_and(|next_comment| {
should_nestle_adjacent_doc_comments(comment, next_comment)
});

write!(f, [maybe_space(!should_nestle)])?;
CommentKind::Block | CommentKind::InlineBlock => match comment.lines_after() {
0 => {
let should_nestle =
leading_comments_iter.peek().is_some_and(|next_comment| {
should_nestle_adjacent_doc_comments(comment, next_comment)
});

write!(f, [maybe_space(!should_nestle)])?;
}
1 => {
if comment.lines_before() == 0 {
write!(f, [soft_line_break_or_space()])?;
} else {
write!(f, [hard_line_break()])?;
}
1 => {
if comment.lines_before() == 0 {
write!(f, [soft_line_break_or_space()])?;
} else {
write!(f, [hard_line_break()])?;
}
}
_ => write!(f, [empty_line()])?,
};
}
}
_ => write!(f, [empty_line()])?,
},
CommentKind::Line => match comment.lines_after() {
0 | 1 => write!(f, [hard_line_break()])?,
_ => write!(f, [empty_line()])?,
Expand Down Expand Up @@ -165,7 +163,7 @@ impl Format<'_> for FormatTrailingComments<'_> {
}
1 => write!(f, [hard_line_break()])?,
_ => write!(f, [empty_line()])?,
};
}

write!(f, [comment])
})),
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_isolated_declarations/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl<'a> IsolatedDeclarations<'a> {
}
}
_ => continue,
};
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_isolated_declarations/src/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'a> IsolatedDeclarations<'a> {
entry.0 |= method.return_type.is_none();
entry.2 = Some(&mut method.return_type);
}
};
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl IsolatedLintHandler {
})
.collect();
return Some(Self::wrap_diagnostics(path, &source_text, reports, start));
};
}

let semantic_ret = SemanticBuilder::new()
.with_cfg(true)
Expand All @@ -151,7 +151,7 @@ impl IsolatedLintHandler {
})
.collect();
return Some(Self::wrap_diagnostics(path, &source_text, reports, start));
};
}

let mut semantic = semantic_ret.semantic;
semantic.set_irregular_whitespaces(ret.irregular_whitespaces);
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_minifier/src/peephole/fold_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'a> PeepholeOptimizations {
} {
*expr = folded_expr;
state.changed = true;
};
}
}

#[expect(clippy::float_cmp)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_minifier/src/peephole/minimize_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'a> PeepholeOptimizations {
} {
*expr = folded_expr;
local_change = true;
};
}
if local_change {
changed = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_minifier/src/peephole/minimize_for_statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<'a> PeepholeOptimizations {
} else {
return;
}
};
}

let Statement::IfStatement(if_stmt) = first else {
return;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_minifier/src/peephole/minimize_statements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<'a> PeepholeOptimizations {
.is_break()
{
break;
};
}
}
if let Some(stmt) = keep_var.get_variable_declaration_statement() {
result.push(stmt);
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_minifier/src/peephole/remove_dead_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl<'a, 'b> PeepholeOptimizations {
}
} else {
keep_var.visit_statement(&if_stmt.consequent);
};
}
let var_stmt = keep_var.get_variable_declaration_statement();
let has_var_stmt = var_stmt.is_some();
if let Some(var_stmt) = var_stmt {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_minifier/src/peephole/replace_known_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl<'a> PeepholeOptimizations {
if start > end {
return None;
}
};
}
Some(ctx.ast.expression_string_literal(
span,
s.value.as_str().substring(start_idx, end_idx),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ impl<'a> PeepholeOptimizations {
*computed = false;
}
return;
};
}
let PropertyKey::StringLiteral(s) = key else { return };
let value = s.value.as_str();
if is_identifier_name(value) {
Expand Down Expand Up @@ -1177,7 +1177,7 @@ impl<'a> LatePeepholeOptimizations {
{
catch.param = None;
}
};
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_parser/src/js/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl<'a> ParserImpl<'a> {
} else if self.at(Kind::LCurly) {
let mut import_specifiers = self.parse_import_specifiers()?;
specifiers.append(&mut import_specifiers);
};
}

self.expect(Kind::From)?;
Ok(specifiers)
Expand Down Expand Up @@ -505,7 +505,7 @@ impl<'a> ParserImpl<'a> {
// It is a Syntax Error if IsStringWellFormedUnicode(the SV of StringLiteral) is false.
if literal.lone_surrogates || !literal.is_string_well_formed_unicode() {
self.error(diagnostics::export_lone_surrogate(literal.span));
};
}
Ok(ModuleExportName::StringLiteral(literal))
}
_ => Ok(ModuleExportName::IdentifierName(self.parse_identifier_name()?)),
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ impl<'a> ParserImpl<'a> {
fn flow_error(&mut self) -> Option<OxcDiagnostic> {
if !self.source_type.is_javascript() {
return None;
};
}
let span = self.lexer.trivia_builder.comments.first()?.span;
if span.source_text(self.source_text).contains("@flow") {
self.errors.clear();
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl<'a> Binder<'a> for Function<'a> {
PropertyKind::Get => *flags |= ScopeFlags::GetAccessor,
PropertyKind::Set => *flags |= ScopeFlags::SetAccessor,
PropertyKind::Init => {}
};
}
}

// Save `@__NO_SIDE_EFFECTS__`
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_semantic/src/checker/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ pub fn check_function_declaration<'a>(
} else if !is_if_stmt_or_labeled_stmt {
ctx.error(function_declaration_non_strict(decl.span));
}
};
}
}

// It is a Syntax Error if IsLabelledFunction(Statement) is true.
Expand Down Expand Up @@ -460,7 +460,7 @@ pub fn check_function_declaration_in_labeled_statement<'a>(
}
ctx.error(function_declaration_non_strict(decl.span));
}
};
}
}

// It is a Syntax Error if any element of the LexicallyDeclaredNames of
Expand Down Expand Up @@ -890,7 +890,7 @@ pub fn check_super<'a>(sup: &Super, node: &AstNode<'a>, ctx: &SemanticBuilder<'a
ctx.error(unexpected_super_call(super_call_span));
}
return;
};
}
}

// ModuleBody : ModuleItemList
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/checker/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ pub fn check_class<'a>(class: &Class<'a>, ctx: &SemanticBuilder<'a>) {
ctx.error(constructor_implementation_missing(a.key.span()));
} else {
ctx.error(function_implementation_missing(a.key.span()));
};
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/class/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<'a> ClassTable<'a> {
let class_id = self.declarations.push(node_id);
if let Some(parent_id) = parent_id {
self.parent_ids.insert(class_id, parent_id);
};
}
self.elements.push(IndexVec::default());
self.private_identifier_references.push(Vec::new());
class_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'a> ClassTester<'a> {

if class.id.clone().is_some_and(|id| id.name == name) {
return Some(class_id);
};
}

None
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl<'a> Traverse<'a> for ArrowFunctionConverter<'a> {
if let Some(ident) = self.get_this_identifier(this.span, ctx) {
*element_name = JSXElementName::IdentifierReference(ident);
}
};
}
}

fn enter_jsx_member_expression_object(
Expand Down Expand Up @@ -921,7 +921,7 @@ impl<'a> ArrowFunctionConverter<'a> {
param_binding.create_read_expression(ctx),
false,
));
};
}

// Create a parameter for the value if it's an assignment.
if is_assignment {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_transformer/src/decorator/legacy/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl<'a> LegacyDecoratorMetadata<'a, '_> {
return Self::global_object(ctx);
}
_ => {}
};
}

let serialized_constituent = self.serialize_type_node(t, ctx);
if matches!(&serialized_constituent, Expression::Identifier(ident) if ident.name == "Object")
Expand Down
Loading
Loading