Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
feat(rome_js_analyze): promote rules (#3471)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Nov 1, 2022
1 parent 5953607 commit 22dd11d
Show file tree
Hide file tree
Showing 284 changed files with 2,453 additions and 1,791 deletions.
26 changes: 6 additions & 20 deletions crates/rome_cli/tests/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,9 @@ const JS_ERRORS_AFTER: &str = "try {
}
";

const NO_DEAD_CODE_ERROR: &str = r#"function f() {
for (;;) {
continue;
break;
}
}
"#;
const UPGRADE_SEVERITY_CODE: &str = r#"class A extends B {
constructor() {}
}"#;

#[test]
fn ok() {
Expand Down Expand Up @@ -542,7 +538,7 @@ fn upgrade_severity() {
);

let file_path = Path::new("file.js");
fs.insert(file_path.into(), NO_DEAD_CODE_ERROR.as_bytes());
fs.insert(file_path.into(), UPGRADE_SEVERITY_CODE.as_bytes());

let result = run_cli(
DynRef::Borrowed(&mut fs),
Expand All @@ -554,24 +550,14 @@ fn upgrade_severity() {

let messages = &console.out_buffer;

dbg!(&result);
assert_eq!(
messages
.iter()
.filter(|m| m.level == LogLevel::Error)
.filter(|m| {
let content = format!("{:?}", m.content);
content.contains("nursery/noUnreachable")
})
.count(),
1
);
assert_eq!(
messages
.iter()
.filter(|m| m.level == LogLevel::Error)
.filter(|m| {
let content = format!("{:?}", m.content);
content.contains("nursery/noUnusedVariables")
content.contains("nursery/noInvalidConstructorSuper")
})
.count(),
1
Expand Down
18 changes: 9 additions & 9 deletions crates/rome_cli/tests/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ pub const CONFIG_ALL_FIELDS: &str = r#"{
"linter": {
"enabled": true,
"rules": {
"complexity": {
"useSimplifiedLogicExpression": "warn"
},
"style": {
"useTemplate": {
"level": "error"
}
},
"correctness": {
"useSimplifiedLogicExpression": "warn",
"noCatchAssign": "error",
"noLabelVar": {
"level": "warn"
},
"useTemplate": {
"level": "error"
}
},
"nursery": {
"noUnreachable": "off"
}
}
Expand Down Expand Up @@ -121,7 +123,6 @@ pub const CONFIG_LINTER_DOWNGRADE_DIAGNOSTIC: &str = r#"{
"rules": {
"recommended": true,
"correctness": {
"recommended": true,
"noDebugger": "warn"
}
}
Expand All @@ -133,8 +134,7 @@ pub const CONFIG_LINTER_UPGRADE_DIAGNOSTIC: &str = r#"{
"rules": {
"recommended": true,
"nursery": {
"noUnreachable": "error",
"noUnusedVariables": "error"
"noInvalidConstructorSuper": "error"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ expression: content
"rules": {
"recommended": true,
"correctness": {
"recommended": true,
"noDebugger": "warn"
}
}
Expand Down
20 changes: 10 additions & 10 deletions crates/rome_cli/tests/snapshots/main_commands_check/lint_error.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,36 @@ errors where emitted while running checks
# Emitted Messages

```block
check.js:1:1 lint/correctness/useBlockStatements FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
check.js:1:1 lint/correctness/useWhile FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Block statements are preferred in this position.
× Use while loops instead of for loops.
> 1 │ for(;true;);
│ ^^^^^^^^^^^^
│ ^^^^^^^^^^^
2 │
i Suggested fix: Wrap the statement with a `JsBlockStatement`
i Suggested fix: Use a while loop
1 │ - for(;true;);
1 │ + for(;true;)·{}
1 │ + while·(true);
2 2 │
```

```block
check.js:1:1 lint/correctness/useWhile FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
check.js:1:1 lint/style/useBlockStatements FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Use while loops instead of for loops.
× Block statements are preferred in this position.
> 1 │ for(;true;);
│ ^^^^^^^^^^^
│ ^^^^^^^^^^^^
2 │
i Suggested fix: Use a while loop
i Suggested fix: Wrap the statement with a `JsBlockStatement`
1 │ - for(;true;);
1 │ + while·(true);
1 │ + for(;true;)·{}
2 2 │
Expand Down
Loading

0 comments on commit 22dd11d

Please sign in to comment.