1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-28 01:59:06 -05:00

upgrade: swc_ecma_visit, dprint, deno_lint (#6580)

This commit is contained in:
Bartek Iwańczuk 2020-07-01 16:04:56 +02:00 committed by GitHub
parent 7858ebd493
commit 851344f2ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 93 additions and 127 deletions

171
Cargo.lock generated
View file

@ -11,10 +11,10 @@ dependencies = [
]
[[package]]
name = "adler32"
version = "1.1.0"
name = "adler"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d"
checksum = "ccc9a9dd069569f212bc4330af9f17c4afb5e8ce185e83dbb14f1349dda18b10"
[[package]]
name = "ahash"
@ -86,9 +86,9 @@ dependencies = [
[[package]]
name = "async-compression"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae84766bab9f774e32979583ba56d6af8c701288c6dc99144819d5d2ee0b170f"
checksum = "9021768bcce77296b64648cc7a7460e3df99979b97ed5c925c38d1cc83778d98"
dependencies = [
"brotli",
"bytes 0.5.5",
@ -121,15 +121,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "base64"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
dependencies = [
"byteorder",
]
[[package]]
name = "base64"
version = "0.11.0"
@ -245,9 +236,9 @@ checksum = "5ba7d7f7b201dfcbc314b14f2176c92f8ba521dab538b40e426ffed25ed7cd80"
[[package]]
name = "cc"
version = "1.0.55"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1be3409f94d7bdceeb5f5fac551039d9b3f00e25da7a74fc4d33400a0d96368"
checksum = "77c1f1d60091c1b73e2b1f4560ab419204b178e625fa945ded7b660becd2bd46"
[[package]]
name = "cfg-if"
@ -419,7 +410,7 @@ dependencies = [
"tokio",
"tokio-rustls",
"tokio-tungstenite",
"url 2.1.1",
"url",
"utime",
"uuid",
"walkdir",
@ -442,14 +433,14 @@ dependencies = [
"rusty_v8",
"serde_json",
"tokio",
"url 2.1.1",
"url",
]
[[package]]
name = "deno_lint"
version = "0.1.10"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc10bb331262fd598e6925ab8b59f72b01cc9c3a5a818ce7d57652e4b23fe45a"
checksum = "71a734b89e863411db358088070812cb9c5d1b5075987ebf8ddb8257edc13bba"
dependencies = [
"lazy_static",
"regex",
@ -471,13 +462,13 @@ dependencies = [
[[package]]
name = "derive_deref"
version = "1.1.0"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11554fdb0aa42363a442e0c4278f51c9621e20c1ce3bac51d79e60646f3b8b8f"
checksum = "dcdbcee2d9941369faba772587a565f4f534e42cb8d17e5295871de730163b2b"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"syn 0.15.44",
"proc-macro2 1.0.18",
"quote 1.0.7",
"syn 1.0.33",
]
[[package]]
@ -520,9 +511,9 @@ dependencies = [
[[package]]
name = "downcast-rs"
version = "1.1.1"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ba6eb47c2131e784a38b726eb54c1e1484904f013e576a25354d0124161af6"
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]]
name = "dprint-core"
@ -535,9 +526,9 @@ dependencies = [
[[package]]
name = "dprint-plugin-typescript"
version = "0.19.3"
version = "0.19.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8239e653999a7061bb6a9a2a077d0c33fd5b760c594e8effe2715b8409d4acc6"
checksum = "98665d90ef9ba5d10a42a82be94266c7ce21cb6bf3d528a11abdf000efbc2689"
dependencies = [
"dprint-core",
"serde",
@ -611,9 +602,9 @@ dependencies = [
[[package]]
name = "flate2"
version = "1.0.14"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42"
checksum = "68c90b0fc46cf89d227cc78b40e494ff81287a92dd07631e5af0d06fe3cf885e"
dependencies = [
"cfg-if",
"crc32fast",
@ -970,17 +961,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
dependencies = [
"matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "idna"
version = "0.2.0"
@ -994,9 +974,9 @@ dependencies = [
[[package]]
name = "if_chain"
version = "0.1.3"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bac95d9aa0624e7b78187d6fb8ab012b41d9f6f54b1bcb61e61c4845f8357ec"
checksum = "c3360c7b59e5ffa2653671fb74b4741a5d343c03f331c0a4aeda42b5c2b0ec7d"
[[package]]
name = "indexmap"
@ -1053,9 +1033,9 @@ checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
[[package]]
name = "js-sys"
version = "0.3.40"
version = "0.3.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce10c23ad2ea25ceca0093bd3192229da4c5b3c0f2de499c1ecac0d98d452177"
checksum = "c4b9172132a62451e56142bff9afc91c8e4a4500aa5b847da36815b63bfda916"
dependencies = [
"wasm-bindgen",
]
@ -1184,11 +1164,11 @@ dependencies = [
[[package]]
name = "miniz_oxide"
version = "0.3.7"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435"
checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f"
dependencies = [
"adler32",
"adler",
]
[[package]]
@ -1224,9 +1204,9 @@ dependencies = [
[[package]]
name = "mio-named-pipes"
version = "0.1.6"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3"
checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656"
dependencies = [
"log 0.4.8",
"mio",
@ -1430,12 +1410,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "percent-encoding"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
[[package]]
name = "percent-encoding"
version = "2.1.0"
@ -1839,14 +1813,14 @@ dependencies = [
"log 0.4.8",
"mime 0.3.16",
"mime_guess 2.0.3",
"percent-encoding 2.1.0",
"percent-encoding",
"pin-project-lite",
"rustls",
"serde",
"serde_urlencoded",
"tokio",
"tokio-rustls",
"url 2.1.1",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@ -2020,9 +1994,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.55"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec2c5d7e739bc07a3e73381a39d61fdb5f671c60c1df26a130690665803d8226"
checksum = "3433e879a558dde8b5e8feb2a04899cf34fdde1fafb894687e52105fc1162ac3"
dependencies = [
"indexmap",
"itoa",
@ -2039,7 +2013,7 @@ dependencies = [
"dtoa",
"itoa",
"serde",
"url 2.1.1",
"url",
]
[[package]]
@ -2111,18 +2085,18 @@ dependencies = [
[[package]]
name = "sourcemap"
version = "5.0.0"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fd57aa9e5cea41b4a3c26a61039fad5585e2154ffe057a2656540a21b03a2d2"
checksum = "d7f42ca034bf301214458cf7f4dcbe7f680fd23d9e4c61193ed139684e2e3adc"
dependencies = [
"base64 0.10.1",
"base64 0.11.0",
"if_chain",
"lazy_static",
"regex",
"rustc_version",
"serde",
"serde_json",
"url 1.7.2",
"url",
]
[[package]]
@ -2199,9 +2173,9 @@ dependencies = [
[[package]]
name = "swc_common"
version = "0.5.12"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac5dc408a5004d6d82914e8c415f4c2a8c716b53ff766ab13af9bf0e5a286d98"
checksum = "86efe22e3fcdb96c77da0c6b03c81bfbdd6ea4821a9282b255f13aeb056ada91"
dependencies = [
"ast_node",
"atty",
@ -2222,9 +2196,9 @@ dependencies = [
[[package]]
name = "swc_ecma_ast"
version = "0.20.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb6105718e50b118ff100acda244b6df4f3f46de76b03e5d1baeaa3e69f97a6a"
checksum = "9ea8a035c2a77f4034266f19f6129a2146f3871ce4503a9baf8c069135bc43ba"
dependencies = [
"enum_kind",
"num-bigint",
@ -2236,9 +2210,9 @@ dependencies = [
[[package]]
name = "swc_ecma_parser"
version = "0.24.5"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b06bb3791cf307722bb7645f36509217649d36ac21e82493a37a8adcdce1d83"
checksum = "2d26e9b9c2fcc4d9359b6ae9fde65eedbada18058b1c0b683341e0c2a1bf58d4"
dependencies = [
"either",
"enum_kind",
@ -2270,9 +2244,9 @@ dependencies = [
[[package]]
name = "swc_ecma_visit"
version = "0.5.1"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43d08204c4454eee8dcef3f5f4b9f2104abd1540740e93ebc49677777553b7b5"
checksum = "571731480f3d9c6aa9d1f76563bd923823f28eb38e2e49822e1ffe9db3959c12"
dependencies = [
"num-bigint",
"swc_atoms",
@ -2547,7 +2521,7 @@ dependencies = [
"log 0.4.8",
"rand 0.7.3",
"sha-1",
"url 2.1.1",
"url",
"utf-8",
]
@ -2610,9 +2584,9 @@ checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
[[package]]
name = "unicode-width"
version = "0.1.7"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]]
name = "unicode-xid"
@ -2632,26 +2606,15 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "url"
version = "1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"
dependencies = [
"idna 0.1.5",
"matches",
"percent-encoding 1.0.1",
]
[[package]]
name = "url"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb"
dependencies = [
"idna 0.2.0",
"idna",
"matches",
"percent-encoding 2.1.0",
"percent-encoding",
]
[[package]]
@ -2771,9 +2734,9 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasm-bindgen"
version = "0.2.63"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c2dc4aa152834bc334f506c1a06b866416a8b6697d5c9f75b9a689c8486def0"
checksum = "6a634620115e4a229108b71bde263bb4220c483b3f07f5ba514ee8d15064c4c2"
dependencies = [
"cfg-if",
"serde",
@ -2783,9 +2746,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.63"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ded84f06e0ed21499f6184df0e0cb3494727b0c5da89534e0fcc55c51d812101"
checksum = "3e53963b583d18a5aa3aaae4b4c1cb535218246131ba22a71f05b518098571df"
dependencies = [
"bumpalo",
"lazy_static",
@ -2798,9 +2761,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.13"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64487204d863f109eb77e8462189d111f27cb5712cc9fdb3461297a76963a2f6"
checksum = "dba48d66049d2a6cc8488702e7259ab7afc9043ad0dc5448444f46f2a453b362"
dependencies = [
"cfg-if",
"js-sys",
@ -2810,9 +2773,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.63"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "838e423688dac18d73e31edce74ddfac468e37b1506ad163ffaf0a46f703ffe3"
checksum = "3fcfd5ef6eec85623b4c6e844293d4516470d8f19cd72d0d12246017eb9060b8"
dependencies = [
"quote 1.0.7",
"wasm-bindgen-macro-support",
@ -2820,9 +2783,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.63"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3156052d8ec77142051a533cdd686cba889537b213f948cd1d20869926e68e92"
checksum = "9adff9ee0e94b926ca81b57f57f86d5545cdcb1d259e21ec9bdd95b901754c75"
dependencies = [
"proc-macro2 1.0.18",
"quote 1.0.7",
@ -2833,15 +2796,15 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.63"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9ba19973a58daf4db6f352eda73dc0e289493cd29fb2632eb172085b6521acd"
checksum = "7f7b90ea6c632dd06fd765d44542e234d5e63d9bb917ecd64d79778a13bd79ae"
[[package]]
name = "web-sys"
version = "0.3.40"
version = "0.3.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b72fe77fd39e4bd3eaa4412fd299a0be6b3dfe9d2597e2f1c20beb968f41d17"
checksum = "863539788676619aac1a23e2df3655e96b32b0e05eb72ca34ba045ad573c625d"
dependencies = [
"js-sys",
"wasm-bindgen",

View file

@ -20,7 +20,7 @@ deno_typescript = { path = "../deno_typescript", version = "0.48.1" }
[dependencies]
deno_core = { path = "../core", version = "0.48.2" }
deno_lint = "0.1.10"
deno_lint = "0.1.12"
deno_typescript = { path = "../deno_typescript", version = "0.48.2" }
atty = "0.2.14"
@ -30,7 +30,7 @@ byteorder = "1.3.4"
clap = "2.33.1"
dissimilar = "1.0.2"
dlopen = "0.1.8"
dprint-plugin-typescript = "0.19.3"
dprint-plugin-typescript = "0.19.4"
futures = { version = "0.3.5", features = ["compat", "io-compat"] }
http = "0.2.1"
indexmap = "1.4.0"
@ -47,7 +47,7 @@ serde = { version = "1.0.112", features = ["derive"] }
serde_derive = "1.0.112"
serde_json = { version = "1.0.55", features = [ "preserve_order" ] }
sys-info = "0.7.0"
sourcemap = "5.0.0"
sourcemap = "6.0.0"
tempfile = "3.1.0"
termcolor = "1.1.0"
tokio = { version = "0.2.21", features = ["rt-core", "tcp", "udp", "uds", "process", "fs", "blocking", "sync", "io-std", "macros", "time"] }
@ -60,7 +60,7 @@ walkdir = "2.3.1"
warp = "0.2.3"
semver-parser = "0.9.0"
uuid = { version = "0.8.1", features = ["v4"] }
swc_ecma_visit = "0.5.1"
swc_ecma_visit = "0.7.0"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.8", features = ["knownfolders", "objbase", "shlobj",

View file

@ -121,7 +121,7 @@ impl Into<TsTypeDef> for &TsTupleType {
let mut type_defs = vec![];
for type_box in &self.elem_types {
let ts_type: &TsType = &(*type_box);
let ts_type: &TsType = &type_box.ty;
let def: TsTypeDef = ts_type.into();
type_defs.push(def)
}

View file

@ -12,11 +12,14 @@ use crate::file_fetcher::map_file_extension;
use crate::fmt::collect_files;
use crate::fmt::run_parallelized;
use crate::fmt_errors;
use crate::swc_ecma_parser::Syntax;
use crate::swc_util;
use deno_core::ErrBox;
use deno_lint::diagnostic::LintDiagnostic;
use deno_lint::linter::Linter;
use deno_lint::linter::LinterBuilder;
use deno_lint::rules;
use deno_lint::rules::LintRule;
use std::fs;
use std::path::PathBuf;
use std::sync::atomic::{AtomicUsize, Ordering};
@ -73,17 +76,19 @@ pub fn print_rules_list() {
}
}
fn create_linter() -> Linter {
Linter::new(
"deno-lint-ignore-file".to_string(),
vec![
"deno-lint-ignore".to_string(),
"eslint-disable-next-line".to_string(),
],
// TODO(bartlomieju): switch to true, once
// https://github.com/denoland/deno_lint/issues/156 is fixed
false,
)
fn create_linter(syntax: Syntax, rules: Vec<Box<dyn LintRule>>) -> Linter {
LinterBuilder::default()
.ignore_file_directives(vec!["deno-lint-ignore-file"])
.ignore_diagnostic_directives(vec![
"deno-lint-ignore",
"eslint-disable-next-line",
])
.lint_unused_ignore_directives(true)
// TODO(bartlomieju): switch to true
.lint_unknown_rules(false)
.syntax(syntax)
.rules(rules)
.build()
}
fn lint_file(file_path: PathBuf) -> Result<Vec<LintDiagnostic>, ErrBox> {
@ -92,11 +97,10 @@ fn lint_file(file_path: PathBuf) -> Result<Vec<LintDiagnostic>, ErrBox> {
let media_type = map_file_extension(&file_path);
let syntax = swc_util::get_syntax_for_media_type(media_type);
let mut linter = create_linter();
let lint_rules = rules::get_recommended_rules();
let mut linter = create_linter(syntax, lint_rules);
let file_diagnostics =
linter.lint(file_name, source_code, syntax, lint_rules)?;
let file_diagnostics = linter.lint(file_name, source_code)?;
Ok(file_diagnostics)
}

View file

@ -8,7 +8,6 @@ import {
// Allow 10 second difference.
// Note this might not be enough for FAT (but we are not testing on such fs).
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function assertFuzzyTimestampEquals(t1: Date | null, t2: Date): void {
assert(t1 instanceof Date);
assert(Math.abs(t1.valueOf() - t2.valueOf()) < 10_000);

View file

@ -91,7 +91,7 @@ export function normalizeGlob(
glob: string,
{ globstar = false }: GlobOptions = {}
): string {
if (!!glob.match(/\0/g)) {
if (glob.match(/\0/g)) {
throw new Error(`Glob contains invalid characters: "${glob}"`);
}
if (!globstar) {

View file

@ -328,13 +328,13 @@ export async function runBenchmarks(
if (!silent) {
// Closing results
console.log(
`benchmark result: ${!!failError ? red("FAIL") : blue("DONE")}. ` +
`benchmark result: ${failError ? red("FAIL") : blue("DONE")}. ` +
`${progress.results.length} measured; ${filtered} filtered`
);
}
// Throw error if there was a failing benchmark
if (!!failError) {
if (failError) {
throw failError;
}