release: 0.9.0
MODIFY
CHANGELOG.md
CHANGELOG.md
# Rome changelog
+## 0.9.0
+
+### CLI
+
+- You can now format content from standard input when using the command `rome format`:
+```shell
+echo "function f() { return {} }" | rome format --stdin-file-path example.js
+```
+the argument `--stdin-file-path` is mandatory when formatting from standard in. The path should represent a
+file name with its extension.
+- Added `--apply-suggested` argument to the `rome check` command, to apply suggested and safe fixes.
+Suggested fixes should be considered **unstable** and applied with care.
+- Added the `rome start` and `rome stop` commands to control the Rome daemon server process.
+- Added the `--use-server` global flag to the command line to make the CLI connect to a running instance of the
+Rome daemon server.
+
+### Configuration
+
+- **BREAKING CHANGE**: removed the second `"rules"` field from a field group.
+```diff
+{
+ "linter": {
+ "enabled": true,
+ "rules": {
+ "js": {
++ "noDebugger": "off"
+- "rules": {
+- "noDebugger": "off"
+- },
+ }
+ }
+ }
+}
+```
+- fixed a problem that was incorrectly turning off rules in certain circumstances
+
+### Formatter
+
+Significantly improved formatting and prettier compatibility of:
+
+* JSX [#3144](https://github.com/rome/tools/pull/3144)
+* Conditional expression and conditional types [#2427](https://github.com/rome/tools/issues/2427)
+* Function signatures [#2993](https://github.com/rome/tools/pull/2993), [#2990](https://github.com/rome/tools/pull/2990)
+* Return and throw statements [#2986](https://github.com/rome/tools/pull/2986)
+* Logical and binary expressions [#3079](https://github.com/rome/tools/pull/3079)
+* Templates [#3063](https://github.com/rome/tools/pull/3063)
+* Arrow expression chains [#3122](https://github.com/rome/tools/pull/3122)
+* Member expression assignments [#3061](https://github.com/rome/tools/pull/3061)
+* Array expressions [#3126](https://github.com/rome/tools/pull/3126)
+* Parenthesized expressions and types, including inserting parentheses to improve readability [#3057](https://github.com/rome/tools/pull/3057), [#3083](https://github.com/rome/tools/pull/3083), [#3108](https://github.com/rome/tools/pull/3108)
+* Doc comments [#3129](https://github.com/rome/tools/pull/3129)
+
+### Linter
+
+- Changed the default severity for recommended rules to "error". You can [change the severity in the rome.json](https://rome.tools/#configure-a-rule).
+- Added [`js/noExtraBooleanCast`](https://rome.tools/docs/lint/rules/noExtraBooleanCast/) lint rule.
+- Added [`js/noDupeArgs`](https://rome.tools/docs/lint/rules/noDupeArgs/) lint rule.
+- Added [`js/noShadowRestrictedNames`](https://rome.tools/docs/lint/rules/noShadowRestrictedNames/) lint rule.
+- Added `js/inlineVariable` code action.
+- Applied various stability fixes to the rule [`js/noUnusedVariables`](https://rome.tools/docs/lint/rules/noUnusedVariables/). [#3124](https://github.com/rome/tools/pull/3124) [#3060](https://github.com/rome/tools/pull/3060) [#3004](https://github.com/rome/tools/pull/3004)
+- Fixed how the suggestion is applied [`js/noNegationElse`](https://rome.tools/docs/lint/rules/noNegationElse/). [#2999](https://github.com/rome/tools/issues/2999)
+- Fixed a false positive in the rule [`js/noShoutyConstants`](https://rome.tools/docs/lint/rules/noShoutyConstants/). [#3077](https://github.com/rome/tools/issues/3077)
+- Fixed a false positive in the rule [`ts/useShorthandArrayType`](https://rome.tools/docs/lint/rules/useShorthandArrayType/). [#3111](https://github.com/rome/tools/issues/3111)
+
+### VSCode
+
+- fixed an issue where it wasn't possible to format newly created files [3006](https://github.com/rome/tools/issues/3006)
+- added a status bar [3139](https://github.com/rome/tools/pull/3139)
+
## 0.8.0
### CLI
- You can create a configuration file called `rome.json` to customize Rome's default options.
This will work from both CLI and LSP.
-### Linter
-
-The linter is now marked as "alpha" and it can be used to lint code from the CLI and
-from the LSP.
-
### Formatter
- You can now use the configuration file `rome.json` to change Rome's defaults:
@@ -33,6 +97,12 @@ from the LSP.
```
- Fixed some edge cases where the comment suppressions were not working as expected.
+### Linter
+
+The linter is now marked as "alpha" and it can be used to lint code from the CLI and
+from the LSP.
+
+
### VSCode
- **BREAKING CHANGE**: Removed the majority of settings that were available in the extension, use the

MODIFY
CONTRIBUTING.md
CONTRIBUTING.md
@@ -39,7 +39,15 @@ The VS Code extension can be installed from the [Marketplace](https://marketplac
"rome.lspBin": "/path/to/rome/target/debug/rome"
```
-To instead build the VS Code extension from source, navigate to the `editors/vscode` directory and run:
+Please note that Windows disallows modifying an executable while it's running,
+meaning you won't be able to recompile the Rome binary once the extension was activated in your editor.
+
+The server is spawned as a background daemon, and continues to run even after the editor is closed.
+
+To stop the running daemon instance use the `rome stop` command, with the editor closed as the extension
+will try to restart it otherwise.
+
+To build the VS Code extension from source, navigate to the `editors/vscode` directory and run:
```bash
npm install

MODIFY
crates/rome_cli/src/commands/help.rs
crates/rome_cli/src/commands/help.rs
@@ -40,12 +40,14 @@ const CHECK: Markup = markup! {
const FORMAT_OPTIONS: Markup = markup! {
"
- "<Dim>"--indent-style <tabs|space>"</Dim>" Determine whether the formatter should use tabs or spaces for indentation (default: tabs)
+ "<Dim>"--write"</Dim>" Edit the files in place (beware!) instead of instead of printing the diff to the console
+ "<Dim>"--skip-errors"</Dim>" Skip over files containing syntax errors instead of emitting an error diagnostic.
+ "<Dim>"--indent-style <tabs|space>"</Dim>" Change the indention character (default: tabs)
"<Dim>"--indent-size <number>"</Dim>" If the indentation style is set to spaces, determine how many spaces should be used for indentation (default: 2)
- "<Dim>"--line-width <number>"</Dim>" Determine how many characters the formatter is allowed to print in a single line (default: 80)
- "<Dim>"--quote-style <single|double>"</Dim>" Determine whether the formatter should use single or double quotes for strings (default: double)
- "<Dim>"--quote-properties <as-needed|preserve>"</Dim>" Determine whether the formatter should preserve quotes in object properties (default: as-needed)
- "<Dim>"--stdin-file-path <string>"</Dim>" Mandatory argument to use when piping content via standard input, e.g. echo 'let a;' | rome format --stdin-filepath file.js
+ "<Dim>"--line-width <number>"</Dim>" Change how many characters the formatter is allowed to print in a single line (default: 80)
+ "<Dim>"--quote-style <single|double>"</Dim>" Changes the quotation character for strings (default: \")
+ "<Dim>"--quote-properties <as-needed|preserve>"</Dim>" Changes when properties in object should be quoted (default: as-needed)
+ "<Dim>"--stdin-file-path <string>"</Dim>" A file name with its extension to pass when reading from standard in, e.g. echo 'let a;' | rome format --stdin-file-path file.js
"
};
@@ -69,9 +71,7 @@ const FORMAT: Markup = markup! {
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
-"<Emphasis>"OPTIONS:"</Emphasis>"
- "<Dim>"--write"</Dim>" Write the output of the formatter to the files instead of printing the diff to the console
- "<Dim>"--skip-errors"</Dim>" Skip over files containing syntax errors instead of returning an error"
+"<Emphasis>"OPTIONS:"</Emphasis>""
{FORMAT_OPTIONS}
};

MODIFY
crates/rome_js_analyze/src/semantic_analyzers/js/no_unused_variables.rs
crates/rome_js_analyze/src/semantic_analyzers/js/no_unused_variables.rs
@@ -12,6 +12,17 @@ use rome_rowan::AstNode;
declare_rule! {
/// Disallow unused variables.
///
+ /// There are two exceptions to this rule:
+ /// 1. variables that starts with underscore, ex: `let _something;`
+ /// 2. the `React` variable;
+ ///
+ /// The pattern of having an underscore as prefix of a name of variable is a very diffuse
+ /// pattern among programmers, and Rome decided to follow it.
+ ///
+ /// Importing the `React` variable was a mandatory pattern until some time ago:
+ ///
+ /// For the time being this rule will ignore it, but this **might change in the future releases**.
+ ///
/// ## Examples
///
/// ### Invalid

MODIFY
editors/vscode/package.json
editors/vscode/package.json
"publisher": "rome",
"displayName": "Rome",
"description": "Rome LSP VS Code Extension",
- "version": "0.12.0",
+ "version": "0.14.0",
"icon": "icon.png",
"activationEvents": [
"onLanguage:javascript",

MODIFY
npm/rome/package.json
npm/rome/package.json
{
"name": "rome",
- "version": "0.8.0-next",
+ "version": "0.9.0-next",
"bin": "bin/rome",
"scripts": {
"postinstall": "node scripts/postinstall.js",
"build": "tsc "
},
"main": "./dist/index.js",
+ "types": "./dist/index.d.ts",
"homepage": "https://rome.tools",
"author": "Sebastian McKenzie",
"bugs": "https://github.com/rome/tools/issues",

ADD
website/src/_includes/docs/architecture.md
+## Architecture (in progress)
+
+Rome uses a server-client architecture to run its tasks.
+
+### Daemon
+
+A [daemon](https://en.wikipedia.org/wiki/Daemon_(computing)) is a long-running server
+that Rome spawns in the background and uses to process requests from the editor and CLI.
\ No newline at end of file

MODIFY
website/src/_includes/docs/cli-commands.md
website/src/_includes/docs/cli-commands.md
@@ -17,3 +17,11 @@ Actions that are performed:
- `rome.json` is created that serves as your [project configuration](#project-configuration).
The command only works on projects that don't have Rome configuration.
+
+#### `rome start`
+
+Start the Rome [daemon](#daemon) server
+
+#### `rome stop`
+
+Stop the Rome [daemon](#deamon) server

MODIFY
website/src/_includes/docs/cli.md
website/src/_includes/docs/cli.md
@@ -5,6 +5,7 @@ Rome CLI offers some options that can be used with all commands:
```shell
OPTIONS:
--no-colors Disable the formatting of markup (print everything as plain text)
+ --use-server Connect to a running instance of the Rome daemon server
```
### Commands

MODIFY
website/src/_includes/docs/formatter.md
website/src/_includes/docs/formatter.md
@@ -52,12 +52,14 @@ USAGE:
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
OPTIONS:
- --write Write the output of the formatter to the files instead of printing the diff to the console
- --skip-errors Skip over files containing syntax errors instead of returning an error
- --indent-style <tabs|space> Determine whether the formatter should use tabs or spaces for indentation (default: tabs)
+ --write Edit the files in place (beware!) instead of instead of printing the diff to the console
+ --skip-errors Skip over files containing syntax errors instead of emitting an error diagnostic.
+ --indent-style <tabs|space> Change the indention character (default: tabs)
--indent-size <number> If the indentation style is set to spaces, determine how many spaces should be used for indentation (default: 2)
- --line-width <number> Determine how many characters the formatter is allowed to print in a single line (default: 80)
- --quote-style <single|double> Determine whether the formatter should use single or double quotes for strings (default: double)
+ --line-width <number> Change how many characters the formatter is allowed to print in a single line (default: 80)
+ --quote-style <single|double> Changes the quotation character for strings (default: ")
+ --quote-properties <as-needed|preserve> Changes when properties in object should be quoted (default: as-needed)
+ --stdin-file-path <string> A file name with its extension to pass when reading from standard in, e.g. echo 'let a;' | rome format --stdin-file-path file.js
```
### Suppression
@@ -198,8 +200,6 @@ function a(b, c) {
}
```
-Please check our [playground] and its result
-
#### Migration from other formatters
Rome doesn't support a lot of options like other web formatters, which means that particular styles

MODIFY
website/src/_includes/docs/linter.md
website/src/_includes/docs/linter.md
@@ -25,6 +25,8 @@ rome check --help
Which will show you the options available at the moment:
```shell
+Rome Check: Run the linter on a set of files
+
USAGE:
rome check <INPUTS...>
@@ -32,6 +34,7 @@ USAGE:
OPTIONS:
--apply Apply safe fixes
+ --apply-suggested Apply safe and suggested fixes
--max-diagnostics Cap the amount of diagnostics displayed - default 20
```

MODIFY
website/src/_includes/docs/project-config.md
website/src/_includes/docs/project-config.md
@@ -60,13 +60,11 @@ Example:
"enabled": true,
"rules": {
"js": {
- "rules": {
"noDebugger": "off"
}
}
}
}
-}
```
@@ -92,13 +90,11 @@ Example:
"enabled": true,
"rules": {
"ts": {
- "rules": {
"useShorthandArrayType": "off"
}
}
}
}
-}
```
@@ -124,13 +120,11 @@ Example:
"enabled": true,
"rules": {
"jsx": {
- "rules": {
"noCommentText": "off"
}
}
}
}
-}
```
@@ -156,13 +150,11 @@ Example:
"enabled": true,
"rules": {
"regex": {
- "rules": {
"noMultipleSpacesInRegularExpressionLiterals": "off"
}
}
}
}
-}
```
@@ -197,6 +189,13 @@ The type of quote used when representing string literals. It can be `single` or
> Default: `double`
+#### `javascript.formatter.quoteProperties`
+
+When properties inside objects should be quoted. It can be `asNeeded` or `preserve`.
+
+> Default: `asNeeded`
+
+
### Configure a rule
A rule can be configured for multiple purposes:
@@ -217,14 +216,12 @@ To enable rules, you need to change their diagnostics severity based on your nee
"enabled": true,
"rules": {
"js": {
- "rules": {
"noDeadCode": "error",
"useCamelCase": "warn"
}
}
}
}
-}
```
#### Turn a rule off
@@ -237,18 +234,14 @@ Just add `"off"` as value inside its configuration. For example:
"enabled": true,
"rules": {
"jsx": {
- "rules": {
"noCommentText": "off"
- }
},
"regex": {
- "rules": {
"noMultipleSpacesInRegularExpressionLiterals": "off"
}
}
}
}
-}
```
#### Change severity of diagnostics
@@ -262,18 +255,14 @@ Just add `"warn"` as value of the rule. Example:
"enabled": true,
"rules": {
"jsx": {
- "rules": {
"noCommentText": "warn"
- }
},
"regex": {
- "rules": {
"noMultipleSpacesInRegularExpressionLiterals": "error"
}
}
}
}
-}
```
This is useful in cases there's being a refactor going on and there's need to make the
@@ -290,7 +279,6 @@ by shaping the value of the rule in a different way.
"enabled": true,
"rules": {
"jsx": {
- "rules": {
"noCommentText": {
"level": "warn",
"options": {}
@@ -299,7 +287,6 @@ by shaping the value of the rule in a different way.
}
}
}
-}
```
- `level` will indicate the severity of the diagnostic, valid values are: `"off"`, `"warn"` and `"error"`;

MODIFY
website/src/docs/lint/rules/noUnusedVariables.md
website/src/docs/lint/rules/noUnusedVariables.md
@@ -9,6 +9,17 @@ layout: layouts/rule.liquid
Disallow unused variables.
+There are two exceptions to this rule:
+
+1. variables that starts with underscore, ex: `let _something;`
+2. the `React` variable;
+The pattern of having an underscore as prefix of a name of variable is a very diffuse
+pattern among programmers, and Rome decided to follow it.
+
+Importing the `React` variable was a mandatory pattern until some time ago:
+
+For the time being this rule will ignore it, but this **might change in the future releases**.
+
## Examples
### Invalid

MODIFY
website/src/index.md
website/src/index.md
@@ -11,5 +11,6 @@ layout: layouts/homepage.liquid
{% include docs/formatter.md %}
{% include docs/linter.md %}
{% include docs/project-config.md %}
+{% include docs/architecture.md %}
{% include docs/philosophy.md %}
{% include docs/_old_diagnostic-anatomy.md %}

MODIFY
xtask/lintdoc/src/main.rs
xtask/lintdoc/src/main.rs
@@ -309,6 +309,30 @@ fn parse_documentation(
writeln!(content)?;
}
+ Event::Start(Tag::Strong) => {
+ write!(content, "**")?;
+ }
+
+ Event::End(Tag::Strong) => {
+ write!(content, "**")?;
+ }
+
+ Event::Start(Tag::Emphasis) => {
+ write!(content, "_")?;
+ }
+
+ Event::End(Tag::Emphasis) => {
+ write!(content, "_")?;
+ }
+
+ Event::Start(Tag::Strikethrough) => {
+ write!(content, "~")?;
+ }
+
+ Event::End(Tag::Strikethrough) => {
+ write!(content, "~")?;
+ }
+
_ => {
// TODO: Implement remaining events as required
bail!("unimplemented event {event:?}")

release: 0.9.0 (#3134)

Co-authored-by: Micha Reiser <micha@rome.tools>
Co-authored-by: l3ops <leo@rome.tools>