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

feat(rome_js_analyze): promote rules #3471

Merged
merged 23 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d031329
feat(rome_js_analyze): add support for spread props in various rules
ematipico Oct 18, 2022
4ebbb96
chore: rebase
ematipico Oct 18, 2022
2976503
chore: code suggestions
ematipico Oct 21, 2022
ce84f80
chore: code suggestions
ematipico Oct 25, 2022
609a784
chore: rebase
ematipico Oct 25, 2022
f243f4c
feat(rome_js_analyze): add support for spread props in various rules
ematipico Oct 18, 2022
fa875b2
chore: better auto focus code action
ematipico Oct 21, 2022
09a7bdb
feat(rome_js_analyze): promote rules
ematipico Oct 21, 2022
cd3a70b
chore: rebase
ematipico Oct 25, 2022
c11f3c4
chore: promote more rules, review groups
ematipico Oct 25, 2022
533a7b2
chore: update json file and playground
ematipico Oct 25, 2022
fec25a9
chore: promote rules
ematipico Oct 26, 2022
c13adc2
feat: support spread props
ematipico Oct 26, 2022
1a33291
feat: support spread props
ematipico Oct 26, 2022
a5881e7
fix regressions
ematipico Oct 27, 2022
2865649
`noDebugger` under `correctness`
ematipico Oct 27, 2022
a798ba5
Merge remote-tracking branch 'origin/main' into feature/promote-rules-v2
ematipico Oct 27, 2022
74c69b9
fix merge
ematipico Oct 27, 2022
0139d44
Merge remote-tracking branch 'origin/main' into feature/promote-rules-v2
ematipico Oct 28, 2022
24e9223
chore: merge
ematipico Oct 28, 2022
6007b66
Merge remote-tracking branch 'origin/main' into feature/promote-rules-v2
ematipico Nov 1, 2022
e254b4a
Merge remote-tracking branch 'origin/main' into feature/promote-rules-v2
ematipico Nov 1, 2022
f4eb5f6
chore: merge
ematipico Nov 1, 2022
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
28 changes: 7 additions & 21 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 @@ -516,7 +512,7 @@ fn downgrade_severity() {
.filter(|m| m.level == LogLevel::Error)
.filter(|m| {
let content = format!("{:#?}", m.content);
content.contains("correctness/noDebugger")
content.contains("security/noDebugger")
})
.count(),
1
Expand All @@ -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
21 changes: 11 additions & 10 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 @@ -98,7 +100,7 @@ pub const CONFIG_LINTER_SUPPRESSED_RULE: &str = r#"{
"linter": {
"rules": {
"recommended": true,
"correctness": {
"security": {
"noDebugger": "off"
}
}
Expand All @@ -120,7 +122,7 @@ pub const CONFIG_LINTER_DOWNGRADE_DIAGNOSTIC: &str = r#"{
"linter": {
"rules": {
"recommended": true,
"correctness": {
"security": {
"recommended": true,
"noDebugger": "warn"
}
Expand All @@ -133,8 +135,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 @@ -9,7 +9,7 @@ expression: content
"linter": {
"rules": {
"recommended": true,
"correctness": {
"security": {
"recommended": true,
"noDebugger": "warn"
}
Expand All @@ -27,7 +27,7 @@ debugger;
# Emitted Messages

```block
file.js:1:1 lint/correctness/noDebugger FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
file.js:1:1 lint/security/noDebugger FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! This is an unexpected use of the debugger statement.

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