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

refactor(rome_js_analyze): groups #3192

Merged
merged 12 commits into from
Sep 13, 2022
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
4 changes: 2 additions & 2 deletions crates/rome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ where
///
/// - `// rome-ignore format` -> `vec![]`
/// - `// rome-ignore lint` -> `vec![None]`
/// - `// rome-ignore lint(js/useWhile)` -> `vec![Some("js/useWhile")]`
/// - `// rome-ignore lint(js/useWhile) lint(js/noDeadCode)` -> `vec![Some("js/useWhile"), Some("js/noDeadCode")]`
/// - `// rome-ignore lint(correctness/useWhile)` -> `vec![Some("correctness/useWhile")]`
/// - `// rome-ignore lint(correctness/useWhile) lint(nursery/noUnreachable)` -> `vec![Some("correctness/useWhile"), Some("nursery/noUnreachable")]`
type SuppressionParser = fn(&str) -> Vec<Option<&str>>;

type SignalHandler<'a, L, Break> = &'a mut dyn FnMut(&dyn AnalyzerSignal<L>) -> ControlFlow<Break>;
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_analyze/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub struct RuleSuppressions<L: Language> {
}

impl<L: Language> RuleSuppressions<L> {
/// Supress query matching for the given node
/// Suppress query matching for the given node
pub fn suppress_node(&mut self, node: SyntaxNode<L>) {
self.inner.insert(node);
}
Expand Down
20 changes: 11 additions & 9 deletions crates/rome_cli/tests/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ pub const CONFIG_ALL_FIELDS: &str = r#"{
"linter": {
"enabled": true,
"rules": {
"js": {
"noDeadCode": "off",
"correctness": {
"useSimplifiedLogicExpression": "warn",
"noCatchAssign": "error",
"noLabelVar": {
Expand All @@ -45,6 +44,9 @@ pub const CONFIG_ALL_FIELDS: &str = r#"{
"useTemplate": {
"level": "error"
}
},
"nursery": {
"noUnreachable": "off"
}
}
},
Expand Down Expand Up @@ -73,10 +75,10 @@ pub const CONFIG_LINTER_WRONG_RULE: &str = r#"{
"linter": {
"enabled": true,
"rules": {
"js": {
"correctness": {
"foo_rule": "off"
},
"jsx": {
"style": {
"what_the_hell": "off"
}
}
Expand All @@ -96,7 +98,7 @@ pub const CONFIG_LINTER_SUPPRESSED_RULE: &str = r#"{
"linter": {
"rules": {
"recommended": true,
"js": {
"correctness": {
"noDebugger": "off"
}
}
Expand All @@ -107,7 +109,7 @@ pub const CONFIG_LINTER_SUPPRESSED_GROUP: &str = r#"{
"linter": {
"rules": {
"recommended": true,
"js": {
"correctness": {
"recommended": false
}
}
Expand All @@ -118,7 +120,7 @@ pub const CONFIG_LINTER_DOWNGRADE_DIAGNOSTIC: &str = r#"{
"linter": {
"rules": {
"recommended": true,
"js": {
"correctness": {
"recommended": true,
"noDebugger": "warn"
}
Expand All @@ -130,8 +132,8 @@ pub const CONFIG_LINTER_UPGRADE_DIAGNOSTIC: &str = r#"{
"linter": {
"rules": {
"recommended": true,
"js": {
"noDeadCode": "error"
"nursery": {
"noUnreachable": "error"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/rome_cli/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ mod check {
.filter(|m| m.level == LogLevel::Error)
.filter(|m| {
let content = format!("{:#?}", m.content);
content.contains("js/noDebugger")
content.contains("correctness/noDebugger")
})
.count(),
1
Expand Down Expand Up @@ -606,7 +606,7 @@ mod check {
.filter(|m| m.level == LogLevel::Error)
.filter(|m| {
let content = format!("{:?}", m.content);
content.contains("js/noDeadCode")
content.contains("nursery/noUnreachable")
})
.count(),
1
Expand All @@ -617,7 +617,7 @@ mod check {
.filter(|m| m.level == LogLevel::Error)
.filter(|m| {
let content = format!("{:?}", m.content);
content.contains("js/noUnusedVariables")
content.contains("nursery/noUnusedVariables")
})
.count(),
1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ expression: content
"linter": {
"rules": {
"recommended": true,
"js": {
"correctness": {
"recommended": true,
"noDebugger": "warn"
}
Expand All @@ -27,7 +27,7 @@ debugger;
# Emitted Messages

```block
warning[js/noDebugger]: This is an unexpected use of the debugger statement.
warning[correctness/noDebugger]: This is an unexpected use of the debugger statement.
┌─ file.js:1:1
1 │ debugger;
Expand Down
4 changes: 2 additions & 2 deletions crates/rome_cli/tests/snapshots/main_check/lint_error.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ errors where emitted while running checks
# Emitted Messages

```block
error[js/useBlockStatements]: Block statements are preferred in this position.
error[correctness/useBlockStatements]: Block statements are preferred in this position.
┌─ check.js:1:1
1 │ for(;true;);
Expand All @@ -33,7 +33,7 @@ Suggested fix: Wrap the statement with a `JsBlockStatement`
```

```block
error[js/useWhile]: Use while loops instead of for loops.
error[correctness/useWhile]: Use while loops instead of for loops.
┌─ check.js:1:1
1 │ for(;true;);
Expand Down
40 changes: 20 additions & 20 deletions crates/rome_cli/tests/snapshots/main_check/maximum_diagnostics.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ errors where emitted while running checks
# Emitted Messages

```block
error[js/useBlockStatements]: Block statements are preferred in this position.
error[correctness/useBlockStatements]: Block statements are preferred in this position.
┌─ check.js:2:1
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -45,7 +45,7 @@ Suggested fix: Wrap the statement with a `JsBlockStatement`
```

```block
error[js/useWhile]: Use while loops instead of for loops.
error[correctness/useWhile]: Use while loops instead of for loops.
┌─ check.js:2:1
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -64,7 +64,7 @@ Suggested fix: Use a while loop
```

```block
error[js/useBlockStatements]: Block statements are preferred in this position.
error[correctness/useBlockStatements]: Block statements are preferred in this position.
┌─ check.js:2:13
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -83,7 +83,7 @@ Suggested fix: Wrap the statement with a `JsBlockStatement`
```

```block
error[js/useWhile]: Use while loops instead of for loops.
error[correctness/useWhile]: Use while loops instead of for loops.
┌─ check.js:2:13
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -102,7 +102,7 @@ Suggested fix: Use a while loop
```

```block
error[js/useBlockStatements]: Block statements are preferred in this position.
error[correctness/useBlockStatements]: Block statements are preferred in this position.
┌─ check.js:2:25
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -121,7 +121,7 @@ Suggested fix: Wrap the statement with a `JsBlockStatement`
```

```block
error[js/useWhile]: Use while loops instead of for loops.
error[correctness/useWhile]: Use while loops instead of for loops.
┌─ check.js:2:25
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -140,7 +140,7 @@ Suggested fix: Use a while loop
```

```block
error[js/useBlockStatements]: Block statements are preferred in this position.
error[correctness/useBlockStatements]: Block statements are preferred in this position.
┌─ check.js:2:37
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -159,7 +159,7 @@ Suggested fix: Wrap the statement with a `JsBlockStatement`
```

```block
error[js/useWhile]: Use while loops instead of for loops.
error[correctness/useWhile]: Use while loops instead of for loops.
┌─ check.js:2:37
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -178,7 +178,7 @@ Suggested fix: Use a while loop
```

```block
error[js/useBlockStatements]: Block statements are preferred in this position.
error[correctness/useBlockStatements]: Block statements are preferred in this position.
┌─ check.js:2:49
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -197,7 +197,7 @@ Suggested fix: Wrap the statement with a `JsBlockStatement`
```

```block
error[js/useWhile]: Use while loops instead of for loops.
error[correctness/useWhile]: Use while loops instead of for loops.
┌─ check.js:2:49
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -216,7 +216,7 @@ Suggested fix: Use a while loop
```

```block
error[js/useBlockStatements]: Block statements are preferred in this position.
error[correctness/useBlockStatements]: Block statements are preferred in this position.
┌─ check.js:2:61
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -235,7 +235,7 @@ Suggested fix: Wrap the statement with a `JsBlockStatement`
```

```block
error[js/useWhile]: Use while loops instead of for loops.
error[correctness/useWhile]: Use while loops instead of for loops.
┌─ check.js:2:61
2 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -254,7 +254,7 @@ Suggested fix: Use a while loop
```

```block
error[js/useBlockStatements]: Block statements are preferred in this position.
error[correctness/useBlockStatements]: Block statements are preferred in this position.
┌─ check.js:3:1
3 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -274,7 +274,7 @@ Suggested fix: Wrap the statement with a `JsBlockStatement`
```

```block
error[js/useWhile]: Use while loops instead of for loops.
error[correctness/useWhile]: Use while loops instead of for loops.
┌─ check.js:3:1
3 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -294,7 +294,7 @@ Suggested fix: Use a while loop
```

```block
error[js/useBlockStatements]: Block statements are preferred in this position.
error[correctness/useBlockStatements]: Block statements are preferred in this position.
┌─ check.js:3:13
3 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -314,7 +314,7 @@ Suggested fix: Wrap the statement with a `JsBlockStatement`
```

```block
error[js/useWhile]: Use while loops instead of for loops.
error[correctness/useWhile]: Use while loops instead of for loops.
┌─ check.js:3:13
3 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -334,7 +334,7 @@ Suggested fix: Use a while loop
```

```block
error[js/useBlockStatements]: Block statements are preferred in this position.
error[correctness/useBlockStatements]: Block statements are preferred in this position.
┌─ check.js:3:25
3 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -354,7 +354,7 @@ Suggested fix: Wrap the statement with a `JsBlockStatement`
```

```block
error[js/useWhile]: Use while loops instead of for loops.
error[correctness/useWhile]: Use while loops instead of for loops.
┌─ check.js:3:25
3 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -374,7 +374,7 @@ Suggested fix: Use a while loop
```

```block
error[js/useBlockStatements]: Block statements are preferred in this position.
error[correctness/useBlockStatements]: Block statements are preferred in this position.
┌─ check.js:3:37
3 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand All @@ -394,7 +394,7 @@ Suggested fix: Wrap the statement with a `JsBlockStatement`
```

```block
error[js/useWhile]: Use while loops instead of for loops.
error[correctness/useWhile]: Use while loops instead of for loops.
┌─ check.js:3:37
3 │ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/rome_cli/tests/snap_test.rs
assertion_line: 147
expression: content
---
## `rome.json`
Expand All @@ -10,7 +9,7 @@ expression: content
"linter": {
"rules": {
"recommended": true,
"js": {
"correctness": {
"noDebugger": "off"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ expression: content
"linter": {
"rules": {
"recommended": true,
"js": {
"correctness": {
"recommended": false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ expression: content
"linter": {
"rules": {
"recommended": true,
"js": {
"noDeadCode": "error"
"nursery": {
"noUnreachable": "error"
}
}
}
Expand Down Expand Up @@ -38,7 +38,7 @@ errors where emitted while running checks
# Emitted Messages

```block
error[js/noDeadCode]: This code is unreachable
error[nursery/noUnreachable]: This code is unreachable
┌─ file.js:3:9
3 │ ┌ continue;
Expand All @@ -49,7 +49,7 @@ error[js/noDeadCode]: This code is unreachable
```

```block
error[js/noUnusedVariables]: This function is unused.
error[nursery/noUnusedVariables]: This function is unused.
┌─ file.js:1:10
1 │ function f() {
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载