diff --git a/Cargo.lock b/Cargo.lock index 655b21708e..fa881fa2eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1937,9 +1937,9 @@ dependencies = [ [[package]] name = "deno_lint" -version = "0.68.2" +version = "0.69.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce713d564f76efd90535061113210bdc6b942ed6327b33eb1d5f76a5daf8e7a5" +checksum = "802583d3ca6c7063e14cafa02ddc206fb34e804e095d52032baf375c56a99515" dependencies = [ "anyhow", "deno_ast", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 0a4487ce56..631edbbb7a 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -74,7 +74,7 @@ deno_doc = { version = "=0.164.0", features = ["rust", "comrak"] } deno_error.workspace = true deno_graph = { version = "=0.87.0" } deno_lib.workspace = true -deno_lint = { version = "=0.68.2" } +deno_lint = { version = "0.69.0" } deno_lockfile.workspace = true deno_media_type = { workspace = true, features = ["data_url", "decoding", "module_specifier"] } deno_npm.workspace = true diff --git a/cli/schemas/lint-rules.v1.json b/cli/schemas/lint-rules.v1.json index 71d1784958..cfec281952 100644 --- a/cli/schemas/lint-rules.v1.json +++ b/cli/schemas/lint-rules.v1.json @@ -8,6 +8,7 @@ "ban-untagged-ignore", "ban-untagged-todo", "ban-unused-ignore", + "button-has-type", "camelcase", "constructor-super", "default-param-last", @@ -19,6 +20,17 @@ "fresh-server-event-handlers", "getter-return", "guard-for-in", + "jsx-boolean-value", + "jsx-curly-braces", + "jsx-key", + "jsx-no-children-prop", + "jsx-no-comment-text-nodes", + "jsx-no-danger-with-children", + "jsx-no-duplicate-props", + "jsx-no-unescaped-entities", + "jsx-no-useless-fragment", + "jsx-props-no-spread-multi", + "jsx-void-dom-elements-no-children", "no-array-constructor", "no-async-promise-executor", "no-await-in-loop", @@ -32,6 +44,7 @@ "no-const-assign", "no-constant-condition", "no-control-regex", + "no-danger", "no-debugger", "no-delete-var", "no-deprecated-deno-api", @@ -70,7 +83,7 @@ "no-non-null-assertion", "no-obj-calls", "no-octal", - "no-process-globals", + "no-process-global", "no-prototype-builtins", "no-redeclare", "no-regex-spaces", @@ -92,6 +105,7 @@ "no-unsafe-negation", "no-unused-labels", "no-unused-vars", + "no-useless-rename", "no-var", "no-window", "no-window-prefix", @@ -103,6 +117,7 @@ "prefer-primordials", "require-await", "require-yield", + "rules-of-hooks", "single-var-declarator", "triple-slash-reference", "use-isnan", diff --git a/cli/tools/lint/mod.rs b/cli/tools/lint/mod.rs index 30d57f4483..29ae3e7a3f 100644 --- a/cli/tools/lint/mod.rs +++ b/cli/tools/lint/mod.rs @@ -458,7 +458,7 @@ fn collect_lint_files( #[allow(clippy::print_stdout)] pub fn print_rules_list(json: bool, maybe_rules_tags: Option>) { let rule_provider = LintRuleProvider::new(None, None); - let all_rules = rule_provider.all_rules(); + let mut all_rules = rule_provider.all_rules(); let configured_rules = rule_provider.resolve_lint_rules( LintRulesConfig { tags: maybe_rules_tags.clone(), @@ -467,6 +467,7 @@ pub fn print_rules_list(json: bool, maybe_rules_tags: Option>) { }, None, ); + all_rules.sort_by_cached_key(|rule| rule.code().to_string()); if json { let json_output = serde_json::json!({ @@ -477,7 +478,7 @@ pub fn print_rules_list(json: bool, maybe_rules_tags: Option>) { // TODO(bartlomieju): print if rule enabled serde_json::json!({ "code": rule.code(), - "tags": rule.tags(), + "tags": rule.tags().iter().map(|t| t.display()).collect::>(), "docs": rule.help_docs_url(), }) }) @@ -493,7 +494,7 @@ pub fn print_rules_list(json: bool, maybe_rules_tags: Option>) { let enabled = if configured_rules.rules.contains(rule) { "✓" } else { - " " + "" }; println!("- {} {}", rule.code(), colors::green(enabled),); println!( @@ -505,7 +506,15 @@ pub fn print_rules_list(json: bool, maybe_rules_tags: Option>) { } else { println!( " {}", - colors::gray(format!("tags: {}", rule.tags().join(", "))) + colors::gray(format!( + "tags: {}", + rule + .tags() + .iter() + .map(|t| t.display()) + .collect::>() + .join(", ") + )) ); } println!(); @@ -658,11 +667,14 @@ mod tests { std::fs::write( &rules_schema_path, - serde_json::to_string_pretty(&RulesSchema { - schema: schema.schema, - rules: all_rules, - }) - .unwrap(), + format!( + "{}\n", + serde_json::to_string_pretty(&RulesSchema { + schema: schema.schema, + rules: all_rules, + }) + .unwrap(), + ), ) .unwrap(); } diff --git a/cli/tools/lint/rules/mod.rs b/cli/tools/lint/rules/mod.rs index 725ca781f6..c3d96e46aa 100644 --- a/cli/tools/lint/rules/mod.rs +++ b/cli/tools/lint/rules/mod.rs @@ -13,6 +13,7 @@ use deno_core::error::AnyError; use deno_graph::ModuleGraph; use deno_lint::diagnostic::LintDiagnostic; use deno_lint::rules::LintRule; +use deno_lint::tags; use crate::resolver::CliSloppyImportsResolver; @@ -25,7 +26,7 @@ pub use no_slow_types::collect_no_slow_type_diagnostics; pub trait PackageLintRule: std::fmt::Debug + Send + Sync { fn code(&self) -> &'static str; - fn tags(&self) -> &'static [&'static str] { + fn tags(&self) -> tags::Tags { &[] } @@ -78,7 +79,7 @@ impl CliLintRule { } } - pub fn tags(&self) -> &'static [&'static str] { + pub fn tags(&self) -> tags::Tags { use CliLintRuleKind::*; match &self.0 { DenoLint(rule) => rule.tags(), @@ -91,7 +92,7 @@ impl CliLintRule { use CliLintRuleKind::*; match &self.0 { DenoLint(rule) => { - Cow::Owned(format!("https://lint.deno.land/rules/{}", rule.code())) + Cow::Owned(format!("https://docs.deno.com/lint/rules/{}", rule.code())) } Extended(rule) => rule.help_docs_url(), Package(rule) => rule.help_docs_url(), @@ -284,7 +285,7 @@ mod test { .resolve_lint_rules(Default::default(), None) .rules .into_iter() - .filter(|r| r.tags().iter().any(|t| *t == "recommended")) + .filter(|r| r.tags().iter().any(|t| *t == tags::RECOMMENDED)) .map(|r| r.code().to_string()) .filter(|n| n != "no-debugger") .collect::>(); diff --git a/cli/tools/lint/rules/no_sloppy_imports.rs b/cli/tools/lint/rules/no_sloppy_imports.rs index 9c0b91f8ac..cf84b3b24f 100644 --- a/cli/tools/lint/rules/no_sloppy_imports.rs +++ b/cli/tools/lint/rules/no_sloppy_imports.rs @@ -16,6 +16,7 @@ use deno_lint::diagnostic::LintDiagnosticRange; use deno_lint::diagnostic::LintFix; use deno_lint::diagnostic::LintFixChange; use deno_lint::rules::LintRule; +use deno_lint::tags; use deno_resolver::sloppy_imports::SloppyImportsResolution; use deno_resolver::sloppy_imports::SloppyImportsResolutionKind; use text_lines::LineAndColumnIndex; @@ -166,8 +167,8 @@ impl LintRule for NoSloppyImportsRule { // include_str!("no_sloppy_imports.md") // } - fn tags(&self) -> &'static [&'static str] { - &["recommended"] + fn tags(&self) -> tags::Tags { + &[tags::RECOMMENDED] } } diff --git a/cli/tools/lint/rules/no_slow_types.rs b/cli/tools/lint/rules/no_slow_types.rs index 5a8742bad7..668bc37689 100644 --- a/cli/tools/lint/rules/no_slow_types.rs +++ b/cli/tools/lint/rules/no_slow_types.rs @@ -9,6 +9,7 @@ use deno_graph::ModuleGraph; use deno_lint::diagnostic::LintDiagnostic; use deno_lint::diagnostic::LintDiagnosticDetails; use deno_lint::diagnostic::LintDiagnosticRange; +use deno_lint::tags; use super::PackageLintRule; @@ -22,8 +23,8 @@ impl PackageLintRule for NoSlowTypesRule { CODE } - fn tags(&self) -> &'static [&'static str] { - &["jsr"] + fn tags(&self) -> tags::Tags { + &[tags::JSR] } // TODO(bartlomieju): these docs need to be hosted somewhere.