From 26cf7fd65b12d2fd12aff06dcefd86c76ed6d8bb Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:17:42 +0200 Subject: [PATCH 1/2] Make JS Lints have lower severity --- crates/turbopack-swc-utils/src/emitter.rs | 32 +++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/crates/turbopack-swc-utils/src/emitter.rs b/crates/turbopack-swc-utils/src/emitter.rs index ae1db280c35de..bcc3a206c9a59 100644 --- a/crates/turbopack-swc-utils/src/emitter.rs +++ b/crates/turbopack-swc-utils/src/emitter.rs @@ -47,6 +47,26 @@ impl Emitter for IssueEmitter { DiagnosticId::Error(s) => format!("error {s}").into(), DiagnosticId::Lint(s) => format!("lint {s}").into(), }); + let is_lint = db + .code + .as_ref() + .map_or(false, |d| matches!(d, DiagnosticId::Lint(_))); + + let severity = (if is_lint { + IssueSeverity::Suggestion + } else { + match level { + Level::Bug => IssueSeverity::Bug, + Level::Fatal | Level::PhaseFatal => IssueSeverity::Fatal, + Level::Error => IssueSeverity::Error, + Level::Warning => IssueSeverity::Warning, + Level::Note => IssueSeverity::Note, + Level::Help => IssueSeverity::Hint, + Level::Cancelled => IssueSeverity::Error, + Level::FailureNote => IssueSeverity::Note, + } + }) + .cell(); let title; if let Some(t) = self.title.as_ref() { @@ -63,17 +83,7 @@ impl Emitter for IssueEmitter { // TODO add other primary and secondary spans with labels as sub_issues let issue = AnalyzeIssue { - severity: match level { - Level::Bug => IssueSeverity::Bug, - Level::Fatal | Level::PhaseFatal => IssueSeverity::Fatal, - Level::Error => IssueSeverity::Error, - Level::Warning => IssueSeverity::Warning, - Level::Note => IssueSeverity::Note, - Level::Help => IssueSeverity::Hint, - Level::Cancelled => IssueSeverity::Error, - Level::FailureNote => IssueSeverity::Note, - } - .cell(), + severity, source_ident: self.source.ident(), title: Vc::cell(title), message: StyledString::Text(message.into()).cell(), From 4b92f78c00a2a8b20484babd8d60139e414cca28 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:20:37 +0200 Subject: [PATCH 2/2] Update test snapshot: warning -> suggestion --- ...1001__ import(FreeVar(Math)[__quo__ra-955b10.txt} | 2 +- ...1002__ require(FreeVar(Math)[__quo__r-2fe3ef.txt} | 2 +- ...P1004__ fs.readFileSync(FreeVar(Math)[-45dc7a.txt | 12 ------------ ...P1004__ fs.readFileSync(FreeVar(Math)[-4d16cb.txt | 12 ++++++++++++ ...1004__ fs.readFileSync(FreeVar(Math)[-95872b.txt} | 2 +- ...1005__ child_process.spawnSync(FreeVa-865e8b.txt} | 2 +- ...t TP1005__ child_process.spawnSync(__-20e03e.txt} | 2 +- ...1005__ child_process.spawnSync(__quo_-9f6b1d.txt} | 2 +- ...P1201__ new URL(Variable(unknown##2), -2b31a0.txt | 10 ++++++++++ ...P1201__ new URL(Variable(unknown##2), -f5ba3f.txt | 10 ---------- 10 files changed, 28 insertions(+), 28 deletions(-) rename crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/{__l___lint TP1001__ import(FreeVar(Math)[__quo__ra-fcce98.txt => __l___lint TP1001__ import(FreeVar(Math)[__quo__ra-955b10.txt} (51%) rename crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/{__l___lint TP1002__ require(FreeVar(Math)[__quo__r-fa7bb4.txt => __l___lint TP1002__ require(FreeVar(Math)[__quo__r-2fe3ef.txt} (55%) delete mode 100644 crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-45dc7a.txt create mode 100644 crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-4d16cb.txt rename crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/{__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-d5af53.txt => __l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-95872b.txt} (50%) rename crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/{__l___lint TP1005__ child_process.spawnSync(FreeVa-fa7b47.txt => __l___lint TP1005__ child_process.spawnSync(FreeVa-865e8b.txt} (58%) rename crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/{__l___lint TP1005__ child_process.spawnSync(__-a30479.txt => __l___lint TP1005__ child_process.spawnSync(__-20e03e.txt} (67%) rename crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/{__l___lint TP1005__ child_process.spawnSync(__quo_-a93044.txt => __l___lint TP1005__ child_process.spawnSync(__quo_-9f6b1d.txt} (56%) create mode 100644 crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1201__ new URL(Variable(unknown##2), -2b31a0.txt delete mode 100644 crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1201__ new URL(Variable(unknown##2), -f5ba3f.txt diff --git a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1001__ import(FreeVar(Math)[__quo__ra-fcce98.txt b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1001__ import(FreeVar(Math)[__quo__ra-955b10.txt similarity index 51% rename from crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1001__ import(FreeVar(Math)[__quo__ra-fcce98.txt rename to crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1001__ import(FreeVar(Math)[__quo__ra-955b10.txt index ef6e8298a5d80..95ccc8ddf81b4 100644 --- a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1001__ import(FreeVar(Math)[__quo__ra-fcce98.txt +++ b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1001__ import(FreeVar(Math)[__quo__ra-955b10.txt @@ -1,4 +1,4 @@ -warning - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:12:0 lint TP1001 import(FreeVar(Math)["random"]()) is very dynamic +suggestion - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:12:0 lint TP1001 import(FreeVar(Math)["random"]()) is very dynamic 8 | child_process.spawnSync("node", [unknown, unknown]); 9 | diff --git a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1002__ require(FreeVar(Math)[__quo__r-fa7bb4.txt b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1002__ require(FreeVar(Math)[__quo__r-2fe3ef.txt similarity index 55% rename from crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1002__ require(FreeVar(Math)[__quo__r-fa7bb4.txt rename to crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1002__ require(FreeVar(Math)[__quo__r-2fe3ef.txt index 3a5080fea30e1..8da6fa2d7c20d 100644 --- a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1002__ require(FreeVar(Math)[__quo__r-fa7bb4.txt +++ b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1002__ require(FreeVar(Math)[__quo__r-2fe3ef.txt @@ -1,4 +1,4 @@ -warning - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:10:0 lint TP1002 require(FreeVar(Math)["random"]()) is very dynamic +suggestion - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:10:0 lint TP1002 require(FreeVar(Math)["random"]()) is very dynamic 6 | child_process.spawnSync(unknown); 7 | child_process.spawnSync("node", unknown); diff --git a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-45dc7a.txt b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-45dc7a.txt deleted file mode 100644 index 6a31c28da0d86..0000000000000 --- a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-45dc7a.txt +++ /dev/null @@ -1,12 +0,0 @@ -warning - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:15:0 lint TP1004 fs.readFileSync(FreeVar(Math)["random"]()) is very dynamic - - 11 | - 12 | import(unknown); - 13 | - 14 | fs.readFileSync(unknown); - + v-------------------v - 15 + readFileSync(unknown); - + ^-------------------^ - 16 | - 17 | new URL(unknown, import.meta.url); - 18 | \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-4d16cb.txt b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-4d16cb.txt new file mode 100644 index 0000000000000..ffaa1d79805f4 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-4d16cb.txt @@ -0,0 +1,12 @@ +suggestion - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:15:0 lint TP1004 fs.readFileSync(FreeVar(Math)["random"]()) is very dynamic + + 11 | + 12 | import(unknown); + 13 | + 14 | fs.readFileSync(unknown); + + v-------------------v + 15 + readFileSync(unknown); + + ^-------------------^ + 16 | + 17 | new URL(unknown, import.meta.url); + 18 | \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-d5af53.txt b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-95872b.txt similarity index 50% rename from crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-d5af53.txt rename to crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-95872b.txt index 3c5e2740bce66..6c99ff019b159 100644 --- a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-d5af53.txt +++ b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1004__ fs.readFileSync(FreeVar(Math)[-95872b.txt @@ -1,4 +1,4 @@ -warning - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:14:0 lint TP1004 fs.readFileSync(FreeVar(Math)["random"]()) is very dynamic +suggestion - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:14:0 lint TP1004 fs.readFileSync(FreeVar(Math)["random"]()) is very dynamic 10 | require(unknown); 11 | diff --git a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(FreeVa-fa7b47.txt b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(FreeVa-865e8b.txt similarity index 58% rename from crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(FreeVa-fa7b47.txt rename to crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(FreeVa-865e8b.txt index bbb5163b08b7f..a30014aab385e 100644 --- a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(FreeVa-fa7b47.txt +++ b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(FreeVa-865e8b.txt @@ -1,4 +1,4 @@ -warning - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:6:0 lint TP1005 child_process.spawnSync(FreeVar(Math)["random"]()) is very dynamic +suggestion - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:6:0 lint TP1005 child_process.spawnSync(FreeVar(Math)["random"]()) is very dynamic 2 | import fs, { readFileSync } from "node:fs"; 3 | diff --git a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__-a30479.txt b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__-20e03e.txt similarity index 67% rename from crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__-a30479.txt rename to crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__-20e03e.txt index adab944608ee8..9b942623ed58c 100644 --- a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__-a30479.txt +++ b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__-20e03e.txt @@ -1,4 +1,4 @@ -warning - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:8:0 lint TP1005 child_process.spawnSync( +suggestion - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:8:0 lint TP1005 child_process.spawnSync( 4 | const unknown = Math.random(); 5 | diff --git a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__quo_-a93044.txt b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__quo_-9f6b1d.txt similarity index 56% rename from crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__quo_-a93044.txt rename to crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__quo_-9f6b1d.txt index abac239782e5c..92e4ce8b38b23 100644 --- a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__quo_-a93044.txt +++ b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1005__ child_process.spawnSync(__quo_-9f6b1d.txt @@ -1,4 +1,4 @@ -warning - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:7:0 lint TP1005 child_process.spawnSync("node", FreeVar(Math)["random"]()) is very dynamic +suggestion - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:7:0 lint TP1005 child_process.spawnSync("node", FreeVar(Math)["random"]()) is very dynamic 3 | 4 | const unknown = Math.random(); diff --git a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1201__ new URL(Variable(unknown##2), -2b31a0.txt b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1201__ new URL(Variable(unknown##2), -2b31a0.txt new file mode 100644 index 0000000000000..943dcd443ee26 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1201__ new URL(Variable(unknown##2), -2b31a0.txt @@ -0,0 +1,10 @@ +suggestion - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:17:0 lint TP1201 new URL(Variable(unknown##2), import.meta.url) is very dynamic + + 13 | + 14 | fs.readFileSync(unknown); + 15 | readFileSync(unknown); + 16 | + + v-------------------------------v + 17 + new URL(unknown, import.meta.url); + + ^-------------------------------^ + 18 | \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1201__ new URL(Variable(unknown##2), -f5ba3f.txt b/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1201__ new URL(Variable(unknown##2), -f5ba3f.txt deleted file mode 100644 index e96bb52573d90..0000000000000 --- a/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/issues/__l___lint TP1201__ new URL(Variable(unknown##2), -f5ba3f.txt +++ /dev/null @@ -1,10 +0,0 @@ -warning - [analysis] [project]/crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js /crates/turbopack-tests/tests/snapshot/dynamic-request/very-dynamic/input/index.js:17:0 lint TP1201 new URL(Variable(unknown##2), import.meta.url) is very dynamic - - 13 | - 14 | fs.readFileSync(unknown); - 15 | readFileSync(unknown); - 16 | - + v-------------------------------v - 17 + new URL(unknown, import.meta.url); - + ^-------------------------------^ - 18 | \ No newline at end of file