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

Commit

Permalink
more configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Aug 3, 2023
1 parent 551db2a commit d228608
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 24 deletions.
4 changes: 2 additions & 2 deletions crates/rome_service/src/configuration/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<QuoteStyle>,
/// 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<QuoteStyle>,
Expand Down
4 changes: 2 additions & 2 deletions editors/vscode/configuration_schema.json

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

4 changes: 2 additions & 2 deletions npm/backend-jsonrpc/src/workspace.ts

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

4 changes: 2 additions & 2 deletions npm/rome/configuration_schema.json

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

8 changes: 5 additions & 3 deletions website/src/pages/analyzer/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,17 +62,17 @@ 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:

```shell
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 <kbd title="Shift">⇧</kbd>+<kbd>Alt</kbd>+<kbd>O</kbd> keyboard shortcut, or is accessible through the _Command Palette_ (<kbd>Ctrl</kbd>/<kbd title="Cmd">⌘</kbd>+<kbd title="Shift">⇧</kbd>+<kbd>P</kbd>) by selecting _Organize Imports_.
Expand Down
46 changes: 41 additions & 5 deletions website/src/pages/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<CodeBlockHeader filename="rome.json" />

```json
{
"files": {
"allowUnknown": true
}
}
```

## `vcs`
Expand Down Expand Up @@ -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`

Expand All @@ -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:

<CodeBlockHeader filename="rome.json" />
Expand All @@ -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.

<CodeBlockHeader filename="rome.json" />

```json
{
"json": {
"parser": {
"allowComments": true
}
}
}
```
18 changes: 10 additions & 8 deletions website/src/pages/schemas/13.0.0/schema.json.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Run `ROME_VERSION=<version number> 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"
}
})
}
"content-type": "application/json",
},
});
}

0 comments on commit d228608

Please sign in to comment.