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

Commit

Permalink
Merge branch 'main' into fix-4353
Browse files Browse the repository at this point in the history
  • Loading branch information
unvalley authored May 15, 2023
2 parents ce2deaa + 0cb1680 commit 8f7bea2
Show file tree
Hide file tree
Showing 7 changed files with 513 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#### Other changes

- 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)
- Fix an issue that [`noUnusedVariables`](https://docs.rome.tools/lint/rules/nounusedvariables/) rule did not correctly detect exports when a variable and an `interface` had the same name [#4468](https://github.com/rome/tools/pull/4468)

### Parser
Expand Down
8 changes: 4 additions & 4 deletions benchmark/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const BENCHMARKS = {
repository: "https://github.com/prettier/prettier.git",
sourceDirectories: {
src: ["js"],
scripts: ["js", "mjs"],
scripts: ["js"],
},
},
},
Expand Down Expand Up @@ -80,7 +80,7 @@ function benchmarkFormatter(rome) {

const dprintCommand = `${resolveDprint()} fmt --incremental=false --config '${require.resolve("./dprint.json")}' ${Object.keys(configuration.sourceDirectories).map(path => `'${path}/**/*'`).join(" ")}`;

const romeCommand = `${rome} format ${Object.keys(
const romeCommand = `${rome} format --max-diagnostics=0 ${Object.keys(
configuration.sourceDirectories,
)
.map((path) => `'${path}'`)
Expand All @@ -93,7 +93,7 @@ function benchmarkFormatter(rome) {
);

// Run 2 warmups to make sure the files are formatted correctly
const hyperfineCommand = `hyperfine -w 2 -n Prettier "${prettierCommand}" -n "Parallel-Prettier" "${parallelPrettierCommand}" -n dprint "${dprintCommand}" -n Rome "${romeCommand}" --shell=${shellOption()} -n "Rome (1 thread)" "${romeSingleCoreCommand}"`;
const hyperfineCommand = `hyperfine --show-output -w 2 -n Prettier "${prettierCommand}" -n "Parallel-Prettier" "${parallelPrettierCommand}" -n dprint "${dprintCommand}" -n Rome "${romeCommand}" --shell=${shellOption()} -n "Rome (1 thread)" "${romeSingleCoreCommand}"`;
console.log(hyperfineCommand);

child_process.execSync(hyperfineCommand, {
Expand All @@ -108,7 +108,7 @@ function resolvePrettier() {
}

function resolveParallelPrettier() {
return path.resolve("node_modules/.bin/pprettier");
return path.resolve("node_modules/@mixer/parallel-prettier/dist/index.js");
}

function resolveDprint() {
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 8f7bea2

Please sign in to comment.