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

Commit

Permalink
fix(rome_js_analyze): Files with fn(() => (aborted = true)); cause -e…
Browse files Browse the repository at this point in the history
…ntered unreachable code - when --apply-unsafe #4464 (#4473)

* fix(rome_js_analyze): Files with fn(() => (aborted = true)); cause - entered unreachable code - when --apply-unsafe #4464
  • Loading branch information
denbezrukov authored May 15, 2023
1 parent 362a39d commit 0cb1680
Show file tree
Hide file tree
Showing 6 changed files with 509 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Editors
### Formatter
### Linter
- Fixed an issue where the `noAssignInExpressions` rule replaced the operator with an invalid token, which caused other lint rules to crash. [#4464](https://github.com/rome/tools/issues/4464)
### Parser
### VSCode
### JavaScript APIs
Expand Down
32 changes: 32 additions & 0 deletions crates/rome_cli/tests/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2080,3 +2080,35 @@ fn should_apply_correct_file_source() {
result,
));
}

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

let file_path = Path::new("fix.js");
fs.insert(
file_path.into(),
"res.onAborted(() => (aborted = true));".as_bytes(),
);

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

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

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

```js
res.onAborted(() => aborted === true);

```

# Emitted Messages

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


Loading

0 comments on commit 0cb1680

Please sign in to comment.