From d228608146657fcfdf1eac19b42953eeeb0eaab8 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Wed, 2 Aug 2023 13:14:22 +0100 Subject: [PATCH] more configuration --- .../src/configuration/javascript.rs | 4 +- editors/vscode/configuration_schema.json | 4 +- npm/backend-jsonrpc/src/workspace.ts | 4 +- npm/rome/configuration_schema.json | 4 +- website/src/pages/analyzer/index.mdx | 8 ++-- website/src/pages/configuration.mdx | 46 +++++++++++++++++-- .../src/pages/schemas/13.0.0/schema.json.js | 18 ++++---- 7 files changed, 64 insertions(+), 24 deletions(-) diff --git a/crates/rome_service/src/configuration/javascript.rs b/crates/rome_service/src/configuration/javascript.rs index e2cecd8df46..ef0e200243f 100644 --- a/crates/rome_service/src/configuration/javascript.rs +++ b/crates/rome_service/src/configuration/javascript.rs @@ -68,11 +68,11 @@ impl JavascriptConfiguration { #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", default, deny_unknown_fields)] pub struct JavascriptFormatter { - /// The style for quotes. Defaults to double. + /// The type of quotes used in JavaScript code. Defaults to double. #[bpaf(long("quote-style"), argument("double|single"), optional)] #[serde(skip_serializing_if = "Option::is_none")] pub quote_style: Option, - /// The style for JSX quotes. Defaults to double. + /// The type of quotes used in JSX. Defaults to double. #[bpaf(long("jsx-quote-style"), argument("double|single"), optional)] #[serde(skip_serializing_if = "Option::is_none")] pub jsx_quote_style: Option, diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index 97a1f0799b1..e4b7b4bcb3c 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -678,7 +678,7 @@ ] }, "jsxQuoteStyle": { - "description": "The style for JSX quotes. Defaults to double.", + "description": "The type of quotes used in JSX. Defaults to double.", "anyOf": [{ "$ref": "#/definitions/QuoteStyle" }, { "type": "null" }] }, "quoteProperties": { @@ -689,7 +689,7 @@ ] }, "quoteStyle": { - "description": "The style for quotes. Defaults to double.", + "description": "The type of quotes used in JavaScript code. Defaults to double.", "anyOf": [{ "$ref": "#/definitions/QuoteStyle" }, { "type": "null" }] }, "semicolons": { diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index fee46edf71c..73b2b336531 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -178,7 +178,7 @@ export interface JavascriptFormatter { */ arrowParentheses?: ArrowParentheses; /** - * The style for JSX quotes. Defaults to double. + * The type of quotes used in JSX. Defaults to double. */ jsxQuoteStyle?: QuoteStyle; /** @@ -186,7 +186,7 @@ export interface JavascriptFormatter { */ quoteProperties?: QuoteProperties; /** - * The style for quotes. Defaults to double. + * The type of quotes used in JavaScript code. Defaults to double. */ quoteStyle?: QuoteStyle; /** diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index 97a1f0799b1..e4b7b4bcb3c 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -678,7 +678,7 @@ ] }, "jsxQuoteStyle": { - "description": "The style for JSX quotes. Defaults to double.", + "description": "The type of quotes used in JSX. Defaults to double.", "anyOf": [{ "$ref": "#/definitions/QuoteStyle" }, { "type": "null" }] }, "quoteProperties": { @@ -689,7 +689,7 @@ ] }, "quoteStyle": { - "description": "The style for quotes. Defaults to double.", + "description": "The type of quotes used in JavaScript code. Defaults to double.", "anyOf": [{ "$ref": "#/definitions/QuoteStyle" }, { "type": "null" }] }, "semicolons": { diff --git a/website/src/pages/analyzer/index.mdx b/website/src/pages/analyzer/index.mdx index 87de3c6cf26..9cd55cbfd54 100644 --- a/website/src/pages/analyzer/index.mdx +++ b/website/src/pages/analyzer/index.mdx @@ -24,6 +24,8 @@ This feature is opt-in via configuration: } ``` +### How imports are sorted + Import statements are sorted by "distance". Modules that are "farther" from the user are put on the top, modules "closer" to the user are put on the bottom: 1. built-in Node.js modules that are explicitly imported using the `node:` protocol; @@ -60,9 +62,9 @@ They will be sorted like this: ``` -You can apply the sorting in two-way: via LSP or CLI +You can apply the sorting in two ways: via [CLI](#import-sorting-via-cli) or [VSCode extension](#import-sorting-via-vscode-extension) -### Imports sorting via CLI +### Import sorting via CLI Due to the nature of the language, the sorting of imports is categorised as **unsafe**, and you can apply it using the `--apply-unsafe` option: @@ -70,7 +72,7 @@ Due to the nature of the language, the sorting of imports is categorised as **un rome check --apply-unsafe ./path/to/src ``` -### Imports sorting via VSCode extension +### Import sorting via VSCode extension The Rome VS Code extension has experimental support for imports sorting through the "Organize Imports" code action. By default this action can be run using the +Alt+O keyboard shortcut, or is accessible through the _Command Palette_ (Ctrl/++P) by selecting _Organize Imports_. diff --git a/website/src/pages/configuration.mdx b/website/src/pages/configuration.mdx index e47ee942434..91a88de13b3 100644 --- a/website/src/pages/configuration.mdx +++ b/website/src/pages/configuration.mdx @@ -163,6 +163,20 @@ match these patterns. "ignore": ["scripts/*.js"] } } +``` + + ### `files.allowUnknown` + +Rome won't emit diagnostics if it encounters files that can't handle. + + + +```json +{ + "files": { + "allowUnknown": true + } +} ``` ## `vcs` @@ -429,13 +443,11 @@ The type of quote used when representing string literals. It can be `single` or > Default: `double` -[//]: # (### `javascript.formatter.jsxQuoteStyle`) +### `javascript.formatter.jsxQuoteStyle` -[//]: # () -[//]: # (The type of quote used when representing jsx string literals. It can be `single` or `double`.) +The type of quote used when representing jsx string literals. It can be `single` or `double`. -[//]: # () -[//]: # (> Default: `double`) +> Default: `double` ### `javascript.formatter.quoteProperties` @@ -460,6 +472,14 @@ It configures where the formatter prints semicolons: > Default: `always` +### `javascript.formatter.arrowParentheses` + +Whether to add non-necessary parentheses to arrow functions: +- `always`, the parentheses are always added; +- `asNeeded`, the parentheses are added only when they are needed; + +> Default: `always` + Example: @@ -486,3 +506,19 @@ A list of global names that Rome should ignore (analyzer, linter, etc.) } } ``` + +### `json.parser.allowComments` + +Enables the parsing of comments in JSON files. + + + +```json +{ + "json": { + "parser": { + "allowComments": true + } + } +} +``` diff --git a/website/src/pages/schemas/13.0.0/schema.json.js b/website/src/pages/schemas/13.0.0/schema.json.js index 4287ccd3dc4..31e031143ab 100644 --- a/website/src/pages/schemas/13.0.0/schema.json.js +++ b/website/src/pages/schemas/13.0.0/schema.json.js @@ -1,16 +1,18 @@ // Run `ROME_VERSION= cargo codegen-website // to generate a new schema -import {readFileSync} from "fs"; -import {join, resolve} from "path" +import { readFileSync } from "fs"; +import { join, resolve } from "path"; export function get() { - const schemaPath = resolve(join("..", "npm", "rome", "configuration_schema.json")); - const schema = readFileSync(schemaPath, "utf8") + const schemaPath = resolve( + join("..", "npm", "rome", "configuration_schema.json"), + ); + const schema = readFileSync(schemaPath, "utf8"); return new Response(schema, { status: 200, headers: { - "content-type": "application/json" - } - }) -} \ No newline at end of file + "content-type": "application/json", + }, + }); +}