mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(rust): move to workspace lint table (#1444)
This commit is contained in:
parent
d02b7470d9
commit
1a576f60a8
37 changed files with 165 additions and 78 deletions
|
|
@ -10,70 +10,3 @@ rule = "run -p rulegen"
|
|||
|
||||
[build]
|
||||
rustflags = ["-C", "target-cpu=native"]
|
||||
|
||||
[target.'cfg(all())']
|
||||
rustflags = [
|
||||
# CLIPPY LINT SETTINGS
|
||||
# This is a workaround to configure lints for the entire workspace, pending the ability to configure this via TOML.
|
||||
# Wait for [RFC3389](https://github.com/rust-lang/rfcs/pull/3389) and [Tracking Issue](https://github.com/rust-lang/cargo/issues/12115)
|
||||
"-Wclippy::all",
|
||||
|
||||
# I want to write the best Rust code so both pedantic and nursery is enabled.
|
||||
# We should only disable rules globally if they are either false positives, chaotic, or does not make sense.
|
||||
"-Wclippy::pedantic",
|
||||
"-Wclippy::nursery",
|
||||
|
||||
# restriction
|
||||
|
||||
"-Wclippy::dbg_macro",
|
||||
"-Wclippy::todo",
|
||||
"-Wclippy::unimplemented",
|
||||
|
||||
# I like the explicitness of this rule as it removes confusion around `clone`.
|
||||
# This increases readability, avoids `clone` mindlessly and heap allocating on accident.
|
||||
"-Wclippy::clone_on_ref_ptr",
|
||||
|
||||
# These two are mutually exclusive, I like `mod.rs` files for better fuzzy searches on module entries.
|
||||
"-Wclippy::self_named_module_files", # "-Wclippy::mod_module_files",
|
||||
|
||||
"-Wclippy::empty_drop",
|
||||
"-Wclippy::empty_structs_with_brackets",
|
||||
"-Wclippy::exit",
|
||||
"-Wclippy::filetype_is_file",
|
||||
"-Wclippy::get_unwrap",
|
||||
"-Wclippy::impl_trait_in_params",
|
||||
"-Wclippy::rc_buffer",
|
||||
"-Wclippy::rc_mutex",
|
||||
"-Wclippy::rest_pat_in_fully_bound_structs",
|
||||
"-Wclippy::unnecessary_safety_comment",
|
||||
"-Wclippy::undocumented_unsafe_blocks",
|
||||
|
||||
# pedantic
|
||||
|
||||
# This rule is too pedantic, I don't want to force this because naming things are hard.
|
||||
"-Aclippy::module_name_repetitions",
|
||||
# All triggers are mostly ignored in our codebase, so this is ignored globally.
|
||||
"-Aclippy::struct_excessive_bools",
|
||||
"-Aclippy::too_many_lines",
|
||||
|
||||
# #[must_use] is creating too much noise for this codebase, it does not add much value execept nagging
|
||||
# the programmer to add a #[must_use] after clippy has been run.
|
||||
# Having #[must_use] every where also hinders readability.
|
||||
"-Aclippy::must_use_candidate",
|
||||
|
||||
# Generated from the `index_vec` crate.
|
||||
# this error originates in the macro `$crate::__define_index_type_inner` which comes from the expansion of the macro `define_index_type`
|
||||
"-Aclippy::used_underscore_binding",
|
||||
"-Aclippy::doc_markdown",
|
||||
|
||||
# nursery
|
||||
|
||||
# `const` functions do not make sense for our project because this is not a `const` library.
|
||||
# This rule also confuses new comers and forces them to add `const` blindlessly without any reason.
|
||||
"-Aclippy::missing_const_for_fn",
|
||||
|
||||
# style
|
||||
|
||||
# Having both `new` and `default` for a struct is confusing, just implement the more appropriate one.
|
||||
"-Aclippy::new_without_default",
|
||||
]
|
||||
|
|
|
|||
46
Cargo.toml
46
Cargo.toml
|
|
@ -13,6 +13,52 @@ license = "MIT"
|
|||
repository = "https://github.com/oxc-project/oxc"
|
||||
rust-version = "1.60"
|
||||
|
||||
[workspace.lints.rust]
|
||||
|
||||
[workspace.lints.clippy]
|
||||
all = { level = "warn" }
|
||||
# restriction
|
||||
dbg_macro = "warn"
|
||||
todo = "warn"
|
||||
unimplemented = "warn"
|
||||
# I like the explicitness of this rule as it removes confusion around `clone`.
|
||||
# This increases readability, avoids `clone` mindlessly and heap allocating on accident.
|
||||
clone_on_ref_ptr = "warn"
|
||||
# These two are mutually exclusive, I like `mod.rs` files for better fuzzy searches on module entries.
|
||||
self_named_module_files = "warn" # "-Wclippy::mod_module_files"
|
||||
empty_drop = "warn"
|
||||
empty_structs_with_brackets = "warn"
|
||||
exit = "warn"
|
||||
filetype_is_file = "warn"
|
||||
get_unwrap = "warn"
|
||||
impl_trait_in_params = "warn"
|
||||
rc_buffer = "warn"
|
||||
rc_mutex = "warn"
|
||||
rest_pat_in_fully_bound_structs = "warn"
|
||||
unnecessary_safety_comment = "warn"
|
||||
undocumented_unsafe_blocks = "warn"
|
||||
# I want to write the best Rust code so both pedantic and nursery is enabled.
|
||||
# We should only disable rules globally if they are either false positives, chaotic, or does not make sense.
|
||||
nursery = { level = "warn", priority = -1 }
|
||||
pedantic = { level = "warn", priority = -1 }
|
||||
# Allowed rules
|
||||
# pedantic
|
||||
# This rule is too pedantic, I don't want to force this because naming things are hard.
|
||||
module_name_repetitions = "allow"
|
||||
# All triggers are mostly ignored in our codebase, so this is ignored globally.
|
||||
struct_excessive_bools = "allow"
|
||||
too_many_lines = "allow"
|
||||
# #[must_use] is creating too much noise for this codebase, it does not add much value except nagging
|
||||
# the programmer to add a #[must_use] after clippy has been run.
|
||||
# Having #[must_use] every where also hinders readability.
|
||||
must_use_candidate = "allow"
|
||||
# used_underscore_binding= "allow"
|
||||
doc_markdown = "allow"
|
||||
# nursery
|
||||
# `const` functions do not make sense for our project because this is not a `const` library.
|
||||
# This rule also confuses new comers and forces them to add `const` blindlessly without any reason.
|
||||
missing_const_for_fn = "allow"
|
||||
|
||||
[workspace.dependencies]
|
||||
# publish = true
|
||||
oxc = { version = "0.3.0", path = "crates/oxc" }
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
test = false
|
||||
doctest = false
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,12 @@ pub struct Linter {
|
|||
options: LintOptions,
|
||||
}
|
||||
|
||||
impl Default for Linter {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Linter {
|
||||
pub fn new() -> Self {
|
||||
let rules = RULES
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
doctest = false
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ impl Parse for AllLintRulesMeta {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
|
||||
pub fn declare_all_lint_rules(metadata: AllLintRulesMeta) -> TokenStream {
|
||||
let AllLintRulesMeta { rules } = metadata;
|
||||
// all the top-level module trees
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
@ -21,7 +24,7 @@ oxc_ast = { workspace = true }
|
|||
oxc_syntax = { workspace = true }
|
||||
oxc_span = { workspace = true }
|
||||
|
||||
bitflags = { workspace = true }
|
||||
bitflags = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
oxc_parser = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ description = "ESM / CJS module resolution"
|
|||
keywords = ["node", "resolve", "cjs", "esm", "enhanced-resolve"]
|
||||
categories = ["development-tools"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
test = false
|
||||
doctest = false
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ license.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
test = false
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "oxc_vscode"
|
||||
test = false
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
test = false
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ repository.workspace = true
|
|||
rust-version.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
test = false
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@ pub struct ResolverFactory {
|
|||
resolver: Resolver,
|
||||
}
|
||||
|
||||
impl Default for ResolverFactory {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[napi]
|
||||
impl ResolverFactory {
|
||||
#[napi(constructor)]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ keywords.workspace = true
|
|||
license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
test = false
|
||||
bench = false
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ publish = false
|
|||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
test = false
|
||||
doctest = false
|
||||
|
|
|
|||
|
|
@ -10,14 +10,17 @@ keywords.workspace = true
|
|||
license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "oxc_coverage"
|
||||
test = false
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
test = false
|
||||
doctest = false
|
||||
|
||||
[[bin]]
|
||||
name = "oxc_coverage"
|
||||
test = false
|
||||
|
||||
[dependencies]
|
||||
oxc_allocator = { workspace = true }
|
||||
oxc_parser = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -5,13 +5,16 @@ publish = false
|
|||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "oxc_minsize"
|
||||
test = false
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
[[bin]]
|
||||
name = "oxc_minsize"
|
||||
test = false
|
||||
|
||||
[dependencies]
|
||||
oxc_span = { workspace = true }
|
||||
oxc_allocator = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ keywords.workspace = true
|
|||
license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ publish = false
|
|||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "rulegen"
|
||||
test = false
|
||||
|
|
|
|||
|
|
@ -10,14 +10,17 @@ keywords.workspace = true
|
|||
license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "oxc_transform_conformance"
|
||||
test = false
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
test = false
|
||||
doctest = false
|
||||
|
||||
[[bin]]
|
||||
name = "oxc_transform_conformance"
|
||||
test = false
|
||||
|
||||
[dependencies]
|
||||
oxc_span = { workspace = true }
|
||||
oxc_allocator = { workspace = true }
|
||||
|
|
|
|||
Loading…
Reference in a new issue