From d3351fd962d50f893c04aae1fc1443226d667393 Mon Sep 17 00:00:00 2001 From: l3ops Date: Tue, 8 Nov 2022 14:26:41 +0100 Subject: [PATCH 1/6] fix(docs): use the standard picture element to display the logo (#3585) --- .github/workflows/release_js_api.yml | 3 --- npm/rome/README.md | 7 ++++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release_js_api.yml b/.github/workflows/release_js_api.yml index 078a61de174..2f1e17cf6fe 100644 --- a/.github/workflows/release_js_api.yml +++ b/.github/workflows/release_js_api.yml @@ -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 diff --git a/npm/rome/README.md b/npm/rome/README.md index 731dd5ebf6a..39da7da2371 100644 --- a/npm/rome/README.md +++ b/npm/rome/README.md @@ -1,9 +1,10 @@

- Rome's logo depicting an ancient Roman arch with the word Rome to its side - Rome's logo depicting an ancient Roman arch with the word Rome to its side + + + Rome's logo depicting an ancient Roman arch with the word Rome to its side +

-
[![MIT licensed][mit-badge]][mit-url] From 82b9aa7be444cf77b14780ee7591cb750884e573 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 8 Nov 2022 14:01:34 +0000 Subject: [PATCH 2/6] release: 10.0.0 (#3526) Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com> Co-authored-by: Micha Reiser Co-authored-by: Sebastian McKenzie --- .github/ISSUE_TEMPLATE/01_bug.yml | 9 +- CHANGELOG.md | 78 +++++++++++ CONTRIBUTING.md | 16 +-- crates/rome_service/src/configuration/mod.rs | 2 +- editors/vscode/configuration_schema.json | 2 +- editors/vscode/package.json | 2 +- npm/backend-jsonrpc/src/workspace.ts | 2 +- npm/js-api/package.json | 2 +- npm/rome/README.md | 42 ++---- npm/rome/package.json | 2 +- website/docs/src/guides/getting-started.md | 6 +- xtask/lintdoc/src/main.rs | 129 ++++++++++++------- 12 files changed, 191 insertions(+), 101 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/01_bug.yml b/.github/ISSUE_TEMPLATE/01_bug.yml index e8cec40b171..5002259ec31 100644 --- a/.github/ISSUE_TEMPLATE/01_bug.yml +++ b/.github/ISSUE_TEMPLATE/01_bug.yml @@ -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 @@ -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. diff --git a/CHANGELOG.md b/CHANGELOG.md index df6b95afbae..f9f35ce057c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f252e299e44..b13c73fb5d3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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: @@ -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 @@ -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. diff --git a/crates/rome_service/src/configuration/mod.rs b/crates/rome_service/src/configuration/mod.rs index 0f8b7016e63..03262c239fb 100644 --- a/crates/rome_service/src/configuration/mod.rs +++ b/crates/rome_service/src/configuration/mod.rs @@ -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, } diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index 2dbf7e2a706..130227fa548 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -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", diff --git a/editors/vscode/package.json b/editors/vscode/package.json index f7b05b7fb18..7d4b04de979 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.16.1", + "version": "0.18.0", "icon": "icon.png", "activationEvents": [ "onLanguage:javascript", diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index cb979ec8e65..aab4a9342e9 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -49,7 +49,7 @@ export interface Configuration { */ export interface 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 + * The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB */ maxSize?: number; } diff --git a/npm/js-api/package.json b/npm/js-api/package.json index e4f2a35dd29..28b29dd2d15 100644 --- a/npm/js-api/package.json +++ b/npm/js-api/package.json @@ -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", diff --git a/npm/rome/README.md b/npm/rome/README.md index 39da7da2371..714248128c2 100644 --- a/npm/rome/README.md +++ b/npm/rome/README.md @@ -20,22 +20,22 @@ [discord-url]: https://discord.gg/rome [ci-badge]: https://github.com/rome/tools/actions/workflows/main.yml/badge.svg [ci-url]: https://github.com/rome/tools/actions/workflows/main.yml -[npm-badge]: https://img.shields.io/npm/v/rome/next?color=brightgreen -[npm-url]: https://www.npmjs.com/package/rome/v/next +[npm-badge]: https://img.shields.io/npm/v/rome/latest?color=brightgreen +[npm-url]: https://www.npmjs.com/package/rome/v/latest [vscode-badge]: https://img.shields.io/visual-studio-marketplace/v/rome.rome?color=brightgreen&label=vscode [vscode-url]: (https://marketplace.visualstudio.com/items?itemName=rome.rome
-**Rome** is a formatter, linter, bundler, and [more](https://rome.tools/#development-status) for JavaScript, TypeScript, JSON, HTML, Markdown, and CSS. +**Rome** is a formatter, linter, bundler, and [more](https://rome.tools/) for JavaScript, TypeScript, JSON, HTML, Markdown, and CSS. **Rome** is designed to replace [Babel](https://babeljs.io/), [ESLint](https://eslint.org/), [webpack](https://webpack.js.org/), [Prettier](https://prettier.io/), [Jest](https://jestjs.io/), and others. **Rome** unifies functionality that has previously been separate tools. Building upon a shared base allows us to provide a cohesive experience for processing code, displaying errors, parallelizing work, caching, and configuration. -**Rome** has strong conventions and aims to have minimal configuration. Read more about our [project philosophy](https://rome.tools/#philosophy). +**Rome** has strong conventions and aims to have minimal configuration. Read more about our [project philosophy](https://docs.rome.tools/internals/philosophy/). -**Rome** is [written in Rust](https://rome.tools/blog/2021/09/21/rome-will-be-rewritten-in-rust). +**Rome** is [written in Rust](https://rome.tools/blog/2021/09/21/rome-will-be-rewritten-in-rust.html). **Rome** has first-class IDE support, with a sophisticated parser that represents the source text in full fidelity and top-notch error recovery. @@ -43,37 +43,13 @@ and top-notch error recovery. **Rome** is [MIT licensed](https://github.com/rome/tools/tree/main/LICENSE) and moderated under the [Contributor Covenant Code of Conduct](https://github.com/rome/tools/tree/main/CODE_OF_CONDUCT.md). -## Installation +## Documentation -```shell -npm i rome@next -``` - -## Usage - -Format files: - -```shell -rome format --write ./path ./path/to/file.js -``` - -For complete documentation, please visit the [official website]. - - -## Philosophy - -The project philosophy can be found on our [website](https://rome.tools/#philosophy). - -## Community - -Contribution and development instructions can be found in [CONTRIBUTING](./CONTRIBUTING.md). - -Additional project coordination and real-time discussion happens on our [Discord server](https://discord.gg/rome). Remember that all activity on the Discord server is still moderated and will be strictly enforced under the project's [Code of Conduct](./CODE_OF_CONDUCT.md). +Check out our [homepage](https://rome.tools) to learn more about Rome, or directly head to the [Getting Started guide](https://docs.rome.tools/guides/getting-started/) if you want to start using Rome. ## Technical documentation -If you're curious to know our internals, you can browse our [technical documentation]. +Browse Rome's internal [Rust API Documentation] if you're interested to learn more about how Rome works. -[official website]: https://rome.tools/ -[technical documentation]: https://rome.github.io/tools/rome +[Rust API Documentation]: https://rome.github.io/tools/rome diff --git a/npm/rome/package.json b/npm/rome/package.json index 7dbe30bc01d..bfd1dfb69ef 100644 --- a/npm/rome/package.json +++ b/npm/rome/package.json @@ -1,6 +1,6 @@ { "name": "rome", - "version": "0.10.1", + "version": "10.0.0", "bin": "bin/rome", "scripts": { "postinstall": "node scripts/postinstall.js" diff --git a/website/docs/src/guides/getting-started.md b/website/docs/src/guides/getting-started.md index c32cc0d6e0f..827a52a1f8a 100644 --- a/website/docs/src/guides/getting-started.md +++ b/website/docs/src/guides/getting-started.md @@ -22,7 +22,7 @@ Run the following commands in a directory with a `package.json` file to install #### npm ```bash -npm install --save-dev rome@next +npm install --save-dev rome ``` You can now use `npx rome` to run Rome. @@ -30,7 +30,7 @@ You can now use `npx rome` to run Rome. #### pnpm ```bash -pnpm install --save-dev rome@next +pnpm install --save-dev rome ``` You can now use `pnpm exec rome` to run Rome. @@ -39,7 +39,7 @@ You can now use `pnpm exec rome` to run Rome. #### yarn ```bash -yarn add rome@next --save-dev +yarn add rome --save-dev ``` You can now use `yarn run rome` to run Rome. diff --git a/xtask/lintdoc/src/main.rs b/xtask/lintdoc/src/main.rs index b7e0aa99f94..456e1838a57 100644 --- a/xtask/lintdoc/src/main.rs +++ b/xtask/lintdoc/src/main.rs @@ -3,11 +3,13 @@ use rome_analyze::{ AnalysisFilter, AnalyzerOptions, ControlFlow, GroupCategory, Queryable, RegistryVisitor, Rule, RuleCategory, RuleFilter, RuleGroup, RuleMetadata, }; +use rome_console::fmt::Termcolor; use rome_console::{ fmt::{Formatter, HTML}, - markup, Console, Markup, + markup, Console, Markup, MarkupBuf, }; use rome_diagnostics::file::FileId; +use rome_diagnostics::termcolor::NoColor; use rome_diagnostics::v2::{Diagnostic, DiagnosticExt, PrintDiagnostic}; use rome_js_analyze::{analyze, visit_registry}; use rome_js_syntax::{JsLanguage, Language, LanguageVariant, ModuleKind, SourceType}; @@ -24,6 +26,8 @@ use xtask::{glue::fs2, *}; fn main() -> Result<()> { let root = project_root().join("website/docs/src/lint/rules"); + let reference_groups = + project_root().join("website/docs/src/_includes/docs/reference/groups.md"); // Clear the rules directory ignoring "not found" errors if let Err(err) = fs2::remove_dir_all(&root) { @@ -41,6 +45,7 @@ fn main() -> Result<()> { // Content of the index page let mut index = Vec::new(); + let mut reference_buffer = Vec::new(); writeln!(index, "---")?; writeln!(index, "title: Lint Rules")?; writeln!(index, "main-class: rules")?; @@ -88,11 +93,17 @@ fn main() -> Result<()> { .remove("nursery") .expect("Expected nursery group to exist"); + writeln!( + reference_buffer, + "" + )?; for (group, rules) in groups { generate_group(group, rules, &root, &mut index, &mut errors)?; + generate_reference(group, &mut reference_buffer)?; } generate_group("nursery", nursery_rules, &root, &mut index, &mut errors)?; + generate_reference("nursery", &mut reference_buffer)?; if !errors.is_empty() { bail!( @@ -105,6 +116,7 @@ fn main() -> Result<()> { } fs2::write(root.join("index.md"), index)?; + fs2::write(reference_groups, reference_buffer)?; Ok(()) } @@ -116,55 +128,11 @@ fn generate_group( mut index: &mut dyn io::Write, errors: &mut Vec<(&'static str, Error)>, ) -> io::Result<()> { - let (group_name, description) = match group { - "a11y" => ( - "Accessibility", - markup! { - "Rules focused on preventing accessibility problems." - }, - ), - "correctness" => ( - "Correctness", - markup! { - "Rules that detect incorrect or useless code." - }, - ), - - "nursery" => ( - "Nursery", - markup! { - "New rules that are still under development. - -Nursery rules require explicit opt-in via configuration because they may still have bugs or performance problems. -Nursery rules get promoted to other groups once they become stable or may be removed. - -Rules that belong to this group ""are not subject to semantic version""." - }, - ), - "style" => ( - "Style", - markup! { - "Rules enforcing a consistent way of writing your code. " - }, - ), - "complexity" => ( - "Complexity", - markup! { - "Rules that focus on inspecting complex code that could be simplified." - }, - ), - "security" => ( - "Security", - markup! { - "Rules that detect potential security flaws." - }, - ), - _ => panic!("Unknown group ID {group:?}"), - }; + let (group_name, description) = extract_group_metadata(group); writeln!(index, "\n## {group_name}")?; writeln!(index)?; - markup_to_string(index, description)?; + write_markup_to_string(index, description)?; writeln!(index)?; writeln!(index, "
")?; @@ -605,8 +573,73 @@ fn assert_lint( Ok(()) } -pub fn markup_to_string(buffer: &mut dyn io::Write, markup: Markup) -> io::Result<()> { +fn generate_reference(group: &'static str, buffer: &mut dyn io::Write) -> io::Result<()> { + let (group_name, description) = extract_group_metadata(group); + let description = markup_to_string(&description.to_owned()); + let description = description.replace('\n', " "); + writeln!(buffer, "- `{}`: {}", group_name, description) +} + +fn extract_group_metadata(group: &str) -> (&str, Markup) { + match group { + "a11y" => ( + "Accessibility", + markup! { + "Rules focused on preventing accessibility problems." + }, + ), + "correctness" => ( + "Correctness", + markup! { + "Rules that detect incorrect or useless code." + }, + ), + + "nursery" => ( + "Nursery", + markup! { + "New rules that are still under development. + +Nursery rules require explicit opt-in via configuration because they may still have bugs or performance problems. +Nursery rules get promoted to other groups once they become stable or may be removed. + +Rules that belong to this group ""are not subject to semantic version""." + }, + ), + "style" => ( + "Style", + markup! { + "Rules enforcing a consistent way of writing your code. " + }, + ), + "complexity" => ( + "Complexity", + markup! { + "Rules that focus on inspecting complex code that could be simplified." + }, + ), + "security" => ( + "Security", + markup! { + "Rules that detect potential security flaws." + }, + ), + _ => panic!("Unknown group ID {group:?}"), + } +} + +pub fn write_markup_to_string(buffer: &mut dyn io::Write, markup: Markup) -> io::Result<()> { let mut write = HTML(buffer); let mut fmt = Formatter::new(&mut write); fmt.write_markup(markup) } + +fn markup_to_string(markup: &MarkupBuf) -> String { + let mut buffer = Vec::new(); + let mut write = Termcolor(NoColor::new(&mut buffer)); + let mut fmt = Formatter::new(&mut write); + fmt.write_markup(markup! { {markup} }) + .expect("to have written in the buffer"); + + String::from_utf8(buffer).expect("to have convert a buffer into a String") +} From fbd333a31777c8c8d567d5c9e1be940e952d705d Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Tue, 8 Nov 2022 09:18:35 -0600 Subject: [PATCH 3/6] Improve font performance --- website/docs/src/_includes/layout.liquid | 4 ++ website/docs/src/styles/_fonts.scss | 78 ++++++++++++------------ 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/website/docs/src/_includes/layout.liquid b/website/docs/src/_includes/layout.liquid index 842b4ea8681..93a9b44a9e7 100644 --- a/website/docs/src/_includes/layout.liquid +++ b/website/docs/src/_includes/layout.liquid @@ -12,6 +12,10 @@ social-image: social-logo.png + + + + diff --git a/website/docs/src/styles/_fonts.scss b/website/docs/src/styles/_fonts.scss index 2672dfed7ca..88d22527225 100644 --- a/website/docs/src/styles/_fonts.scss +++ b/website/docs/src/styles/_fonts.scss @@ -3,16 +3,16 @@ font-style: normal; font-weight: 100; font-display: swap; - src: url("/fonts/Inter-Thin.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-Thin.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-Thin.woff2") format("woff2"), + url("/fonts/Inter-Thin.woff") format("woff"); } @font-face { font-family: 'Inter'; font-style: italic; font-weight: 100; font-display: swap; - src: url("/fonts/Inter-ThinItalic.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-ThinItalic.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-ThinItalic.woff2") format("woff2"), + url("/fonts/Inter-ThinItalic.woff") format("woff"); } @font-face { @@ -20,16 +20,16 @@ font-style: normal; font-weight: 200; font-display: swap; - src: url("/fonts/Inter-ExtraLight.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-ExtraLight.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-ExtraLight.woff2") format("woff2"), + url("/fonts/Inter-ExtraLight.woff") format("woff"); } @font-face { font-family: 'Inter'; font-style: italic; font-weight: 200; font-display: swap; - src: url("/fonts/Inter-ExtraLightItalic.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-ExtraLightItalic.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-ExtraLightItalic.woff2") format("woff2"), + url("/fonts/Inter-ExtraLightItalic.woff") format("woff"); } @font-face { @@ -37,16 +37,16 @@ font-style: normal; font-weight: 300; font-display: swap; - src: url("/fonts/Inter-Light.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-Light.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-Light.woff2") format("woff2"), + url("/fonts/Inter-Light.woff") format("woff"); } @font-face { font-family: 'Inter'; font-style: italic; font-weight: 300; font-display: swap; - src: url("/fonts/Inter-LightItalic.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-LightItalic.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-LightItalic.woff2") format("woff2"), + url("/fonts/Inter-LightItalic.woff") format("woff"); } @font-face { @@ -54,16 +54,16 @@ font-style: normal; font-weight: 400; font-display: swap; - src: url("/fonts/Inter-Regular.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-Regular.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-Regular.woff2") format("woff2"), + url("/fonts/Inter-Regular.woff") format("woff"); } @font-face { font-family: 'Inter'; font-style: italic; font-weight: 400; font-display: swap; - src: url("/fonts/Inter-Italic.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-Italic.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-Italic.woff2") format("woff2"), + url("/fonts/Inter-Italic.woff") format("woff"); } @font-face { @@ -71,16 +71,16 @@ font-style: normal; font-weight: 500; font-display: swap; - src: url("/fonts/Inter-Medium.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-Medium.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-Medium.woff2") format("woff2"), + url("/fonts/Inter-Medium.woff") format("woff"); } @font-face { font-family: 'Inter'; font-style: italic; font-weight: 500; font-display: swap; - src: url("/fonts/Inter-MediumItalic.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-MediumItalic.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-MediumItalic.woff2") format("woff2"), + url("/fonts/Inter-MediumItalic.woff") format("woff"); } @font-face { @@ -88,16 +88,16 @@ font-style: normal; font-weight: 600; font-display: swap; - src: url("/fonts/Inter-SemiBold.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-SemiBold.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-SemiBold.woff2") format("woff2"), + url("/fonts/Inter-SemiBold.woff") format("woff"); } @font-face { font-family: 'Inter'; font-style: italic; font-weight: 600; font-display: swap; - src: url("/fonts/Inter-SemiBoldItalic.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-SemiBoldItalic.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-SemiBoldItalic.woff2") format("woff2"), + url("/fonts/Inter-SemiBoldItalic.woff") format("woff"); } @font-face { @@ -105,16 +105,16 @@ font-style: normal; font-weight: 700; font-display: swap; - src: url("/fonts/Inter-Bold.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-Bold.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-Bold.woff2") format("woff2"), + url("/fonts/Inter-Bold.woff") format("woff"); } @font-face { font-family: 'Inter'; font-style: italic; font-weight: 700; font-display: swap; - src: url("/fonts/Inter-BoldItalic.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-BoldItalic.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-BoldItalic.woff2") format("woff2"), + url("/fonts/Inter-BoldItalic.woff") format("woff"); } @font-face { @@ -122,16 +122,16 @@ font-style: normal; font-weight: 800; font-display: swap; - src: url("/fonts/Inter-ExtraBold.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-ExtraBold.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-ExtraBold.woff2") format("woff2"), + url("/fonts/Inter-ExtraBold.woff") format("woff"); } @font-face { font-family: 'Inter'; font-style: italic; font-weight: 800; font-display: swap; - src: url("/fonts/Inter-ExtraBoldItalic.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-ExtraBoldItalic.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-ExtraBoldItalic.woff2") format("woff2"), + url("/fonts/Inter-ExtraBoldItalic.woff") format("woff"); } @font-face { @@ -139,16 +139,16 @@ font-style: normal; font-weight: 900; font-display: swap; - src: url("/fonts/Inter-Black.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-Black.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-Black.woff2") format("woff2"), + url("/fonts/Inter-Black.woff") format("woff"); } @font-face { font-family: 'Inter'; font-style: italic; font-weight: 900; font-display: swap; - src: url("/fonts/Inter-BlackItalic.woff2?v=3.19") format("woff2"), - url("/fonts/Inter-BlackItalic.woff?v=3.19") format("woff"); + src: url("/fonts/Inter-BlackItalic.woff2") format("woff2"), + url("/fonts/Inter-BlackItalic.woff") format("woff"); } /* ------------------------------------------------------- @@ -166,7 +166,7 @@ Usage: font-display: swap; font-style: normal; font-named-instance: 'Regular'; - src: url("/fonts/Inter-roman.var.woff2?v=3.19") format("woff2"); + src: url("/fonts/Inter-roman.var.woff2") format("woff2"); } @font-face { font-family: 'Inter var'; @@ -174,7 +174,7 @@ Usage: font-display: swap; font-style: italic; font-named-instance: 'Italic'; - src: url("/fonts/Inter-italic.var.woff2?v=3.19") format("woff2"); + src: url("/fonts/Inter-italic.var.woff2") format("woff2"); } @@ -196,5 +196,5 @@ explicitly, e.g. font-weight: 100 900; font-display: swap; font-style: oblique 0deg 10deg; - src: url("/fonts/Inter.var.woff2?v=3.19") format("woff2"); + src: url("/fonts/Inter.var.woff2") format("woff2"); } From 42d5d61b6e2a22163819cd45b289b8d1eb1c7d40 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Tue, 8 Nov 2022 09:52:19 -0600 Subject: [PATCH 4/6] Add crossorigin header --- website/docs/src/_includes/layout.liquid | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/src/_includes/layout.liquid b/website/docs/src/_includes/layout.liquid index 93a9b44a9e7..1f0aee45a04 100644 --- a/website/docs/src/_includes/layout.liquid +++ b/website/docs/src/_includes/layout.liquid @@ -13,9 +13,9 @@ social-image: social-logo.png - - - + + + From 5c6ee73d806a74ddd36763b5a61e52a71c67e008 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Tue, 8 Nov 2022 17:51:10 +0100 Subject: [PATCH 5/6] doc: Fix configuration example --- website/docs/src/configuration.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/src/configuration.md b/website/docs/src/configuration.md index 20477e181e7..615cdf78ece 100644 --- a/website/docs/src/configuration.md +++ b/website/docs/src/configuration.md @@ -27,7 +27,7 @@ Here's an example: } ``` -This configuration file enables the linter and formatter and sets the preferred indent style and width of the formatter. +This configuration file enables the formatter and sets the preferred indent style and width. The linter is disabled. ## `rome.json` @@ -36,9 +36,9 @@ This configuration file enables the linter and formatter and sets the preferred ##### `files.maxSize` The maximum allowed size for source code files in bytes. Files above -this limit will be ignored for performance reason. +this limit will be ignored for performance reason. -> Default: 1024 +> Default: 1024*1024 (1MB) ### Linter From 4fc6d085f1aa515ff147df943bb985a7b9c33c2e Mon Sep 17 00:00:00 2001 From: l3ops Date: Tue, 8 Nov 2022 17:57:27 +0100 Subject: [PATCH 6/6] fix(rome_js_analyze): improve the logic of jsx_reference_identifier_is_fragment (#3592) --- crates/rome_js_analyze/src/react.rs | 53 +++++++++++++------ .../fromImportRenameValid.jsx | 7 ++- .../fromImportRenameValid.jsx.snap | 8 ++- .../noUselessFragments/notFragmentValid.jsx | 6 +++ .../notFragmentValid.jsx.snap | 17 ++++++ .../noUselessFragments/userDefinedValid.jsx | 2 +- .../userDefinedValid.jsx.snap | 3 +- 7 files changed, 73 insertions(+), 23 deletions(-) create mode 100644 crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/notFragmentValid.jsx create mode 100644 crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/notFragmentValid.jsx.snap diff --git a/crates/rome_js_analyze/src/react.rs b/crates/rome_js_analyze/src/react.rs index d31e62f7cce..e105e11e9e6 100644 --- a/crates/rome_js_analyze/src/react.rs +++ b/crates/rome_js_analyze/src/react.rs @@ -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}; @@ -331,21 +333,38 @@ pub(crate) fn jsx_reference_identifier_is_fragment( name: &JsxReferenceIdentifier, model: &SemanticModel, ) -> Option { - 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::()?; + 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::()?; + let import_specifiers = import_specifier_list.parent::()?; + let import_clause = import_specifiers.parent::()?; + let import = import_clause.parent::()?; + 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) + } + } } diff --git a/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/fromImportRenameValid.jsx b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/fromImportRenameValid.jsx index 0263f8548e4..f20deb2583e 100644 --- a/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/fromImportRenameValid.jsx +++ b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/fromImportRenameValid.jsx @@ -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"; <> - foo + foo + + foo diff --git a/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/fromImportRenameValid.jsx.snap b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/fromImportRenameValid.jsx.snap index 2c41a16804a..9fbf19b72f1 100644 --- a/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/fromImportRenameValid.jsx.snap +++ b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/fromImportRenameValid.jsx.snap @@ -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"; <> - foo + foo + + foo ``` diff --git a/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/notFragmentValid.jsx b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/notFragmentValid.jsx new file mode 100644 index 00000000000..d1495bc9634 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/notFragmentValid.jsx @@ -0,0 +1,6 @@ +import React, { StrictMode } from "react"; + +<> + + + diff --git a/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/notFragmentValid.jsx.snap b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/notFragmentValid.jsx.snap new file mode 100644 index 00000000000..ec5b4c8fb77 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/notFragmentValid.jsx.snap @@ -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"; + +<> + + + + +``` + + diff --git a/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/userDefinedValid.jsx b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/userDefinedValid.jsx index 722e5e1740a..27f7d45fef5 100644 --- a/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/userDefinedValid.jsx +++ b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/userDefinedValid.jsx @@ -2,5 +2,5 @@ function Fragment() {} let React = { Fragment }; <> test - test + test diff --git a/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/userDefinedValid.jsx.snap b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/userDefinedValid.jsx.snap index a5b8c1f8949..c8b666310c3 100644 --- a/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/userDefinedValid.jsx.snap +++ b/crates/rome_js_analyze/tests/specs/correctness/noUselessFragments/userDefinedValid.jsx.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 99 expression: userDefinedValid.jsx --- # Input @@ -8,7 +9,7 @@ function Fragment() {} let React = { Fragment }; <> test - test + test ```