+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.
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
2 changes: 1 addition & 1 deletion benchmark/bench.rome.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"noDebugger": "error",
"noDelete": "error",
"noDoubleEquals": "error",
"noDupeArgs": "error",
"noDuplicateParameters": "error",
"noEmptyPattern": "error",
"noFunctionAssign": "error",
"noImportAssign": "error",
Expand Down
12 changes: 6 additions & 6 deletions crates/rome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,19 +626,19 @@ fn range_match(filter: Option<TextRange>, range: TextRange) -> bool {
///
/// - `// rome-ignore format` -> `vec![]`
/// - `// rome-ignore lint` -> `vec![Everything]`
/// - `// rome-ignore lint/correctness/useWhile` -> `vec![Rule("correctness/useWhile")]`
/// - `// rome-ignore lint/correctness/useWhile lint/nursery/noUnreachable` -> `vec![Rule("correctness/useWhile"), Rule("nursery/noUnreachable")]`
/// - `// rome-ignore lint(correctness/useWhile)` -> `vec![MaybeLegacy("correctness/useWhile")]`
/// - `// rome-ignore lint(correctness/useWhile) lint(nursery/noUnreachable)` -> `vec![MaybeLegacy("correctness/useWhile"), MaybeLegacy("nursery/noUnreachable")]`
/// - `// rome-ignore lint/style/useWhile` -> `vec![Rule("style/useWhile")]`
/// - `// rome-ignore lint/style/useWhile lint/nursery/noUnreachable` -> `vec![Rule("style/useWhile"), Rule("nursery/noUnreachable")]`
/// - `// rome-ignore lint(style/useWhile)` -> `vec![MaybeLegacy("style/useWhile")]`
/// - `// rome-ignore lint(style/useWhile) lint(nursery/noUnreachable)` -> `vec![MaybeLegacy("style/useWhile"), MaybeLegacy("nursery/noUnreachable")]`
type SuppressionParser<D> = fn(&str) -> Vec<Result<SuppressionKind, D>>;

/// This enum is used to categorize what is disabled by a suppression comment and with what syntax
pub enum SuppressionKind<'a> {
/// A suppression disabling all lints eg. `// rome-ignore lint`
Everything,
/// A suppression disabling a specific rule eg. `// rome-ignore lint/correctness/useWhile`
/// A suppression disabling a specific rule eg. `// rome-ignore lint/style/useWhile`
Rule(&'a str),
/// A suppression using the legacy syntax to disable a specific rule eg. `// rome-ignore lint(correctness/useWhile)`
/// A suppression using the legacy syntax to disable a specific rule eg. `// rome-ignore lint(style/useWhile)`
MaybeLegacy(&'a str),
}

Expand Down
18 changes: 10 additions & 8 deletions crates/rome_cli/tests/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);for(;true;);
"#;

const NO_DEBUGGER: &str = "debugger;";
const NEW_SYMBOL: &str = "new Symbol(\"\");";

const FIX_BEFORE: &str = "
if(a != -0) {}
Expand Down Expand Up @@ -68,8 +69,7 @@ const UPGRADE_SEVERITY_CODE: &str = r#"class A extends B {
constructor() {}
}"#;

const NURSERY_UNSTABLE: &str = r#"const array = ["split", "the text", "into words"];
array.map(sentence => sentence.split(' ')).flat();"#;
const NURSERY_UNSTABLE: &str = r#"if(a = b) {}"#;

#[test]
fn ok() {
Expand Down Expand Up @@ -174,6 +174,8 @@ fn maximum_diagnostics() {
Arguments::from_vec(vec![OsString::from("check"), file_path.as_os_str().into()]),
);

println!("{console:#?}");

assert!(result.is_err(), "run_cli returned {result:?}");

let messages = &console.out_buffer;
Expand All @@ -193,7 +195,7 @@ fn maximum_diagnostics() {
let content = format!("{:?}", m.content);
content.contains("The number of diagnostics exceeds the number allowed by Rome")
&& content.contains("Diagnostics not shown")
&& content.contains("76")
&& content.contains("28")
}));

assert_cli_snapshot(SnapshotPayload::new(
Expand Down Expand Up @@ -539,7 +541,7 @@ fn downgrade_severity() {
.filter(|m| m.level == LogLevel::Error)
.filter(|m| {
let content = format!("{:#?}", m.content);
content.contains("correctness/noDebugger")
content.contains("suspicious/noDebugger")
})
.count(),
1
Expand Down Expand Up @@ -993,7 +995,7 @@ fn max_diagnostics_default() {
let mut console = BufferConsole::default();

// Creates 40 diagnostics.
for i in 0..20 {
for i in 0..40 {
let file_path = PathBuf::from(format!("src/file_{i}.js"));
fs.insert(file_path, LINT_ERROR.as_bytes());
}
Expand Down Expand Up @@ -1043,7 +1045,7 @@ fn max_diagnostics() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

for i in 0..10 {
for i in 0..20 {
let file_path = PathBuf::from(format!("src/file_{i}.js"));
fs.insert(file_path, LINT_ERROR.as_bytes());
}
Expand Down Expand Up @@ -1123,7 +1125,7 @@ fn deprecated_suppression_comment() {
let file_path = Path::new("file.js");
fs.insert(
file_path.into(),
*b"// rome-ignore lint(correctness/noDoubleEquals): test
*b"// rome-ignore lint(suspicious/noDoubleEquals): test
a == b;",
);

Expand Down Expand Up @@ -1244,7 +1246,7 @@ fn config_recommended_group() {
fs.insert(file_path.into(), CONFIG_RECOMMENDED_GROUP.as_bytes());

let file_path = Path::new("check.js");
fs.insert(file_path.into(), NO_DEBUGGER.as_bytes());
fs.insert(file_path.into(), NEW_SYMBOL.as_bytes());

let result = run_cli(
DynRef::Borrowed(&mut fs),
Expand Down
10 changes: 6 additions & 4 deletions crates/rome_cli/tests/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ pub const CONFIG_ALL_FIELDS: &str = r#"{
}
},
"correctness": {
"noUnreachable": "off"
},
"suspicious": {
"noCatchAssign": "error",
"noLabelVar": {
"level": "warn"
},
"noUnreachable": "off"
}
}
}
},
Expand Down Expand Up @@ -110,7 +112,7 @@ pub const CONFIG_LINTER_SUPPRESSED_RULE: &str = r#"{
"linter": {
"rules": {
"recommended": true,
"correctness": {
"suspicious": {
"noDebugger": "off"
}
}
Expand All @@ -132,7 +134,7 @@ pub const CONFIG_LINTER_DOWNGRADE_DIAGNOSTIC: &str = r#"{
"linter": {
"rules": {
"recommended": true,
"correctness": {
"suspicious": {
"noDebugger": "warn"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ expression: content
## `check.js`

```js
debugger;
new Symbol("");
```

# Termination Message
Expand All @@ -32,17 +32,17 @@ some errors were emitted while running checks
# Emitted Messages

```block
check.js:1:1 lint/correctness/noDebugger FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
check.js:1:1 lint/correctness/noNewSymbol FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× This is an unexpected use of the debugger statement.
× Symbol cannot be called as a constructor.

> 1 │ debugger;
│ ^^^^^^^^^
> 1 │ new Symbol("");
│ ^^^^^^^^^^^^^^

i Suggested fix: Remove debugger statement
i Suggested fix: Remove new.

1 │ debugger;
│ ---------
1 │ new·Symbol("");
│ ----

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expression: content
## `file.js`

```js
// rome-ignore lint(correctness/noDoubleEquals): test
// rome-ignore lint(suspicious/noDoubleEquals): test
a == b;
```

Expand All @@ -16,14 +16,14 @@ file.js:1:1 suppressions/deprecatedSyntax FIXABLE ━━━━━━━━━

! Suppression is using a deprecated syntax

> 1 │ // rome-ignore lint(correctness/noDoubleEquals): test
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 1 │ // rome-ignore lint(suspicious/noDoubleEquals): test
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │ a == b;

i Safe fix: Rewrite suppression to use the newer syntax

1 │ - //·rome-ignore·lint(correctness/noDoubleEquals):·test
1 │ + //·rome-ignore·lint/correctness/noDoubleEquals:·test
1 │ - //·rome-ignore·lint(suspicious/noDoubleEquals):·test
1 │ + //·rome-ignore·lint/suspicious/noDoubleEquals:·test
2 2 │ a == b;


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": {
"suspicious": {
"noDebugger": "warn"
}
}
Expand All @@ -26,7 +26,7 @@ debugger;
# Emitted Messages

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

! This is an unexpected use of the debugger statement.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ some errors were emitted while running checks
# Emitted Messages

```block
check.js:1:1 lint/correctness/useWhile FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
check.js:1:1 lint/style/useWhile FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Use while loops instead of for loops.

Expand All @@ -33,24 +33,6 @@ check.js:1:1 lint/correctness/useWhile FIXABLE ━━━━━━━━━━
2 2 │


```

```block
check.js:1:1 lint/style/useBlockStatements FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Block statements are preferred in this position.

> 1 │ for(;true;);
│ ^^^^^^^^^^^^
2 │

i Suggested fix: Wrap the statement with a `JsBlockStatement`

1 │ - for(;true;);
1 │ + for(;true;)·{}
2 2 │


```

```block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,76 @@ for(;true;);

```

## `src/file_10.js`

```js
for(;true;);

```

## `src/file_11.js`

```js
for(;true;);

```

## `src/file_12.js`

```js
for(;true;);

```

## `src/file_13.js`

```js
for(;true;);

```

## `src/file_14.js`

```js
for(;true;);

```

## `src/file_15.js`

```js
for(;true;);

```

## `src/file_16.js`

```js
for(;true;);

```

## `src/file_17.js`

```js
for(;true;);

```

## `src/file_18.js`

```js
for(;true;);

```

## `src/file_19.js`

```js
for(;true;);

```

## `src/file_2.js`

```js
Expand Down Expand Up @@ -86,7 +156,7 @@ Diagnostics not shown: 10.
```

```block
Checked 10 file(s) in <TIME>
Checked 20 file(s) in <TIME>
```


Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载