Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make JS Lints have lower severity #8837

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions crates/turbopack-swc-utils/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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 |
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 |
Original file line number Diff line number Diff line change
@@ -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 |
Expand Down
Original file line number Diff line number Diff line change
@@ -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 |
Expand Down
Original file line number Diff line number Diff line change
@@ -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 |
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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 |

This file was deleted.

Loading