Skip to content

Commit

Permalink
refactor(rust): remove the annoying clippy::wildcard_imports (#6860)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Oct 24, 2024
1 parent 99e3b32 commit 423d54c
Show file tree
Hide file tree
Showing 73 changed files with 8 additions and 108 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ too_many_lines = "allow"
# except nagging the programmer to add a `#[must_use]` after clippy has been run.
# Having `#[must_use]` everywhere also hinders readability.
must_use_candidate = "allow"
# Too annoying, we import by name anyway.
wildcard_imports = "allow"
# used_underscore_binding= "allow"
doc_markdown = "allow"
# nursery
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/ast_builder_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use oxc_allocator::{Allocator, Box, FromIn, String, Vec};
use oxc_span::{Atom, GetSpan, Span};
use oxc_syntax::{number::NumberBase, operator::UnaryOperator};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;
use crate::AstBuilder;

Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

use std::mem::{align_of, offset_of, size_of};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;

#[allow(clippy::wildcard_imports)]
use oxc_regular_expression::ast::*;

#[cfg(target_pointer_width = "64")]
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use std::cell::Cell;
use oxc_allocator::{Allocator, Box, IntoIn, Vec};
use oxc_syntax::{reference::ReferenceId, scope::ScopeId, symbol::SymbolId};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;

/// AST builder for creating AST nodes
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/generated/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use oxc_span::{GetSpan, Span};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;

#[derive(Debug, Clone, Copy)]
Expand Down
5 changes: 0 additions & 5 deletions crates/oxc_ast/src/generated/derive_clone_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@

use oxc_allocator::{Allocator, CloneIn};

#[allow(clippy::wildcard_imports)]
use crate::ast::comment::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::js::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::jsx::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::literal::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::ts::*;

impl<'alloc> CloneIn<'alloc> for BooleanLiteral {
Expand Down
5 changes: 0 additions & 5 deletions crates/oxc_ast/src/generated/derive_content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@

use oxc_span::cmp::ContentEq;

#[allow(clippy::wildcard_imports)]
use crate::ast::comment::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::js::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::jsx::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::literal::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::ts::*;

impl ContentEq for BooleanLiteral {
Expand Down
5 changes: 0 additions & 5 deletions crates/oxc_ast/src/generated/derive_content_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@ use std::{hash::Hasher, mem::discriminant};

use oxc_span::hash::ContentHash;

#[allow(clippy::wildcard_imports)]
use crate::ast::comment::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::js::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::jsx::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::literal::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::ts::*;

impl ContentHash for BooleanLiteral {
Expand Down
4 changes: 0 additions & 4 deletions crates/oxc_ast/src/generated/derive_estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@

use serde::{ser::SerializeMap, Serialize, Serializer};

#[allow(clippy::wildcard_imports)]
use crate::ast::js::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::jsx::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::literal::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::ts::*;

impl Serialize for BooleanLiteral {
Expand Down
4 changes: 0 additions & 4 deletions crates/oxc_ast/src/generated/derive_get_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@

use oxc_span::{GetSpan, Span};

#[allow(clippy::wildcard_imports)]
use crate::ast::js::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::jsx::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::literal::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::ts::*;

impl GetSpan for BooleanLiteral {
Expand Down
4 changes: 0 additions & 4 deletions crates/oxc_ast/src/generated/derive_get_span_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@

use oxc_span::{GetSpanMut, Span};

#[allow(clippy::wildcard_imports)]
use crate::ast::js::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::jsx::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::literal::*;

#[allow(clippy::wildcard_imports)]
use crate::ast::ts::*;

impl GetSpanMut for BooleanLiteral {
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use std::cell::Cell;
use oxc_allocator::Vec;
use oxc_syntax::scope::{ScopeFlags, ScopeId};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;
use crate::ast_kind::AstKind;

Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use std::cell::Cell;
use oxc_allocator::Vec;
use oxc_syntax::scope::{ScopeFlags, ScopeId};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;
use crate::ast_kind::AstType;

Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(clippy::wildcard_imports)]
// TODO: I'm not sure if it is a but or intentional but clippy needs this allowed both on this
// module and the generated one.
#![allow(clippy::self_named_module_files)]
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::ops::Not;

use cow_utils::CowUtils;
#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;
use oxc_span::GetSpan;
use oxc_syntax::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;

/// Returns true if this is a literal value. We define a literal value as any node that evaluates
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ecmascript/src/constant_evaluation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::{borrow::Cow, cmp::Ordering};
use num_bigint::BigInt;
use num_traits::{One, Zero};

#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;

use crate::{side_effects::MayHaveSideEffects, ToBigInt, ToInt32, ToJsString};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;
use oxc_syntax::operator::UnaryOperator;

Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ecmascript/src/to_number.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;

/// `ToNumber`
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ecmascript/src/to_string.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::borrow::Cow;

#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;
use oxc_syntax::operator::UnaryOperator;

Expand Down
1 change: 0 additions & 1 deletion crates/oxc_index/src/idxslice.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[allow(clippy::wildcard_imports)]
use super::*;

/// A slice that only accepts indices of a specific type. Note that the intended
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_isolated_declarations/src/class.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::borrow::Cow;

use oxc_allocator::{Box, CloneIn};
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, NONE};
use oxc_span::{GetSpan, SPAN};
use rustc_hash::FxHashMap;
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_isolated_declarations/src/declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::cell::Cell;
use oxc_allocator::Box;
use oxc_allocator::CloneIn;
use oxc_allocator::Vec;
#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;
use oxc_ast::visit::walk_mut::walk_ts_signatures;
use oxc_ast::{Visit, VisitMut};
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_isolated_declarations/src/enum.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use rustc_hash::FxHashMap;

#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;
use oxc_ecmascript::ToInt32;
use oxc_span::{Atom, GetSpan, SPAN};
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_isolated_declarations/src/function.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use oxc_allocator::Box;
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, NONE};
use oxc_span::{Span, SPAN};

Expand Down
1 change: 0 additions & 1 deletion crates/oxc_isolated_declarations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use std::{cell::RefCell, mem};

use diagnostics::function_with_assigning_properties;
use oxc_allocator::{Allocator, CloneIn};
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, AstBuilder, Visit, NONE};
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::{Atom, GetSpan, SourceType, SPAN};
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_isolated_declarations/src/module.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use oxc_allocator::Box;
use oxc_allocator::Vec;
#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;
use oxc_span::{Atom, GetSpan, SPAN};

Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_isolated_declarations/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use std::cell::Cell;
use bitflags::bitflags;
use rustc_hash::FxHashMap;

#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;
#[allow(clippy::wildcard_imports)]
use oxc_ast::{visit::walk::*, Visit};
use oxc_span::Atom;
use oxc_syntax::scope::{ScopeFlags, ScopeId};
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_linter/src/ast_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use oxc_semantic::{AstNode, IsGlobalReference, NodeId, Semantic, SymbolId};
use oxc_span::{GetSpan, Span};
use oxc_syntax::operator::{AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator};

#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;

/// Test if an AST node is a boolean value that never changes. Specifically we
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, AstKind};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! This module checks if an unused variable is allowed. Note that this does not
//! consider variables ignored by name pattern, but by where they are declared.
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, AstKind};
use oxc_semantic::{AstNode, NodeId, Semantic};
use oxc_span::GetSpan;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;
use oxc_semantic::{Semantic, SymbolId};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, AstKind};
use oxc_span::{CompactStr, GetSpan, Span};

Expand Down
1 change: 0 additions & 1 deletion crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! This module contains logic for checking if any [`Reference`]s to a
//! [`Symbol`] are considered a usage.
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, AstKind};
use oxc_semantic::{AstNode, NodeId, Reference, ScopeId, SymbolFlags, SymbolId};
use oxc_span::{GetSpan, Span};
Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_minifier/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(clippy::wildcard_imports)]

//! ECMAScript Minifier
mod ast_passes;
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_module_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use oxc_ast::visit::walk::{
walk_export_all_declaration, walk_export_named_declaration, walk_import_declaration,
walk_import_expression, walk_meta_property, walk_module_declaration, walk_statement,
};
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, Visit};
use oxc_ecmascript::BoundNames;
use oxc_span::{Atom, GetSpan};
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
//!
//! See [full linter example](https://github.com/Boshen/oxc/blob/ab2ef4f89ba3ca50c68abb2ca43e36b7793f3673/crates/oxc_linter/examples/linter.rs#L38-L39)
#![allow(clippy::wildcard_imports)] // allow for use `oxc_ast::ast::*`
#![warn(missing_docs)]

mod context;
Expand Down
5 changes: 2 additions & 3 deletions crates/oxc_prettier/src/format/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use oxc_span::GetSpan;
use super::assignment::AssignmentLikeNode;
use crate::{
array,
doc::{Doc, DocBuilder, Group, IfBreak, Line},
doc::{Doc, DocBuilder, Group, IfBreak},
format::{assignment, Separator},
group, hardline, if_break, indent, indent_if_break, line, softline, space, ss, Format,
Prettier,
group, hardline, indent, line, softline, space, ss, Format, Prettier,
};

pub(super) fn print_class<'a>(p: &mut Prettier<'a>, class: &Class<'a>) -> Doc<'a> {
Expand Down
3 changes: 1 addition & 2 deletions crates/oxc_prettier/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#![allow(unused, clippy::unused_self)]
//! Prettier
//!
//! A port of <https://github.com/prettier/prettier>
#![allow(unused, clippy::wildcard_imports, clippy::unused_self)]

mod binaryish;
mod comments;
mod doc;
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_regular_expression/src/ast_impl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::{
iter::Peekable,
};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;
use crate::surrogate_pair::{combine_surrogate_pair, is_lead_surrogate, is_trail_surrogate};

Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_regular_expression/src/ast_impl/visit.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// NOTE: For now, this file is implemented by hand for convenience.
// But like `oxc_ast`, this should be generated by `tasks/ast_tools` in the future.

#![allow(unused_variables, clippy::wildcard_imports)]
use oxc_span::{GetSpan, Span};
use walk::walk_pattern;

Expand Down Expand Up @@ -68,9 +67,10 @@ impl<'a> GetSpan for RegExpAstKind<'a> {
/// RegEx syntax tree traversal
pub trait Visit<'a>: Sized {
#[inline]
fn enter_node(&mut self, kind: RegExpAstKind<'a>) {}
fn enter_node(&mut self, _kind: RegExpAstKind<'a>) {}

#[inline]
fn leave_node(&mut self, kind: RegExpAstKind<'a>) {}
fn leave_node(&mut self, _kind: RegExpAstKind<'a>) {}

#[inline]
fn alloc<T>(&self, t: &T) -> &'a T {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use oxc_allocator::{Allocator, CloneIn};

#[allow(clippy::wildcard_imports)]
use crate::ast::*;

impl<'old_alloc, 'new_alloc> CloneIn<'new_alloc> for Pattern<'old_alloc> {
Expand Down
Loading

0 comments on commit 423d54c

Please sign in to comment.