+
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
22 changes: 14 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@

## [Unreleased]

## CLI
## Configuration
## Editors
## Formatter
## Linter
### CLI
### Configuration

#### Other changes

- Fix regression where a specific combination of configuration didn't load
the correct rules to apply [#4502](https://github.com/rome/tools/issues/4502)

### Editors
### Formatter
### Linter

#### Other changes

- `noInnerDeclarations`: allow function declarations in nested block inside an _ES module_ [#4492](https://github.com/rome/tools/compare/main...Conaclos:noInnerDeclarations/4492?expand=1).
- `noInvalidConstructorSuper`: recognize `extends` clauses that use static member access such as `extends mod.C` [#4499](https://github.com/rome/tools/issues/4499)

## Parser
## VSCode
## JavaScript APIs
### Parser
### VSCode
### JavaScript APIs

## 12.1.1

Expand Down
50 changes: 50 additions & 0 deletions crates/rome_cli/tests/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2170,3 +2170,53 @@ fn should_not_enable_all_recommended_rules() {
result,
));
}

#[test]
fn should_not_disable_recommended_rules_for_a_group() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let configuration = r#" {
"$schema": "https://docs.rome.tools/schemas/12.1.0/schema.json",
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noUselessSwitchCase": "off"
}
}
}
}"#;

let configuration_path = Path::new("rome.json");
fs.insert(configuration_path.into(), configuration.as_bytes());

let file_path = Path::new("fix.js");
fs.insert(
file_path.into(),
r#"const array = ["split", "the text", "into words"];
// next line should error because of the recommended rule
array.map((sentence) => sentence.split(" ")).flat();
"#,
);

let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]),
);

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

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"should_not_disable_recommended_rules_for_a_group",
fs,
console,
result,
));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
source: crates/rome_cli/tests/snap_test.rs
expression: content
---
## `rome.json`

```json
{
"$schema": "https://docs.rome.tools/schemas/12.1.0/schema.json",
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noUselessSwitchCase": "off"
}
}
}
}
```

## `fix.js`

```js
const array = ["split", "the text", "into words"];
// next line should error because of the recommended rule
array.map((sentence) => sentence.split(" ")).flat();

```

# Termination Message

```block
internalError/io ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Some errors were emitted while running checks



```

# Emitted Messages

```block
fix.js:3:1 lint/complexity/useFlatMap FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× The call chain .map().flat() can be replaced with a single .flatMap() call.

1 │ const array = ["split", "the text", "into words"];
2 │ // next line should error because of the recommended rule
> 3 │ array.map((sentence) => sentence.split(" ")).flat();
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 │

i Safe fix: Replace the chain with .flatMap().

1 1 │ const array = ["split", "the text", "into words"];
2 2 │ // next line should error because of the recommended rule
3 │ - array.map((sentence)·=>·sentence.split("·")).flat();
3 │ + array.flatMap((sentence)·=>·sentence.split("·"));
4 4 │


```

```block
Checked 1 file(s) in <TIME>
```


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