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

Commit

Permalink
release: 12.0.0 (#4002)
Browse files Browse the repository at this point in the history
Co-authored-by: Victorien ELVINGER <[email protected]>
Co-authored-by: Emanuele Stoppa <[email protected]>
Co-authored-by: IWANABETHATGUY <[email protected]>
Co-authored-by: David Larlet <[email protected]>
Co-authored-by: realtimetodie <[email protected]>
Co-authored-by: Daiki Nishikawa <[email protected]>
Co-authored-by: JunkMeal <[email protected]>
  • Loading branch information
7 people authored Mar 28, 2023
1 parent dbfc8d4 commit 83dae00
Show file tree
Hide file tree
Showing 73 changed files with 1,308 additions and 993 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ indent_size = 2

# YAML doesn't support hard tabs 🙃
# Templates that will be weird with hard tabs in the website editor
[{**.yml, .github/**.md, **.rs}]
[{**.yml, **.md, **.rs, **.mdx}]
indent_style = space

[*.rs]
Expand Down
10 changes: 10 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output. -->

## Changelog

<!--
Read the following paragraph for more information: https://github.com/rome/tools/blob/main/CONTRIBUTING.md#changelog
Tick the checkbox if your PR requires a new line in the changelog.
-->

- [ ] The PR requires a changelog line

## Documentation

<!--
Expand Down
131 changes: 131 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,136 @@
# Rome changelog

## [Unreleased]

### CLI
### Configuration
### Editors
### Formatter
### Linter
### Parser
### VSCode
### JavaScript APIs


## 12.0.0

### CLI

##### Breaking changes

- Review how the traversal of the file system works. Now Rome won't navigate folders that are ignored.
While this change is a bug fix, this could affect how the `ignore` entries are defined inside a project. We suggest to review them
and make sure they still work.
- `--apply-suggested` is now called `--apply-unsafe`
- `rome check --apply` and `rome check --apply-unsafe` exits with non-zero code (error code)
if there are still diagnostics to be addressed.

##### Other changes

- `rome check` now checks import statements. This is an experimental feature that needs to be
enabled via configuration. Import can be sorted using `rome check --apply-unsafe`
- Rome is able to auto discover the configuration file. If Rome doesn't fine a configuration in the
working directory, it will try to find one in the parent directories.
- Add a new global options called `--config-path`. It tells Rome to try and discover a `rome.json` file
in the given path.
```shell
rome format --config-path=../../other/path/
rome check --config-path=../../other/path/
```

### Configuration

#### Other changes

- Rome now uses the internal JSON parser to validate the configuration file. This means Rome won't
exit anymore if there are issues with the `rome.json` file, instead it will apply its defaults
to the sections that are incorrect.
- Add `javascript.organizeImports`. This is an experimental feature and users need to opt-in.

```json
{
"organizeImports": {
"enabled": true,
"ignore": ["trickyFile.js"]
}
}
```
- Add `linter.rules.all` and `linter.rules.[group].all`. These options allow to enable or disable **all**
rules, or all rules for a **given group**. `all` and `recommended` can't be both `true`.


```json
{
"linter": {
"rules": {
"all": true,
"style" : {
"all": false
}
}
}
}
```

The previous example will enable all rules and disable all rules that belong to the `style` group.

### Editors

##### Other changes

- Add support to display diagnostics for JSON files.
- Add support to format JSON files.
- Pull diagnostics when parsing a `rome.json` file.
- Imports sorting is not applied for files that are not supported or ignored.

### Formatter

- Add support for JSON files
- Add support for TypeScript 4.7
- Add support for TypeScript 5.0

### Linter

New rules are promoted, please check [#4239](https://github.com/rome/tools/pull/4239) for more
details.
- [lint/correctness/noUnsafeFinally](https://docs.rome.tools/lint/rules/noUnsafeFinally)
- [lint/correctness/noConstructorReturn](https://docs.rome.tools/lint/rules/noConstructorReturn)
- [lint/correctness/noPrecisionLoss](https://docs.rome.tools/lint/rules/noPrecisionLoss)
- [lint/correctness/noVoidTypeReturn](https://docs.rome.tools/lint/rules/noVoidTypeReturn)
- [lint/correctness/noStringCaseMismatch](https://docs.rome.tools/lint/rules/noStringCaseMismatch)
- [lint/correctness/noSetterReturn](https://docs.rome.tools/lint/rules/noSetterReturn)
- [lint/a11y/useHtmlLang](https://docs.rome.tools/lint/rules/useHtmlLang)
- [lint/a11y/noDistractingElements](https://docs.rome.tools/lint/rules/noDistractingElements)
- [lint/a11y/noHeaderScope](https://docs.rome.tools/lint/rules/noHeaderScope)
- [lint/a11y/noAccessKey](https://docs.rome.tools/lint/rules/noAccessKey)
- [lint/style/useExponentiationOperator](https://docs.rome.tools/lint/rules/useExponentiationOperator)
- [lint/style/useNumericLiterals](https://docs.rome.tools/lint/rules/useNumericLiterals)
- [lint/style/useDefaultParameterLast](https://docs.rome.tools/lint/rules/useDefaultParameterLast)
- [lint/style/useConst](https://docs.rome.tools/lint/rules/useConst)
- [lint/style/noVar](https://docs.rome.tools/lint/rules/noVar)
- [lint/style/noNonNullAssertion](https://docs.rome.tools/lint/rules/noNonNullAssertion)
- [lint/style/useEnumInitializers](https://docs.rome.tools/lint/rules/useEnumInitializers)
- [lint/suspicious/noEmptyInterface](https://docs.rome.tools/lint/rules/noEmptyInterface)
- [lint/suspicious/noExtraNonNullAssertion](https://docs.rome.tools/lint/rules/noExtraNonNullAssertion)
- [lint/suspicious/noRedundantUseStrict](https://docs.rome.tools/lint/rules/noRedundantUseStrict)
- [lint/suspicious/noConstEnum](https://docs.rome.tools/lint/rules/noConstEnum)
- [lint/suspicious/useDefaultSwitchClauseLast](https://docs.rome.tools/lint/rules/useDefaultSwitchClauseLast)
- [lint/suspicious/noDuplicateObjectKeys](https://docs.rome.tools/lint/rules/noDuplicateObjectKeys)


### Parser

- Support for TypeScript 4.7
- Support for TypeScript 5.0

### VSCode

##### Other changes
- Add a new option called `requireConfiguration`. Enabling this option will force Rome to require
a configuration file in your workspace/project. If Rome doesn't find a `rome.json` file, it won't
emit diagnostics.


## 11.0.0

### CLI
Expand Down
94 changes: 82 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,46 @@ cargo run --bin rome -- --help

Rome can be used as a language server by following the instructions below.

## Testing

To run the tests, just run

```shell
cargo test
```

Or

```shell
cargo t
```

If you want to test run tests for a single crates, just change path inside the root of the crate you want to test.
For example, if you want to run the tests of the `rome_cli` crate, you would run:

```shell
cd ./crates/rome_cli
cargo t
```

If you to run only the doctests, you would need to pass an argument to the command:
```shell
cargo test --doc
```

In some crates, we use snapshot testing. The majority of snapshot testing is done using [`insta`](https://insta.rs).

Make sure to install it globally via `cargo`:

```shell
cargo install cargo-insta
```

When a snapshot test fails, you can run:
- `cargo insta accept` to accept all the changes and update all the snapshots;
- `cargo insta reject` to reject all the changes;
- `cargo insta review` to review snapshots singularly;

## Language Server and VS Code Extension Development

The Rome language server is the binary crate `rome` which can be built using the command:
Expand All @@ -36,7 +76,9 @@ If benchmarking the language server, be sure to build with the `--release` flag.
The VS Code extension can be installed from the [Marketplace](https://marketplace.visualstudio.com/items?itemName=rome.rome) and can be used with a development build of the language server by setting the `"rome.lspBin"` VS Code setting to the path of the binary:

```json
"rome.lspBin": "/path/to/rome/target/debug/rome"
{
"rome.lspBin": "/path/to/rome/target/debug/rome"
}
```

Please note that Windows disallows modifying an executable while it's running,
Expand Down Expand Up @@ -107,7 +149,6 @@ pnpm start

## Checks


- `cargo lint` is a cargo alias that runs [`clippy`](https://github.com/rust-lang/rust-clippy) - rust official linter - under the hood;
- `cargo format` is a cargo alias that runs [`rust-fmt`](https://github.com/rust-lang/rustfmt) - rust official formatter - under the hood;
- `cargo test` will run the suite; make sure to run this command from the root of the project, so it will run the tests of all the internal crates;
Expand Down Expand Up @@ -177,6 +218,44 @@ When creating a new pull request, it's preferable to use a conventional commit-f

Please use the template provided.

#### Changelog

If the PR you're about to open is a bugfix/feature around Rome, you should add a new line to the `CHANGELOG.md`.

At the top of the file you will see a `[Unreleased]` section. The headings divide the sections by "feature", make sure
to add a new bullet point.

Here's a sample of the headings:

```markdown
## [Unreleased]

## CLI
## Configuration
## Editors
## Formatter
## Linter
## Parser
## VSCode
## JavaScript APIs
```

When you edit a blank section:

- If your PR adds a **breaking change**, create a new heading called `#### BREAKING CHANGES` and add
bullet point that explains the breaking changes; provide a migration path if possible.
- If your PR adds a new feature of a fix, create a new heading called `#### Other changes` and
add a bullet point that explains the fix or the new feature. Make sure that this new heading
appears after the `#### BREAKING CHANGES` heading.

##### Writing a changelog line

- Use the present tense, e.g. "Add new feature", "Fix edge case".
- If you fix a bug, please add the link to the issue, e.g. "Fix edge case [#4444]()".
- Whenever applicable, add a code block to show your new changes. For example, for a new
rule you might want to show an invalid case, for the formatter you might want to show
how the new formatting changes, and so on.

#### Documentation

If your PR requires some update on the website (new features, breaking changes, etc.), you should create a new PR once the previous PR is successfully merged.
Expand All @@ -191,10 +270,7 @@ The template should help to give all the information to the team.

Here are some other scripts that you might find useful.

#### If you are a core contributor

If you are a core contributor, and you have access to create new branches
from the main repository (not a fork), use these comments to run specific workflows:
#### Magic comments

- `!bench_parser` benchmarks the parser's runtime performance and writes a comment with the results;
- `!bench_formatter` benchmarks the formatter runtime performance and writes a comment with the results;
Expand Down Expand Up @@ -226,12 +302,6 @@ Even minor versions are dedicated to official releases, e.g. `*.6.*`.

- [run the playground locally](/website/playground/README.md)

### Snapshot tests

Internally, we use [`insta`](https://insta.rs/) for snapshot tests. This means that you
follow their [installation instructions](https://insta.rs/docs/cli/) to update/accept
the new snapshot tests.

### Using just

A lot of the commands above are mor easily accessible using our [Just](https://just.systems/man/en/) recipes. For example:
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion crates/rome_cli/src/commands/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ const CHECK: Markup = markup! {
"<Emphasis>"USAGE:"</Emphasis>"
rome check <INPUTS...>
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
INPUTS can be one or more filesystem paths, each pointing to a single file or an entire directory.
"<Emphasis>"EXAMPLES:"</Emphasis>"
rome check ./scripts/file.js
rome check ./
rome check ./src ./internal ./scripts
"<Emphasis>"OPTIONS:"</Emphasis>"
"<Dim>"--apply"</Dim>" Apply safe fixes
Expand Down Expand Up @@ -62,6 +67,11 @@ const CI: 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>"EXAMPLES:"</Emphasis>"
rome ci ./scripts/file.js
rome ci ./
rome ci ./src ./internal ./scripts
"<Emphasis>"OPTIONS:"</Emphasis>"
"<Dim>"--formatter-enabled"</Dim>" Allow to enable or disable the formatter check. (default: true)
"<Dim>"--linter-enabled"</Dim>" Allow to enable or disable the linter check. (default: true)
Expand All @@ -80,6 +90,11 @@ 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>"EXAMPLES:"</Emphasis>"
rome format ./scripts/file.js
rome format ./
rome format ./src ./internal ./scripts
"<Emphasis>"OPTIONS:"</Emphasis>"
"<Dim>"--write"</Dim>" Edit the files in place (beware!) instead of printing the diff to the console
"<Dim>"--skip-errors"</Dim>" Skip over files containing syntax errors instead of emitting an error diagnostic.
Expand Down
3 changes: 2 additions & 1 deletion crates/rome_cli/src/commands/rage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ impl Display for RageConfiguration<'_, '_> {
{KeyValuePair("Status", status)}
{KeyValuePair("Formatter disabled", markup!({DebugDisplay(configuration.is_formatter_disabled())}))}
{KeyValuePair("Linter disabled", markup!({DebugDisplay(configuration.is_linter_disabled())}))}
{KeyValuePair("Organize imports disabled", markup!({DebugDisplay(configuration.is_organize_imports_disabled())}))}
).fmt(fmt)?
}
Err(err) => markup! (
Expand Down Expand Up @@ -236,7 +237,7 @@ impl Display for KeyValuePair<'_> {
let KeyValuePair(key, value) = self;
write!(fmt, " {key}:")?;

let padding_width = 22usize.saturating_sub(key.len() + 1);
let padding_width = 30usize.saturating_sub(key.len() + 1);

for _ in 0..padding_width {
fmt.write_str(" ")?;
Expand Down
7 changes: 3 additions & 4 deletions crates/rome_cli/tests/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1423,10 +1423,9 @@ fn applies_organize_imports() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let rome_json = r#"{ "organizeImports": { "enabled": true } }"#;

let config_path = Path::new("rome.json");
fs.insert(config_path.into(), rome_json.as_bytes());
let config = r#"{ "organizeImports": { "enabled": true } }"#;
let file_path = Path::new("rome.json");
fs.insert(file_path.into(), config.as_bytes());

let file_path = Path::new("check.js");
let content = r#"import { lorem, foom, bar } from "foo";
Expand Down
Loading

0 comments on commit 83dae00

Please sign in to comment.