From d40816475aaeeefc8771b5e28a09401aff105a5f Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 6 Jun 2022 12:05:52 -0300 Subject: [PATCH 1/7] release: 0.6.0 --- CHANGELOG.md | 27 ++++++++++++++++++++ editors/vscode/package-lock.json | 4 +-- editors/vscode/package.json | 2 +- npm/rome/package.json | 2 +- website/src/_includes/docs/ci.md | 15 +++++++++++ website/src/_includes/docs/formatter.md | 3 --- website/src/_includes/docs/linter.md | 33 +++++++++++++++++++++++++ website/src/index.md | 2 ++ 8 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 website/src/_includes/docs/ci.md create mode 100644 website/src/_includes/docs/linter.md diff --git a/CHANGELOG.md b/CHANGELOG.md index c688b932e78..1e8a704ac3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Rome changelog +## 0.6.0 + +- BREAKING CHANGES: the command `rome format --ci` has been removed, use `rome ci` instead. +- Improved the compatibility with Prettier (check #2403 for more details): + - TypeScript's formatting is now in line with what Prettier does. + - Better formatting of string literals. The formatter now does a lot of cleaning: + ```js + // original code + let a = { + "something": 3 + } + let b = "cool ins\'t it"; + + // formatted code + let a = { + someething: 3 + } + let b = "cool ins't it"; + ``` + - Better formatting of various statements + - Improved the performance of the formatting of averagely 20%! Check the [relative +PR](https://github.com/rome/tools/pull/2634) if you're interested of what the team did. + +To reach a better compatibility with Prettier, the team had to review the foundation of our printer, +which caused some regressions around how comments are printed. These are known issues that we +plan to close by next release. + ## 0.5.0 - BREAKING CHANGES: the `format` command doesn't write on disk by default. Now the command prints on terminal. diff --git a/editors/vscode/package-lock.json b/editors/vscode/package-lock.json index 35274c44685..a21096a597f 100644 --- a/editors/vscode/package-lock.json +++ b/editors/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "rome", - "version": "0.6.0", + "version": "0.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rome", - "version": "0.6.0", + "version": "0.8.0", "license": "MIT", "dependencies": { "vscode-languageclient": "^8.0.0-next.13" diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 98bc9c2db6d..3491a2fd62c 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -3,7 +3,7 @@ "publisher": "rome", "displayName": "Rome", "description": "Rome LSP VS Code Extension", - "version": "0.6.0", + "version": "0.8.0", "icon": "icon.png", "activationEvents": [ "onLanguage:javascript", diff --git a/npm/rome/package.json b/npm/rome/package.json index ab7122dec16..d0edcad96b1 100644 --- a/npm/rome/package.json +++ b/npm/rome/package.json @@ -1,6 +1,6 @@ { "name": "rome", - "version": "0.5.0-next", + "version": "0.6.0-next", "bin": "bin/rome", "scripts": { "postinstall": "node scripts/postinstall.js" diff --git a/website/src/_includes/docs/ci.md b/website/src/_includes/docs/ci.md new file mode 100644 index 00000000000..1dd31fe06d7 --- /dev/null +++ b/website/src/_includes/docs/ci.md @@ -0,0 +1,15 @@ +## CI + +Rome comes with a CI mode that allows run multiple CI checks jsut by +running one single command. + +This mode is only available via CLI. + +### Use CI mode via CLI + +```shell +rome ci +``` + +This command will: +- run the formatter in check mode \ No newline at end of file diff --git a/website/src/_includes/docs/formatter.md b/website/src/_includes/docs/formatter.md index 84f293275aa..435042b7518 100644 --- a/website/src/_includes/docs/formatter.md +++ b/website/src/_includes/docs/formatter.md @@ -35,8 +35,6 @@ appear only for documents that Rome supports. ### Use the formatter with the CLI -The only command that is supported is `format`. - You can start by running the CLI with the `--help` flag: ```shell @@ -55,7 +53,6 @@ USAGE: OPTIONS: --write Write the output of the formatter to the files instead of printing the diff to the console - --ci Enable CI mode, lock files and exit with an error if the formatter would modify them --skip-errors Skip over files containing syntax errors instead of returning an error --indent-style Determine whether the formatter should use tabs or spaces for indentation (default: tabs) --indent-size If the indentation style is set to spaces, determine how many spaces should be used for indentation (default: 2) diff --git a/website/src/_includes/docs/linter.md b/website/src/_includes/docs/linter.md new file mode 100644 index 00000000000..ba9eda26160 --- /dev/null +++ b/website/src/_includes/docs/linter.md @@ -0,0 +1,33 @@ +## Linter + +You can use the linter via our [VS Code extension] or by downloading our CLI directly from our [release page]. + +> WARNING: The CLI and VS Code extension are packaged with separate binaries, which means that if you don't +> use our default options, you will have to **pass them to both the extension AND the CLI**. +> +> This is a temporary choice to allow people to play with our formatter. This will change in the near future. + + +> WARNING: this command is experimental for the time being won't do anything + +### Use the formatter via CLI + +You can start by running the CLI with the `--help` flag: + +```shell +rome check --help +``` + +Which will show you the options available at the moment: + +```shell +USAGE: + rome check + + INPUTS can be one or more filesystem path, each pointing to a single file or an entire directory to be searched recursively for supported files + +``` + + +[VS Code extension]: https://marketplace.visualstudio.com/items?itemName=rome.rome +[release page]: https://github.com/rome/tools/releases diff --git a/website/src/index.md b/website/src/index.md index 372c7521a20..9745063648c 100644 --- a/website/src/index.md +++ b/website/src/index.md @@ -8,5 +8,7 @@ layout: layouts/homepage.liquid {% include docs/getting-started.md %} {% include docs/status.md %} {% include docs/formatter.md %} +{% include docs/linter.md %} +{% include docs/ci.md %} {% include docs/philosophy.md %} {% include docs/_old_diagnostic-anatomy.md %} From a72d151d3a75490071eeff9bd0ebbbdf5e401a69 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 6 Jun 2022 18:11:23 +0100 Subject: [PATCH 2/7] Apply suggestions from code review Co-authored-by: Yasser Elassal --- CHANGELOG.md | 6 +++--- website/src/_includes/docs/ci.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e8a704ac3f..90a2683b212 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,10 +20,10 @@ let b = "cool ins't it"; ``` - Better formatting of various statements - - Improved the performance of the formatting of averagely 20%! Check the [relative -PR](https://github.com/rome/tools/pull/2634) if you're interested of what the team did. + - Improved the performance of the formatter an average of 20%! Check the [relevant +PR](https://github.com/rome/tools/pull/2634) if you're interested in what the team did. -To reach a better compatibility with Prettier, the team had to review the foundation of our printer, +To reach better compatibility with Prettier, the team had to revise the foundation of our printer, which caused some regressions around how comments are printed. These are known issues that we plan to close by next release. diff --git a/website/src/_includes/docs/ci.md b/website/src/_includes/docs/ci.md index 1dd31fe06d7..eed0ed84f82 100644 --- a/website/src/_includes/docs/ci.md +++ b/website/src/_includes/docs/ci.md @@ -1,6 +1,6 @@ ## CI -Rome comes with a CI mode that allows run multiple CI checks jsut by +Rome comes with a CI mode that allows performing multiple CI checks just by running one single command. This mode is only available via CLI. From 475ee0fd0903f05107a82823722060432a2f7313 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 6 Jun 2022 19:27:09 +0100 Subject: [PATCH 3/7] Update CHANGELOG.md Co-authored-by: strager --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90a2683b212..0fc77d4a673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ // formatted code let a = { - someething: 3 + something: 3 } let b = "cool ins't it"; ``` From 0690abbe91ce71295b024b4ff09345248edc0691 Mon Sep 17 00:00:00 2001 From: l3ops Date: Tue, 7 Jun 2022 11:02:36 +0200 Subject: [PATCH 4/7] downgrade the severity level of lint rules to warning --- crates/rome_analyze/src/analyzers/no_double_equals.rs | 2 +- crates/rome_analyze/src/analyzers/use_while.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/rome_analyze/src/analyzers/no_double_equals.rs b/crates/rome_analyze/src/analyzers/no_double_equals.rs index 9169a29e37d..122a7b60421 100644 --- a/crates/rome_analyze/src/analyzers/no_double_equals.rs +++ b/crates/rome_analyze/src/analyzers/no_double_equals.rs @@ -34,7 +34,7 @@ impl Rule for NoDoubleEquals { fn diagnostic(_: &Self::Query, op: &Self::State) -> Option { Some(RuleDiagnostic { - severity: Severity::Error, + severity: Severity::Warning, message: markup! { "Do not use the "{op.text_trimmed()}" operator" } diff --git a/crates/rome_analyze/src/analyzers/use_while.rs b/crates/rome_analyze/src/analyzers/use_while.rs index 53b25cbe338..6ca52ee3037 100644 --- a/crates/rome_analyze/src/analyzers/use_while.rs +++ b/crates/rome_analyze/src/analyzers/use_while.rs @@ -46,7 +46,7 @@ impl Rule for UseWhile { fn diagnostic(node: &Self::Query, _: &Self::State) -> Option { Some(RuleDiagnostic { - severity: Severity::Error, + severity: Severity::Warning, message: markup! { "Use a while loop instead of a for loop" } From 6afa7d3e7b00aa1b6d166b708789939a33c9e0bc Mon Sep 17 00:00:00 2001 From: l3ops Date: Tue, 7 Jun 2022 11:21:29 +0200 Subject: [PATCH 5/7] update the tests for the changed lint rules --- crates/rome_analyze/tests/specs/noDoubleEquals.js.snap | 9 +++++---- crates/rome_analyze/tests/specs/useWhile.js.snap | 5 +++-- crates/rome_cli/tests/main.rs | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/rome_analyze/tests/specs/noDoubleEquals.js.snap b/crates/rome_analyze/tests/specs/noDoubleEquals.js.snap index 9263d747c10..4beeec5fb26 100644 --- a/crates/rome_analyze/tests/specs/noDoubleEquals.js.snap +++ b/crates/rome_analyze/tests/specs/noDoubleEquals.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_analyze/tests/spec_tests.rs +assertion_line: 96 expression: noDoubleEquals.js --- # Input @@ -14,11 +15,11 @@ const isNonNull = a != null; # Diagnostics ``` -error[noDoubleEquals]: Do not use the == operator +warning[noDoubleEquals]: Do not use the == operator ┌─ noDoubleEquals.js:1:18 │ 1 │ const isZero = a == 0; - │ ^^ Do not use the == operator + │ -- Do not use the == operator Replace with strict equality | @@ -1,4 +1,4 @@ @@ -32,11 +33,11 @@ Replace with strict equality ``` ``` -error[noDoubleEquals]: Do not use the != operator +warning[noDoubleEquals]: Do not use the != operator ┌─ noDoubleEquals.js:2:21 │ 2 │ const isNonZero = a != 0; - │ ^^ Do not use the != operator + │ -- Do not use the != operator Replace with strict equality | @@ -1,5 +1,5 @@ diff --git a/crates/rome_analyze/tests/specs/useWhile.js.snap b/crates/rome_analyze/tests/specs/useWhile.js.snap index 5cce68d3d3c..9d2e9178a3a 100644 --- a/crates/rome_analyze/tests/specs/useWhile.js.snap +++ b/crates/rome_analyze/tests/specs/useWhile.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_analyze/tests/spec_tests.rs +assertion_line: 96 expression: useWhile.js --- # Input @@ -12,11 +13,11 @@ for (; true; ) {} # Diagnostics ``` -error[useWhile]: Use a while loop instead of a for loop +warning[useWhile]: Use a while loop instead of a for loop ┌─ useWhile.js:3:1 │ 3 │ for (; true; ) {} - │ ^^^^^^^^^^^^^^^^^ Use a while loop instead of a for loop + │ ----------------- Use a while loop instead of a for loop Use a while loop | @@ -1,3 +1,3 @@ diff --git a/crates/rome_cli/tests/main.rs b/crates/rome_cli/tests/main.rs index 9802274a91c..b3a51939ecd 100644 --- a/crates/rome_cli/tests/main.rs +++ b/crates/rome_cli/tests/main.rs @@ -55,6 +55,7 @@ mod check { } #[test] + #[ignore = "lint errors are disabled until the linter is stable"] fn lint_error() { let mut fs = MemoryFileSystem::default(); From 507c81f0ade64ef0b55b65d035b5add86f014eba Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 7 Jun 2022 11:53:22 +0100 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Micha Reiser --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fc77d4a673..bc130172dbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ let a = { "something": 3 } - let b = "cool ins\'t it"; + let b = "cool isn\'t it"; // formatted code let a = { @@ -20,8 +20,8 @@ let b = "cool ins't it"; ``` - Better formatting of various statements - - Improved the performance of the formatter an average of 20%! Check the [relevant -PR](https://github.com/rome/tools/pull/2634) if you're interested in what the team did. + - Improved the performance of the formatter an average of 20%! Check the relevant +PRs [1](https://github.com/rome/tools/pull/2456), [2](https://github.com/rome/tools/pull/2638), [3](https://github.com/rome/tools/pull/2612), [4](https://github.com/rome/tools/pull/2462), [5](https://github.com/rome/tools/pull/2634) if you're interested in what the team did. To reach better compatibility with Prettier, the team had to revise the foundation of our printer, which caused some regressions around how comments are printed. These are known issues that we From f3879e7a9976cedfe71748d1f690ca651ca89a29 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 7 Jun 2022 08:07:36 -0300 Subject: [PATCH 7/7] chore: code review suggestions --- CHANGELOG.md | 29 +++++++++++++++++++------ website/src/_includes/docs/formatter.md | 2 +- website/src/_includes/docs/linter.md | 6 ++++- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc130172dbe..ad56ee0cfb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,31 +2,46 @@ ## 0.6.0 +### Formatter + - BREAKING CHANGES: the command `rome format --ci` has been removed, use `rome ci` instead. -- Improved the compatibility with Prettier (check #2403 for more details): - - TypeScript's formatting is now in line with what Prettier does. - - Better formatting of string literals. The formatter now does a lot of cleaning: + +#### Improved the compatibility with Prettier (check [#2403](https://github.com/rome/tools/issues/2403) for more details) + +- TypeScript's formatting is better in line with what Prettier does. +- Better formatting of string literals. +Removing unnecessary quotes in string literals and quotes from member names. +Correctly choose the correct quote based on quantity of quotes inside a literal: ```js // original code let a = { "something": 3 } let b = "cool isn\'t it"; + let c = "\"content\" ' "; // formatted code let a = { something: 3 } - let b = "cool ins't it"; + let b = "cool ins't it"; + let c = '"content" \' '; ``` - - Better formatting of various statements - - Improved the performance of the formatter an average of 20%! Check the relevant +- Better formatting of various statements +- Improved the performance of the formatter an average of 20%-30%! Check the relevant PRs [1](https://github.com/rome/tools/pull/2456), [2](https://github.com/rome/tools/pull/2638), [3](https://github.com/rome/tools/pull/2612), [4](https://github.com/rome/tools/pull/2462), [5](https://github.com/rome/tools/pull/2634) if you're interested in what the team did. - + To reach better compatibility with Prettier, the team had to revise the foundation of our printer, which caused some regressions around how comments are printed. These are known issues that we plan to close by next release. +### Linter + +We've built the foundation of our linter. At the moment is only opt-in, and it contains +only a bunch of rules. **Safe fixes are not enabled yet via CLI**. + +Refer to the [website](https://rome.tools/#linter) to learn how to start using it. + ## 0.5.0 - BREAKING CHANGES: the `format` command doesn't write on disk by default. Now the command prints on terminal. diff --git a/website/src/_includes/docs/formatter.md b/website/src/_includes/docs/formatter.md index 435042b7518..fe49ad7ab02 100644 --- a/website/src/_includes/docs/formatter.md +++ b/website/src/_includes/docs/formatter.md @@ -16,7 +16,7 @@ Our formatter is really strict and has support for only a few options: - quantity of spaces, applied only if you choose spaces as indent style; - line width, which is the number of characters that fit in a single line; **Rome's default is `80`** -### VSCode extension +### Use the formatter via VSCode extension The extension allows you to change the default [formatter options](#formatter-options). diff --git a/website/src/_includes/docs/linter.md b/website/src/_includes/docs/linter.md index ba9eda26160..137ddd680e3 100644 --- a/website/src/_includes/docs/linter.md +++ b/website/src/_includes/docs/linter.md @@ -8,7 +8,11 @@ You can use the linter via our [VS Code extension] or by downloading our CLI dir > This is a temporary choice to allow people to play with our formatter. This will change in the near future. -> WARNING: this command is experimental for the time being won't do anything +### Use the formatter via VSCode extension + +The feature is opt-in, and you'd need to enable the following options: +- `analysis.enableDiagnostics` +- `analysis.enableCodeActions` ### Use the formatter via CLI