Skip to content

Commit ce269c0

Browse files
committed
refactor(formatter): remove global !clippy::enum_variant_names and !clippy::struct_field_names (#15938)
1 parent 45fffc1 commit ce269c0

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

crates/oxc_formatter/src/formatter/builders.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,7 @@ pub fn group<'ast>(content: &impl Format<'ast>) -> Group<'_, 'ast> {
16691669
#[derive(Copy, Clone)]
16701670
pub struct Group<'fmt, 'ast> {
16711671
content: Argument<'fmt, 'ast>,
1672+
#[expect(clippy::struct_field_names)] // Keep the name the same as it is in the original source
16721673
group_id: Option<GroupId>,
16731674
should_expand: bool,
16741675
}

crates/oxc_formatter/src/formatter/comments.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ use crate::{
114114
#[derive(Debug, Clone)]
115115
pub struct Comments<'a> {
116116
source_text: SourceText<'a>,
117-
comments: &'a [Comment],
117+
inner: &'a [Comment],
118118
/// **Critical state field**: Tracks how many comments have been processed.
119119
///
120120
/// This acts as a cursor dividing the comments array into two sections:
@@ -139,7 +139,7 @@ impl<'a> Comments<'a> {
139139
pub fn new(source_text: SourceText<'a>, comments: &'a [Comment]) -> Self {
140140
Comments {
141141
source_text,
142-
comments,
142+
inner: comments,
143143
printed_count: 0,
144144
last_handled_type_cast_comment: 0,
145145
type_cast_node_span: Span::default(),
@@ -150,14 +150,14 @@ impl<'a> Comments<'a> {
150150
/// Returns comments that have not been printed yet.
151151
#[inline]
152152
pub fn unprinted_comments(&self) -> &'a [Comment] {
153-
let end = self.view_limit.unwrap_or(self.comments.len());
154-
&self.comments[self.printed_count..end]
153+
let end = self.view_limit.unwrap_or(self.inner.len());
154+
&self.inner[self.printed_count..end]
155155
}
156156

157157
/// Returns comments that have already been printed.
158158
#[inline]
159159
pub fn printed_comments(&self) -> &'a [Comment] {
160-
&self.comments[..self.printed_count]
160+
&self.inner[..self.printed_count]
161161
}
162162

163163
/// Returns an iterator over comments that end before or at the given position.
@@ -458,13 +458,13 @@ impl<'a> Comments<'a> {
458458

459459
// Find the index of the first comment that starts at or after end_pos
460460
// Using binary search would be more efficient for large comment arrays
461-
let limit_index = self.comments[self.printed_count..]
461+
let limit_index = self.inner[self.printed_count..]
462462
.iter()
463463
.position(|c| c.span.start >= end_pos)
464-
.map_or(self.comments.len(), |idx| self.printed_count + idx);
464+
.map_or(self.inner.len(), |idx| self.printed_count + idx);
465465

466466
// Only update if we're actually limiting the view
467-
if limit_index < self.comments.len() {
467+
if limit_index < self.inner.len() {
468468
self.view_limit = Some(limit_index);
469469
}
470470

crates/oxc_formatter/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
clippy::inline_always,
44
clippy::missing_panics_doc,
55
clippy::needless_pass_by_ref_mut,
6-
clippy::unused_self,
7-
clippy::enum_variant_names,
8-
clippy::struct_field_names
6+
clippy::unused_self
97
)] // FIXME: all these needs to be fixed.
108

119
mod ast_nodes;

crates/oxc_formatter/src/options.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ impl fmt::Debug for LineWidth {
326326
}
327327

328328
/// Error type returned when parsing a [LineWidth] or [IndentWidth] from a string fails
329+
#[expect(clippy::enum_variant_names)]
329330
pub enum ParseFormatNumberError {
330331
/// The string could not be parsed to a number
331332
ParseError(ParseIntError),

crates/oxc_formatter/src/write/parameters.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ impl<'a> FormatWrite<'a> for AstNode<'a, TSThisParameter<'a>> {
138138

139139
enum Parameter<'a, 'b> {
140140
This(&'b AstNode<'a, TSThisParameter<'a>>),
141-
FormalParameter(&'b AstNode<'a, FormalParameter<'a>>),
141+
Formal(&'b AstNode<'a, FormalParameter<'a>>),
142142
Rest(&'b AstNode<'a, BindingRestElement<'a>>),
143143
}
144144

145145
impl GetSpan for Parameter<'_, '_> {
146146
fn span(&self) -> Span {
147147
match self {
148148
Self::This(param) => param.span(),
149-
Self::FormalParameter(param) => param.span(),
149+
Self::Formal(param) => param.span(),
150150
Self::Rest(e) => e.span(),
151151
}
152152
}
@@ -156,7 +156,7 @@ impl<'a> Format<'a> for Parameter<'a, '_> {
156156
fn fmt(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> {
157157
match self {
158158
Self::This(param) => param.fmt(f),
159-
Self::FormalParameter(param) => param.fmt(f),
159+
Self::Formal(param) => param.fmt(f),
160160
Self::Rest(e) => e.fmt(f),
161161
}
162162
}
@@ -181,7 +181,7 @@ impl<'a, 'b> Iterator for FormalParametersIter<'a, 'b> {
181181
self.this.take().map(Parameter::This).or_else(|| {
182182
self.params
183183
.next()
184-
.map(Parameter::FormalParameter)
184+
.map(Parameter::Formal)
185185
.or_else(|| self.rest.take().map(Parameter::Rest))
186186
})
187187
}

0 commit comments

Comments
 (0)