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

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr committed Jul 18, 2023
2 parents 20f3552 + 1349452 commit cdb81f7
Show file tree
Hide file tree
Showing 293 changed files with 2,928 additions and 621 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ if no error diagnostics are emitted.

- Added a new option called `--jsx-quote-style` to the formatter. This option allows you to choose between single and double quotes for JSX attributes. [#4486](https://github.com/rome/tools/issues/4486)

- Added a new option called `--arrow-parentheses` to the formatter. This option allows you to set the parentheses style for arrow functions. [#4666](https://github.com/rome/tools/issues/4666)

### Linter

- [`noDuplicateParameters`](https://docs.rome.tools/lint/rules/noduplicateparameters/): enhanced rule to manage constructor parameters.
Expand Down Expand Up @@ -145,6 +147,10 @@ if no error diagnostics are emitted.

This rule disallows useless `export {}`.

- Add [`useIsArray`](https://docs.rome.tools/lint/rules/useIsArray/)

This rule proposes using `Array.isArray()` instead of `instanceof Array`.

#### Other changes

- Add new TypeScript globals (`AsyncDisposable`, `Awaited`, `DecoratorContext`, and others) [4643](https://github.com/rome/tools/issues/4643).
Expand Down
9 changes: 5 additions & 4 deletions Cargo.lock

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

38 changes: 19 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ rome_aria_metadata = { path = "./crates/rome_aria_metadata" }
rome_cli = { path = "./crates/rome_cli" }
rome_console = { version = "0.0.1", path = "./crates/rome_console" }
rome_control_flow = { path = "./crates/rome_control_flow" }
rome_css_factory = { path = "./crates/rome_css_factory" }
rome_css_parser = { path = "./crates/rome_css_parser" }
rome_css_syntax = { path = "./crates/rome_css_syntax" }
rome_deserialize = { version = "0.0.0", path = "./crates/rome_deserialize" }
rome_diagnostics = { version = "0.0.1", path = "./crates/rome_diagnostics" }
rome_diagnostics_categories = { version = "0.0.1", path = "./crates/rome_diagnostics_categories" }
Expand All @@ -54,6 +51,9 @@ rome_json_factory = { version = "0.0.1", path = "./crates/rome_json_fa
rome_json_formatter = { path = "./crates/rome_json_formatter" }
rome_json_parser = { path = "./crates/rome_json_parser" }
rome_json_syntax = { version = "0.0.1", path = "./crates/rome_json_syntax" }
rome_css_factory = { path = "./crates/rome_css_factory" }
rome_css_parser = { path = "./crates/rome_css_parser" }
rome_css_syntax = { path = "./crates/rome_css_syntax" }
rome_lsp = { path = "./crates/rome_lsp" }
rome_markup = { version = "0.0.1", path = "./crates/rome_markup" }
rome_migrate = { path = "./crates/rome_migrate" }
Expand All @@ -65,24 +65,24 @@ rome_text_size = { version = "0.0.1", path = "./crates/rome_text_si
tests_macros = { path = "./crates/tests_macros" }

# Crates needed in the workspace
bitflags = "2.3.1"
bpaf = { version = "0.9.1", features = ["derive"] }
countme = "3.0.1"
dashmap = "5.4.0"
indexmap = "1.9.3"
insta = "1.29.0"
lazy_static = "1.4.0"
quickcheck = "1.0.3"
quickcheck_macros = "1.0.0"
quote = { version = "1.0.28" }
rustc-hash = "1.1.0"
schemars = { version = "0.8.12" }
serde = { version = "1.0.163", features = ["derive"], default-features = false }
serde_json = "1.0.96"
smallvec = { version = "1.10.0", features = ["union", "const_new"] }
tracing = { version = "0.1.37", default-features = false, features = ["std"] }
quickcheck = "1.0.3"
bitflags = "2.3.1"
bpaf = { version = "0.9.2", features = ["derive"] }
countme = "3.0.1"
dashmap = "5.4.0"
indexmap = "1.9.3"
insta = "1.29.0"
lazy_static = "1.4.0"
quote = { version = "1.0.28" }
rustc-hash = "1.1.0"
schemars = { version = "0.8.12" }
serde = { version = "1.0.163", features = ["derive"], default-features = false }
serde_json = "1.0.96"
smallvec = { version = "1.10.0", features = ["union", "const_new"] }
tracing = { version = "0.1.37", default-features = false, features = ["std"] }
# pinning to version 1.18 to avoid multiple versions of windows-sys as dependency
tokio = { version = "~1.18.5" }
tokio = { version = "~1.18.5" }


[profile.dev.package.rome_wasm]
Expand Down
3 changes: 3 additions & 0 deletions crates/rome_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ rome_js_formatter = { workspace = true }
rome_json_formatter = { workspace = true }
rome_json_parser = { workspace = true }
tokio = { workspace = true, features = ["io-util"] }

[features]
docgen = ["bpaf/docgen"]
2 changes: 0 additions & 2 deletions crates/rome_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ pub(crate) mod version;

#[derive(Debug, Clone, Bpaf)]
#[bpaf(options, version(VERSION))]
/// Rome CLI
///
/// Rome official CLI. Use it to check the health of your project or run it to check single files.
pub enum RomeCommand {
/// Shows the Rome version information and quit
Expand Down
62 changes: 62 additions & 0 deletions crates/rome_cli/tests/commands/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ const APPLY_TRAILING_COMMA_AFTER: &str = r#"const a = [
];
"#;

const APPLY_ARROW_PARENTHESES_BEFORE: &str = r#"
action => {}
(action) => {}
({ action }) => {}
([ action ]) => {}
(...action) => {}
(action = 1) => {}
"#;

const APPLY_ARROW_PARENTHESES_AFTER: &str = r#"action => {};
action => {};
({ action }) => {};
([action]) => {};
(...action) => {};
(action = 1) => {};
"#;

const DEFAULT_CONFIGURATION_BEFORE: &str = r#"function f() {
return { a, b }
}"#;
Expand Down Expand Up @@ -707,6 +724,51 @@ fn applies_custom_trailing_comma() {
));
}

#[test]
fn applies_custom_arrow_parentheses() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let file_path = Path::new("file.js");
fs.insert(file_path.into(), APPLY_ARROW_PARENTHESES_BEFORE.as_bytes());

let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from(
[
("format"),
("--arrow-parentheses"),
("as-needed"),
("--write"),
file_path.as_os_str().to_str().unwrap(),
]
.as_slice(),
),
);

assert!(result.is_ok(), "run_cli returned {result:?}");

let mut file = fs
.open(file_path)
.expect("formatting target file was removed by the CLI");

let mut content = String::new();
file.read_to_string(&mut content)
.expect("failed to read file from memory FS");

assert_eq!(content, APPLY_ARROW_PARENTHESES_AFTER);

drop(file);
assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"applies_custom_arrow_parentheses",
fs,
console,
result,
));
}

#[test]
fn trailing_comma_parse_errors() {
let mut console = BufferConsole::default();
Expand Down
35 changes: 18 additions & 17 deletions crates/rome_cli/tests/snapshots/main_commands_check/check_help.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The configuration that is contained inside the file `rome.json`
--vcs-enabled=<true|false> Whether Rome should integrate itself with the VCS client
--vcs-use-ignore-file=<true|false> Whether Rome should use the VCS ignore file. When [true],
Rome will ignore the files specified in the ignore file.
--vcs-root=PATH The folder where Rome should check for VCS files. By default, Rome will
--vcs-root=PATH The folder where Rome should check for VCS files. By default, Rome will
use the same folder where `rome.json` was found.
If Rome can't find the configuration, it will attempt to use the current
working directory. If no current working directory can't be found, Rome
Expand All @@ -24,45 +24,46 @@ The configuration that is contained inside the file `rome.json`
--files-ignore-unknown=<true|false> Tells Rome to not emit diagnostics when handling files that
doesn't know
--indent-style=<tab|space> The indent style.
--indent-size=NUMBER The size of the indentation, 2 by default
--line-width=NUMBER What's the max width of a line. Defaults to 80.
--indent-size=NUMBER The size of the indentation, 2 by default
--line-width=NUMBER What's the max width of a line. Defaults to 80.
--quote-style=<double|single> The style for quotes. Defaults to double.
--jsx-quote-style=<double|single> The style for JSX quotes. Defaults to double.
--quote-properties=<preserve|as-needed> When properties in objects are quoted. Defaults to asNeeded.
--trailing-comma=<all|es5|none> Print trailing commas wherever possible in multi-line comma-separated
syntactic structures. Defaults to "all".
--semicolons=<always|as-needed> Whether the formatter prints semicolons for all statements or
only in for statements where it is necessary because of ASI.
--arrow-parentheses=<always|as-needed> Whether to add non-necessary parentheses to arrow functions.
Defaults to "always".
Global options applied to all commands
--colors=<off|force> Set the formatting mode for markup: "off" prints everything as plain
text, "force" forces the formatting of markup using ANSI even if the console
--colors=<off|force> Set the formatting mode for markup: "off" prints everything as plain text,
"force" forces the formatting of markup using ANSI even if the console
output is determined to be incompatible
--use-server Connect to a running instance of the Rome daemon server.
--verbose Print additional verbose advices on diagnostics
--config-path=PATH Set the filesystem path to the directory of the rome.json configuration
--use-server Connect to a running instance of the Rome daemon server.
--verbose Print additional verbose advices on diagnostics
--config-path=PATH Set the filesystem path to the directory of the rome.json configuration
file
--max-diagnostics=NUMBER Cap the amount of diagnostics displayed.
[default: 20]
--skip-errors Skip over files containing syntax errors instead of emitting an error
diagnostic.
[default: 20]
--skip-errors Skip over files containing syntax errors instead of emitting an error diagnostic.
--no-errors-on-unmatched Silence errors that would be emitted in case no files were processed
during the execution of the command.
--error-on-warnings Tell Rome to exit with an error code if some diagnostics emit warnings.
--json Reports information using the JSON format
--error-on-warnings Tell Rome to exit with an error code if some diagnostics emit warnings.
--json Reports information using the JSON format
Available positional items:
PATH Single file, single path or list of paths
PATH Single file, single path or list of paths
Available options:
--apply Apply safe fixes, formatting
--apply-unsafe Apply safe fixes and unsafe fixes, formatting and import sorting
--apply Apply safe fixes, formatting
--apply-unsafe Apply safe fixes and unsafe fixes, formatting and import sorting
--formatter-enabled=<true|false> Allow to enable or disable the formatter check.
--linter-enabled=<true|false> Allow to enable or disable the linter check.
--organize-imports-enabled=<true|false> Allow to enable or disable the organize imports.
--stdin-file-path=PATH A file name with its extension to pass when reading from standard in,
e.g. echo 'let a;' | rome check --stdin-file-path=file.js"
-h, --help Prints help information
-h, --help Prints help information
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━
× Failed to parse CLI arguments.
Caused by:
Couldn't parse `-1`: invalid digit found in string
couldn't parse `-1`: invalid digit found in string
Expand Down
31 changes: 16 additions & 15 deletions crates/rome_cli/tests/snapshots/main_commands_ci/ci_help.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The configuration that is contained inside the file `rome.json`
--vcs-enabled=<true|false> Whether Rome should integrate itself with the VCS client
--vcs-use-ignore-file=<true|false> Whether Rome should use the VCS ignore file. When [true],
Rome will ignore the files specified in the ignore file.
--vcs-root=PATH The folder where Rome should check for VCS files. By default, Rome will
--vcs-root=PATH The folder where Rome should check for VCS files. By default, Rome will
use the same folder where `rome.json` was found.
If Rome can't find the configuration, it will attempt to use the current
working directory. If no current working directory can't be found, Rome
Expand All @@ -25,41 +25,42 @@ The configuration that is contained inside the file `rome.json`
--files-ignore-unknown=<true|false> Tells Rome to not emit diagnostics when handling files that
doesn't know
--indent-style=<tab|space> The indent style.
--indent-size=NUMBER The size of the indentation, 2 by default
--line-width=NUMBER What's the max width of a line. Defaults to 80.
--indent-size=NUMBER The size of the indentation, 2 by default
--line-width=NUMBER What's the max width of a line. Defaults to 80.
--quote-style=<double|single> The style for quotes. Defaults to double.
--jsx-quote-style=<double|single> The style for JSX quotes. Defaults to double.
--quote-properties=<preserve|as-needed> When properties in objects are quoted. Defaults to asNeeded.
--trailing-comma=<all|es5|none> Print trailing commas wherever possible in multi-line comma-separated
syntactic structures. Defaults to "all".
--semicolons=<always|as-needed> Whether the formatter prints semicolons for all statements or
only in for statements where it is necessary because of ASI.
--arrow-parentheses=<always|as-needed> Whether to add non-necessary parentheses to arrow functions.
Defaults to "always".
Global options applied to all commands
--colors=<off|force> Set the formatting mode for markup: "off" prints everything as plain
text, "force" forces the formatting of markup using ANSI even if the console
--colors=<off|force> Set the formatting mode for markup: "off" prints everything as plain text,
"force" forces the formatting of markup using ANSI even if the console
output is determined to be incompatible
--use-server Connect to a running instance of the Rome daemon server.
--verbose Print additional verbose advices on diagnostics
--config-path=PATH Set the filesystem path to the directory of the rome.json configuration
--use-server Connect to a running instance of the Rome daemon server.
--verbose Print additional verbose advices on diagnostics
--config-path=PATH Set the filesystem path to the directory of the rome.json configuration
file
--max-diagnostics=NUMBER Cap the amount of diagnostics displayed.
[default: 20]
--skip-errors Skip over files containing syntax errors instead of emitting an error
diagnostic.
[default: 20]
--skip-errors Skip over files containing syntax errors instead of emitting an error diagnostic.
--no-errors-on-unmatched Silence errors that would be emitted in case no files were processed
during the execution of the command.
--error-on-warnings Tell Rome to exit with an error code if some diagnostics emit warnings.
--json Reports information using the JSON format
--error-on-warnings Tell Rome to exit with an error code if some diagnostics emit warnings.
--json Reports information using the JSON format
Available positional items:
PATH Single file, single path or list of paths
PATH Single file, single path or list of paths
Available options:
--formatter-enabled=<true|false> Allow to enable or disable the formatter check.
--linter-enabled=<true|false> Allow to enable or disable the linter check.
--organize-imports-enabled=<true|false> Allow to enable or disable the organize imports.
-h, --help Prints help information
-h, --help Prints help information
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━
× Failed to parse CLI arguments.
Caused by:
Couldn't parse `-1`: invalid digit found in string
couldn't parse `-1`: invalid digit found in string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
source: crates/rome_cli/tests/snap_test.rs
expression: content
---
## `file.js`

```js
action => {};
action => {};
({ action }) => {};
([action]) => {};
(...action) => {};
(action = 1) => {};

```

# Emitted Messages

```block
Formatted 1 file(s) in <TIME>
```


Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━
× Failed to parse CLI arguments.
Caused by:
Couldn't parse `-1`: invalid digit found in string
couldn't parse `-1`: invalid digit found in string
Expand Down
Loading

0 comments on commit cdb81f7

Please sign in to comment.