Skip to content

Commit 034b275

Browse files
committed
refactor(formatter): remove global !clippy::unused_self (#15939)
1 parent ce269c0 commit 034b275

File tree

7 files changed

+16
-35
lines changed

7 files changed

+16
-35
lines changed

crates/oxc_formatter/src/formatter/formatter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ impl<'buf, 'ast> Formatter<'buf, 'ast> {
241241
Ok(self.intern_vec(elements))
242242
}
243243

244+
#[expect(clippy::unused_self)] // Keep `self` the same as the original source
244245
pub fn intern_vec(
245246
&mut self,
246247
mut elements: ArenaVec<'ast, FormatElement<'ast>>,

crates/oxc_formatter/src/formatter/token/number.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct NumberFormatOptions {
1717
}
1818

1919
impl NumberFormatOptions {
20-
pub fn keep_one_trailing_decimal_zero(self) -> Self {
20+
pub fn keep_one_trailing_decimal_zero() -> Self {
2121
Self { keep_one_trailing_decimal_zero: true }
2222
}
2323
}

crates/oxc_formatter/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
unused,
33
clippy::inline_always,
44
clippy::missing_panics_doc,
5-
clippy::needless_pass_by_ref_mut,
6-
clippy::unused_self
5+
clippy::needless_pass_by_ref_mut
76
)] // FIXME: all these needs to be fixed.
87

98
mod ast_nodes;

crates/oxc_formatter/src/utils/conditional.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ impl<'a> FormatConditionalLike<'a, '_> {
355355

356356
/// Checks if any part of the conditional has multiline comments
357357
#[inline]
358-
fn has_multiline_comment(&self, _f: &Formatter<'_, 'a>) -> bool {
358+
fn has_multiline_comment(_f: &Formatter<'_, 'a>) -> bool {
359359
// TODO: Implement multiline comment detection
360360
false
361361
}
@@ -518,7 +518,7 @@ impl<'a> Format<'a> for FormatConditionalLike<'a, '_> {
518518
fn fmt(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> {
519519
let layout = self.layout(f);
520520
let should_extra_indent = self.should_extra_indent(layout);
521-
let has_multiline_comment = self.has_multiline_comment(f);
521+
let has_multiline_comment = Self::has_multiline_comment(f);
522522
let is_jsx_chain = self.options.jsx_chain || layout.is_jsx_chain();
523523

524524
let format_inner = format_with(|f| {

crates/oxc_formatter/src/utils/member_chain/simple_argument.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ impl<'a, 'b> SimpleArgument<'a, 'b> {
7777
Expression::TaggedTemplateExpression(template) => {
7878
is_simple_template_literal(&template.quasi, depth + 1)
7979
}
80-
Expression::ObjectExpression(object) => self.is_simple_object(object, depth),
81-
Expression::ArrayExpression(array) => self.is_simple_array(array, depth),
80+
Expression::ObjectExpression(object) => Self::is_simple_object(object, depth),
81+
Expression::ArrayExpression(array) => Self::is_simple_array(array, depth),
8282
Expression::UnaryExpression(unary_expression) => {
8383
matches!(
8484
unary_expression.operator,
@@ -102,14 +102,14 @@ impl<'a, 'b> SimpleArgument<'a, 'b> {
102102
&& Self::from(&computed_expression.object).is_simple_impl(depth)
103103
}
104104
Expression::NewExpression(expr) => {
105-
self.is_simple_call_like(&expr.callee, &expr.arguments, depth)
105+
Self::is_simple_call_like(&expr.callee, &expr.arguments, depth)
106106
}
107107
Expression::CallExpression(expr) => {
108-
self.is_simple_call_like(&expr.callee, &expr.arguments, depth)
108+
Self::is_simple_call_like(&expr.callee, &expr.arguments, depth)
109109
}
110110
Expression::ImportExpression(expr) => depth < 2 && expr.options.is_none(),
111111
Expression::ChainExpression(chain) => {
112-
self.is_simple_chain_element(&chain.expression, depth)
112+
Self::is_simple_chain_element(&chain.expression, depth)
113113
}
114114
_ => false,
115115
},
@@ -119,7 +119,7 @@ impl<'a, 'b> SimpleArgument<'a, 'b> {
119119
}
120120

121121
#[inline]
122-
fn is_simple_object(&self, object: &'b ObjectExpression<'a>, depth: u8) -> bool {
122+
fn is_simple_object(object: &'b ObjectExpression<'a>, depth: u8) -> bool {
123123
object.properties.iter().all(|member| {
124124
if let ObjectPropertyKind::ObjectProperty(property) = member {
125125
if property.method {
@@ -138,7 +138,7 @@ impl<'a, 'b> SimpleArgument<'a, 'b> {
138138
}
139139

140140
#[inline]
141-
fn is_simple_array(&self, array: &'b ArrayExpression<'a>, depth: u8) -> bool {
141+
fn is_simple_array(array: &'b ArrayExpression<'a>, depth: u8) -> bool {
142142
array.elements.iter().all(|element| match element {
143143
match_expression!(ArrayExpressionElement) => {
144144
Self::from(element.to_expression()).is_simple_impl(depth + 1)
@@ -150,7 +150,6 @@ impl<'a, 'b> SimpleArgument<'a, 'b> {
150150

151151
#[inline]
152152
fn is_simple_call_like(
153-
&self,
154153
callee: &'b Expression<'a>,
155154
arguments: &'b [Argument<'a>],
156155
depth: u8,
@@ -161,10 +160,10 @@ impl<'a, 'b> SimpleArgument<'a, 'b> {
161160
}
162161

163162
#[inline]
164-
fn is_simple_chain_element(&self, element: &'b ChainElement<'a>, depth: u8) -> bool {
163+
fn is_simple_chain_element(element: &'b ChainElement<'a>, depth: u8) -> bool {
165164
match element {
166165
ChainElement::CallExpression(call) => {
167-
self.is_simple_call_like(&call.callee, &call.arguments, depth)
166+
Self::is_simple_call_like(&call.callee, &call.arguments, depth)
168167
}
169168
ChainElement::TSNonNullExpression(assertion) => {
170169
Self::from(&assertion.expression).is_simple_impl(depth)

crates/oxc_formatter/src/write/jsx/child_list.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl FormatJsxChildList {
3838
f: &mut Formatter<'_, 'a>,
3939
) -> FormatResult<FormatChildrenResult<'a>> {
4040
// Use Biome's exact approach - no need for jsx_split_children at this stage
41-
let children_meta = self.children_meta(children, f.context().comments());
41+
let children_meta = Self::children_meta(children, f.context().comments());
4242
let layout = self.layout(children_meta);
4343

4444
let multiline_layout = if children_meta.meaningful_text {
@@ -349,7 +349,6 @@ impl FormatJsxChildList {
349349
}
350350

351351
fn children_meta(
352-
&self,
353352
children: &AstNode<'_, ArenaVec<'_, JSXChild<'_>>>,
354353
comments: &Comments<'_>,
355354
) -> ChildrenMeta {
@@ -392,23 +391,6 @@ impl FormatJsxChildList {
392391
JsxChildListLayout::Multiline => JsxChildListLayout::Multiline,
393392
}
394393
}
395-
396-
/// Determine if we should use Biome's Fill layout pattern
397-
fn should_use_fill_layout(&self, jsx_children: &[JsxChild<'_, '_>]) -> bool {
398-
let mut has_text = false;
399-
let mut has_elements = false;
400-
401-
for child in jsx_children {
402-
match child {
403-
JsxChild::Word(_) => has_text = true,
404-
JsxChild::NonText(_) => has_elements = true,
405-
_ => {}
406-
}
407-
}
408-
409-
// Fill layout is needed for mixed text and elements
410-
has_text && has_elements && jsx_children.len() > 2
411-
}
412394
}
413395

414396
/// The result of formatting the children of a JSX child list.

crates/oxc_formatter/src/write/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ impl<'a> FormatWrite<'a> for AstNode<'a, NumericLiteral<'a>> {
10531053
format_number_token(
10541054
f.source_text().text_for(self),
10551055
self.span(),
1056-
NumberFormatOptions::default().keep_one_trailing_decimal_zero(),
1056+
NumberFormatOptions::keep_one_trailing_decimal_zero(),
10571057
)
10581058
.fmt(f)
10591059
}

0 commit comments

Comments
 (0)