From d3f01ebf6ea97e71bcda8c84b054943e1f24cd4e Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Sat, 30 Nov 2024 00:13:50 -0800 Subject: [PATCH] chore(lint): ensure lint config is correct (#1528) - Move lints to workspace manifest - Add lint config to backend crates - Fix one small lint error --- Cargo.toml | 42 +++++++++++++++++++++++++++++ ratatui-core/Cargo.toml | 6 ++--- ratatui-core/src/text/text.rs | 2 +- ratatui-crossterm/Cargo.toml | 3 +++ ratatui-termion/Cargo.toml | 3 +++ ratatui-termwiz/Cargo.toml | 3 +++ ratatui-widgets/Cargo.toml | 51 ++--------------------------------- ratatui/Cargo.toml | 43 ++--------------------------- 8 files changed, 58 insertions(+), 95 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6a474b01..6e0207e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,3 +53,45 @@ termion = "4.0.0" [profile.bench] codegen-units = 1 lto = true + +[workspace.lints.rust] +unsafe_code = "forbid" + +[workspace.lints.clippy] +cargo = { level = "warn", priority = -1 } +pedantic = { level = "warn", priority = -1 } +cast_possible_truncation = "allow" +cast_possible_wrap = "allow" +cast_precision_loss = "allow" +cast_sign_loss = "allow" +missing_errors_doc = "allow" +missing_panics_doc = "allow" +module_name_repetitions = "allow" +must_use_candidate = "allow" + +# we often split up a module into multiple files with the main type in a file named after the +# module, so we want to allow this pattern +module_inception = "allow" + +# nursery or restricted +as_underscore = "warn" +deref_by_slicing = "warn" +else_if_without_else = "warn" +empty_line_after_doc_comments = "warn" +equatable_if_let = "warn" +fn_to_numeric_cast_any = "warn" +format_push_string = "warn" +map_err_ignore = "warn" +missing_const_for_fn = "warn" +mixed_read_write_in_expression = "warn" +mod_module_files = "warn" +needless_pass_by_ref_mut = "warn" +needless_raw_strings = "warn" +or_fun_call = "warn" +redundant_type_annotations = "warn" +rest_pat_in_fully_bound_structs = "warn" +string_lit_chars_any = "warn" +string_slice = "warn" +string_to_string = "warn" +unnecessary_self_imports = "warn" +use_self = "warn" diff --git a/ratatui-core/Cargo.toml b/ratatui-core/Cargo.toml index 3e148cd4..dd2eecef 100644 --- a/ratatui-core/Cargo.toml +++ b/ratatui-core/Cargo.toml @@ -64,7 +64,5 @@ serde_json.workspace = true [target.'cfg(not(windows))'.dev-dependencies] ratatui = { workspace = true, features = ["termion"] } -[lints.clippy] -# we often split up a module into multiple files with the main type in a file named after the -# module, so we want to allow this pattern -module_inception = "allow" +[lints] +workspace = true diff --git a/ratatui-core/src/text/text.rs b/ratatui-core/src/text/text.rs index 2f1bd2fd..a6c1347d 100755 --- a/ratatui-core/src/text/text.rs +++ b/ratatui-core/src/text/text.rs @@ -730,7 +730,7 @@ impl fmt::Display for Text<'_> { impl Widget for Text<'_> { fn render(self, area: Rect, buf: &mut Buffer) { - Widget::render(&self, area, buf) + Widget::render(&self, area, buf); } } diff --git a/ratatui-crossterm/Cargo.toml b/ratatui-crossterm/Cargo.toml index 3b191f57..ba70a722 100644 --- a/ratatui-crossterm/Cargo.toml +++ b/ratatui-crossterm/Cargo.toml @@ -43,3 +43,6 @@ ratatui-core = { workspace = true } [dev-dependencies] ratatui = { path = "../ratatui", features = ["crossterm"] } rstest.workspace = true + +[lints] +workspace = true diff --git a/ratatui-termion/Cargo.toml b/ratatui-termion/Cargo.toml index a03e1371..3c4a2804 100644 --- a/ratatui-termion/Cargo.toml +++ b/ratatui-termion/Cargo.toml @@ -33,3 +33,6 @@ instability.workspace = true [dev-dependencies] rstest.workspace = true + +[lints] +workspace = true diff --git a/ratatui-termwiz/Cargo.toml b/ratatui-termwiz/Cargo.toml index 6ee39f7d..cc180456 100644 --- a/ratatui-termwiz/Cargo.toml +++ b/ratatui-termwiz/Cargo.toml @@ -37,3 +37,6 @@ termwiz.workspace = true [dev-dependencies] ratatui = { path = "../ratatui", features = ["termwiz"] } rstest.workspace = true + +[lints] +workspace = true diff --git a/ratatui-widgets/Cargo.toml b/ratatui-widgets/Cargo.toml index e1e8e085..b53ebe08 100644 --- a/ratatui-widgets/Cargo.toml +++ b/ratatui-widgets/Cargo.toml @@ -66,52 +66,5 @@ pretty_assertions.workspace = true ratatui = { path = "../ratatui" } rstest.workspace = true -[lints.rust] -unsafe_code = "forbid" - -[lints.clippy] -cargo = { level = "warn", priority = -1 } -pedantic = { level = "warn", priority = -1 } -cast_possible_truncation = "allow" -cast_possible_wrap = "allow" -cast_precision_loss = "allow" -cast_sign_loss = "allow" -missing_errors_doc = "allow" -missing_panics_doc = "allow" -module_name_repetitions = "allow" -must_use_candidate = "allow" - -# we often split up a module into multiple files with the main type in a file named after the -# module, so we want to allow this pattern -module_inception = "allow" - -# nursery or restricted -as_underscore = "warn" -deref_by_slicing = "warn" -else_if_without_else = "warn" -empty_line_after_doc_comments = "warn" -equatable_if_let = "warn" -fn_to_numeric_cast_any = "warn" -format_push_string = "warn" -map_err_ignore = "warn" -missing_const_for_fn = "warn" -mixed_read_write_in_expression = "warn" -mod_module_files = "warn" -needless_pass_by_ref_mut = "warn" -needless_raw_strings = "warn" -or_fun_call = "warn" -redundant_type_annotations = "warn" -rest_pat_in_fully_bound_structs = "warn" -string_lit_chars_any = "warn" -string_slice = "warn" -string_to_string = "warn" -unnecessary_self_imports = "warn" -use_self = "warn" - -[[example]] -name = "barchart" -doc-scrape-examples = true - -[[example]] -name = "block" -doc-scrape-examples = true +[lints] +workspace = true diff --git a/ratatui/Cargo.toml b/ratatui/Cargo.toml index 14cf4833..39860852 100644 --- a/ratatui/Cargo.toml +++ b/ratatui/Cargo.toml @@ -131,47 +131,8 @@ tracing = "0.1.40" tracing-appender = "0.2.3" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } -[lints.rust] -unsafe_code = "forbid" - -[lints.clippy] -cargo = { level = "warn", priority = -1 } -pedantic = { level = "warn", priority = -1 } -cast_possible_truncation = "allow" -cast_possible_wrap = "allow" -cast_precision_loss = "allow" -cast_sign_loss = "allow" -missing_errors_doc = "allow" -missing_panics_doc = "allow" -module_name_repetitions = "allow" -must_use_candidate = "allow" - -# we often split up a module into multiple files with the main type in a file named after the -# module, so we want to allow this pattern -module_inception = "allow" - -# nursery or restricted -as_underscore = "warn" -deref_by_slicing = "warn" -else_if_without_else = "warn" -empty_line_after_doc_comments = "warn" -equatable_if_let = "warn" -fn_to_numeric_cast_any = "warn" -format_push_string = "warn" -map_err_ignore = "warn" -missing_const_for_fn = "warn" -mixed_read_write_in_expression = "warn" -mod_module_files = "warn" -needless_pass_by_ref_mut = "warn" -needless_raw_strings = "warn" -or_fun_call = "warn" -redundant_type_annotations = "warn" -rest_pat_in_fully_bound_structs = "warn" -string_lit_chars_any = "warn" -string_slice = "warn" -string_to_string = "warn" -unnecessary_self_imports = "warn" -use_self = "warn" +[lints] +workspace = true [lib] bench = false