Skip to content

Commit 880e50e

Browse files
committed
Merge remote-tracking branch 'upstream/main' into no-dupe-keys
* upstream/main: fix(rome_js_analyze): improve the logic of jsx_reference_identifier_is_fragment (rome#3592) doc: Fix configuration example Add crossorigin header Improve font performance release: 10.0.0 (rome#3526) fix(docs): use the standard picture element to display the logo (rome#3585)
2 parents cfb93ce + 4fc6d08 commit 880e50e

File tree

23 files changed

+314
-172
lines changed

23 files changed

+314
-172
lines changed

.github/ISSUE_TEMPLATE/01_bug.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ body:
1515
id: environment
1616
attributes:
1717
label: Environment information
18-
description: Please share any information about your environment that can help debug your issue (OS and OS version, CPU architecture, installation method, etc.).
19-
render: bash
18+
description: Run the command `rome rage` and paste its output here. Please review it, in case there are sensitive information you don't want to share.
19+
render: block
2020
validations:
2121
required: true
2222
- type: textarea
@@ -25,7 +25,10 @@ body:
2525
label: What happened?
2626
description: |
2727
Provide a detailed list of steps that reproduce the issue
28-
The more information and included steps, the quicker your report can be confirmed and addressed!
28+
The more information and included steps, the quicker your report can be triaged and addressed!
29+
30+
You can also use the [playground](https://play.rome.tools) to share code snippets.
31+
This is useful to reproduce the issue.
2932
placeholder: |
3033
1.
3134
2.

.github/workflows/release_js_api.yml

-3
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,4 @@ jobs:
158158
tag_name: js-api/v${{ needs.build.outputs.version }}
159159
draft: false
160160
prerelease: ${{ needs.build.outputs.prerelease == 'true' }}
161-
files: |
162-
dist/*
163-
fail_on_unmatched_files: true
164161
generate_release_notes: true

CHANGELOG.md

+78
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,83 @@
11
# Rome changelog
22

3+
## 10.0.0
4+
5+
### CLI
6+
7+
- Added the new command `rome version`.
8+
- Added the new command `rome rage`.
9+
- Added the new command `rome lsp-proxy`.
10+
- Added the new option`--version` as an alias for `rome version`
11+
- Added a new argument `--files-max-size` to change the allowed size of files, in bytes.
12+
- Added a new argument `--formatter-enabled` to the command `rome ci`.
13+
- Added a new argument `--linter-enabled` to the command `rome ci`.
14+
- Added the new `format` option `--trailing-comma` to configure where to add trailing commas.
15+
- Correctly show the supported options for `rome ci`, closes [#3456](https://github.com/rome/tools/issues/3456).
16+
- Fixed the command `rome ci` command to run the linter even if the formatter is disabled, closes [#3495](https://github.com/rome/tools/issues/3495).
17+
- Fixed the messaging of some diagnostics, [#3460](https://github.com/rome/tools/pull/3460).
18+
19+
### Configuration
20+
21+
- Added `files.maxSize`, to change the allowed size of files, in bytes.
22+
23+
### Diagnostics
24+
25+
- Fix false positive for unknown lint rule in suppression comments during formatting [#3406](https://github.com/rome/tools/issues/3406).
26+
- Correctly handle empty lines when printing code diffs [#3375](https://github.com/rome/tools/issues/3375).
27+
28+
29+
### Formatter
30+
31+
- Added the new trailing comma option that configures where to add trailing commas. Supports the values: `all`, `es5` and `none`; refer to the [documentation](https://rome.tools/docs/#javascriptformattertrailingcomma) to learn more.
32+
- Improved JSX formatting [#3499](https://github.com/rome/tools/issues/3499), [#3211](https://github.com/rome/tools/issues/3211), [#3377](https://github.com/rome/tools/issues/3377)
33+
- Better formatting of object destructing
34+
- Improved formatting of test calls
35+
- Fixed formatting of trailing comments in arrow functions
36+
37+
### Linter
38+
39+
- **BREAKING CHANGE**: some rules have been moved to new groups to better reflect their purpose. This may result in Rome failing to load your configuration or suppression comments that now refer to unknown rules. Please check out [#3471](https://github.com/rome/tools/pull/3471) to learn more about the affected rules.
40+
- Fixed issues in the `noUnreachable` rule
41+
- Fixed false positive cases for `noNegationElse` [#3141](https://github.com/rome/tools/issues/3141)
42+
- Fixed false positive cases for `noUnusedVariables` [#3169](https://github.com/rome/tools/issues/3169)
43+
- Fixed an issue in our CFG [#3390](https://github.com/rome/tools/issues/3390)
44+
45+
#### New rules
46+
47+
- [`noAutoFocus`](https://rome.tools/docs/lint/rules/noAutoFocus/)
48+
- [`useAltText`](https://rome.tools/docs/lint/rules/useAltText/)
49+
- [`noBlankTarget`](https://rome.tools/docs/lint/rules/noBlankTarget/)
50+
- [`useAnchorContent`](https://rome.tools/docs/lint/rules/useAnchorContent/)
51+
- [`useKeyWithClickEvents`](https://rome.tools/docs/lint/rules/useKeyWithClickEvents/)
52+
- [`useKeyWithMouseEvents`](https://rome.tools/docs/lint/rules/useKeyWithMouseEvents/)
53+
- [`noPositiveTabIndex`](https://rome.tools/docs/lint/rules/noPositiveTabIndex/)
54+
- [`useValidAnchor`](https://rome.tools/docs/lint/rules/useValidAnchor/)
55+
- [`noRestrictedGlobals`](https://rome.tools/docs/lint/rules/noRestrictedGlobals/)
56+
- [`useSimplifiedBooleanExpression`](https://rome.tools/docs/lint/rules/useSimplifiedBooleanExpression/)
57+
- [`noInvalidConstructorSuper`](https://rome.tools/docs/lint/rules/noInvalidConstructorSuper/)
58+
- [`useValidForDirection`](https://rome.tools/docs/lint/rules/useValidForDirection/)
59+
- [`noConstAssign`](https://rome.tools/docs/lint/rules/noConstAssign/)
60+
- [`noExplicitAny`](https://rome.tools/docs/lint/rules/noExplicitAny/)
61+
- [`noBannedTypes`](https://rome.tools/docs/lint/rules/noBannedTypes/)
62+
- [`useMapFlat`](https://rome.tools/docs/lint/rules/useMapFlat/)
63+
- [`useExhaustiveDependencies`](https://rome.tools/docs/lint/rules/useExhaustiveDependencies/)
64+
65+
### Parser
66+
67+
- Improved messaging of diagnostics, using our new infrastructure
68+
- Fixed an issue where diagnostics couldn't be printed in WASM [#3349](https://github.com/rome/tools/pull/3349)
69+
- Allow arguments in d.ts files [#3388](https://github.com/rome/tools/issues/3388)
70+
- Fix parsing of less than in optional call chains [#3486](https://github.com/rome/tools/issues/3486)
71+
- Fixed a case where `export {"a"} from "b";` wasn't correctly parsed
72+
73+
### VSCode
74+
75+
- Make the "rename" command opt-in and use the VS Code provided "rename" feature that offers whole project renaming instead.
76+
- Added the new command `Restart LSP Server`
77+
- The LSP server is now able to listen to changes of `rome.json` and apply the new configuration
78+
79+
80+
381
## 0.10.1
482

583
### CLI

CONTRIBUTING.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ The VS Code extension can be installed from the [Marketplace](https://marketplac
3939
"rome.lspBin": "/path/to/rome/target/debug/rome"
4040
```
4141

42-
Please note that Windows disallows modifying an executable while it's running,
42+
Please note that Windows disallows modifying an executable while it's running,
4343
meaning you won't be able to recompile the Rome binary once the extension was activated in your editor.
4444

45-
The server is spawned as a background daemon, and continues to run even after the editor is closed.
45+
The server is spawned as a background daemon, and continues to run even after the editor is closed.
4646

47-
To stop the running daemon instance use the `rome stop` command, with the editor closed as the extension
47+
To stop the running daemon instance use the `rome stop` command, with the editor closed as the extension
4848
will try to restart it otherwise.
4949

5050
To build the VS Code extension from source, navigate to the `editors/vscode` directory and run:
@@ -88,11 +88,11 @@ The npm module npm/rome contains Rome's Node JS API that supports different back
8888
For testing and developing, you need to build these packages, following the steps:
8989
1. install [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) globally;
9090
2. run the `build` command inside the package `backend-jsonrpc`;
91-
3. run the `build:wasm-node-dev` command inside the package `rome` (folder `npm/rome`);
92-
4. run `pnpm i` inside the package `rome` (folder `npm/rome`), this will link the WebAssembly bindings and the
91+
3. run the `build:wasm-node-dev` command inside the package `js-api` (folder `npm/js-api`);
92+
4. run `pnpm i` inside the package `js-api` (folder `npm/js-api`), this will link the WebAssembly bindings and the
9393
JSON-RPC bindings;
9494

95-
The tests are run against the compiled files, which means that you need to run the
95+
The tests are run against the compiled files, which means that you need to run the
9696
`build` command after you implemented features/bug fixes.
9797

9898
## Website
@@ -214,6 +214,6 @@ Even minor versions are dedicated to official releases, e.g. `*.6.*`.
214214

215215
### Snapshot tests
216216

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

crates/rome_js_analyze/src/react.rs

+36-17
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ pub mod hooks;
44

55
use rome_js_semantic::SemanticModel;
66
use rome_js_syntax::{
7-
JsAnyCallArgument, JsAnyExpression, JsCallExpression, JsIdentifierBinding, JsImport,
8-
JsObjectExpression, JsPropertyObjectMember, JsxMemberName, JsxReferenceIdentifier,
7+
JsAnyCallArgument, JsAnyExpression, JsAnyNamedImportSpecifier, JsCallExpression,
8+
JsIdentifierBinding, JsImport, JsImportNamedClause, JsNamedImportSpecifierList,
9+
JsNamedImportSpecifiers, JsObjectExpression, JsPropertyObjectMember, JsxMemberName,
10+
JsxReferenceIdentifier,
911
};
1012
use rome_rowan::{AstNode, AstSeparatedList};
1113

@@ -331,21 +333,38 @@ pub(crate) fn jsx_reference_identifier_is_fragment(
331333
name: &JsxReferenceIdentifier,
332334
model: &SemanticModel,
333335
) -> Option<bool> {
334-
let value_token = name.value_token().ok()?;
335-
let mut maybe_react_fragment = value_token.text_trimmed() == "Fragment";
336-
if let Some(reference) = model.declaration(name) {
337-
if let Some(js_import) = reference
338-
.syntax()
339-
.ancestors()
340-
.find_map(|ancestor| JsImport::cast_ref(&ancestor))
341-
{
342-
let source_is_react = js_import.source_is("react").ok()?;
343-
maybe_react_fragment = source_is_react;
344-
} else {
345-
// `Fragment` is a binding g but it doesn't come from the "react" package
346-
maybe_react_fragment = false;
336+
match model.declaration(name) {
337+
Some(reference) => {
338+
let ident = JsIdentifierBinding::cast_ref(reference.syntax())?;
339+
340+
let import_specifier = ident.parent::<JsAnyNamedImportSpecifier>()?;
341+
let name_token = match &import_specifier {
342+
JsAnyNamedImportSpecifier::JsNamedImportSpecifier(named_import) => {
343+
named_import.name().ok()?.value().ok()?
344+
}
345+
JsAnyNamedImportSpecifier::JsShorthandNamedImportSpecifier(_) => {
346+
ident.name_token().ok()?
347+
}
348+
JsAnyNamedImportSpecifier::JsUnknownNamedImportSpecifier(_) => {
349+
return None;
350+
}
351+
};
352+
353+
if name_token.text_trimmed() != "Fragment" {
354+
return Some(false);
355+
}
356+
357+
let import_specifier_list = import_specifier.parent::<JsNamedImportSpecifierList>()?;
358+
let import_specifiers = import_specifier_list.parent::<JsNamedImportSpecifiers>()?;
359+
let import_clause = import_specifiers.parent::<JsImportNamedClause>()?;
360+
let import = import_clause.parent::<JsImport>()?;
361+
import.source_is("react").ok()
347362
}
348-
}
349363

350-
Some(maybe_react_fragment)
364+
None => {
365+
let value_token = name.value_token().ok()?;
366+
let is_fragment = value_token.text_trimmed() == "Fragment";
367+
Some(is_fragment)
368+
}
369+
}
351370
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import AwesomeReact, { Fragment as AwesomeFragment } from "noReact";
1+
import AwesomeNoReact, { Fragment as AwesomeFragment } from "noReact";
2+
import AwesomeReact, { StrictMode as AwesomeStrictMode } from "react";
23

34
<>
45
<AwesomeFragment></AwesomeFragment>
5-
<AwesomeReact.Fragment>foo</AwesomeReact.Fragment>
6+
<AwesomeNoReact.Fragment>foo</AwesomeNoReact.Fragment>
7+
<AwesomeStrictMode></AwesomeStrictMode>
8+
<AwesomeReact.StrictMode>foo</AwesomeReact.StrictMode>
69
</>

crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/fromImportRenameValid.jsx.snap

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
---
22
source: crates/rome_js_analyze/tests/spec_tests.rs
3+
assertion_line: 99
34
expression: fromImportRenameValid.jsx
45
---
56
# Input
67
```js
7-
import AwesomeReact, { Fragment as AwesomeFragment } from "noReact";
8+
import AwesomeNoReact, { Fragment as AwesomeFragment } from "noReact";
9+
import AwesomeReact, { StrictMode as AwesomeStrictMode } from "react";
810
911
<>
1012
<AwesomeFragment></AwesomeFragment>
11-
<AwesomeReact.Fragment>foo</AwesomeReact.Fragment>
13+
<AwesomeNoReact.Fragment>foo</AwesomeNoReact.Fragment>
14+
<AwesomeStrictMode></AwesomeStrictMode>
15+
<AwesomeReact.StrictMode>foo</AwesomeReact.StrictMode>
1216
</>
1317
1418
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React, { StrictMode } from "react";
2+
3+
<>
4+
<StrictMode></StrictMode>
5+
<React.StrictMode></React.StrictMode>
6+
</>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
source: crates/rome_js_analyze/tests/spec_tests.rs
3+
assertion_line: 99
4+
expression: notFragmentValid.jsx
5+
---
6+
# Input
7+
```js
8+
import React, { StrictMode } from "react";
9+
10+
<>
11+
<StrictMode></StrictMode>
12+
<React.StrictMode></React.StrictMode>
13+
</>
14+
15+
```
16+
17+

crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/userDefinedValid.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ function Fragment() {}
22
let React = { Fragment };
33
<>
44
<Fragment>test</Fragment>
5-
<React>test</React>
5+
<React.Fragment>test</React.Fragment>
66
</>

crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/userDefinedValid.jsx.snap

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: crates/rome_js_analyze/tests/spec_tests.rs
3+
assertion_line: 99
34
expression: userDefinedValid.jsx
45
---
56
# Input
@@ -8,7 +9,7 @@ function Fragment() {}
89
let React = { Fragment };
910
<>
1011
<Fragment>test</Fragment>
11-
<React>test</React>
12+
<React.Fragment>test</React.Fragment>
1213
</>
1314
1415
```

crates/rome_service/src/configuration/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Configuration {
7878
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
7979
pub struct FilesConfiguration {
8080
/// The maximum allowed size for source code files in bytes. Files above
81-
/// this limit will be ignore for performance reason. Defaults to 1 MiB
81+
/// this limit will be ignored for performance reason. Defaults to 1 MiB
8282
pub max_size: Option<NonZeroU64>,
8383
}
8484

editors/vscode/configuration_schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@
515515
"type": "object",
516516
"properties": {
517517
"maxSize": {
518-
"description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignore for performance reason. Defaults to 1 MiB",
518+
"description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB",
519519
"default": null,
520520
"type": [
521521
"integer",

editors/vscode/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "rome",
44
"displayName": "Rome",
55
"description": "Rome LSP VS Code Extension",
6-
"version": "0.16.1",
6+
"version": "0.18.0",
77
"icon": "icon.png",
88
"activationEvents": [
99
"onLanguage:javascript",

npm/backend-jsonrpc/src/workspace.ts

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm/js-api/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rometools/js-api",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"description": "JavaScript APIs for the Rome package",
55
"scripts": {
66
"tsc": "tsc --noEmit",

0 commit comments

Comments
 (0)