diff --git a/.cargo/config.toml b/.cargo/config.toml index d098869da..5fe786e9f 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -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", -] diff --git a/Cargo.toml b/Cargo.toml index 4438a64e3..eea97becd 100644 --- a/Cargo.toml +++ b/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" } diff --git a/crates/oxc/Cargo.toml b/crates/oxc/Cargo.toml index 65a40505c..57c6a663a 100644 --- a/crates/oxc/Cargo.toml +++ b/crates/oxc/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] test = false doctest = false diff --git a/crates/oxc_allocator/Cargo.toml b/crates/oxc_allocator/Cargo.toml index 464895425..207aab35d 100644 --- a/crates/oxc_allocator/Cargo.toml +++ b/crates/oxc_allocator/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index bd567866f..84ad604b1 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_cli/Cargo.toml b/crates/oxc_cli/Cargo.toml index 34d2469a8..42b8cd993 100644 --- a/crates/oxc_cli/Cargo.toml +++ b/crates/oxc_cli/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_codegen/Cargo.toml b/crates/oxc_codegen/Cargo.toml index f4b9f8869..d16144833 100644 --- a/crates/oxc_codegen/Cargo.toml +++ b/crates/oxc_codegen/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_diagnostics/Cargo.toml b/crates/oxc_diagnostics/Cargo.toml index 7babac22a..fc6796184 100644 --- a/crates/oxc_diagnostics/Cargo.toml +++ b/crates/oxc_diagnostics/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_formatter/Cargo.toml b/crates/oxc_formatter/Cargo.toml index 2c071212c..9db57f41b 100644 --- a/crates/oxc_formatter/Cargo.toml +++ b/crates/oxc_formatter/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_index/Cargo.toml b/crates/oxc_index/Cargo.toml index e28db50c4..2d3df8709 100644 --- a/crates/oxc_index/Cargo.toml +++ b/crates/oxc_index/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_linter/Cargo.toml b/crates/oxc_linter/Cargo.toml index 144a0c94e..77eca34e2 100644 --- a/crates/oxc_linter/Cargo.toml +++ b/crates/oxc_linter/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_linter/src/lib.rs b/crates/oxc_linter/src/lib.rs index 3583ade0c..439571776 100644 --- a/crates/oxc_linter/src/lib.rs +++ b/crates/oxc_linter/src/lib.rs @@ -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 diff --git a/crates/oxc_linter_plugin/Cargo.toml b/crates/oxc_linter_plugin/Cargo.toml index 14f084668..069647afe 100644 --- a/crates/oxc_linter_plugin/Cargo.toml +++ b/crates/oxc_linter_plugin/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_macros/Cargo.toml b/crates/oxc_macros/Cargo.toml index ba5285daf..aa9c0186a 100644 --- a/crates/oxc_macros/Cargo.toml +++ b/crates/oxc_macros/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] proc-macro = true doctest = false diff --git a/crates/oxc_macros/src/declare_all_lint_rules/mod.rs b/crates/oxc_macros/src/declare_all_lint_rules/mod.rs index 117631ab8..d86b8d883 100644 --- a/crates/oxc_macros/src/declare_all_lint_rules/mod.rs +++ b/crates/oxc_macros/src/declare_all_lint_rules/mod.rs @@ -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 diff --git a/crates/oxc_minifier/Cargo.toml b/crates/oxc_minifier/Cargo.toml index fd1bb962f..0ab434086 100644 --- a/crates/oxc_minifier/Cargo.toml +++ b/crates/oxc_minifier/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_parser/Cargo.toml b/crates/oxc_parser/Cargo.toml index 085f472e5..22f99b500 100644 --- a/crates/oxc_parser/Cargo.toml +++ b/crates/oxc_parser/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_prettier/Cargo.toml b/crates/oxc_prettier/Cargo.toml index 5f06aa724..fc0b0dff8 100644 --- a/crates/oxc_prettier/Cargo.toml +++ b/crates/oxc_prettier/Cargo.toml @@ -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 } diff --git a/crates/oxc_query/Cargo.toml b/crates/oxc_query/Cargo.toml index 4a049b043..5fec91c9b 100644 --- a/crates/oxc_query/Cargo.toml +++ b/crates/oxc_query/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_resolver/Cargo.toml b/crates/oxc_resolver/Cargo.toml index 8d65f853d..4744af591 100644 --- a/crates/oxc_resolver/Cargo.toml +++ b/crates/oxc_resolver/Cargo.toml @@ -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 diff --git a/crates/oxc_semantic/Cargo.toml b/crates/oxc_semantic/Cargo.toml index 9baa2781e..8292796d3 100644 --- a/crates/oxc_semantic/Cargo.toml +++ b/crates/oxc_semantic/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_span/Cargo.toml b/crates/oxc_span/Cargo.toml index 777f1abff..1c9c41964 100644 --- a/crates/oxc_span/Cargo.toml +++ b/crates/oxc_span/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_syntax/Cargo.toml b/crates/oxc_syntax/Cargo.toml index 35f63a13e..554206fbd 100644 --- a/crates/oxc_syntax/Cargo.toml +++ b/crates/oxc_syntax/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_transformer/Cargo.toml b/crates/oxc_transformer/Cargo.toml index d5af3a59e..8e2c9dc43 100644 --- a/crates/oxc_transformer/Cargo.toml +++ b/crates/oxc_transformer/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/oxc_type_synthesis/Cargo.toml b/crates/oxc_type_synthesis/Cargo.toml index 7021fdab6..f7bcd965f 100644 --- a/crates/oxc_type_synthesis/Cargo.toml +++ b/crates/oxc_type_synthesis/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] test = false doctest = false diff --git a/crates/oxc_wasm/Cargo.toml b/crates/oxc_wasm/Cargo.toml index ec43617f1..e5510311e 100644 --- a/crates/oxc_wasm/Cargo.toml +++ b/crates/oxc_wasm/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] crate-type = ["cdylib", "rlib"] test = false diff --git a/editors/vscode/server/Cargo.toml b/editors/vscode/server/Cargo.toml index 84d3ae7f6..d9efbd1e0 100644 --- a/editors/vscode/server/Cargo.toml +++ b/editors/vscode/server/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [[bin]] name = "oxc_vscode" test = false diff --git a/napi/parser/Cargo.toml b/napi/parser/Cargo.toml index cbde145a3..7483b9702 100644 --- a/napi/parser/Cargo.toml +++ b/napi/parser/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] crate-type = ["cdylib"] test = false diff --git a/napi/resolver/Cargo.toml b/napi/resolver/Cargo.toml index 1aa8b4fd9..345f1a667 100644 --- a/napi/resolver/Cargo.toml +++ b/napi/resolver/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true rust-version.workspace = true categories.workspace = true +[lints] +workspace = true + [lib] crate-type = ["cdylib"] test = false diff --git a/napi/resolver/src/lib.rs b/napi/resolver/src/lib.rs index 3057997d9..b90092cc1 100644 --- a/napi/resolver/src/lib.rs +++ b/napi/resolver/src/lib.rs @@ -15,6 +15,12 @@ pub struct ResolverFactory { resolver: Resolver, } +impl Default for ResolverFactory { + fn default() -> Self { + Self::new() + } +} + #[napi] impl ResolverFactory { #[napi(constructor)] diff --git a/tasks/benchmark/Cargo.toml b/tasks/benchmark/Cargo.toml index d983df072..67926df84 100644 --- a/tasks/benchmark/Cargo.toml +++ b/tasks/benchmark/Cargo.toml @@ -10,6 +10,9 @@ keywords.workspace = true license.workspace = true repository.workspace = true +[lints] +workspace = true + [lib] test = false bench = false diff --git a/tasks/common/Cargo.toml b/tasks/common/Cargo.toml index 15f45d6a9..7820b8ce2 100644 --- a/tasks/common/Cargo.toml +++ b/tasks/common/Cargo.toml @@ -5,6 +5,9 @@ publish = false edition.workspace = true license.workspace = true +[lints] +workspace = true + [lib] test = false doctest = false diff --git a/tasks/coverage/Cargo.toml b/tasks/coverage/Cargo.toml index 60cefdb11..2c481ebb5 100644 --- a/tasks/coverage/Cargo.toml +++ b/tasks/coverage/Cargo.toml @@ -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 } diff --git a/tasks/minsize/Cargo.toml b/tasks/minsize/Cargo.toml index eb303d5c9..35b95bb4a 100644 --- a/tasks/minsize/Cargo.toml +++ b/tasks/minsize/Cargo.toml @@ -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 } diff --git a/tasks/prettier_conformance/Cargo.toml b/tasks/prettier_conformance/Cargo.toml index ad8c790dd..ba23203be 100644 --- a/tasks/prettier_conformance/Cargo.toml +++ b/tasks/prettier_conformance/Cargo.toml @@ -10,6 +10,9 @@ keywords.workspace = true license.workspace = true repository.workspace = true +[lints] +workspace = true + [lib] doctest = false diff --git a/tasks/rulegen/Cargo.toml b/tasks/rulegen/Cargo.toml index bcf12e2e8..1130f0939 100644 --- a/tasks/rulegen/Cargo.toml +++ b/tasks/rulegen/Cargo.toml @@ -5,6 +5,9 @@ publish = false edition.workspace = true license.workspace = true +[lints] +workspace = true + [[bin]] name = "rulegen" test = false diff --git a/tasks/transform_conformance/Cargo.toml b/tasks/transform_conformance/Cargo.toml index 51d151164..66da0fe16 100644 --- a/tasks/transform_conformance/Cargo.toml +++ b/tasks/transform_conformance/Cargo.toml @@ -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 }