From 2bf032199f2ed10dbc7ff9d5b9163845e145a88e Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 18 Oct 2021 22:57:59 -0400 Subject: [PATCH] 0.18.0 (#942) --- Cargo.lock | 58 +++++++++++++++++++++++++++-------------------- Cargo.toml | 4 ++-- src/ast_parser.rs | 36 ++--------------------------- src/linter.rs | 4 ++-- 4 files changed, 39 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 793baa53f..97a9c42d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -238,9 +238,9 @@ dependencies = [ [[package]] name = "deno_ast" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d177a5fbe88bec8d8b86882c77b7ba39ba03be99c5d80d3c9fc529191f3c0933" +checksum = "f9f3b4f3ed02c96faa6f877d54463b6ae499f9e347b0ab406958cb729d0cead3" dependencies = [ "dprint-swc-ecma-ast-view", "serde", @@ -273,7 +273,7 @@ dependencies = [ [[package]] name = "deno_lint" -version = "0.17.0" +version = "0.18.0" dependencies = [ "annotate-snippets", "ansi_term 0.12.1", @@ -309,9 +309,9 @@ dependencies = [ [[package]] name = "dprint-swc-ecma-ast-view" -version = "0.39.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3530a71ad541e1182d19a1fa4da83c8d134e38f6fffd4cd1035440444dd08d15" +checksum = "61449b64e74bd9a8f3b8319462c250adcef52aa11b032bc17a2c9fce20ad9fb8" dependencies = [ "bumpalo", "num-bigint", @@ -1170,12 +1170,13 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "string_cache" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ddb1139b5353f96e429e1a5e19fbaf663bddedaa06d1dbd49f82e352601209a" +checksum = "923f0f39b6267d37d23ce71ae7235602134b250ace715dd2c90421998ddac0c6" dependencies = [ "lazy_static", "new_debug_unreachable", + "parking_lot", "phf_shared", "precomputed-hash", "serde", @@ -1220,9 +1221,9 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "swc_atoms" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "837a3ef86c2817228e733b6f173c821fd76f9eb21a0bc9001a826be48b00b4e7" +checksum = "6a20e0ff436c9967b5cbafbc0872f384fef5be6f9913ce92fb5f017427e95c7e" dependencies = [ "string_cache", "string_cache_codegen", @@ -1230,9 +1231,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.13.4" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "259212df9a949aa6ec440b64244475bcda531609a85489a22eb27908dd8d1b0d" +checksum = "09b096f9f8b1400690ccd25cb030b89267d40cd549b99bece6e936c5eb71e7a7" dependencies = [ "ahash", "ast_node", @@ -1255,9 +1256,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.54.3" +version = "0.55.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae24a6603262822de50069ff72394b0d208267e5bd5298678ba6a79f670c40f" +checksum = "e40d99e5376086f6a057202b3889f276c3f5cbcafeead8f536ed088ad0bf36b3" dependencies = [ "is-macro", "num-bigint", @@ -1269,9 +1270,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.73.7" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e15e3e4f316aee7662a11cad0e4bb723d35e164b6ea9360bd3cbc81c7956f5af" +checksum = "a95c7f1ee909bac1b4e185385271e53aeea8a16b38bb48411e6082de7fdf0fef" dependencies = [ "either", "enum_kind", @@ -1284,14 +1285,15 @@ dependencies = [ "swc_ecma_ast", "swc_ecma_visit", "tracing", + "typed-arena", "unicode-xid", ] [[package]] name = "swc_ecma_transforms" -version = "0.81.0" +version = "0.86.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9170807286d86c713320a5122c299a5cd62c81ac62e572e2259aa1a93d80c171" +checksum = "9d164f71a1170590db5ddbe3c882c2afe3dd58e29aa8be0138fd86295a540eed" dependencies = [ "swc_atoms", "swc_common", @@ -1305,9 +1307,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.37.1" +version = "0.39.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ab2108361a8bb8664951ae0f533fab36c609aa849143b3358e29ed33060bbe" +checksum = "4eb705217c929679f7c6a0003179e03acce1501076afc3ef8c746d1b4bb4c5c1" dependencies = [ "once_cell", "phf", @@ -1323,9 +1325,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.47.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7438f518f4392bf059886ec4ea524e8cc501bbaf077410161c4151226780fb3c" +checksum = "fc932d46dabd2250f4bb690cf5eb14a672c6c054caee1a1a9ff3ecf77b472606" dependencies = [ "once_cell", "scoped-tls", @@ -1338,9 +1340,9 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.40.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c24a7600061813d7df3248d93ff27cacc1a81f9eeec47701866f3adc9ae2930" +checksum = "c242ca4236cf826f9d575f27235a049e7e5629b66f130fdc1f333fa23e6a2ff4" dependencies = [ "num-bigint", "swc_atoms", @@ -1351,9 +1353,9 @@ dependencies = [ [[package]] name = "swc_ecmascript" -version = "0.73.0" +version = "0.78.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8147c047015f4289b3202a5362a6ed8c384a585eee05c98f040299a0b303f22e" +checksum = "affa64aa63157f944acbe058a3bf54b67965c81ed37c001844daf8739156fc3a" dependencies = [ "swc_ecma_ast", "swc_ecma_parser", @@ -1504,6 +1506,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "typed-arena" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0685c84d5d54d1c26f7d3eb96cd41550adb97baed141a761cf335d3d33bcd0ae" + [[package]] name = "unicase" version = "2.6.0" diff --git a/Cargo.toml b/Cargo.toml index 3b0a2f3d5..1c354c6d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "deno_lint" -version = "0.17.0" +version = "0.18.0" edition = "2018" description = "lint for deno" authors = ["the Deno authors"] @@ -21,7 +21,7 @@ default = [] docs = [] [dependencies] -deno_ast = { version = "0.3.0", features = ["transforms", "utils", "visit", "view"] } +deno_ast = { version = "0.4.0", features = ["transforms", "utils", "visit", "view"] } log = "0.4.14" serde = { version = "1.0.125", features = ["derive"] } serde_json = "1.0.64" diff --git a/src/ast_parser.rs b/src/ast_parser.rs index b42644927..660655663 100644 --- a/src/ast_parser.rs +++ b/src/ast_parser.rs @@ -1,45 +1,14 @@ // Copyright 2020-2021 the Deno authors. All rights reserved. MIT license. use deno_ast::swc::parser::Syntax; +use deno_ast::Diagnostic; use deno_ast::MediaType; use deno_ast::ParsedSource; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Debug)] -pub struct SwcDiagnostic { - pub filename: String, - pub line_display: usize, - pub column_display: usize, - pub message: String, -} - -impl Error for SwcDiagnostic {} - -impl fmt::Display for SwcDiagnostic { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(&format!( - "{} at {}:{}:{}", - self.message, self.filename, self.line_display, self.column_display - )) - } -} - -impl SwcDiagnostic { - pub(crate) fn from_diagnostic(diagnostic: &deno_ast::Diagnostic) -> Self { - SwcDiagnostic { - line_display: diagnostic.display_position.line_number, - column_display: diagnostic.display_position.column_number, - filename: diagnostic.specifier.clone(), - message: diagnostic.message.clone(), - } - } -} pub(crate) fn parse_program( file_name: &str, syntax: Syntax, source_code: String, -) -> Result { +) -> Result { deno_ast::parse_program(deno_ast::ParseParams { specifier: file_name.to_string(), media_type: MediaType::Unknown, @@ -48,5 +17,4 @@ pub(crate) fn parse_program( maybe_syntax: Some(syntax), scope_analysis: true, }) - .map_err(|diagnostic| SwcDiagnostic::from_diagnostic(&diagnostic)) } diff --git a/src/linter.rs b/src/linter.rs index 6b83fdd45..38660ac45 100644 --- a/src/linter.rs +++ b/src/linter.rs @@ -1,6 +1,5 @@ // Copyright 2020-2021 the Deno authors. All rights reserved. MIT license. use crate::ast_parser::parse_program; -use crate::ast_parser::SwcDiagnostic; use crate::context::Context; use crate::control_flow::ControlFlow; use crate::diagnostic::LintDiagnostic; @@ -10,6 +9,7 @@ use crate::ignore_directives::{ use crate::rules::LintRule; use crate::scopes::Scope; use deno_ast::view::ProgramRef; +use deno_ast::Diagnostic; use deno_ast::MediaType; use deno_ast::ParsedSource; use std::sync::Arc; @@ -116,7 +116,7 @@ impl Linter { mut self, file_name: String, source_code: String, - ) -> Result<(ParsedSource, Vec), SwcDiagnostic> { + ) -> Result<(ParsedSource, Vec), Diagnostic> { let start = Instant::now(); let syntax = deno_ast::get_syntax(self.media_type);