From f210fc6e9be332807e635b71d15468a26bcbde1f Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 20 Oct 2023 14:51:14 +0900 Subject: [PATCH] feat: upgrade to deno_ast 0.30 (#1202) --- Cargo.lock | 44 ++++++++--------- Cargo.toml | 2 +- deno.json | 10 ++++ docs/rules/no_unsafe_negation.md | 2 + examples/dlint/color.rs | 18 +++---- rust-toolchain.toml | 2 +- src/control_flow/mod.rs | 12 ++--- src/rules/ban_ts_comment.rs | 6 +-- src/rules/ban_untagged_ignore.rs | 6 ++- src/rules/ban_untagged_todo.rs | 2 +- src/rules/fresh_handler_export.rs | 4 +- src/rules/fresh_server_event_handlers.rs | 4 +- src/rules/no_console.rs | 4 +- src/rules/no_constant_condition.rs | 30 ++++++------ src/rules/no_control_regex.rs | 48 +++++++++---------- src/rules/no_dupe_class_members.rs | 2 +- src/rules/no_dupe_else_if.rs | 5 +- src/rules/no_empty_character_class.rs | 10 ++-- src/rules/no_external_imports.rs | 2 +- src/rules/no_invalid_regexp.rs | 20 ++++---- .../no_invalid_triple_slash_reference.rs | 2 +- tools/format.ts | 5 -- tools/lint.ts | 2 +- www/deno.json | 2 +- www/static/docs.json | 2 +- 25 files changed, 126 insertions(+), 120 deletions(-) create mode 100644 deno.json diff --git a/Cargo.lock b/Cargo.lock index b2fc79723..81839d045 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "cc" @@ -204,9 +204,9 @@ checksum = "41b319d1b62ffbd002e057f36bebd1f42b9f97927c9577461d855f3513c4289f" [[package]] name = "deno_ast" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b041461b8b531a409fc635a5a476aee79b82f2c502d1d279c5995b6768ed944a" +checksum = "ab72d91c08a358bc05c2b544bc60c38e1eb9f0715bedbda78da1fa0ad378a129" dependencies = [ "deno_media_type", "dprint-swc-ext", @@ -278,9 +278,9 @@ dependencies = [ [[package]] name = "dprint-swc-ext" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a0a2492465344a58a37ae119de59e81fe5a2885f2711c7b5048ef0dfa14ce42" +checksum = "7b2f24ce6b89a06ae3eb08d5d4f88c05d0aef1fa58e2eba8dd92c97b84210c25" dependencies = [ "bumpalo", "num-bigint", @@ -1067,9 +1067,9 @@ dependencies = [ [[package]] name = "swc_atoms" -version = "0.5.9" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f54563d7dcba626d4acfe14ed12def7ecc28e004debe3ecd2c3ee07cc47e449" +checksum = "ebf7a12229f0c0efb654a6a0f8cbfd94fbd320a57c764857a82d8abe9342b450" dependencies = [ "once_cell", "rustc-hash", @@ -1081,9 +1081,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39cb7fcd56655c8ae7dcf2344f0be6cbff4d9c7cb401fe3ec8e56e1de8dfe582" +checksum = "490e199e25d2aa3fbef675524fa81408651f4e7178b51110470ddd1b3e3bbe75" dependencies = [ "ast_node", "better_scoped_tls", @@ -1107,9 +1107,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.109.0" +version = "0.110.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bc2286cedd688a68f214faa1c19bb5cceab7c9c54d0cbe3273e4c1704e38f69" +checksum = "5cbbf9918976a7e7fbdb4f76fe659d08e291a8b56b524b424183fc67d1189679" dependencies = [ "bitflags 2.3.3", "is-macro", @@ -1124,9 +1124,9 @@ dependencies = [ [[package]] name = "swc_ecma_loader" -version = "0.44.2" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d7c322462657ae27ac090a2c89f7e456c94416284a2f5ecf66c43a6a3c19d1" +checksum = "a7fe06d942fe20a5a81cc14f4a53e64a5efdc851fa895a869224b2d41df73276" dependencies = [ "anyhow", "pathdiff", @@ -1137,9 +1137,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.139.0" +version = "0.141.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eab46cb863bc5cd61535464e07e5b74d5f792fa26a27b9f6fd4c8daca9903b7" +checksum = "97025b945d6d0b80089225de57a031bee01b3754a148eb5469b2d13a3b1dda48" dependencies = [ "either", "num-bigint", @@ -1157,9 +1157,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.132.2" +version = "0.134.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ffd4a8149052bfc1ec1832fcbe04f317846ce635a49ec438df33b06db27d26" +checksum = "eb62881d11242b097e10815834a44063ce7d1308290f9c00a2a5c6ab70404984" dependencies = [ "better_scoped_tls", "bitflags 2.3.3", @@ -1180,9 +1180,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.122.0" +version = "0.124.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11006a3398ffd4693c4d3b0a1b1a5030edbdc04228159f5301120a6178144708" +checksum = "ca44c8eb2841389493b6b532fc80c635b73a9f3f0e936edec4783abc7fa8e979" dependencies = [ "indexmap", "num_cpus", @@ -1198,9 +1198,9 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.95.0" +version = "0.96.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f628ec196e76e67892441e14eef2e423a738543d32bffdabfeec20c29582117" +checksum = "47081acd84cdb2d49d6340ed3204e17738b444da10a3e1dd1eb3d7c8e4d47091" dependencies = [ "num-bigint", "swc_atoms", diff --git a/Cargo.toml b/Cargo.toml index 4243957a7..1ddeb159b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ default = [] docs = [] [dependencies] -deno_ast = { version = "0.29.0", features = ["scopes", "transforms", "utils", "visit", "view", "module_specifier"] } +deno_ast = { version = "0.30.0", features = ["scopes", "transforms", "utils", "visit", "view", "module_specifier"] } log = "0.4.14" serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.79" diff --git a/deno.json b/deno.json new file mode 100644 index 000000000..43c84099f --- /dev/null +++ b/deno.json @@ -0,0 +1,10 @@ +{ + "tasks": { + "update-docs": "cargo run --features=docs --example dlint rules --json > www/static/docs.json" + }, + "exclude": [ + "target", + "examples", + "benchmarks/oak" + ] +} diff --git a/docs/rules/no_unsafe_negation.md b/docs/rules/no_unsafe_negation.md index 8bef57bd9..9ae28f988 100644 --- a/docs/rules/no_unsafe_negation.md +++ b/docs/rules/no_unsafe_negation.md @@ -14,6 +14,8 @@ it will be less confusing. ### Invalid: + + ```typescript if (!key in object) {} if (!foo instanceof Foo) {} diff --git a/examples/dlint/color.rs b/examples/dlint/color.rs index af7e94a51..01e5fa825 100644 --- a/examples/dlint/color.rs +++ b/examples/dlint/color.rs @@ -289,20 +289,16 @@ fn colorize_code_block(lang: CodeBlockLang, src: &str) -> String { decorate(&line[range], Attribute::Yellow) } Word::Keyword(_) => decorate(&line[range], Attribute::Cyan), - Word::Ident(ident) => { - if ident == *"undefined" { - decorate(&line[range], Attribute::Gray) - } else if ident == *"Infinity" || ident == *"NaN" { + Word::Ident(ident) => match ident.as_ref() { + "undefined" => decorate(&line[range], Attribute::Gray), + "Infinity" | "NaN" => { decorate(&line[range], Attribute::Yellow) - } else if matches!( - ident.as_ref(), - "async" | "of" | "enum" | "type" | "interface" - ) { + } + "async" | "of" | "enum" | "type" | "interface" => { decorate(&line[range], Attribute::Cyan) - } else { - line[range].to_string() } - } + _ => line[range].to_string(), + }, }, _ => line[range].to_string(), }, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5299106e2..3c4b81ebf 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.70.0" +channel = "1.73.0" components = ["clippy", "rustfmt"] diff --git a/src/control_flow/mod.rs b/src/control_flow/mod.rs index 3549b8150..1569606ff 100644 --- a/src/control_flow/mod.rs +++ b/src/control_flow/mod.rs @@ -471,19 +471,13 @@ impl Visit for Analyzer<'_> { .cases .iter() .filter_map(|case| self.get_end_reason(case.start())) - .fold( - Some(End::Forced { + .try_fold( + End::Forced { ret: false, throw: false, infinite_loop: false, - }), - |acc, cur| { - if let Some(acc) = acc { - acc.merge_forced(cur) - } else { - None - } }, + |acc, cur| acc.merge_forced(cur), ); match forced_end { diff --git a/src/rules/ban_ts_comment.rs b/src/rules/ban_ts_comment.rs index d24c2fdb3..cfbdb654c 100644 --- a/src/rules/ban_ts_comment.rs +++ b/src/rules/ban_ts_comment.rs @@ -105,11 +105,11 @@ fn check_comment(comment: &Comment) -> Option { } static EXPECT_ERROR_REGEX: Lazy = - Lazy::new(|| Regex::new(r#"^/*\s*@ts-expect-error\s*$"#).unwrap()); + Lazy::new(|| Regex::new(r"^/*\s*@ts-expect-error\s*$").unwrap()); static IGNORE_REGEX: Lazy = - Lazy::new(|| Regex::new(r#"^/*\s*@ts-ignore\s*$"#).unwrap()); + Lazy::new(|| Regex::new(r"^/*\s*@ts-ignore\s*$").unwrap()); static NOCHECK_REGEX: Lazy = - Lazy::new(|| Regex::new(r#"^/*\s*@ts-nocheck\s*$"#).unwrap()); + Lazy::new(|| Regex::new(r"^/*\s*@ts-nocheck\s*$").unwrap()); if EXPECT_ERROR_REGEX.is_match(&comment.text) { return Some(DirectiveKind::ExpectError); diff --git a/src/rules/ban_untagged_ignore.rs b/src/rules/ban_untagged_ignore.rs index 5d683cdba..f05339537 100644 --- a/src/rules/ban_untagged_ignore.rs +++ b/src/rules/ban_untagged_ignore.rs @@ -25,14 +25,16 @@ impl LintRule for BanUntaggedIgnore { let mut violated_ranges: Vec = context .file_ignore_directive() .iter() - .filter_map(|d| d.ignore_all().then(|| d.range())) + .filter(|d| d.ignore_all()) + .map(|d| d.range()) .collect(); violated_ranges.extend( context .line_ignore_directives() .values() - .filter_map(|d| d.ignore_all().then(|| d.range())), + .filter(|d| d.ignore_all()) + .map(|d| d.range()), ); for range in violated_ranges { diff --git a/src/rules/ban_untagged_todo.rs b/src/rules/ban_untagged_todo.rs index 1102746c7..46d87f341 100644 --- a/src/rules/ban_untagged_todo.rs +++ b/src/rules/ban_untagged_todo.rs @@ -59,7 +59,7 @@ fn check_comment(comment: &Comment) -> bool { } static TODO_RE: Lazy = - Lazy::new(|| Regex::new(r#"todo\((#|@)?\S+\)"#).unwrap()); + Lazy::new(|| Regex::new(r"todo\((#|@)?\S+\)").unwrap()); if TODO_RE.is_match(text) { return false; diff --git a/src/rules/fresh_handler_export.rs b/src/rules/fresh_handler_export.rs index 619d80055..b4bd3c149 100644 --- a/src/rules/fresh_handler_export.rs +++ b/src/rules/fresh_handler_export.rs @@ -60,7 +60,9 @@ impl Handler for Visitor { let id = match export_decl.decl { Decl::Var(var_decl) => { if let Some(first) = var_decl.decls.first() { - let Pat::Ident(name_ident) = first.name else {return}; + let Pat::Ident(name_ident) = first.name else { + return; + }; name_ident.id } else { return; diff --git a/src/rules/fresh_server_event_handlers.rs b/src/rules/fresh_server_event_handlers.rs index 73dc64367..6a9ff762f 100644 --- a/src/rules/fresh_server_event_handlers.rs +++ b/src/rules/fresh_server_event_handlers.rs @@ -91,7 +91,9 @@ impl Handler for Visitor { _ => return, }; - let JSXExpr::Expr(expr_value) = expr.expr else {return}; + let JSXExpr::Expr(expr_value) = expr.expr else { + return; + }; // If we pass a function expression or an arrow function expression // then we know for sure that we can't render that. diff --git a/src/rules/no_console.rs b/src/rules/no_console.rs index 1b72a28f3..3d4418825 100644 --- a/src/rules/no_console.rs +++ b/src/rules/no_console.rs @@ -52,9 +52,9 @@ mod tests { assert_lint_ok!( NoConsole, // ignored - r#"// deno-lint-ignore no-console\nconsole.error('Error message');"#, + r"// deno-lint-ignore no-console\nconsole.error('Error message');", // not global - r#"const console = { log() {} } console.log('Error message');"#, + r"const console = { log() {} } console.log('Error message');", ); } diff --git a/src/rules/no_constant_condition.rs b/src/rules/no_constant_condition.rs index 3af6cc7e9..7027189a6 100644 --- a/src/rules/no_constant_condition.rs +++ b/src/rules/no_constant_condition.rs @@ -333,105 +333,105 @@ mod tests { fn no_constant_condition_invalid() { assert_lint_err! { NoConstantCondition, - r#"true ? 1 : 2;"#: [ + r"true ? 1 : 2;": [ { col: 0, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"q = 0 ? 1 : 2;"#: [ + r"q = 0 ? 1 : 2;": [ { col: 4, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"(q = 0) ? 1 : 2;"#: [ + r"(q = 0) ? 1 : 2;": [ { col: 0, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"`` ? 1 : 2;"#: [ + r"`` ? 1 : 2;": [ { col: 0, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"`foo` ? 1 : 2;"#: [ + r"`foo` ? 1 : 2;": [ { col: 0, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"`foo${bar}` ? 1 : 2;"#: [ + r"`foo${bar}` ? 1 : 2;": [ { col: 0, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"if(-2);"#: [ + r"if(-2);": [ { col: 3, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"if(true);"#: [ + r"if(true);": [ { col: 3, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"if({});"#: [ + r"if({});": [ { col: 3, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"if(0 < 1);"#: [ + r"if(0 < 1);": [ { col: 3, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"if(0 || 1);"#: [ + r"if(0 || 1);": [ { col: 3, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"if(a, 1);"#: [ + r"if(a, 1);": [ { col: 3, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"if(`foo`);"#: [ + r"if(`foo`);": [ { col: 3, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"if(``);"#: [ + r"if(``);": [ { col: 3, message: NoConstantConditionMessage::Unexpected, hint: NoConstantConditionHint::Remove, } ], - r#"if(`\\\n`);"#: [ + r"if(`\\\n`);": [ { col: 3, message: NoConstantConditionMessage::Unexpected, diff --git a/src/rules/no_control_regex.rs b/src/rules/no_control_regex.rs index 4354cc065..d87b37fe3 100644 --- a/src/rules/no_control_regex.rs +++ b/src/rules/no_control_regex.rs @@ -192,19 +192,19 @@ mod tests { fn no_control_regex_valid() { assert_lint_ok! { NoControlRegex, - r#"/x1f/"#, - r#"/\\x1f/"#, - r#"/u001f/"#, - r#"/\\u001f/"#, - r#"/u{001f}/"#, - r#"/\\u{001f}/"#, - r#"/u{0001f}/"#, - r#"/\\u{0001f}/"#, - r#"new RegExp('x1f')"#, - r#"RegExp('x1f')"#, - r#"new RegExp('[')"#, - r#"RegExp('[')"#, - r#"new (function foo(){})('\\x1f')"#, + r"/x1f/", + r"/\\x1f/", + r"/u001f/", + r"/\\u001f/", + r"/u{001f}/", + r"/\\u{001f}/", + r"/u{0001f}/", + r"/\\u{0001f}/", + r"new RegExp('x1f')", + r"RegExp('x1f')", + r"new RegExp('[')", + r"RegExp('[')", + r"new (function foo(){})('\\x1f')", }; } @@ -212,77 +212,77 @@ mod tests { fn no_control_regex_invalid() { assert_lint_err! { NoControlRegex, - r#"/\x1f/"#: [ + r"/\x1f/": [ { col: 0, message: NoControlRegexMessage::Unexpected(0x1f), hint: NoControlRegexHint::DisableOrRework, } ], - r#"/\u001f/"#: [ + r"/\u001f/": [ { col: 0, message: NoControlRegexMessage::Unexpected(0x1f), hint: NoControlRegexHint::DisableOrRework, } ], - r#"/\u{001f}/"#: [ + r"/\u{001f}/": [ { col: 0, message: NoControlRegexMessage::Unexpected(0x1f), hint: NoControlRegexHint::DisableOrRework, } ], - r#"/\u{0001f}/"#: [ + r"/\u{0001f}/": [ { col: 0, message: NoControlRegexMessage::Unexpected(0x1f), hint: NoControlRegexHint::DisableOrRework, } ], - r#"/\\\x1f\\x1e/"#: [ + r"/\\\x1f\\x1e/": [ { col: 0, message: NoControlRegexMessage::Unexpected(0x1f), hint: NoControlRegexHint::DisableOrRework, } ], - r#"/\\\x1fFOO\\x00/"#: [ + r"/\\\x1fFOO\\x00/": [ { col: 0, message: NoControlRegexMessage::Unexpected(0x1f), hint: NoControlRegexHint::DisableOrRework, } ], - r#"/FOO\\\x1fFOO\\x1f/"#: [ + r"/FOO\\\x1fFOO\\x1f/": [ { col: 0, message: NoControlRegexMessage::Unexpected(0x1f), hint: NoControlRegexHint::DisableOrRework, } ], - r#"new RegExp('\\x1f\\x1e')"#: [ + r"new RegExp('\\x1f\\x1e')": [ { col: 0, message: NoControlRegexMessage::Unexpected(0x1f), hint: NoControlRegexHint::DisableOrRework, } ], - r#"new RegExp('\\x1fFOO\\x00')"#: [ + r"new RegExp('\\x1fFOO\\x00')": [ { col: 0, message: NoControlRegexMessage::Unexpected(0x1f), hint: NoControlRegexHint::DisableOrRework, } ], - r#"new RegExp('FOO\\x1fFOO\\x1f')"#: [ + r"new RegExp('FOO\\x1fFOO\\x1f')": [ { col: 0, message: NoControlRegexMessage::Unexpected(0x1f), hint: NoControlRegexHint::DisableOrRework, } ], - r#"RegExp('\\x1f')"#: [ + r"RegExp('\\x1f')": [ { col: 0, message: NoControlRegexMessage::Unexpected(0x1f), diff --git a/src/rules/no_dupe_class_members.rs b/src/rules/no_dupe_class_members.rs index d20a4ad53..87303e111 100644 --- a/src/rules/no_dupe_class_members.rs +++ b/src/rules/no_dupe_class_members.rs @@ -135,7 +135,7 @@ impl<'a, 'b, 'view> Visit for ClassVisitor<'a, 'b, 'view> { self .appeared_methods .entry(m) - .or_insert_with(Vec::new) + .or_default() .push((class_method.range(), name)); } } diff --git a/src/rules/no_dupe_else_if.rs b/src/rules/no_dupe_else_if.rs index 7570cf4de..3f66e023e 100644 --- a/src/rules/no_dupe_else_if.rs +++ b/src/rules/no_dupe_else_if.rs @@ -146,7 +146,10 @@ impl<'c, 'view> VisitAll for NoDupeElseIfVisitor<'c, 'view> { fn mk_condition_to_check(cond: Expr) -> Vec { match cond { - Expr::Bin(BinExpr { op, .. }) if op == BinaryOp::LogicalAnd => { + Expr::Bin(BinExpr { + op: BinaryOp::LogicalAnd, + .. + }) => { let mut c = vec![cond.clone()]; c.append(&mut split_by_and(cond)); c diff --git a/src/rules/no_empty_character_class.rs b/src/rules/no_empty_character_class.rs index a97f22f30..d56b004c6 100644 --- a/src/rules/no_empty_character_class.rs +++ b/src/rules/no_empty_character_class.rs @@ -95,27 +95,27 @@ mod tests { fn no_empty_character_invalid() { assert_lint_err! { NoEmptyCharacterClass, - r#"const foo = /^abc[]/;"#: [{ + r"const foo = /^abc[]/;": [{ col: 12, message: MESSAGE, hint: HINT, }], - r#"const foo = /foo[]bar/;"#: [{ + r"const foo = /foo[]bar/;": [{ col: 12, message: MESSAGE, hint: HINT, }], - r#"const foo = /[]]/;"#: [{ + r"const foo = /[]]/;": [{ col: 12, message: MESSAGE, hint: HINT, }], - r#"const foo = /\[[]/;"#: [{ + r"const foo = /\[[]/;": [{ col: 12, message: MESSAGE, hint: HINT, }], - r#"const foo = /\\[\\[\\]a-z[]/;"#: [{ + r"const foo = /\\[\\[\\]a-z[]/;": [{ col: 12, message: MESSAGE, hint: HINT, diff --git a/src/rules/no_external_imports.rs b/src/rules/no_external_imports.rs index 67fb66cfe..6e65b2ec3 100644 --- a/src/rules/no_external_imports.rs +++ b/src/rules/no_external_imports.rs @@ -39,7 +39,7 @@ impl LintRule for NoExternalImport { context: &mut Context, program: Program, ) { - let mut handler = NoExternalImportHandler::default(); + let mut handler = NoExternalImportHandler; handler.traverse(program, context); } diff --git a/src/rules/no_invalid_regexp.rs b/src/rules/no_invalid_regexp.rs index e3b96fcb6..94355058f 100644 --- a/src/rules/no_invalid_regexp.rs +++ b/src/rules/no_invalid_regexp.rs @@ -143,7 +143,7 @@ mod tests { fn no_invalid_regexp_valid() { assert_lint_ok! { NoInvalidRegexp, - r#"RegExp(''); + r"RegExp(''); RegExp(); RegExp('.', 'g'); new RegExp('.'); @@ -176,7 +176,7 @@ var foo = new RegExp('a', ''); /(a)bc[de]/.test('abcd'); /(a)bc[de]/u; let x = new FooBar('\\'); -let re = new RegExp('foo', x);"#, +let re = new RegExp('foo', x);", }; } @@ -184,14 +184,14 @@ let re = new RegExp('foo', x);"#, fn no_invalid_regexp_invalid() { assert_lint_err! { NoInvalidRegexp, - r#"RegExp('[');"#: [{ col: 0, message: MESSAGE, hint: HINT }], - r#"RegExp('.', 'z');"#: [{ col: 0, message: MESSAGE, hint: HINT }], - r#"new RegExp(')');"#: [{ col: 0, message: MESSAGE, hint: HINT }], - r#"new RegExp('\\');"#: [{ col: 0, message: MESSAGE, hint: HINT }], - r#"var foo = new RegExp('(', '');"#: [{ col: 10, message: MESSAGE, hint: HINT }], - r#"/(?a)\ka)\k = - Lazy::new(|| Regex::new(r#"(?i)^/\s*"#).unwrap()); + Lazy::new(|| Regex::new(r"(?i)^/\s*").unwrap()); static PATH_REFERENCE_RE: Lazy = Lazy::new(|| { Regex::new(r#"(?i)\spath\s*=\s*["'](?P[^"']*)["']"#).unwrap() }); diff --git a/tools/format.ts b/tools/format.ts index 3352ca7ad..b0f449c2c 100755 --- a/tools/format.ts +++ b/tools/format.ts @@ -35,11 +35,6 @@ const p3 = new Deno.Command("deno", { args: [ "fmt", ...checkArgs, - "tools", - "benchmarks/benchmarks.ts", - "www/pages", - "docs/rules", - "README.md", ], stdin: "null", }).spawn(); diff --git a/tools/lint.ts b/tools/lint.ts index 4a73ecc59..5cf7f81dc 100755 --- a/tools/lint.ts +++ b/tools/lint.ts @@ -15,7 +15,7 @@ const clippy = [ "clippy::all", ]; -let p1 = new Deno.Command("cargo", { +const p1 = new Deno.Command("cargo", { args: clippy, stdin: "null", }); diff --git a/www/deno.json b/www/deno.json index 483ab41a7..e60b73ec6 100644 --- a/www/deno.json +++ b/www/deno.json @@ -18,4 +18,4 @@ "marked": "https://esm.sh/marked@3.0.4", "prism": "https://esm.sh/prismjs@1.25.0?pin=v57" } -} \ No newline at end of file +} diff --git a/www/static/docs.json b/www/static/docs.json index dba549cab..8e6b45129 100644 --- a/www/static/docs.json +++ b/www/static/docs.json @@ -523,7 +523,7 @@ }, { "code": "no-unsafe-negation", - "docs": "Disallows the usage of negation operator `!` as the left operand of relational\noperators.\n\n`!` operators appearing in the left operand of the following operators will\nsometimes cause an unexpected behavior because of the operator precedence:\n\n- `in` operator\n- `instanceof` operator\n\nFor example, when developers write a code like `!key in someObject`, most likely\nthey want it to behave just like `!(key in someObject)`, but actually it behaves\nlike `(!key) in someObject`. This lint rule warns such usage of `!` operator so\nit will be less confusing.\n\n### Invalid:\n\n```typescript\nif (!key in object) {}\nif (!foo instanceof Foo) {}\n```\n\n### Valid:\n\n```typescript\nif (!(key in object)) {}\nif (!(foo instanceof Foo)) {}\nif ((!key) in object) {}\nif ((!foo) instanceof Foo) {}\n```\n", + "docs": "Disallows the usage of negation operator `!` as the left operand of relational\noperators.\n\n`!` operators appearing in the left operand of the following operators will\nsometimes cause an unexpected behavior because of the operator precedence:\n\n- `in` operator\n- `instanceof` operator\n\nFor example, when developers write a code like `!key in someObject`, most likely\nthey want it to behave just like `!(key in someObject)`, but actually it behaves\nlike `(!key) in someObject`. This lint rule warns such usage of `!` operator so\nit will be less confusing.\n\n### Invalid:\n\n\n\n```typescript\nif (!key in object) {}\nif (!foo instanceof Foo) {}\n```\n\n### Valid:\n\n```typescript\nif (!(key in object)) {}\nif (!(foo instanceof Foo)) {}\nif ((!key) in object) {}\nif ((!foo) instanceof Foo) {}\n```\n", "tags": [ "recommended" ]