diff --git a/CHANGELOG.md b/CHANGELOG.md index c688b932e78..ad56ee0cfb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,47 @@ # Rome changelog +## 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](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 c = '"content" \' '; + ``` +- 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/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" } 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(); 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..eed0ed84f82 --- /dev/null +++ b/website/src/_includes/docs/ci.md @@ -0,0 +1,15 @@ +## CI + +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. + +### 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..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). @@ -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..137ddd680e3 --- /dev/null +++ b/website/src/_includes/docs/linter.md @@ -0,0 +1,37 @@ +## 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. + + +### 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 + +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 %}