diff --git a/CHANGELOG.md b/CHANGELOG.md index bbc823b96e0..ae8877fc64e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/crates/rome_cli/tests/commands/check.rs b/crates/rome_cli/tests/commands/check.rs index e830cd92d6e..754d066a1b8 100644 --- a/crates/rome_cli/tests/commands/check.rs +++ b/crates/rome_cli/tests/commands/check.rs @@ -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, + )); +} diff --git a/crates/rome_cli/tests/snapshots/main_commands_check/apply_unsafe_no_assign_in_expression.snap b/crates/rome_cli/tests/snapshots/main_commands_check/apply_unsafe_no_assign_in_expression.snap new file mode 100644 index 00000000000..ea1ea59d5ac --- /dev/null +++ b/crates/rome_cli/tests/snapshots/main_commands_check/apply_unsafe_no_assign_in_expression.snap @@ -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