Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into no-dupe-keys
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
jeysal committed Nov 8, 2022
2 parents cfb93ce + 4fc6d08 commit 880e50e
Show file tree
Hide file tree
Showing 23 changed files with 314 additions and 172 deletions.
9 changes: 6 additions & 3 deletions .github/ISSUE_TEMPLATE/01_bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ body:
id: environment
attributes:
label: Environment information
description: Please share any information about your environment that can help debug your issue (OS and OS version, CPU architecture, installation method, etc.).
render: bash
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.
render: block
validations:
required: true
- type: textarea
Expand All @@ -25,7 +25,10 @@ body:
label: What happened?
description: |
Provide a detailed list of steps that reproduce the issue
The more information and included steps, the quicker your report can be confirmed and addressed!
The more information and included steps, the quicker your report can be triaged and addressed!
You can also use the [playground](https://play.rome.tools) to share code snippets.
This is useful to reproduce the issue.
placeholder: |
1.
2.
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release_js_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,4 @@ jobs:
tag_name: js-api/v${{ needs.build.outputs.version }}
draft: false
prerelease: ${{ needs.build.outputs.prerelease == 'true' }}
files: |
dist/*
fail_on_unmatched_files: true
generate_release_notes: true
78 changes: 78 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,83 @@
# Rome changelog

## 10.0.0

### CLI

- Added the new command `rome version`.
- Added the new command `rome rage`.
- Added the new command `rome lsp-proxy`.
- Added the new option`--version` as an alias for `rome version`
- Added a new argument `--files-max-size` to change the allowed size of files, in bytes.
- Added a new argument `--formatter-enabled` to the command `rome ci`.
- Added a new argument `--linter-enabled` to the command `rome ci`.
- Added the new `format` option `--trailing-comma` to configure where to add trailing commas.
- Correctly show the supported options for `rome ci`, closes [#3456](https://github.com/rome/tools/issues/3456).
- 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).
- Fixed the messaging of some diagnostics, [#3460](https://github.com/rome/tools/pull/3460).

### Configuration

- Added `files.maxSize`, to change the allowed size of files, in bytes.

### Diagnostics

- Fix false positive for unknown lint rule in suppression comments during formatting [#3406](https://github.com/rome/tools/issues/3406).
- Correctly handle empty lines when printing code diffs [#3375](https://github.com/rome/tools/issues/3375).


### Formatter

- 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.
- 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)
- Better formatting of object destructing
- Improved formatting of test calls
- Fixed formatting of trailing comments in arrow functions

### Linter

- **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.
- Fixed issues in the `noUnreachable` rule
- Fixed false positive cases for `noNegationElse` [#3141](https://github.com/rome/tools/issues/3141)
- Fixed false positive cases for `noUnusedVariables` [#3169](https://github.com/rome/tools/issues/3169)
- Fixed an issue in our CFG [#3390](https://github.com/rome/tools/issues/3390)

#### New rules

- [`noAutoFocus`](https://rome.tools/docs/lint/rules/noAutoFocus/)
- [`useAltText`](https://rome.tools/docs/lint/rules/useAltText/)
- [`noBlankTarget`](https://rome.tools/docs/lint/rules/noBlankTarget/)
- [`useAnchorContent`](https://rome.tools/docs/lint/rules/useAnchorContent/)
- [`useKeyWithClickEvents`](https://rome.tools/docs/lint/rules/useKeyWithClickEvents/)
- [`useKeyWithMouseEvents`](https://rome.tools/docs/lint/rules/useKeyWithMouseEvents/)
- [`noPositiveTabIndex`](https://rome.tools/docs/lint/rules/noPositiveTabIndex/)
- [`useValidAnchor`](https://rome.tools/docs/lint/rules/useValidAnchor/)
- [`noRestrictedGlobals`](https://rome.tools/docs/lint/rules/noRestrictedGlobals/)
- [`useSimplifiedBooleanExpression`](https://rome.tools/docs/lint/rules/useSimplifiedBooleanExpression/)
- [`noInvalidConstructorSuper`](https://rome.tools/docs/lint/rules/noInvalidConstructorSuper/)
- [`useValidForDirection`](https://rome.tools/docs/lint/rules/useValidForDirection/)
- [`noConstAssign`](https://rome.tools/docs/lint/rules/noConstAssign/)
- [`noExplicitAny`](https://rome.tools/docs/lint/rules/noExplicitAny/)
- [`noBannedTypes`](https://rome.tools/docs/lint/rules/noBannedTypes/)
- [`useMapFlat`](https://rome.tools/docs/lint/rules/useMapFlat/)
- [`useExhaustiveDependencies`](https://rome.tools/docs/lint/rules/useExhaustiveDependencies/)

### Parser

- Improved messaging of diagnostics, using our new infrastructure
- Fixed an issue where diagnostics couldn't be printed in WASM [#3349](https://github.com/rome/tools/pull/3349)
- Allow arguments in d.ts files [#3388](https://github.com/rome/tools/issues/3388)
- Fix parsing of less than in optional call chains [#3486](https://github.com/rome/tools/issues/3486)
- Fixed a case where `export {"a"} from "b";` wasn't correctly parsed

### VSCode

- Make the "rename" command opt-in and use the VS Code provided "rename" feature that offers whole project renaming instead.
- Added the new command `Restart LSP Server`
- The LSP server is now able to listen to changes of `rome.json` and apply the new configuration



## 0.10.1

### CLI
Expand Down
16 changes: 8 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ The VS Code extension can be installed from the [Marketplace](https://marketplac
"rome.lspBin": "/path/to/rome/target/debug/rome"
```

Please note that Windows disallows modifying an executable while it's running,
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.
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
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:
Expand Down Expand Up @@ -88,11 +88,11 @@ The npm module npm/rome contains Rome's Node JS API that supports different back
For testing and developing, you need to build these packages, following the steps:
1. install [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) globally;
2. run the `build` command inside the package `backend-jsonrpc`;
3. run the `build:wasm-node-dev` command inside the package `rome` (folder `npm/rome`);
4. run `pnpm i` inside the package `rome` (folder `npm/rome`), this will link the WebAssembly bindings and the
3. run the `build:wasm-node-dev` command inside the package `js-api` (folder `npm/js-api`);
4. run `pnpm i` inside the package `js-api` (folder `npm/js-api`), this will link the WebAssembly bindings and the
JSON-RPC bindings;

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

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

### 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
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.
53 changes: 36 additions & 17 deletions crates/rome_js_analyze/src/react.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ pub mod hooks;

use rome_js_semantic::SemanticModel;
use rome_js_syntax::{
JsAnyCallArgument, JsAnyExpression, JsCallExpression, JsIdentifierBinding, JsImport,
JsObjectExpression, JsPropertyObjectMember, JsxMemberName, JsxReferenceIdentifier,
JsAnyCallArgument, JsAnyExpression, JsAnyNamedImportSpecifier, JsCallExpression,
JsIdentifierBinding, JsImport, JsImportNamedClause, JsNamedImportSpecifierList,
JsNamedImportSpecifiers, JsObjectExpression, JsPropertyObjectMember, JsxMemberName,
JsxReferenceIdentifier,
};
use rome_rowan::{AstNode, AstSeparatedList};

Expand Down Expand Up @@ -331,21 +333,38 @@ pub(crate) fn jsx_reference_identifier_is_fragment(
name: &JsxReferenceIdentifier,
model: &SemanticModel,
) -> Option<bool> {
let value_token = name.value_token().ok()?;
let mut maybe_react_fragment = value_token.text_trimmed() == "Fragment";
if let Some(reference) = model.declaration(name) {
if let Some(js_import) = reference
.syntax()
.ancestors()
.find_map(|ancestor| JsImport::cast_ref(&ancestor))
{
let source_is_react = js_import.source_is("react").ok()?;
maybe_react_fragment = source_is_react;
} else {
// `Fragment` is a binding g but it doesn't come from the "react" package
maybe_react_fragment = false;
match model.declaration(name) {
Some(reference) => {
let ident = JsIdentifierBinding::cast_ref(reference.syntax())?;

let import_specifier = ident.parent::<JsAnyNamedImportSpecifier>()?;
let name_token = match &import_specifier {
JsAnyNamedImportSpecifier::JsNamedImportSpecifier(named_import) => {
named_import.name().ok()?.value().ok()?
}
JsAnyNamedImportSpecifier::JsShorthandNamedImportSpecifier(_) => {
ident.name_token().ok()?
}
JsAnyNamedImportSpecifier::JsUnknownNamedImportSpecifier(_) => {
return None;
}
};

if name_token.text_trimmed() != "Fragment" {
return Some(false);
}

let import_specifier_list = import_specifier.parent::<JsNamedImportSpecifierList>()?;
let import_specifiers = import_specifier_list.parent::<JsNamedImportSpecifiers>()?;
let import_clause = import_specifiers.parent::<JsImportNamedClause>()?;
let import = import_clause.parent::<JsImport>()?;
import.source_is("react").ok()
}
}

Some(maybe_react_fragment)
None => {
let value_token = name.value_token().ok()?;
let is_fragment = value_token.text_trimmed() == "Fragment";
Some(is_fragment)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import AwesomeReact, { Fragment as AwesomeFragment } from "noReact";
import AwesomeNoReact, { Fragment as AwesomeFragment } from "noReact";
import AwesomeReact, { StrictMode as AwesomeStrictMode } from "react";

<>
<AwesomeFragment></AwesomeFragment>
<AwesomeReact.Fragment>foo</AwesomeReact.Fragment>
<AwesomeNoReact.Fragment>foo</AwesomeNoReact.Fragment>
<AwesomeStrictMode></AwesomeStrictMode>
<AwesomeReact.StrictMode>foo</AwesomeReact.StrictMode>
</>
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
---
source: crates/rome_js_analyze/tests/spec_tests.rs
assertion_line: 99
expression: fromImportRenameValid.jsx
---
# Input
```js
import AwesomeReact, { Fragment as AwesomeFragment } from "noReact";
import AwesomeNoReact, { Fragment as AwesomeFragment } from "noReact";
import AwesomeReact, { StrictMode as AwesomeStrictMode } from "react";

<>
<AwesomeFragment></AwesomeFragment>
<AwesomeReact.Fragment>foo</AwesomeReact.Fragment>
<AwesomeNoReact.Fragment>foo</AwesomeNoReact.Fragment>
<AwesomeStrictMode></AwesomeStrictMode>
<AwesomeReact.StrictMode>foo</AwesomeReact.StrictMode>
</>

```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React, { StrictMode } from "react";

<>
<StrictMode></StrictMode>
<React.StrictMode></React.StrictMode>
</>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
source: crates/rome_js_analyze/tests/spec_tests.rs
assertion_line: 99
expression: notFragmentValid.jsx
---
# Input
```js
import React, { StrictMode } from "react";

<>
<StrictMode></StrictMode>
<React.StrictMode></React.StrictMode>
</>

```


Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ function Fragment() {}
let React = { Fragment };
<>
<Fragment>test</Fragment>
<React>test</React>
<React.Fragment>test</React.Fragment>
</>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: crates/rome_js_analyze/tests/spec_tests.rs
assertion_line: 99
expression: userDefinedValid.jsx
---
# Input
Expand All @@ -8,7 +9,7 @@ function Fragment() {}
let React = { Fragment };
<>
<Fragment>test</Fragment>
<React>test</React>
<React.Fragment>test</React.Fragment>
</>

```
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_service/src/configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Configuration {
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct FilesConfiguration {
/// The maximum allowed size for source code files in bytes. Files above
/// this limit will be ignore for performance reason. Defaults to 1 MiB
/// this limit will be ignored for performance reason. Defaults to 1 MiB
pub max_size: Option<NonZeroU64>,
}

Expand Down
2 changes: 1 addition & 1 deletion editors/vscode/configuration_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
"type": "object",
"properties": {
"maxSize": {
"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",
"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",
"default": null,
"type": [
"integer",
Expand Down
2 changes: 1 addition & 1 deletion editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "rome",
"displayName": "Rome",
"description": "Rome LSP VS Code Extension",
"version": "0.16.1",
"version": "0.18.0",
"icon": "icon.png",
"activationEvents": [
"onLanguage:javascript",
Expand Down
2 changes: 1 addition & 1 deletion npm/backend-jsonrpc/src/workspace.ts

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

2 changes: 1 addition & 1 deletion npm/js-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rometools/js-api",
"version": "0.0.0",
"version": "0.1.0",
"description": "JavaScript APIs for the Rome package",
"scripts": {
"tsc": "tsc --noEmit",
Expand Down
Loading

0 comments on commit 880e50e

Please sign in to comment.