From 5912acdf954c96706b9cb6a2566583fb11883134 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Fri, 16 Sep 2022 16:08:52 +0100 Subject: [PATCH 1/4] docs(website): add newline (#3247) --- website/src/docs/lint/rules/noAsyncPromiseExecutor.md | 1 + website/src/docs/lint/rules/noUnusedVariables.md | 1 + xtask/lintdoc/src/main.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/website/src/docs/lint/rules/noAsyncPromiseExecutor.md b/website/src/docs/lint/rules/noAsyncPromiseExecutor.md index 1dedf152fcf..0109c29be83 100644 --- a/website/src/docs/lint/rules/noAsyncPromiseExecutor.md +++ b/website/src/docs/lint/rules/noAsyncPromiseExecutor.md @@ -13,6 +13,7 @@ The executor function can also be an async function. However, this is usually a 1. If an async executor function throws an error, the error will be lost and won't cause the newly-constructed `Promise` to reject. This could make it difficult to debug and handle some errors. 2. If a Promise executor function is using `await`, this is usually a sign that it is not actually necessary to use the `new Promise` constructor, or the scope of the `new Promise` constructor can be reduced. + ## Examples ### Invalid diff --git a/website/src/docs/lint/rules/noUnusedVariables.md b/website/src/docs/lint/rules/noUnusedVariables.md index 51b6acdecd6..57b215d6528 100644 --- a/website/src/docs/lint/rules/noUnusedVariables.md +++ b/website/src/docs/lint/rules/noUnusedVariables.md @@ -11,6 +11,7 @@ There are two exceptions to this rule: 1. variables that starts with underscore, ex: `let _something;` 2. the `React` variable; + The pattern of having an underscore as prefix of a name of variable is a very diffuse pattern among programmers, and Rome decided to follow it. diff --git a/xtask/lintdoc/src/main.rs b/xtask/lintdoc/src/main.rs index 3d69ae83558..f0624a86616 100644 --- a/xtask/lintdoc/src/main.rs +++ b/xtask/lintdoc/src/main.rs @@ -317,6 +317,7 @@ fn parse_documentation( Event::End(Tag::List(_)) => { list_order = None; + writeln!(content)?; } Event::Start(Tag::Item) => { if let Some(num) = list_order { From 51f9f0f64cdb7e92837a35572f9959a00d01786d Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 19 Sep 2022 09:26:25 +0100 Subject: [PATCH 2/4] refactor(website): add script to update the code contributors (#3223) --- .cargo/config.toml | 1 + Cargo.lock | 29 ++ Cargo.toml | 1 + website/src/_includes/contributors.md | 672 ++++++++++++++++++++++++++ website/src/credits.md | 303 +----------- xtask/contributors/Cargo.toml | 13 + xtask/contributors/src/main.rs | 99 ++++ xtask/src/lib.rs | 2 +- 8 files changed, 817 insertions(+), 303 deletions(-) create mode 100644 website/src/_includes/contributors.md create mode 100644 xtask/contributors/Cargo.toml create mode 100644 xtask/contributors/src/main.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index a4813f0d89a..84b6f9b2206 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -27,6 +27,7 @@ bench_analyzer = "run -p xtask_bench --release -- --feature analyzer" coverage = "run -p xtask_coverage --profile=release-with-debug --" rome-cli = "run -p rome_cli --release --" rome-cli-dev = "run -p rome_cli --" +contributors = "run -p xtask_contributors --" [profile.release] lto = true diff --git a/Cargo.lock b/Cargo.lock index 5216423acca..2af2bb44136 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -744,6 +744,15 @@ dependencies = [ "libc", ] +[[package]] +name = "html-escape" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e7479fa1ef38eb49fb6a42c426be515df2d063f06cb8efd3e50af073dbc26c" +dependencies = [ + "utf8-width", +] + [[package]] name = "httparse" version = "1.7.1" @@ -2513,6 +2522,8 @@ dependencies = [ "log", "once_cell", "rustls", + "serde", + "serde_json", "url", "webpki", "webpki-roots", @@ -2531,6 +2542,12 @@ dependencies = [ "serde", ] +[[package]] +name = "utf8-width" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" + [[package]] name = "valuable" version = "0.1.0" @@ -2837,6 +2854,18 @@ dependencies = [ "xtask", ] +[[package]] +name = "xtask_contributors" +version = "0.0.0" +dependencies = [ + "html-escape", + "pico-args", + "serde", + "serde_json", + "ureq", + "xtask", +] + [[package]] name = "xtask_coverage" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index 1aff5ce69e6..6da4801a0e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "xtask/coverage", "xtask/lintdoc", "xtask/libs_bench", + "xtask/contributors", ] [profile.release-with-debug] diff --git a/website/src/_includes/contributors.md b/website/src/_includes/contributors.md new file mode 100644 index 00000000000..2ad95787f66 --- /dev/null +++ b/website/src/_includes/contributors.md @@ -0,0 +1,672 @@ + + +### Code contributors + + diff --git a/website/src/credits.md b/website/src/credits.md index df0a7c27b34..e5059a78056 100644 --- a/website/src/credits.md +++ b/website/src/credits.md @@ -107,308 +107,7 @@ layout: layouts/page.liquid -## Code Contributors - - - - +{% include ./contributors.md %} ### Acknowledgements diff --git a/xtask/contributors/Cargo.toml b/xtask/contributors/Cargo.toml new file mode 100644 index 00000000000..aa0c4e9b8a9 --- /dev/null +++ b/xtask/contributors/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "xtask_contributors" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies] +serde = { version = "1.0.133", features = ["derive"] } +serde_json = { version = "1.0.74" } +xtask = { path = '../', version = "0.0" } +ureq = { version = "2.4.0", features = ["json"] } +pico-args = "0.5.0" +html-escape = "0.2.11" \ No newline at end of file diff --git a/xtask/contributors/src/main.rs b/xtask/contributors/src/main.rs new file mode 100644 index 00000000000..998693c740e --- /dev/null +++ b/xtask/contributors/src/main.rs @@ -0,0 +1,99 @@ +use pico_args::Arguments; +use serde::{Deserialize, Serialize}; +use std::fmt::Write; +use xtask::glue::fs2; +use xtask::*; + +/// A token is needed to run this script. To create a token, go to https://github.com/settings/tokens +/// and give it read access to the repository. +/// +/// Only users that have read rights can run this script +fn main() -> Result<()> { + let root = project_root().join("website/src/_includes"); + let mut args = Arguments::from_env(); + let token: String = args.value_from_str("--token").unwrap(); + let contributors = get_contributors(&token); + + let mut content = String::new(); + + let command = "Use the command `cargo contributors`".to_string(); + write!(content, "", prepend_generated_preamble(command))?; + content.push('\n'); + content.push_str("### Code contributors"); + content.push('\n'); + content.push_str(""); + fs2::write(root.join("contributors.md"), content)?; + + Ok(()) +} + +#[derive(Debug, Deserialize, Serialize)] +struct Contributor { + avatar_url: String, + login: String, +} + +fn get_contributors(token: &str) -> Vec { + let mut contributors = Vec::new(); + contributors_request( + "https://api.github.com/repos/rome/tools/contributors", + token, + &mut contributors, + ); + contributors +} + +fn contributors_request(url: &str, token: &str, contributors: &mut Vec) { + let request = ureq::get(url) + .set("User-Agent", "@rome") + .set("Authorization", &format!("token {token}")); + + match request.call() { + Ok(response) => { + if let Some(link) = response.header("link") { + if link.contains("rel=\"next\"") { + let start_index = link + .find("rel=\"prev\", ") + .map(|index| index + "rel=\"prev\", ".len()) + .unwrap_or(0); + // SAFETY: checked before + let end_index = link.find("; rel=\"next\"").unwrap(); + let url = &link[start_index..end_index]; + let url = url.replace('<', "").replace('>', ""); + + contributors_request(&url, token, contributors); + } + } + let result: Result, std::io::Error> = response.into_json(); + if let Ok(new_contributors) = result { + contributors.extend(new_contributors); + } + } + Err(err) => { + eprintln!("{:?}", err); + } + } +} diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index edcd613f325..ec28b54c3ca 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -43,7 +43,7 @@ pub fn reformat(text: impl Display) -> Result { reformat_without_preamble(text).map(prepend_generated_preamble) } -const PREAMBLE: &str = "Generated file, do not edit by hand, see `xtask/codegen`"; +pub const PREAMBLE: &str = "Generated file, do not edit by hand, see `xtask/codegen`"; pub fn prepend_generated_preamble(content: impl Display) -> String { format!("//! {}\n\n{}", PREAMBLE, content) } From 9a767d6a716647ea7c8ae89533640fd74259ef9b Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Tue, 20 Sep 2022 11:18:24 +0200 Subject: [PATCH 3/4] test(rome_js_formatter): Add prettier's JSX tests (#3255) --- .../rome_js_formatter/tests/prettier_tests.rs | 2 +- ...k-line-between-specifiers.js.prettier-snap | 2 - .../blank-line-between-specifiers.js.snap | 80 - .../specs/prettier/js/if/trailing_comment.js | 7 - .../prettier/js/if/trailing_comment.js.snap | 27 +- .../js/import-assertions/re-export.js | 2 +- .../re-export.js.prettier-snap | 2 +- .../specs/prettier/js/method-chain/13018.js | 8 + .../js/method-chain/13018.js.prettier-snap | 20 + .../prettier/js/method-chain/13018.js.snap | 69 + .../specs/prettier/js/range/function-body.js | 3 + .../js/range/function-body.js.prettier-snap | 3 + .../prettier/js/range/function-body.js.snap | 37 + .../tests/specs/prettier/js/record/spread.js | 1 - .../specs/prettier/js/record/spread.js.snap | 3 +- .../prettier/js/strings/multiline-literal.js | 9 + .../multiline-literal.js.prettier-snap | 10 + .../js/strings/multiline-literal.js.snap | 55 + .../test_declarations.js.prettier-snap | 80 +- .../test_declarations.js.snap | 92 +- .../prettier/jsx/attr-element/attr-element.js | 2 + .../attr-element.js.prettier-snap | 12 + .../relational-operators.js | 19 + .../relational-operators.js.prettier-snap | 19 + .../tests/specs/prettier/jsx/do/do.js | 5 + .../specs/prettier/jsx/do/do.js.prettier-snap | 5 + .../tests/specs/prettier/jsx/do/do.js.snap | 61 + .../tests/specs/prettier/jsx/escape/escape.js | 1 + .../jsx/escape/escape.js.prettier-snap | 1 + .../tests/specs/prettier/jsx/escape/nbsp.js | 13 + .../prettier/jsx/escape/nbsp.js.prettier-snap | 9 + .../tests/specs/prettier/jsx/fbt/test.js | 115 ++ .../prettier/jsx/fbt/test.js.prettier-snap | 104 ++ .../tests/specs/prettier/jsx/fbt/test.js.snap | 281 ++++ .../specs/prettier/jsx/fragment/fragment.js | 72 + .../jsx/fragment/fragment.js.prettier-snap | 72 + .../prettier/jsx/fragment/fragment.js.snap | 202 +++ .../specs/prettier/jsx/ignore/jsx_ignore.js | 56 + .../jsx/ignore/jsx_ignore.js.prettier-snap | 55 + .../prettier/jsx/ignore/jsx_ignore.js.snap | 193 +++ .../prettier/jsx/multiline-assign/test.js | 19 + .../multiline-assign/test.js.prettier-snap | 31 + .../jsx/namespace/jsx_namespaced_name.js | 3 + .../jsx_namespaced_name.js.prettier-snap | 3 + .../tests/specs/prettier/jsx/newlines/test.js | 94 ++ .../jsx/newlines/test.js.prettier-snap | 57 + .../specs/prettier/jsx/newlines/test.js.snap | 193 +++ .../specs/prettier/jsx/newlines/windows.js | 3 + .../jsx/newlines/windows.js.prettier-snap | 1 + .../jsx/significant-space/comments.js | 7 + .../comments.js.prettier-snap | 7 + .../prettier/jsx/significant-space/test.js | 74 + .../significant-space/test.js.prettier-snap | 117 ++ .../jsx/significant-space/test.js.snap | 290 ++++ .../single-attribute-per-line.js | 27 + ...single-attribute-per-line.js.prettier-snap | 38 + .../specs/prettier/jsx/split-attrs/test.js | 49 + .../jsx/split-attrs/test.js.prettier-snap | 170 ++ .../prettier/jsx/split-attrs/test.js.snap | 261 ++++ .../specs/prettier/jsx/spread/attribute.js | 25 + .../jsx/spread/attribute.js.prettier-snap | 36 + .../prettier/jsx/spread/attribute.js.snap | 115 ++ .../tests/specs/prettier/jsx/spread/child.js | 23 + .../jsx/spread/child.js.prettier-snap | 32 + .../specs/prettier/jsx/spread/child.js.snap | 116 ++ .../prettier/jsx/stateless-arrow-fn/test.js | 73 + .../stateless-arrow-fn/test.js.prettier-snap | 170 ++ .../jsx/stateless-arrow-fn/test.js.snap | 300 ++++ .../jsx/template/styled-components.js | 18 + .../styled-components.js.prettier-snap | 19 + .../jsx/template/styled-components.js.snap | 75 + .../specs/prettier/jsx/text-wrap/test.js | 458 ++++++ .../jsx/text-wrap/test.js.prettier-snap | 570 +++++++ .../specs/prettier/jsx/text-wrap/test.js.snap | 1390 +++++++++++++++++ .../tests/specs/prettier/prepare_tests.js | 8 + .../conditional-types/issue-13275.ts | 1 + .../issue-13275.ts.prettier-snap | 1 + .../enum/computed-members.ts.prettier-snap | 6 +- .../typescript/enum/computed-members.ts.snap | 8 +- .../jsdoc_only_types.ts.prettier-snap | 4 +- .../error-recovery/jsdoc_only_types.ts.snap | 6 +- .../prettier/typescript/interface2/break.ts | 4 +- .../typescript/interface2/break.ts.snap | 61 +- .../prettier/typescript/literal/multiline.ts | 6 + .../literal/multiline.ts.prettier-snap | 7 + .../typescript/literal/multiline.ts.snap | 47 + .../typescript/typeof-this/decorators.ts | 6 + .../typeof-this/decorators.ts.prettier-snap | 6 + .../typescript/typeof-this/decorators.ts.snap | 46 + .../typescript/typeof-this/typeof-this.ts | 3 + .../typeof-this/typeof-this.ts.prettier-snap | 3 + 91 files changed, 6710 insertions(+), 186 deletions(-) delete mode 100644 crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/attr-element/attr-element.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/attr-element/attr-element.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/binary-expressions/relational-operators.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/binary-expressions/relational-operators.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/escape/escape.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/escape/escape.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/escape/nbsp.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/escape/nbsp.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/multiline-assign/test.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/multiline-assign/test.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/namespace/jsx_namespaced_name.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/namespace/jsx_namespaced_name.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/windows.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/windows.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/comments.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/comments.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/single-attribute-per-line/single-attribute-per-line.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/single-attribute-per-line/single-attribute-per-line.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts create mode 100644 crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts create mode 100644 crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts create mode 100644 crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts.prettier-snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts.snap create mode 100644 crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/typeof-this.ts create mode 100644 crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/typeof-this.ts.prettier-snap diff --git a/crates/rome_js_formatter/tests/prettier_tests.rs b/crates/rome_js_formatter/tests/prettier_tests.rs index e3fbc3c72aa..503668524ee 100644 --- a/crates/rome_js_formatter/tests/prettier_tests.rs +++ b/crates/rome_js_formatter/tests/prettier_tests.rs @@ -31,7 +31,7 @@ struct TestInfo { mod check_reformat; -tests_macros::gen_tests! {"tests/specs/prettier/{js,typescript}/**/*.{js,ts,jsx,tsx}", crate::test_snapshot, "script"} +tests_macros::gen_tests! {"tests/specs/prettier/{js,typescript,jsx}/**/*.{js,ts,jsx,tsx}", crate::test_snapshot, "script"} const PRETTIER_IGNORE: &str = "prettier-ignore"; const ROME_IGNORE: &str = "rome-ignore format: prettier ignore"; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.prettier-snap index 82cd20637b6..8856b3df341 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.prettier-snap @@ -1,7 +1,6 @@ export { // a foo1, - // b bar1, baz1, @@ -14,7 +13,6 @@ const baz2 = 1; export { // a foo2, - // b bar2, baz2, diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.snap deleted file mode 100644 index 51e23774716..00000000000 --- a/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.snap +++ /dev/null @@ -1,80 +0,0 @@ ---- -source: crates/rome_js_formatter/tests/prettier_tests.rs ---- - -# Input - -```js -export { - // a - foo1, - - // b - bar1, - baz1, -} from "mod"; - -const foo2 = 1; -const bar2 = 1; -const baz2 = 1; - -export { - // a - foo2, - - // b - bar2, - baz2, -}; -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Rome -@@ -1,7 +1,6 @@ - export { - // a - foo1, -- - // b - bar1, - baz1, -@@ -14,7 +13,6 @@ - export { - // a - foo2, -- - // b - bar2, - baz2, -``` - -# Output - -```js -export { - // a - foo1, - // b - bar1, - baz1, -} from "mod"; - -const foo2 = 1; -const bar2 = 1; -const baz2 = 1; - -export { - // a - foo2, - // b - bar2, - baz2, -}; -``` - - - diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/if/trailing_comment.js b/crates/rome_js_formatter/tests/specs/prettier/js/if/trailing_comment.js index 9b745ed0727..575cf4d57d2 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/if/trailing_comment.js +++ b/crates/rome_js_formatter/tests/specs/prettier/js/if/trailing_comment.js @@ -10,10 +10,3 @@ if ( ) { a; } - -if ( - // comment - 1 -) { - b; -} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/if/trailing_comment.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/if/trailing_comment.js.snap index 964019986f2..1ff518ef544 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/if/trailing_comment.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/if/trailing_comment.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/if/trailing_comment.js --- # Input @@ -17,13 +19,6 @@ if ( ) { a; } - -if ( - // comment - 1 -) { - b; -} ``` @@ -42,17 +37,6 @@ if ( } if (code === 92) { /* '\' */ -@@ -16,3 +15,10 @@ - ) { - a; - } -+ -+if ( -+ // comment -+ 1 -+) { -+ b; -+} ``` # Output @@ -75,13 +59,6 @@ if ( ) { a; } - -if ( - // comment - 1 -) { - b; -} ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js index dd9640ec20a..f7f9640a868 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js @@ -1,3 +1,3 @@ -export { foo2 } from "foo.json" assert { type: "json" }; +export { default as foo2 } from "foo.json" assert { type: "json" }; export * from "foo.json" assert { type: "json" }; export * as foo3 from "foo.json" assert { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js.prettier-snap index dd9640ec20a..f7f9640a868 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/re-export.js.prettier-snap @@ -1,3 +1,3 @@ -export { foo2 } from "foo.json" assert { type: "json" }; +export { default as foo2 } from "foo.json" assert { type: "json" }; export * from "foo.json" assert { type: "json" }; export * as foo3 from "foo.json" assert { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js new file mode 100644 index 00000000000..a0a4dc5ebf2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js @@ -0,0 +1,8 @@ +foo(_a).bar().leet(); +foo(-a).bar().leet(); +foo(+a).bar().leet(); +foo(~a).bar().leet(); +foo(++a).bar().leet(); +foo(--a).bar().leet(); +foo(a++).bar().leet(); +foo(a--).bar().leet(); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js.prettier-snap new file mode 100644 index 00000000000..7c19e0fb00b --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js.prettier-snap @@ -0,0 +1,20 @@ +foo(_a).bar().leet(); +foo(-a).bar().leet(); +foo(+a) + .bar() + .leet(); +foo(~a) + .bar() + .leet(); +foo(++a) + .bar() + .leet(); +foo(--a) + .bar() + .leet(); +foo(a++) + .bar() + .leet(); +foo(a--) + .bar() + .leet(); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js.snap new file mode 100644 index 00000000000..d3a5c2b1867 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/13018.js.snap @@ -0,0 +1,69 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/method-chain/13018.js +--- + +# Input + +```js +foo(_a).bar().leet(); +foo(-a).bar().leet(); +foo(+a).bar().leet(); +foo(~a).bar().leet(); +foo(++a).bar().leet(); +foo(--a).bar().leet(); +foo(a++).bar().leet(); +foo(a--).bar().leet(); +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,20 +1,8 @@ + foo(_a).bar().leet(); + foo(-a).bar().leet(); +-foo(+a) +- .bar() +- .leet(); +-foo(~a) +- .bar() +- .leet(); +-foo(++a) +- .bar() +- .leet(); +-foo(--a) +- .bar() +- .leet(); +-foo(a++) +- .bar() +- .leet(); +-foo(a--) +- .bar() +- .leet(); ++foo(+a).bar().leet(); ++foo(~a).bar().leet(); ++foo(++a).bar().leet(); ++foo(--a).bar().leet(); ++foo(a++).bar().leet(); ++foo(a--).bar().leet(); +``` + +# Output + +```js +foo(_a).bar().leet(); +foo(-a).bar().leet(); +foo(+a).bar().leet(); +foo(~a).bar().leet(); +foo(++a).bar().leet(); +foo(--a).bar().leet(); +foo(a++).bar().leet(); +foo(a--).bar().leet(); +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js b/crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js new file mode 100644 index 00000000000..1705cd72985 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js @@ -0,0 +1,3 @@ +let fn =a((x ) => { +<<>> quux (); //<<>> +}); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js.prettier-snap new file mode 100644 index 00000000000..b9dc6f74df6 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js.prettier-snap @@ -0,0 +1,3 @@ +let fn = a((x) => { + quux(); // +}); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js.snap new file mode 100644 index 00000000000..daadadf8510 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/function-body.js.snap @@ -0,0 +1,37 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/function-body.js +--- + +# Input + +```js +let fn =a((x ) => { + quux (); // +}); +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,3 +1,3 @@ +-let fn = a((x) => { ++let fn =a((x ) => { + quux(); // + }); +``` + +# Output + +```js +let fn =a((x ) => { + quux(); // +}); +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/record/spread.js b/crates/rome_js_formatter/tests/specs/prettier/js/record/spread.js index 765d4270d55..31bfe0c7667 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/record/spread.js +++ b/crates/rome_js_formatter/tests/specs/prettier/js/record/spread.js @@ -4,4 +4,3 @@ const taskLater = #{ ...taskNow, status: "DONE" } // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 }) - diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/record/spread.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/record/spread.js.snap index c5086def062..b45e5e818ec 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/record/spread.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/record/spread.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/record/spread.js --- # Input @@ -11,7 +13,6 @@ const taskLater = #{ ...taskNow, status: "DONE" } // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 }) - ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js b/crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js new file mode 100644 index 00000000000..fcecf64f399 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js @@ -0,0 +1,9 @@ +// https://github.com/prettier/prettier/pull/13274 + +const loremIpsumFooBazBar1 = 'Multiline string\ + Multiline string\ +' + +const loremIpsumFooBazBar2 = 'Multiline string\ + Multiline string\ + Multiline string' diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js.prettier-snap new file mode 100644 index 00000000000..5ccb636b7e7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js.prettier-snap @@ -0,0 +1,10 @@ +// https://github.com/prettier/prettier/pull/13274 + +const loremIpsumFooBazBar1 = "Multiline string\ + Multiline string\ +"; + +const loremIpsumFooBazBar2 = + "Multiline string\ + Multiline string\ + Multiline string"; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js.snap new file mode 100644 index 00000000000..caed317319a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/strings/multiline-literal.js.snap @@ -0,0 +1,55 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/strings/multiline-literal.js +--- + +# Input + +```js +// https://github.com/prettier/prettier/pull/13274 + +const loremIpsumFooBazBar1 = 'Multiline string\ + Multiline string\ +' + +const loremIpsumFooBazBar2 = 'Multiline string\ + Multiline string\ + Multiline string' +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,6 +1,7 @@ + // https://github.com/prettier/prettier/pull/13274 + +-const loremIpsumFooBazBar1 = "Multiline string\ ++const loremIpsumFooBazBar1 = ++ "Multiline string\ + Multiline string\ + "; + +``` + +# Output + +```js +// https://github.com/prettier/prettier/pull/13274 + +const loremIpsumFooBazBar1 = + "Multiline string\ + Multiline string\ +"; + +const loremIpsumFooBazBar2 = + "Multiline string\ + Multiline string\ + Multiline string"; +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.prettier-snap index 3bddc7bb29d..c07928430cd 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.prettier-snap @@ -85,43 +85,75 @@ skip(`does something really long and complicated so I have to write a very long skip("does something really long and complicated so I have to write a very long name for the test", () => {}); -test.step("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.step( + "does something really long and complicated so I have to write a very long name for the test", + () => {}, +); -test.step(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +test.step( + `does something really long and complicated so I have to write a very long name for the test`, + () => {}, +); -test.describe("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe( + "does something really long and complicated so I have to write a very long name for the test", + () => {}, +); -test.describe(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +test.describe( + `does something really long and complicated so I have to write a very long name for the test`, + () => {}, +); -test.describe - .only("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe.only( + "does something really long and complicated so I have to write a very long name for the test", + () => {}, +); -test.describe - .only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +test.describe.only( + `does something really long and complicated so I have to write a very long name for the test`, + () => {}, +); -test.describe - .parallel("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe.parallel( + "does something really long and complicated so I have to write a very long name for the test", + () => {}, +); -test.describe - .parallel(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +test.describe.parallel( + `does something really long and complicated so I have to write a very long name for the test`, + () => {}, +); -test.describe.parallel - .only("does something really long and complicated so I have to write a very long name for the testThis is a very", () => {}); +test.describe.parallel.only( + "does something really long and complicated so I have to write a very long name for the testThis is a very", + () => {}, +); -test.describe.parallel - .only(`does something really long and complicated so I have to write a very long name for the testThis is a very`, () => {}); +test.describe.parallel.only( + `does something really long and complicated so I have to write a very long name for the testThis is a very`, + () => {}, +); -test.describe - .serial("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe.serial( + "does something really long and complicated so I have to write a very long name for the test", + () => {}, +); -test.describe - .serial(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +test.describe.serial( + `does something really long and complicated so I have to write a very long name for the test`, + () => {}, +); -test.describe.serial - .only("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe.serial.only( + "does something really long and complicated so I have to write a very long name for the test", + () => {}, +); -test.describe.serial - .only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +test.describe.serial.only( + `does something really long and complicated so I have to write a very long name for the test`, + () => {}, +); // Should break diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.snap index 2b6182c096b..a3b6c802729 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/test-declarations/test_declarations.js --- # Input @@ -175,53 +177,97 @@ it( ```diff --- Prettier +++ Rome -@@ -93,35 +93,25 @@ +@@ -85,75 +85,33 @@ - test.describe(`does something really long and complicated so I have to write a very long name for the test`, () => {}); + skip("does something really long and complicated so I have to write a very long name for the test", () => {}); --test.describe -- .only("does something really long and complicated so I have to write a very long name for the test", () => {}); +-test.step( +- "does something really long and complicated so I have to write a very long name for the test", +- () => {}, +-); ++test.step("does something really long and complicated so I have to write a very long name for the test", () => {}); + +-test.step( +- `does something really long and complicated so I have to write a very long name for the test`, +- () => {}, +-); ++test.step(`does something really long and complicated so I have to write a very long name for the test`, () => {}); + +-test.describe( +- "does something really long and complicated so I have to write a very long name for the test", +- () => {}, +-); ++test.describe("does something really long and complicated so I have to write a very long name for the test", () => {}); + +-test.describe( +- `does something really long and complicated so I have to write a very long name for the test`, +- () => {}, +-); ++test.describe(`does something really long and complicated so I have to write a very long name for the test`, () => {}); + +-test.describe.only( +- "does something really long and complicated so I have to write a very long name for the test", +- () => {}, +-); +test.describe.only("does something really long and complicated so I have to write a very long name for the test", () => {}); --test.describe -- .only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +-test.describe.only( +- `does something really long and complicated so I have to write a very long name for the test`, +- () => {}, +-); +test.describe.only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); --test.describe -- .parallel("does something really long and complicated so I have to write a very long name for the test", () => {}); +-test.describe.parallel( +- "does something really long and complicated so I have to write a very long name for the test", +- () => {}, +-); +test.describe.parallel("does something really long and complicated so I have to write a very long name for the test", () => {}); --test.describe -- .parallel(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +-test.describe.parallel( +- `does something really long and complicated so I have to write a very long name for the test`, +- () => {}, +-); +test.describe.parallel(`does something really long and complicated so I have to write a very long name for the test`, () => {}); --test.describe.parallel -- .only("does something really long and complicated so I have to write a very long name for the testThis is a very", () => {}); +-test.describe.parallel.only( +- "does something really long and complicated so I have to write a very long name for the testThis is a very", +- () => {}, +-); +test.describe.parallel.only("does something really long and complicated so I have to write a very long name for the testThis is a very", () => {}); --test.describe.parallel -- .only(`does something really long and complicated so I have to write a very long name for the testThis is a very`, () => {}); +-test.describe.parallel.only( +- `does something really long and complicated so I have to write a very long name for the testThis is a very`, +- () => {}, +-); +test.describe.parallel.only(`does something really long and complicated so I have to write a very long name for the testThis is a very`, () => {}); --test.describe -- .serial("does something really long and complicated so I have to write a very long name for the test", () => {}); +-test.describe.serial( +- "does something really long and complicated so I have to write a very long name for the test", +- () => {}, +-); +test.describe.serial("does something really long and complicated so I have to write a very long name for the test", () => {}); --test.describe -- .serial(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +-test.describe.serial( +- `does something really long and complicated so I have to write a very long name for the test`, +- () => {}, +-); +test.describe.serial(`does something really long and complicated so I have to write a very long name for the test`, () => {}); --test.describe.serial -- .only("does something really long and complicated so I have to write a very long name for the test", () => {}); +-test.describe.serial.only( +- "does something really long and complicated so I have to write a very long name for the test", +- () => {}, +-); +test.describe.serial.only("does something really long and complicated so I have to write a very long name for the test", () => {}); --test.describe.serial -- .only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +-test.describe.serial.only( +- `does something really long and complicated so I have to write a very long name for the test`, +- () => {}, +-); +test.describe.serial.only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); // Should break -@@ -152,10 +142,7 @@ +@@ -184,10 +142,7 @@ () => {}, ); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/attr-element/attr-element.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/attr-element/attr-element.js new file mode 100644 index 00000000000..f31bd2306ce --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/attr-element/attr-element.js @@ -0,0 +1,2 @@ + />; + />; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/attr-element/attr-element.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/attr-element/attr-element.js.prettier-snap new file mode 100644 index 00000000000..fc79981e98a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/attr-element/attr-element.js.prettier-snap @@ -0,0 +1,12 @@ + + + +/>; + + + + + +/>; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/binary-expressions/relational-operators.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/binary-expressions/relational-operators.js new file mode 100644 index 00000000000..41d6bcc8b72 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/binary-expressions/relational-operators.js @@ -0,0 +1,19 @@ +(
) < 5; +
> 5; +(
) < 5; +
> 5; + +
<= 5; +
>= 5; +
<= 5; +
>= 5; + +(
) <
; +
>
; +(
) <
; +
>
; + +
<=
; +
>=
; +
<=
; +
>=
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/binary-expressions/relational-operators.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/binary-expressions/relational-operators.js.prettier-snap new file mode 100644 index 00000000000..41d6bcc8b72 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/binary-expressions/relational-operators.js.prettier-snap @@ -0,0 +1,19 @@ +(
) < 5; +
> 5; +(
) < 5; +
> 5; + +
<= 5; +
>= 5; +
<= 5; +
>= 5; + +(
) <
; +
>
; +(
) <
; +
>
; + +
<=
; +
>=
; +
<=
; +
>=
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js new file mode 100644 index 00000000000..7890763ee5b --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js @@ -0,0 +1,5 @@ +
+ {do { + 1 + }} +
diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js.prettier-snap new file mode 100644 index 00000000000..e3b5f2b7896 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js.prettier-snap @@ -0,0 +1,5 @@ +
+ {do { + 1; + }} +
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js.snap new file mode 100644 index 00000000000..b08a2e5f23a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/do/do.js.snap @@ -0,0 +1,61 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/do/do.js +--- + +# Input + +```js +
+ {do { + 1 + }} +
+``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,5 +1,5 @@ +
+ {do { +- 1; ++ 1 + }} +-
; ++
+``` + +# Output + +```js +
+ {do { + 1 + }} +
+``` + + +# Errors +``` +error[SyntaxError]: expected `}` but instead found `do` + ┌─ do.js:2:4 + │ +2 │ {do { + │ ^^ unexpected + +error: Unexpected token. Did you mean `{'}'}` or `}`? + ┌─ do.js:4:4 + │ +4 │ }} + │ ^ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/escape.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/escape.js new file mode 100644 index 00000000000..db12ce51b7a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/escape.js @@ -0,0 +1 @@ +
<
diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/escape.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/escape.js.prettier-snap new file mode 100644 index 00000000000..167cd46e48d --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/escape.js.prettier-snap @@ -0,0 +1 @@ +
<
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/nbsp.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/nbsp.js new file mode 100644 index 00000000000..87d434f5f84 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/nbsp.js @@ -0,0 +1,13 @@ +many_nbsp =
   
+single_nbsp =
 
+nbsp_with_newline = +
+   +
+ +many_raw_nbsp =
   
+many_raw_spaces =
+ + +amp = foo & bar +raw_amp = foo & bar diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/nbsp.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/nbsp.js.prettier-snap new file mode 100644 index 00000000000..af7aed664c7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/escape/nbsp.js.prettier-snap @@ -0,0 +1,9 @@ +many_nbsp =
   
; +single_nbsp =
 
; +nbsp_with_newline =
 
; + +many_raw_nbsp =
   
; +many_raw_spaces =
; + +amp = foo & bar; +raw_amp = foo & bar; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js new file mode 100644 index 00000000000..1cc594b1957 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js @@ -0,0 +1,115 @@ +x = + + + First + , + + Second + + + +x = + + + First + + , + + Second + + + +x = + + First,Second + + +x = + + + First + , + Second + + + +x = + + Prefix comes before + + + suffix + + + + +x = + + Prefix comes before + + + suffix + + + + + suffix + + + + +x = + + Count Chocula knows the the number + + is awesome + + +x = ( + + {hour}:{minute}:{second} + +); + +x = ( + + {hour} + : + {minute} + : + {second} + +); + +x = ( + + {hour}: + {minute}: + {second} + +); + +first = ( + + Text
+ More text
+ And more
+
+); + +second = ( + + Text
More text
And more
+
+); + +third = ( + + Text +
+ More text +
+ And more +
+
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js.prettier-snap new file mode 100644 index 00000000000..cf87039fe74 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js.prettier-snap @@ -0,0 +1,104 @@ +x = ( + + First, + Second + +); + +x = ( + + First + , + Second + +); + +x = ( + + First,Second + +); + +x = ( + + First,Second + +); + +x = ( + + Prefix comes before + + suffix + + +); + +x = ( + + Prefix comes before + + suffix + + + suffix + + +); + +x = ( + + Count Chocula knows the the number + + is awesome + +); + +x = ( + + {hour}:{minute}:{second} + +); + +x = ( + + {hour} + : + {minute} + : + {second} + +); + +x = ( + + {hour}: + {minute}: + {second} + +); + +first = ( + + Text
+ More text
+ And more
+
+); + +second = ( + + Text
More text
And more
+
+); + +third = ( + + Text +
+ More text +
+ And more +
+
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js.snap new file mode 100644 index 00000000000..ca247636882 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/fbt/test.js.snap @@ -0,0 +1,281 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/fbt/test.js +--- + +# Input + +```js +x = + + + First + , + + Second + + + +x = + + + First + + , + + Second + + + +x = + + First,Second + + +x = + + + First + , + Second + + + +x = + + Prefix comes before + + + suffix + + + + +x = + + Prefix comes before + + + suffix + + + + + suffix + + + + +x = + + Count Chocula knows the the number + + is awesome + + +x = ( + + {hour}:{minute}:{second} + +); + +x = ( + + {hour} + : + {minute} + : + {second} + +); + +x = ( + + {hour}: + {minute}: + {second} + +); + +first = ( + + Text
+ More text
+ And more
+
+); + +second = ( + + Text
More text
And more
+
+); + +third = ( + + Text +
+ More text +
+ And more +
+
+); +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -80,15 +80,23 @@ + + first = ( + +- Text
+- More text
+- And more
++ Text ++
++ More text ++
++ And more ++
+
+ ); + + second = ( + +- Text
More text
And more
++ Text ++
++ More text ++
++ And more ++
+
+ ); + +``` + +# Output + +```js +x = ( + + First, + Second + +); + +x = ( + + First + , + Second + +); + +x = ( + + First,Second + +); + +x = ( + + First,Second + +); + +x = ( + + Prefix comes before + + suffix + + +); + +x = ( + + Prefix comes before + + suffix + + + suffix + + +); + +x = ( + + Count Chocula knows the the number + + is awesome + +); + +x = ( + + {hour}:{minute}:{second} + +); + +x = ( + + {hour} + : + {minute} + : + {second} + +); + +x = ( + + {hour}: + {minute}: + {second} + +); + +first = ( + + Text +
+ More text +
+ And more +
+
+); + +second = ( + + Text +
+ More text +
+ And more +
+
+); + +third = ( + + Text +
+ More text +
+ And more +
+
+); +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js new file mode 100644 index 00000000000..c8c4657fd90 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js @@ -0,0 +1,72 @@ +<>; + +<> + text +; + +<> + + +; + +<> + text +

heading

+ text +

heading

+ text +; + +
+ <> + <> + Hello + world + + <> + Goodbye + world + + +
; + +foo = ( + // comment + <> +); + + + + +; + +< // open fragment +> + + +; + +[<>, <>]; +const fun1 = () => <>; +x = <> +function fun2(param = <>) {} +1 + <>; +1 || <>; +fun2(<>); +test ? <> : x; +<>; + + <> +; +const obj = { + foo: <> +}; +const fragmentVar = <>; +function fun3() { + return <>; +} +(<>).toString(); +(<>).props; +(<>)["computed"]; +(<>)["computed"](); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js.prettier-snap new file mode 100644 index 00000000000..6c2f55893d6 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js.prettier-snap @@ -0,0 +1,72 @@ +<>; + +<>text; + +<> + + +; + +<> + text +

heading

+ text +

heading

+ text +; + +
+ <> + <> + Hello + world + + <> + Goodbye + world + + +
; + +foo = ( + // comment + <> +); + + + + +; + +< + // open fragment +> + + +; + +[<>, <>]; +const fun1 = () => <>; +x = <>; +function fun2(param = <>) {} +1 + <>; +1 || <>; +fun2(<>); +test ? <> : x; +<>; + + <> +; +const obj = { + foo: <>, +}; +const fragmentVar = <>; +function fun3() { + return <>; +} +(<>).toString(); +(<>).props; +(<>)["computed"]; +(<>)["computed"](); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js.snap new file mode 100644 index 00000000000..24a6be4d5ab --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/fragment/fragment.js.snap @@ -0,0 +1,202 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/fragment/fragment.js +--- + +# Input + +```js +<>; + +<> + text +; + +<> + + +; + +<> + text +

heading

+ text +

heading

+ text +; + +
+ <> + <> + Hello + world + + <> + Goodbye + world + + +
; + +foo = ( + // comment + <> +); + + + + +; + +< // open fragment +> + + +; + +[<>, <>]; +const fun1 = () => <>; +x = <> +function fun2(param = <>) {} +1 + <>; +1 || <>; +fun2(<>); +test ? <> : x; +<>; + + <> +; +const obj = { + foo: <> +}; +const fragmentVar = <>; +function fun3() { + return <>; +} +(<>).toString(); +(<>).props; +(<>)["computed"]; +(<>)["computed"](); +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -28,24 +28,22 @@ + +
; + +-foo = ( +- // comment +- <> +-); ++foo = ++ ( ++ // comment ++ <> ++ ); + +- ++< /* open fragment */ > + + +-; ++; + +-< ++<> + // open fragment +-> + + +-; ++; // close fragment + + [<>, <>]; + const fun1 = () => <>; +``` + +# Output + +```js +<>; + +<>text; + +<> + + +; + +<> + text +

heading

+ text +

heading

+ text +; + +
+ <> + <> + Hello + world + + <> + Goodbye + world + + +
; + +foo = + ( + // comment + <> + ); + +< /* open fragment */ > + + +; + +<> + // open fragment + + +; // close fragment + +[<>, <>]; +const fun1 = () => <>; +x = <>; +function fun2(param = <>) {} +1 + <>; +1 || <>; +fun2(<>); +test ? <> : x; +<>; + + <> +; +const obj = { + foo: <>, +}; +const fragmentVar = <>; +function fun3() { + return <>; +} +(<>).toString(); +(<>).props; +(<>)["computed"]; +(<>)["computed"](); +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js new file mode 100644 index 00000000000..f540cd8b2a8 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js @@ -0,0 +1,56 @@ +// this should remain as-is +
+ {/* prettier-ignore */} + +
; + +// this should remain as-is +
+ {/* prettier-ignore */} + +
; + +// this should remain as-is +f( + + {/*prettier-ignore*/} + + +); + +// this be formatted +
+ {/* prettier-ignore */} foo + +
; + +// this should remain as-is +
+{ + /* prettier-ignore */ + foo ( ) +} +
; + +// this should remain as-is +
+{ + /* prettier-ignore */ + x ? : +} +
; + +push( + // prettier-ignore + :) + , +); + +function f() { + // rome-ignore format: Instability issue + return ( + // prettier-ignore + /* $FlowFixMe(>=0.53.0) */ + + ); +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js.prettier-snap new file mode 100644 index 00000000000..d90e35e6e80 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js.prettier-snap @@ -0,0 +1,55 @@ +// this should remain as-is +
+ {/* prettier-ignore */} + +
; + +// this should remain as-is +
+ {/* prettier-ignore */} + +
; + +// this should remain as-is +f( + + {/*prettier-ignore*/} + + , +); + +// this be formatted +
+ {/* prettier-ignore */} foo + +
; + +// this should remain as-is +
+ { + /* prettier-ignore */ + foo ( ) + } +
; + +// this should remain as-is +
+ { + /* prettier-ignore */ + x ? : + } +
; + +push( + // prettier-ignore + :) + , +); + +function f() { + return ( + // prettier-ignore + /* $FlowFixMe(>=0.53.0) */ + + ); +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js.snap new file mode 100644 index 00000000000..7d74b6711bf --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/ignore/jsx_ignore.js.snap @@ -0,0 +1,193 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/ignore/jsx_ignore.js +--- + +# Input + +```js +// this should remain as-is +
+ {/* prettier-ignore */} + +
; + +// this should remain as-is +
+ {/* prettier-ignore */} + +
; + +// this should remain as-is +f( + + {/*prettier-ignore*/} + + +); + +// this be formatted +
+ {/* prettier-ignore */} foo + +
; + +// this should remain as-is +
+{ + /* prettier-ignore */ + foo ( ) +} +
; + +// this should remain as-is +
+{ + /* prettier-ignore */ + x ? : +} +
; + +push( + // prettier-ignore + :) + , +); + +function f() { + // rome-ignore format: Instability issue + return ( + // prettier-ignore + /* $FlowFixMe(>=0.53.0) */ + + ); +} +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,20 +1,22 @@ + // this should remain as-is +
+ {/* prettier-ignore */} +- ++ +
; + + // this should remain as-is +
+ {/* prettier-ignore */} +- ++ +
; + + // this should remain as-is + f( + + {/*prettier-ignore*/} +- ++ + , + ); + +@@ -28,16 +30,15 @@ +
+ { + /* prettier-ignore */ +- foo ( ) ++ foo ( ) + } +
; + + // this should remain as-is +
+ { +- /* prettier-ignore */ +- x ? : +- } ++ /* prettier-ignore */ ++ x ? : } +
; + + push( +@@ -47,6 +48,7 @@ + ); + + function f() { ++ // rome-ignore format: Instability issue + return ( + // prettier-ignore + /* $FlowFixMe(>=0.53.0) */ +``` + +# Output + +```js +// this should remain as-is +
+ {/* prettier-ignore */} + +
; + +// this should remain as-is +
+ {/* prettier-ignore */} + +
; + +// this should remain as-is +f( + + {/*prettier-ignore*/} + + , +); + +// this be formatted +
+ {/* prettier-ignore */} foo + +
; + +// this should remain as-is +
+ { + /* prettier-ignore */ + foo ( ) + } +
; + +// this should remain as-is +
+ { + /* prettier-ignore */ + x ? : } +
; + +push( + // prettier-ignore + :) + , +); + +function f() { + // rome-ignore format: Instability issue + return ( + // prettier-ignore + /* $FlowFixMe(>=0.53.0) */ + + ); +} +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/multiline-assign/test.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/multiline-assign/test.js new file mode 100644 index 00000000000..7c3649a6e7c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/multiline-assign/test.js @@ -0,0 +1,19 @@ +const comp1 = ( +
+ Keep the wrapping parens. +
+); + +const comp2 =
+ Create wrapping parens. +
; + +comp2A =
+ Create wrapping parens. +
; + +const comp3 =
Bump to next line without parens
; + +const comp4 =
Create wrapping parens and indent all the things.
; + +const comp5 =
Keep it on one line.
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/multiline-assign/test.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/multiline-assign/test.js.prettier-snap new file mode 100644 index 00000000000..810b627f7c3 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/multiline-assign/test.js.prettier-snap @@ -0,0 +1,31 @@ +const comp1 = ( +
+ Keep the wrapping parens. +
+); + +const comp2 = ( +
+ Create wrapping parens. +
+); + +comp2A = ( +
+ Create wrapping parens. +
+); + +const comp3 = ( +
+ Bump to next line without parens +
+); + +const comp4 = ( +
+ Create wrapping parens and indent all the things. +
+); + +const comp5 =
Keep it on one line.
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/namespace/jsx_namespaced_name.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/namespace/jsx_namespaced_name.js new file mode 100644 index 00000000000..7f4591ee043 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/namespace/jsx_namespaced_name.js @@ -0,0 +1,3 @@ +; + +1; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/namespace/jsx_namespaced_name.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/namespace/jsx_namespaced_name.js.prettier-snap new file mode 100644 index 00000000000..7f4591ee043 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/namespace/jsx_namespaced_name.js.prettier-snap @@ -0,0 +1,3 @@ +; + +1; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js new file mode 100644 index 00000000000..d5fedf9e3ab --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js @@ -0,0 +1,94 @@ +keep =

+ Welcome to the Universal React Starter-kyt. + This starter kyt should serve as the base for an advanced, + server-rendered React app. +

+ +newlines_text = +
+ hi + there + how + + are you + + + are you fine today? +
+ +newlines_text_spaced = +
+ + space above + + space below + +
+ +newlines_elems_spaced = +
+ + space above + + space below + +
+ +newlines_mixed = +
+ hi + there + + how + + are you + + + are you fine today? +
+ +newlines_elems = +
+
+ + +
+ + +
+ + + hi + + +
+ + + + + + + + +
+ +regression_extra_newline = ( +
+ + New Messages +
+); + + +regression_extra_newline_2 = ( +
+ ( + + ) +
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js.prettier-snap new file mode 100644 index 00000000000..19d48412ee7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js.prettier-snap @@ -0,0 +1,57 @@ +keep = ( +

+ Welcome to the Universal React Starter-kyt. This starter + kyt should serve as the base for an advanced, server-rendered React app. +

+); + +newlines_text =
hi there how are you are you fine today?
; + +newlines_text_spaced =
space above space below
; + +newlines_elems_spaced = ( +
+ space above + + space below +
+); + +newlines_mixed = ( +
+ hi + there + how are you + are you fine today? +
+); + +newlines_elems = ( +
+
+
+
+ hi +
+ + +
+); + +regression_extra_newline = ( +
+ + New Messages +
+); + +regression_extra_newline_2 = ( +
+ ( + + ) +
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js.snap new file mode 100644 index 00000000000..6561133b729 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/test.js.snap @@ -0,0 +1,193 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/newlines/test.js +--- + +# Input + +```js +keep =

+ Welcome to the Universal React Starter-kyt. + This starter kyt should serve as the base for an advanced, + server-rendered React app. +

+ +newlines_text = +
+ hi + there + how + + are you + + + are you fine today? +
+ +newlines_text_spaced = +
+ + space above + + space below + +
+ +newlines_elems_spaced = +
+ + space above + + space below + +
+ +newlines_mixed = +
+ hi + there + + how + + are you + + + are you fine today? +
+ +newlines_elems = +
+
+ + +
+ + +
+ + + hi + + +
+ + + + + + + + +
+ +regression_extra_newline = ( +
+ + New Messages +
+); + + +regression_extra_newline_2 = ( +
+ ( + + ) +
+); +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -33,7 +33,9 @@ +
+ hi +
++ + ++ + +
+ ); +``` + +# Output + +```js +keep = ( +

+ Welcome to the Universal React Starter-kyt. This starter + kyt should serve as the base for an advanced, server-rendered React app. +

+); + +newlines_text =
hi there how are you are you fine today?
; + +newlines_text_spaced =
space above space below
; + +newlines_elems_spaced = ( +
+ space above + + space below +
+); + +newlines_mixed = ( +
+ hi + there + how are you + are you fine today? +
+); + +newlines_elems = ( +
+
+
+
+ hi +
+ + + + +
+); + +regression_extra_newline = ( +
+ + New Messages +
+); + +regression_extra_newline_2 = ( +
+ ( + + ) +
+); +``` + + +# Lines exceeding max width of 80 characters +``` + 45: +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/windows.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/windows.js new file mode 100644 index 00000000000..d2b04f35a93 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/windows.js @@ -0,0 +1,3 @@ +
+Text +
diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/windows.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/windows.js.prettier-snap new file mode 100644 index 00000000000..a51f7aafaa9 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/newlines/windows.js.prettier-snap @@ -0,0 +1 @@ +
Text
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/comments.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/comments.js new file mode 100644 index 00000000000..7a0895dcb44 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/comments.js @@ -0,0 +1,7 @@ +
+ { + // TODO: don't harcode this space! not all locales use whitespace + // in the same way + ' ' + } +
diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/comments.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/comments.js.prettier-snap new file mode 100644 index 00000000000..3632e7d413f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/comments.js.prettier-snap @@ -0,0 +1,7 @@ +
+ { + // TODO: don't harcode this space! not all locales use whitespace + // in the same way + " " + } +
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js new file mode 100644 index 00000000000..6f25e76bfdb --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js @@ -0,0 +1,74 @@ +after = + + foo bar + + +before = + + bar foo + + +before_break1 = + + foo + + +before_break2 = + + foo + + +after_break = + + foo + + +within = + + foo bar + + +break_components = +
+ + +

foobar bar bar

yep

+
+

nope

+
+ +var x =
+ hello hi sdkflsdfjk +
; + +nest_plz = +
+
+
+
+
+ +regression_not_transformed_1 = + ; + +regression_not_transformed_2 = + ; + +similar_1 = + ; + +similar_2 = + ; + +similar_3 = + ; + +not_broken_end = +
+ long text long text long text long text long text long text long text long text url long text long text +
+ +not_broken_begin = +
+
long text long text long text long text long text long text long text long texturl long text long text +
diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js.prettier-snap new file mode 100644 index 00000000000..15330365b76 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js.prettier-snap @@ -0,0 +1,117 @@ +after = ( + + foo bar + +); + +before = ( + + bar foo + +); + +before_break1 = ( + + {" "} + foo + +); + +before_break2 = ( + + {" "} + foo + +); + +after_break = ( + + foo{" "} + + +); + +within = ( + + foo bar + +); + +break_components = ( +
+ + +

+ foobar bar bar +

+

+ + yep + +

+
+

nope

+
+); + +var x = ( +
+ hello hi sdkflsdfjk +
+); + +nest_plz = ( +
+
+
+
+
+); + +regression_not_transformed_1 = ( + + {" "} + + +); + +regression_not_transformed_2 = ( + + {" "} + +); + +similar_1 = ( + + {" "} + + +); + +similar_2 = ( + + {" "} + +); + +similar_3 = ( + + + +); + +not_broken_end = ( +
+ long text long text long text long text long text long text long text long + text url long text long text +
+); + +not_broken_begin = ( +
+
long text long text long text long text long text long text long text + long texturl long text long text +
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js.snap new file mode 100644 index 00000000000..054555963c5 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/significant-space/test.js.snap @@ -0,0 +1,290 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/significant-space/test.js +--- + +# Input + +```js +after = + + foo bar + + +before = + + bar foo + + +before_break1 = + + foo + + +before_break2 = + + foo + + +after_break = + + foo + + +within = + + foo bar + + +break_components = +
+ + +

foobar bar bar

yep

+
+

nope

+
+ +var x =
+ hello hi sdkflsdfjk +
; + +nest_plz = +
+
+
+
+
+ +regression_not_transformed_1 = + ; + +regression_not_transformed_2 = + ; + +similar_1 = + ; + +similar_2 = + ; + +similar_3 = + ; + +not_broken_end = +
+ long text long text long text long text long text long text long text long text url long text long text +
+ +not_broken_begin = +
+
long text long text long text long text long text long text long text long texturl long text long text +
+``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -12,7 +12,7 @@ + + before_break1 = ( + +- {" "} ++ + foo + + ); +@@ -21,15 +21,16 @@ + + {" "} ++ /> + foo + + ); + + after_break = ( + +- foo{" "} +- ++ foo + + ); + +@@ -79,7 +80,8 @@ + + regression_not_transformed_2 = ( + +- {" "} ++ ++ {" "} + + ); + +@@ -92,13 +94,15 @@ + + similar_2 = ( + +- {" "} ++ ++ {" "} + + ); + + similar_3 = ( + +- ++ ++ + + ); + +@@ -111,7 +115,8 @@ + + not_broken_begin = ( +
+-
long text long text long text long text long text long text long text +- long texturl long text long text ++
++ long text long text long text long text long text long text long text long ++ texturl long text long text +
+ ); +``` + +# Output + +```js +after = ( + + foo bar + +); + +before = ( + + bar foo + +); + +before_break1 = ( + + + foo + +); + +before_break2 = ( + + + foo + +); + +after_break = ( + + foo + +); + +within = ( + + foo bar + +); + +break_components = ( +
+ + +

+ foobar bar bar +

+

+ + yep + +

+
+

nope

+
+); + +var x = ( +
+ hello hi sdkflsdfjk +
+); + +nest_plz = ( +
+
+
+
+
+); + +regression_not_transformed_1 = ( + + {" "} + + +); + +regression_not_transformed_2 = ( + + + {" "} + +); + +similar_1 = ( + + {" "} + + +); + +similar_2 = ( + + + {" "} + +); + +similar_3 = ( + + + + +); + +not_broken_end = ( +
+ long text long text long text long text long text long text long text long + text url long text long text +
+); + +not_broken_begin = ( +
+
+ long text long text long text long text long text long text long text long + texturl long text long text +
+); +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/single-attribute-per-line/single-attribute-per-line.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/single-attribute-per-line/single-attribute-per-line.js new file mode 100644 index 00000000000..299cb8332aa --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/single-attribute-per-line/single-attribute-per-line.js @@ -0,0 +1,27 @@ +import React from "react"; + +const Component = () => ( +
+
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. +
+ +
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. +
+ +
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. +
+ +
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. +
+ + + + bar + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. +
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/single-attribute-per-line/single-attribute-per-line.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/single-attribute-per-line/single-attribute-per-line.js.prettier-snap new file mode 100644 index 00000000000..c447f80ded5 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/single-attribute-per-line/single-attribute-per-line.js.prettier-snap @@ -0,0 +1,38 @@ +import React from "react"; + +const Component = () => ( +
+
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. +
+ +
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. +
+ +
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. +
+ +
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. +
+ + + + bar + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. +
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js new file mode 100644 index 00000000000..59f3a7a8ae1 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js @@ -0,0 +1,49 @@ +long_closed = + + +long_open = + + hello + + +long_open_long_children = + + + Hello world + +
hey hiya how are ya
+
+
+
+
+ d + + + +short_closed = + + +short_open = + + hello + + +make_self_closing = +
+ + + +
+ +leave_opening = + + +long_string = +
hello world
+ +long_string_with_extra_param = +
hello world
+ +// rome-ignore format: Instability issue +long_obj = +
hello world
diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js.prettier-snap new file mode 100644 index 00000000000..1a4851d6ae5 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js.prettier-snap @@ -0,0 +1,170 @@ +long_closed = ( + +); + +long_open = ( + + hello + +); + +long_open_long_children = ( + + + Hello world + +
+
+
+
+
+
hey hiya how are ya
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + d + + + + + +); + +short_closed = ; + +short_open = ( + + hello + +); + +make_self_closing = ( +
+ + +
+); + +leave_opening = ( + + {" "} + +); + +long_string = ( +
+ hello world +
+); + +long_string_with_extra_param = ( +
+ hello world +
+); + +long_obj = ( +
+ hello world +
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js.snap new file mode 100644 index 00000000000..9042378ed7f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/split-attrs/test.js.snap @@ -0,0 +1,261 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/split-attrs/test.js +--- + +# Input + +```js +long_closed = + + +long_open = + + hello + + +long_open_long_children = + + + Hello world + +
hey hiya how are ya
+
+
+
+
+ d + + + +short_closed = + + +short_open = + + hello + + +make_self_closing = +
+ + + +
+ +leave_opening = + + +long_string = +
hello world
+ +long_string_with_extra_param = +
hello world
+ +// rome-ignore format: Instability issue +long_obj = +
hello world
+``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -155,16 +155,6 @@ +
+ ); + +-long_obj = ( +-
+- hello world +-
+-); ++// rome-ignore format: Instability issue ++long_obj = ++
hello world
+``` + +# Output + +```js +long_closed = ( + +); + +long_open = ( + + hello + +); + +long_open_long_children = ( + + + Hello world + +
+
+
+
+
+
hey hiya how are ya
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + d + + + + + +); + +short_closed = ; + +short_open = ( + + hello + +); + +make_self_closing = ( +
+ + +
+); + +leave_opening = ( + + {" "} + +); + +long_string = ( +
+ hello world +
+); + +long_string_with_extra_param = ( +
+ hello world +
+); + +// rome-ignore format: Instability issue +long_obj = +
hello world
+``` + + +# Lines exceeding max width of 80 characters +``` + 144:
+ 151: className="i use bootstrap and just put loooaads of classnames in here all the time" + 160:
hello world
+``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js new file mode 100644 index 00000000000..2f12f980007 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js @@ -0,0 +1,25 @@ +
; + +
; + +
; + +
; + +
; + +
; + +
; + +
; + +
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js.prettier-snap new file mode 100644 index 00000000000..a4fa06210ae --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js.prettier-snap @@ -0,0 +1,36 @@ +
; + +
; + +
; + +
; + +
; + +
; + +
; + +
; + +
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js.snap new file mode 100644 index 00000000000..39071cb7e1f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/attribute.js.snap @@ -0,0 +1,115 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/spread/attribute.js +--- + +# Input + +```js +
; + +
; + +
; + +
; + +
; + +
; + +
; + +
; + +
; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -9,28 +9,21 @@ +
; + +
; + +
; + +
; + +
; +``` + +# Output + +```js +
; + +
; + +
; + +
; + +
; + +
; + +
; + +
; + +
; +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js new file mode 100644 index 00000000000..94e59bf6d24 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js @@ -0,0 +1,23 @@ +
{...a}
; + +
{...a /* comment */}
; + +
{/* comment */...a}
; + +// rome-ignore format: Instability issue +
{...a //comment +}
; + +
{...a + //comment +}
; + +
{ + //comment + ...a +}
; + +// rome-ignore format: Instability issue +
{//comment + ...a // comment +}
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js.prettier-snap new file mode 100644 index 00000000000..fc218066144 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js.prettier-snap @@ -0,0 +1,32 @@ +
{...a}
; + +
{...a /* comment */}
; + +
{/* comment */ ...a}
; + +
+ { + ...a //comment + } +
; + +
+ { + ...a + //comment + } +
; + +
+ { + //comment + ...a + } +
; + +
+ { + //comment + ...a // comment + } +
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js.snap new file mode 100644 index 00000000000..5358e69534a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/spread/child.js.snap @@ -0,0 +1,116 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/spread/child.js +--- + +# Input + +```js +
{...a}
; + +
{...a /* comment */}
; + +
{/* comment */...a}
; + +// rome-ignore format: Instability issue +
{...a //comment +}
; + +
{...a + //comment +}
; + +
{ + //comment + ...a +}
; + +// rome-ignore format: Instability issue +
{//comment + ...a // comment +}
; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -4,29 +4,23 @@ + +
{/* comment */ ...a}
; + +-
+- { +- ...a //comment +- } +-
; ++// rome-ignore format: Instability issue ++
{...a //comment ++}
; + +
+- { +- ...a +- //comment ++ {...a ++ //comment + } +
; + +
+ { +- //comment +- ...a +- } ++ //comment ++ ...a} +
; + +-
+- { +- //comment +- ...a // comment +- } +-
; ++// rome-ignore format: Instability issue ++
{//comment ++ ...a // comment ++}
; +``` + +# Output + +```js +
{...a}
; + +
{...a /* comment */}
; + +
{/* comment */ ...a}
; + +// rome-ignore format: Instability issue +
{...a //comment +}
; + +
+ {...a + //comment + } +
; + +
+ { + //comment + ...a} +
; + +// rome-ignore format: Instability issue +
{//comment + ...a // comment +}
; +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js new file mode 100644 index 00000000000..2099e5bc09a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js @@ -0,0 +1,73 @@ +const render1 = ({ styles }) => ( +
+ Keep the wrapping parens. Put each key on its own line. +
+); + +const render2 = ({ styles }) =>
+ Create wrapping parens. +
; + +const render3 = ({ styles }) =>
Create wrapping parens.
; + +const render4 = ({ styles }) =>
Create wrapping parens and indent all the things.
; + +const render5 = ({ styles }) =>
Keep it on one line.
; + +const render6 = ({ styles }) => ( +
+
ddd d dd d d dddd dddd hello
+
ddd d dd d d dddd dddd hello
+
+
ddd d dd d d dddd dddd hello
hello
+
+) + +const render7 = () => +
+ Dont break each elem onto its own line. +
+
+ +const render7A = () => ( +
+
+
+) + +const render7B = () => ( +
+ Dont break plz + Dont break plz + Dont break plz +
+) + +const render8 = (props) =>
{props.text}
+const render9 = (props) =>
{props.looooooooooooooooooooooooooooooong_text}
+const render10 = (props) =>
{props.even_looooooooooooooooooooooooooooooooooooooooooonger_contents}
+ +const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams(cccccccccccc, dddddddddddddddddddddd) + +React.render( + + , document.querySelector('#react-root') +) + + +const renderTernary = (props) => + + {props.showTheThing ? + Hello world + : "hello " + "howdy! "} + {props.showTheThing ? + Hello world + : + null + } + {props.showTheThing ? null : + Hello world + } + {props.showTheOtherThing ?
I am here
:
} + {props.showTheOtherThing ?
I am here!!
: null} + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js.prettier-snap new file mode 100644 index 00000000000..7cbcef966ad --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js.prettier-snap @@ -0,0 +1,170 @@ +const render1 = ({ styles }) => ( +
+ Keep the wrapping parens. Put each key on its own line. +
+); + +const render2 = ({ styles }) => ( +
+ Create wrapping parens. +
+); + +const render3 = ({ styles }) => ( +
+ Create wrapping parens. +
+); + +const render4 = ({ styles }) => ( +
+ Create wrapping parens and indent all the things. +
+); + +const render5 = ({ styles }) =>
Keep it on one line.
; + +const render6 = ({ styles }) => ( +
+
+ ddd d dd d d dddd dddd hello +
+
+ ddd d dd d d dddd dddd hello +
+
+
+ ddd d dd d d dddd dddd hello +
{" "} + hello +
+
+); + +const render7 = () => ( +
+ + Dont break each elem onto its own line. +
+
+); + +const render7A = () => ( +
+
+
+
+
+); + +const render7B = () => ( +
+ + {" "} + Dont break plz + + + + Dont break plz + + + Dont break plz + + +
+); + +const render8 = (props) =>
{props.text}
; +const render9 = (props) => ( +
{props.looooooooooooooooooooooooooooooong_text}
+); +const render10 = (props) => ( +
+ {props.even_looooooooooooooooooooooooooooooooooooooooooonger_contents} +
+); + +const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => + this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams( + cccccccccccc, + dddddddddddddddddddddd, + ); + +React.render( + , + document.querySelector("#react-root"), +); + +const renderTernary = (props) => ( + + {props.showTheThing ? ( + + Hello world + + ) : ( + "hello " + "howdy! " + )} + {props.showTheThing ? ( + + Hello world + + ) : null} + {props.showTheThing ? null : ( + + Hello world + + )} + {props.showTheOtherThing ?
I am here
:
} + {props.showTheOtherThing ?
I am here!!
: null} + +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js.snap new file mode 100644 index 00000000000..bd71e968e67 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/stateless-arrow-fn/test.js.snap @@ -0,0 +1,300 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/stateless-arrow-fn/test.js +--- + +# Input + +```js +const render1 = ({ styles }) => ( +
+ Keep the wrapping parens. Put each key on its own line. +
+); + +const render2 = ({ styles }) =>
+ Create wrapping parens. +
; + +const render3 = ({ styles }) =>
Create wrapping parens.
; + +const render4 = ({ styles }) =>
Create wrapping parens and indent all the things.
; + +const render5 = ({ styles }) =>
Keep it on one line.
; + +const render6 = ({ styles }) => ( +
+
ddd d dd d d dddd dddd hello
+
ddd d dd d d dddd dddd hello
+
+
ddd d dd d d dddd dddd hello
hello
+
+) + +const render7 = () => +
+ Dont break each elem onto its own line. +
+
+ +const render7A = () => ( +
+
+
+) + +const render7B = () => ( +
+ Dont break plz + Dont break plz + Dont break plz +
+) + +const render8 = (props) =>
{props.text}
+const render9 = (props) =>
{props.looooooooooooooooooooooooooooooong_text}
+const render10 = (props) =>
{props.even_looooooooooooooooooooooooooooooooooooooooooonger_contents}
+ +const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams(cccccccccccc, dddddddddddddddddddddd) + +React.render( + + , document.querySelector('#react-root') +) + + +const renderTernary = (props) => + + {props.showTheThing ? + Hello world + : "hello " + "howdy! "} + {props.showTheThing ? + Hello world + : + null + } + {props.showTheThing ? null : + Hello world + } + {props.showTheOtherThing ?
I am here
:
} + {props.showTheOtherThing ?
I am here!!
: null} + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -55,7 +55,7 @@ + attr4 + > + ddd d dd d d dddd dddd hello +-
{" "} ++
+ hello +
+
+@@ -65,7 +65,8 @@ +
+ + Dont break each elem onto its own line. +-
++
++
+
+ ); + +@@ -81,7 +82,8 @@ +
+ + {" "} +- Dont break plz ++ ++ Dont break plz + + + +``` + +# Output + +```js +const render1 = ({ styles }) => ( +
+ Keep the wrapping parens. Put each key on its own line. +
+); + +const render2 = ({ styles }) => ( +
+ Create wrapping parens. +
+); + +const render3 = ({ styles }) => ( +
+ Create wrapping parens. +
+); + +const render4 = ({ styles }) => ( +
+ Create wrapping parens and indent all the things. +
+); + +const render5 = ({ styles }) =>
Keep it on one line.
; + +const render6 = ({ styles }) => ( +
+
+ ddd d dd d d dddd dddd hello +
+
+ ddd d dd d d dddd dddd hello +
+
+
+ ddd d dd d d dddd dddd hello +
+ hello +
+
+); + +const render7 = () => ( +
+ + Dont break each elem onto its own line. +
+
+
+); + +const render7A = () => ( +
+
+
+
+
+); + +const render7B = () => ( +
+ + {" "} + + Dont break plz + + + + Dont break plz + + + Dont break plz + + +
+); + +const render8 = (props) =>
{props.text}
; +const render9 = (props) => ( +
{props.looooooooooooooooooooooooooooooong_text}
+); +const render10 = (props) => ( +
+ {props.even_looooooooooooooooooooooooooooooooooooooooooonger_contents} +
+); + +const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => + this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams( + cccccccccccc, + dddddddddddddddddddddd, + ); + +React.render( + , + document.querySelector("#react-root"), +); + +const renderTernary = (props) => ( + + {props.showTheThing ? ( + + Hello world + + ) : ( + "hello " + "howdy! " + )} + {props.showTheThing ? ( + + Hello world + + ) : null} + {props.showTheThing ? null : ( + + Hello world + + )} + {props.showTheOtherThing ?
I am here
:
} + {props.showTheOtherThing ?
I am here!!
: null} + +); +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js new file mode 100644 index 00000000000..3377c40783a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js @@ -0,0 +1,18 @@ +; + +; + +; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js.prettier-snap new file mode 100644 index 00000000000..d47d923e3c3 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js.prettier-snap @@ -0,0 +1,19 @@ +; + +; + +; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js.snap new file mode 100644 index 00000000000..020bfb36ac6 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/template/styled-components.js.snap @@ -0,0 +1,75 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/template/styled-components.js +--- + +# Input + +```js +; + +; + +; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -11,9 +11,8 @@ + `}; + + ; +``` + +# Output + +```js +; + +; + +; +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js new file mode 100644 index 00000000000..f8cb6255443 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js @@ -0,0 +1,458 @@ +// Wrapping text +x = +
+ Some text that would need to wrap on to a new line in order to display correctly and nicely +
+ +// Wrapping tags +x = +
+ f f f f f f +
+ +// Wrapping tags +x = +
+ ffffff +
+ +// Wrapping tags +x = + + +// Wrapping tags +x = +
+ f +
+ +x = +
+ before
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur at mollis lorem.
after +
+ +x = +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}{stuff}{stuff}after{stuff}after +
+ +x = +
+ before {stuff} after {stuff} after {stuff} after {stuff} after {stuff} after {stuff} {stuff} {stuff} after {stuff} after +
+ +x = +
+ Please state your name and occupation for the board of school directors. +
+ +function DiffOverview(props) { + const { source, target, since } = props; + return ( +
+
+

+ This diff overview is computed against the current list of records in + this collection and the list it contained on {humanDate(since)}. +

+

+ Note: last_modified and schema record metadata + are omitted for easier review. +

+
+ +
+ ); +} + +x = Starting at minute {graphActivity.startTime}, running for {graphActivity.length} to minute {graphActivity.startTime + graphActivity.length} + +x = +
+ First second third +
Something
+
+ +x = +
+
+ First +
+ Second +
+ Third +
+
+ +x = +
+ First
+ Second +
Third +
+ +leading_whitespace = +
First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth
+ +trailing_whitespace = +
First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth
+ +no_leading_or_trailing_whitespace = +
First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth
+ +facebook_translation_leave_text_around_tag = +
+ + First + , + ( + Second + ) +
+ +x = +
+ + First second third fourth fifth sixth seventh + , + ( + Second + ) +
+ +this_really_should_split_across_lines = +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after +
+ +unstable_before = +
+ Your score: {`${mini.crosstable.users[sessionUserId]} - ${mini.crosstable.users[user.id]}`} +
+ +unstable_after_first_run = ( +
+ Your score:{" "} + {`${mini.crosstable.users[sessionUserId]} - ${mini + .crosstable.users[user.id]}`} +
+); + +solitary_whitespace = +
+ +jsx_whitespace_on_newline = +
+
+ First +
+ Second +
+ Third +
+
+ +jsx_around_multiline_element = +
Before
{"Enough text to make this element wrap on to multiple lines when formatting"}
After
+ +jsx_around_multiline_element_second_pass = ( +
+ Before{" "} +
+ { + "Enough text to make this element wrap on to multiple lines when formatting" + } +
{" "} + After +
+); + +convert_space_expressions = +
{" "}
+ +x = +
+ + + + + + +
+ +const Abc = () => { + return ( +
+ Please state your + {" "} + name + {" "} + and + {" "} + occupation + {" "} + for the board of directors. +
+ ); +}; + +x =
Some stuff here
+ +headers_and_paragraphs = ( +
+

First

+

The first paragraph.

+ +

Second

+

The second paragraph.

+
+); + +no_text_one_tag_per_line = +
+ +
+ +with_text_fill_line = +
+ Text +
+ +line_after_br = +
+ Text
+ More text
+ And more
+
+ +line_after_br = +
+ Text
More text
And more
+
+ +line_after_br = +
+ Text +
+ More text +
+ And more +
+
+ +line_after_br_2 =
A
B
C
+ +br_followed_by_whitespace =

text
+ +dont_preserve_blank_lines_when_jsx_contains_text = +
+ +
Zeroth
+ +
First
+ + Second + +
+ +multiple_expressions = +
+ {header} + {body} + {footer} +
+ +single_expression_child_tags = +
+ You currently have {dashboardStr} and {userStr} +
+ +expression_does_not_break = +
texty text text text text text text text text text text text {this.props.type}
+ +// FIXME +br_triggers_expression_break = +

+ text text text text text text text text text text text {this.props.type}
+ +jsx_whitespace_after_tag = +
+ + {variable} + + {" "} + ({variable}) +
+ +x = +
+ ENDS IN
+ text text text text text text text text text text text +
{" "} + HRS +
+ +x = +
+

Message

+ Hello, I'm a simple message. +
+ +x = +
+ Hello, I'm a simple message. +

Message

+
+ +x = +
+
+
+
+
+ Line {startRange.row + 1}:{startRange.column + 1} - {endRange.row + 1}:{endRange.column + 1}{caller} +
+
+
+
+
+ +x = +
+ {" "}
text
+
+ +// NOTE: Multiple JSX whitespaces are collapsed into a single space. +x = +
+ {" "}{" "}{" "} +
+ +// Don't break a self-closing element without attributes +// ---------- +x = +

+ text text text text text text text text text text text text text text text
text text text text text text +

; + +x = +
+
+ First +
- +
+ Second +
+
+ +x = +
+
+ First +
+ - +
+ Second +
+
+ +x = +
+
First
-
Second
+
+ +x = +
+
+ First +
- +
+ Second +
+
+ +x = +
+
+ First +
+ - +
+ Second +
+
+ +x = +
+
First
-
Second
+
+ +x = +
+ {hour}:{minute}:{second} +
+ +x = +
+ {hour} + : + {minute} + : + {second} +
+ +x = +
+ {hour}: + {minute}: + {second} +
+ +x =
text here.
+ +x =
Sales tax estimated using a rate of {salesTax * 100}%.
+ +x =
+ {title}  +
+ +x =
bar
+ +x =
+ + {name}’s{' '} + + Hello world.
+ You {type}ed this shipment to +
+ +x = + {parameter.Description}: {errorMsg} + + +x = + +x = Copy "{name}" + +x = (avg. {value}/5) + +x =

+ Use the Button's +

; + +this_really_should_split_across_lines = +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after +
+ +let myDiv = ReactTestUtils.renderIntoDocument( +
+
, +
+
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js.prettier-snap new file mode 100644 index 00000000000..8d55c7a9103 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js.prettier-snap @@ -0,0 +1,570 @@ +// Wrapping text +x = ( +
+ Some text that would need to wrap on to a new line in order to display + correctly and nicely +
+); + +// Wrapping tags +x = ( +
+ f f f f{" "} + f f +
+); + +// Wrapping tags +x = ( +
+ f + f + f + f + f + f +
+); + +// Wrapping tags +x = ( +
+); + +// Wrapping tags +x = ( +
+ {" "} + f +
+); + +x = ( +
+ before +
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur at + mollis lorem. +
+ after +
+); + +x = ( +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff} + {stuff} + {stuff}after{stuff}after +
+); + +x = ( +
+ before {stuff} after {stuff} after {stuff} after {stuff} after {stuff} after{" "} + {stuff} {stuff} {stuff} after {stuff} after +
+); + +x = ( +
+ Please state your name and occupation for the board of{" "} + school directors. +
+); + +function DiffOverview(props) { + const { source, target, since } = props; + return ( +
+
+

+ This diff overview is computed against the current list of records in + this collection and the list it contained on {humanDate(since)} + . +

+

+ Note: last_modified and schema record + metadata are omitted for easier review. +

+
+ +
+ ); +} + +x = ( + + + Starting at minute {graphActivity.startTime}, running for{" "} + {graphActivity.length} to minute{" "} + {graphActivity.startTime + graphActivity.length} + + +); + +x = ( +
+ First second third +
+ Something +
+
+); + +x = ( +
+
First
+ Second +
Third
+
+); + +x = ( +
+ First
Second
Third +
+); + +leading_whitespace = ( +
+ {" "} + First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh + Twelfth Thirteenth Fourteenth +
+); + +trailing_whitespace = ( +
+ First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh + Twelfth Thirteenth Fourteenth{" "} +
+); + +no_leading_or_trailing_whitespace = ( +
+ First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh + Twelfth Thirteenth Fourteenth +
+); + +facebook_translation_leave_text_around_tag = ( +
+ First, (Second) +
+); + +x = ( +
+ First second third fourth fifth sixth seventh, ( + Second) +
+); + +this_really_should_split_across_lines = ( +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff} + after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff} + after{stuff}after{stuff}after +
+); + +unstable_before = ( +
+ Your score:{" "} + {`${mini.crosstable.users[sessionUserId]} - ${ + mini.crosstable.users[user.id] + }`} +
+); + +unstable_after_first_run = ( +
+ Your score:{" "} + {`${mini.crosstable.users[sessionUserId]} - ${ + mini.crosstable.users[user.id] + }`} +
+); + +solitary_whitespace = ( +
+ {" "} +
+); + +jsx_whitespace_on_newline = ( +
+
First
Second
Third
+
+); + +jsx_around_multiline_element = ( +
+ Before{" "} +
+ { + "Enough text to make this element wrap on to multiple lines when formatting" + } +
{" "} + After +
+); + +jsx_around_multiline_element_second_pass = ( +
+ Before{" "} +
+ { + "Enough text to make this element wrap on to multiple lines when formatting" + } +
{" "} + After +
+); + +convert_space_expressions =
; + +x = ( +
+ + + + + + +
+); + +const Abc = () => { + return ( +
+ Please state your name and occupation for the board of + directors. +
+ ); +}; + +x =
Some stuff here
; + +headers_and_paragraphs = ( +
+

First

+

The first paragraph.

+ +

Second

+

The second paragraph.

+
+); + +no_text_one_tag_per_line = ( +
+ + +
+); + +with_text_fill_line = ( +
+ Text + +
+); + +line_after_br = ( +
+ Text +
+ More text +
+ And more +
+
+); + +line_after_br = ( +
+ Text +
+ More text +
+ And more +
+
+); + +line_after_br = ( +
+ Text +
+ More text +
+ And more +
+
+); + +line_after_br_2 = ( +
+ A
B
C +
+); + +br_followed_by_whitespace = ( +
+
text +
+); + +dont_preserve_blank_lines_when_jsx_contains_text = ( +
+
Zeroth
+
First
+ Second +
+); + +multiple_expressions = ( +
+ {header} + {body} + {footer} +
+); + +single_expression_child_tags = ( +
+ You currently have {dashboardStr} and{" "} + {userStr} +
+); + +expression_does_not_break = ( +
+ texty text text text text text text text text text text text{" "} + {this.props.type}{" "} +
+); + +// FIXME +br_triggers_expression_break = ( +
+
+ text text text text text text text text text text text { + this.props.type + }{" "} +
+); + +jsx_whitespace_after_tag = ( +
+ + {variable} + {" "} + ({variable}) +
+); + +x = ( +
+ ENDS IN
text text text text text text text text text text text
{" "} + HRS +
+); + +x = ( +
+

Message

+ Hello, I'm a simple message. +
+); + +x = ( +
+ Hello, I'm a simple message. +

Message

+
+); + +x = ( +
+
+
+
+
+ Line {startRange.row + 1}:{startRange.column + 1} -{" "} + {endRange.row + 1}:{endRange.column + 1} + {caller} +
+
+
+
+
+); + +x = ( +
+ {" "} +
text
+
+); + +// NOTE: Multiple JSX whitespaces are collapsed into a single space. +x =
; + +// Don't break a self-closing element without attributes +// ---------- +x = ( +

+ text text text text text text text text text text text text text text text +
+ text text text text text text +

+); + +x = ( +
+
First
-
Second
+
+); + +x = ( +
+
First
-
Second
+
+); + +x = ( +
+
First
-
Second
+
+); + +x = ( +
+
+ First +
+ - +
+ Second +
+
+); + +x = ( +
+
+ First +
+ - +
+ Second +
+
+); + +x = ( +
+
+ First +
+ - +
+ Second +
+
+); + +x = ( +
+ {hour}:{minute}:{second} +
+); + +x = ( +
+ {hour}:{minute}:{second} +
+); + +x = ( +
+ {hour}:{minute}:{second} +
+); + +x = ( +
+ text here.
+
+); + +x =
Sales tax estimated using a rate of {salesTax * 100}%.
; + +x =
{title} 
; + +x = ( +
+ + bar +
+); + +x = ( +
+ + {name}’s{" "} + + Hello world.
+ You {type}ed this shipment to +
+); + +x = ( + + {parameter.Description}: {errorMsg} + +); + +x = ( + +); + +x = Copy "{name}"; + +x = (avg. {value}/5); + +x = ( +

+ Use the Button's +

+); + +this_really_should_split_across_lines = ( +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff} + after{stuff}after +
+); + +let myDiv = ReactTestUtils.renderIntoDocument( +
+
, +
+
, +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js.snap new file mode 100644 index 00000000000..03eb8021691 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/text-wrap/test.js.snap @@ -0,0 +1,1390 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/text-wrap/test.js +--- + +# Input + +```js +// Wrapping text +x = +
+ Some text that would need to wrap on to a new line in order to display correctly and nicely +
+ +// Wrapping tags +x = +
+ f f f f f f +
+ +// Wrapping tags +x = +
+ ffffff +
+ +// Wrapping tags +x = +
+ +// Wrapping tags +x = +
+ f +
+ +x = +
+ before
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur at mollis lorem.
after +
+ +x = +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}{stuff}{stuff}after{stuff}after +
+ +x = +
+ before {stuff} after {stuff} after {stuff} after {stuff} after {stuff} after {stuff} {stuff} {stuff} after {stuff} after +
+ +x = +
+ Please state your name and occupation for the board of school directors. +
+ +function DiffOverview(props) { + const { source, target, since } = props; + return ( +
+
+

+ This diff overview is computed against the current list of records in + this collection and the list it contained on {humanDate(since)}. +

+

+ Note: last_modified and schema record metadata + are omitted for easier review. +

+
+ +
+ ); +} + +x = Starting at minute {graphActivity.startTime}, running for {graphActivity.length} to minute {graphActivity.startTime + graphActivity.length} + +x = +
+ First second third +
Something
+
+ +x = +
+
+ First +
+ Second +
+ Third +
+
+ +x = +
+ First
+ Second +
Third +
+ +leading_whitespace = +
First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth
+ +trailing_whitespace = +
First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth
+ +no_leading_or_trailing_whitespace = +
First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth
+ +facebook_translation_leave_text_around_tag = +
+ + First + , + ( + Second + ) +
+ +x = +
+ + First second third fourth fifth sixth seventh + , + ( + Second + ) +
+ +this_really_should_split_across_lines = +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after +
+ +unstable_before = +
+ Your score: {`${mini.crosstable.users[sessionUserId]} - ${mini.crosstable.users[user.id]}`} +
+ +unstable_after_first_run = ( +
+ Your score:{" "} + {`${mini.crosstable.users[sessionUserId]} - ${mini + .crosstable.users[user.id]}`} +
+); + +solitary_whitespace = +
+ +jsx_whitespace_on_newline = +
+
+ First +
+ Second +
+ Third +
+
+ +jsx_around_multiline_element = +
Before
{"Enough text to make this element wrap on to multiple lines when formatting"}
After
+ +jsx_around_multiline_element_second_pass = ( +
+ Before{" "} +
+ { + "Enough text to make this element wrap on to multiple lines when formatting" + } +
{" "} + After +
+); + +convert_space_expressions = +
{" "}
+ +x = +
+ + + + + + +
+ +const Abc = () => { + return ( +
+ Please state your + {" "} + name + {" "} + and + {" "} + occupation + {" "} + for the board of directors. +
+ ); +}; + +x =
Some stuff here
+ +headers_and_paragraphs = ( +
+

First

+

The first paragraph.

+ +

Second

+

The second paragraph.

+
+); + +no_text_one_tag_per_line = +
+ +
+ +with_text_fill_line = +
+ Text +
+ +line_after_br = +
+ Text
+ More text
+ And more
+
+ +line_after_br = +
+ Text
More text
And more
+
+ +line_after_br = +
+ Text +
+ More text +
+ And more +
+
+ +line_after_br_2 =
A
B
C
+ +br_followed_by_whitespace =

text
+ +dont_preserve_blank_lines_when_jsx_contains_text = +
+ +
Zeroth
+ +
First
+ + Second + +
+ +multiple_expressions = +
+ {header} + {body} + {footer} +
+ +single_expression_child_tags = +
+ You currently have {dashboardStr} and {userStr} +
+ +expression_does_not_break = +
texty text text text text text text text text text text text {this.props.type}
+ +// FIXME +br_triggers_expression_break = +

+ text text text text text text text text text text text {this.props.type}
+ +jsx_whitespace_after_tag = +
+ + {variable} + + {" "} + ({variable}) +
+ +x = +
+ ENDS IN
+ text text text text text text text text text text text +
{" "} + HRS +
+ +x = +
+

Message

+ Hello, I'm a simple message. +
+ +x = +
+ Hello, I'm a simple message. +

Message

+
+ +x = +
+
+
+
+
+ Line {startRange.row + 1}:{startRange.column + 1} - {endRange.row + 1}:{endRange.column + 1}{caller} +
+
+
+
+
+ +x = +
+ {" "}
text
+
+ +// NOTE: Multiple JSX whitespaces are collapsed into a single space. +x = +
+ {" "}{" "}{" "} +
+ +// Don't break a self-closing element without attributes +// ---------- +x = +

+ text text text text text text text text text text text text text text text
text text text text text text +

; + +x = +
+
+ First +
- +
+ Second +
+
+ +x = +
+
+ First +
+ - +
+ Second +
+
+ +x = +
+
First
-
Second
+
+ +x = +
+
+ First +
- +
+ Second +
+
+ +x = +
+
+ First +
+ - +
+ Second +
+
+ +x = +
+
First
-
Second
+
+ +x = +
+ {hour}:{minute}:{second} +
+ +x = +
+ {hour} + : + {minute} + : + {second} +
+ +x = +
+ {hour}: + {minute}: + {second} +
+ +x =
text here.
+ +x =
Sales tax estimated using a rate of {salesTax * 100}%.
+ +x =
+ {title}  +
+ +x =
bar
+ +x =
+ + {name}’s{' '} + + Hello world.
+ You {type}ed this shipment to +
+ +x = + {parameter.Description}: {errorMsg} + + +x = + +x = Copy "{name}" + +x = (avg. {value}/5) + +x =

+ Use the Button's +

; + +this_really_should_split_across_lines = +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after +
+ +let myDiv = ReactTestUtils.renderIntoDocument( +
+ + ); + + // Wrapping tags + x = ( +
+- {" "} ++ + f +
+ ); +@@ -66,15 +69,19 @@ + + x = ( +
+- before {stuff} after {stuff} after {stuff} after {stuff} after {stuff} after{" "} +- {stuff} {stuff} {stuff} after {stuff} after ++ before {stuff} after {stuff} after {stuff} after {stuff} after {stuff} after { ++ stuff ++ } ++ {stuff} {stuff} after {stuff} after +
+ ); + + x = ( +
+- Please state your name and occupation for the board of{" "} +- school directors. ++ Please state your name and occupation for the board of ++ school ++ ++ directors. +
+ ); + +@@ -101,9 +108,10 @@ + x = ( + + +- Starting at minute {graphActivity.startTime}, running for{" "} +- {graphActivity.length} to minute{" "} +- {graphActivity.startTime + graphActivity.length} ++ Starting at minute {graphActivity.startTime}, running for { ++ graphActivity.length ++ } ++ to minute {graphActivity.startTime + graphActivity.length} + + + ); +@@ -176,19 +184,17 @@ + + unstable_before = ( +
+- Your score:{" "} +- {`${mini.crosstable.users[sessionUserId]} - ${ +- mini.crosstable.users[user.id] +- }`} ++ Your score: {`${ ++ mini.crosstable.users[sessionUserId] ++ } - ${mini.crosstable.users[user.id]}`} +
+ ); + + unstable_after_first_run = ( +
+- Your score:{" "} +- {`${mini.crosstable.users[sessionUserId]} - ${ +- mini.crosstable.users[user.id] +- }`} ++ Your score: {`${ ++ mini.crosstable.users[sessionUserId] ++ } - ${mini.crosstable.users[user.id]}`} +
+ ); + +@@ -213,24 +219,22 @@ + + jsx_around_multiline_element = ( +
+- Before{" "} +-
++ Before
+ { + "Enough text to make this element wrap on to multiple lines when formatting" + } +-
{" "} ++
+ After +
+ ); + + jsx_around_multiline_element_second_pass = ( +
+- Before{" "} +-
++ Before
+ { + "Enough text to make this element wrap on to multiple lines when formatting" + } +-
{" "} ++
+ After +
+ ); +@@ -251,8 +255,11 @@ + const Abc = () => { + return ( +
+- Please state your name and occupation for the board of +- directors. ++ Please state your ++ {" "}name ++ and ++ {" "}occupation ++ for the board of directors. +
+ ); + }; +@@ -318,19 +325,25 @@ + + line_after_br_2 = ( +
+- A
B
C ++ A ++
++ B ++
++ C +
+ ); + + br_followed_by_whitespace = ( +
+-
text ++
++ text +
+ ); + + dont_preserve_blank_lines_when_jsx_contains_text = ( +
+
Zeroth
++ +
First
+ Second +
+@@ -346,15 +359,18 @@ + + single_expression_child_tags = ( +
+- You currently have {dashboardStr} and{" "} +- {userStr} ++ You currently have {dashboardStr} and ++ {userStr} ++ +
+ ); + + expression_does_not_break = ( +
+- texty text text text text text text text text text text text{" "} +- {this.props.type}{" "} ++ texty text text text text text text text text text text text { ++ this.props.type ++ } ++ {" "} +
+ ); + +@@ -362,9 +378,8 @@ + br_triggers_expression_break = ( +
+
+- text text text text text text text text text text text { +- this.props.type +- }{" "} ++ text text text text text text text text text text text {this.props.type} ++ {" "} +
+ ); + +@@ -372,14 +387,14 @@ +
+ + {variable} +- {" "} ++ + ({variable}) +
+ ); + + x = ( +
+- ENDS IN
text text text text text text text text text text text
{" "} ++ ENDS IN
text text text text text text text text text text text
+ HRS +
+ ); +@@ -404,8 +419,9 @@ +
+
+
+- Line {startRange.row + 1}:{startRange.column + 1} -{" "} +- {endRange.row + 1}:{endRange.column + 1} ++ Line {startRange.row + 1}:{startRange.column + 1} - {endRange.row + ++ 1} ++ :{endRange.column + 1} + {caller} +
+
+@@ -436,13 +452,16 @@ + + x = ( +
+-
First
-
Second
++
First
- ++
Second
+
+ ); + + x = ( +
+-
First
-
Second
++
First
++ - ++
Second
+
+ ); + +@@ -496,19 +515,26 @@ + + x = ( +
+- {hour}:{minute}:{second} ++ {hour} ++ : ++ {minute} ++ : ++ {second} +
+ ); + + x = ( +
+- {hour}:{minute}:{second} ++ {hour}: ++ {minute}: ++ {second} +
+ ); + + x = ( +
+- text here.
++ text here. ++
+
+ ); + +@@ -528,7 +554,8 @@ + + {name}’s{" "} + +- Hello world.
++ Hello world. ++
+ You {type}ed this shipment to +
+ ); +@@ -564,7 +591,8 @@ + + let myDiv = ReactTestUtils.renderIntoDocument( +
+-
, ++
++ , +
+
, + ); +``` + +# Output + +```js +// Wrapping text +x = ( +
+ Some text that would need to wrap on to a new line in order to display + correctly and nicely +
+); + +// Wrapping tags +x = ( +
+ f f f f + f + + f +
+); + +// Wrapping tags +x = ( +
+ f + f + f + f + f + f +
+); + +// Wrapping tags +x = ( +
+); + +// Wrapping tags +x = ( +
+ + f +
+); + +x = ( +
+ before +
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur at + mollis lorem. +
+ after +
+); + +x = ( +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff} + {stuff} + {stuff}after{stuff}after +
+); + +x = ( +
+ before {stuff} after {stuff} after {stuff} after {stuff} after {stuff} after { + stuff + } + {stuff} {stuff} after {stuff} after +
+); + +x = ( +
+ Please state your name and occupation for the board of + school + + directors. +
+); + +function DiffOverview(props) { + const { source, target, since } = props; + return ( +
+
+

+ This diff overview is computed against the current list of records in + this collection and the list it contained on {humanDate(since)} + . +

+

+ Note: last_modified and schema record + metadata are omitted for easier review. +

+
+ +
+ ); +} + +x = ( + + + Starting at minute {graphActivity.startTime}, running for { + graphActivity.length + } + to minute {graphActivity.startTime + graphActivity.length} + + +); + +x = ( +
+ First second third +
+ Something +
+
+); + +x = ( +
+
First
+ Second +
Third
+
+); + +x = ( +
+ First
Second
Third +
+); + +leading_whitespace = ( +
+ {" "} + First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh + Twelfth Thirteenth Fourteenth +
+); + +trailing_whitespace = ( +
+ First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh + Twelfth Thirteenth Fourteenth{" "} +
+); + +no_leading_or_trailing_whitespace = ( +
+ First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh + Twelfth Thirteenth Fourteenth +
+); + +facebook_translation_leave_text_around_tag = ( +
+ First, (Second) +
+); + +x = ( +
+ First second third fourth fifth sixth seventh, ( + Second) +
+); + +this_really_should_split_across_lines = ( +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff} + after{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff} + after{stuff}after{stuff}after +
+); + +unstable_before = ( +
+ Your score: {`${ + mini.crosstable.users[sessionUserId] + } - ${mini.crosstable.users[user.id]}`} +
+); + +unstable_after_first_run = ( +
+ Your score: {`${ + mini.crosstable.users[sessionUserId] + } - ${mini.crosstable.users[user.id]}`} +
+); + +solitary_whitespace = ( +
+ {" "} +
+); + +jsx_whitespace_on_newline = ( +
+
First
Second
Third
+
+); + +jsx_around_multiline_element = ( +
+ Before
+ { + "Enough text to make this element wrap on to multiple lines when formatting" + } +
+ After +
+); + +jsx_around_multiline_element_second_pass = ( +
+ Before
+ { + "Enough text to make this element wrap on to multiple lines when formatting" + } +
+ After +
+); + +convert_space_expressions =
; + +x = ( +
+ + + + + + +
+); + +const Abc = () => { + return ( +
+ Please state your + {" "}name + and + {" "}occupation + for the board of directors. +
+ ); +}; + +x =
Some stuff here
; + +headers_and_paragraphs = ( +
+

First

+

The first paragraph.

+ +

Second

+

The second paragraph.

+
+); + +no_text_one_tag_per_line = ( +
+ + +
+); + +with_text_fill_line = ( +
+ Text + +
+); + +line_after_br = ( +
+ Text +
+ More text +
+ And more +
+
+); + +line_after_br = ( +
+ Text +
+ More text +
+ And more +
+
+); + +line_after_br = ( +
+ Text +
+ More text +
+ And more +
+
+); + +line_after_br_2 = ( +
+ A +
+ B +
+ C +
+); + +br_followed_by_whitespace = ( +
+
+ text +
+); + +dont_preserve_blank_lines_when_jsx_contains_text = ( +
+
Zeroth
+ +
First
+ Second +
+); + +multiple_expressions = ( +
+ {header} + {body} + {footer} +
+); + +single_expression_child_tags = ( +
+ You currently have {dashboardStr} and + {userStr} + +
+); + +expression_does_not_break = ( +
+ texty text text text text text text text text text text text { + this.props.type + } + {" "} +
+); + +// FIXME +br_triggers_expression_break = ( +
+
+ text text text text text text text text text text text {this.props.type} + {" "} +
+); + +jsx_whitespace_after_tag = ( +
+ + {variable} + + ({variable}) +
+); + +x = ( +
+ ENDS IN
text text text text text text text text text text text
+ HRS +
+); + +x = ( +
+

Message

+ Hello, I'm a simple message. +
+); + +x = ( +
+ Hello, I'm a simple message. +

Message

+
+); + +x = ( +
+
+
+
+
+ Line {startRange.row + 1}:{startRange.column + 1} - {endRange.row + + 1} + :{endRange.column + 1} + {caller} +
+
+
+
+
+); + +x = ( +
+ {" "} +
text
+
+); + +// NOTE: Multiple JSX whitespaces are collapsed into a single space. +x =
; + +// Don't break a self-closing element without attributes +// ---------- +x = ( +

+ text text text text text text text text text text text text text text text +
+ text text text text text text +

+); + +x = ( +
+
First
- +
Second
+
+); + +x = ( +
+
First
+ - +
Second
+
+); + +x = ( +
+
First
-
Second
+
+); + +x = ( +
+
+ First +
+ - +
+ Second +
+
+); + +x = ( +
+
+ First +
+ - +
+ Second +
+
+); + +x = ( +
+
+ First +
+ - +
+ Second +
+
+); + +x = ( +
+ {hour}:{minute}:{second} +
+); + +x = ( +
+ {hour} + : + {minute} + : + {second} +
+); + +x = ( +
+ {hour}: + {minute}: + {second} +
+); + +x = ( +
+ text here. +
+
+); + +x =
Sales tax estimated using a rate of {salesTax * 100}%.
; + +x =
{title} 
; + +x = ( +
+ + bar +
+); + +x = ( +
+ + {name}’s{" "} + + Hello world. +
+ You {type}ed this shipment to +
+); + +x = ( + + {parameter.Description}: {errorMsg} + +); + +x = ( + +); + +x = Copy "{name}"; + +x = (avg. {value}/5); + +x = ( +

+ Use the Button's +

+); + +this_really_should_split_across_lines = ( +
+ before{stuff}after{stuff}after{stuff}after{stuff}after{stuff}after{stuff} + after{stuff}after +
+); + +let myDiv = ReactTestUtils.renderIntoDocument( +
+
+ , +
+
, +); +``` + + +# Lines exceeding max width of 80 characters +``` + 72: before {stuff} after {stuff} after {stuff} after {stuff} after {stuff} after { + 122:
+ 224: "Enough text to make this element wrap on to multiple lines when formatting" + 235: "Enough text to make this element wrap on to multiple lines when formatting" +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/prepare_tests.js b/crates/rome_js_formatter/tests/specs/prettier/prepare_tests.js index 288ca96c300..9840ae0e75e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/prepare_tests.js +++ b/crates/rome_js_formatter/tests/specs/prettier/prepare_tests.js @@ -78,6 +78,7 @@ async function traverseDir(dir, config) { } const PRETTIER_ROOT_JS = path.resolve(PRETTIER_ROOT, "js"); +const PRETTIER_ROOT_JSX = path.resolve(PRETTIER_ROOT, "jsx"); const PRETTIER_ROOT_TS = path.resolve(PRETTIER_ROOT, "typescript"); const defaultConfig = { @@ -94,6 +95,13 @@ async function main() { ...defaultConfig, parser: "babel", }); + + console.log("Extracting tests from %s ...", {PRETTIER_ROOT_JSX}); + await traverseDir(PRETTIER_ROOT_JSX, { + ...defaultConfig, + parser: "babel", + }); + console.log("Extracting tests from %s ...", PRETTIER_ROOT_TS); await traverseDir(PRETTIER_ROOT_TS, { ...defaultConfig, diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts new file mode 100644 index 00000000000..de1ccb2859a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts @@ -0,0 +1 @@ +type Foo = T extends ((...a: any[]) => infer R extends string) ? R : never; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts.prettier-snap new file mode 100644 index 00000000000..de1ccb2859a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts.prettier-snap @@ -0,0 +1 @@ +type Foo = T extends ((...a: any[]) => infer R extends string) ? R : never; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.prettier-snap index ba48c56ec74..7ba227a2b2c 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.prettier-snap @@ -1,13 +1,13 @@ enum A { - [i++], + i++, } const bar = "bar"; enum B { - [bar] = 2, + bar = 2, } const foo = () => "foo"; enum C { - [foo()] = 2, + foo() = 2, } diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.snap index 0f789d4cf8d..3c1443ded3f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/enum/computed-members.ts --- # Input @@ -28,19 +30,19 @@ enum C { +++ Rome @@ -1,13 +1,7 @@ -enum A { -- [i++], +- i++, -} +enum A { [i++] } const bar = "bar"; -enum B { -- [bar] = 2, +- bar = 2, -} +enum B { [bar] = 2 } const foo = () => "foo"; -enum C { -- [foo()] = 2, +- foo() = 2, -} +enum C { [foo()] = 2 } ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.prettier-snap index 7751d7a4192..fd8cf153040 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.prettier-snap @@ -1,8 +1,8 @@ let a: *; function b(x: ?) {} let c: ?string; -let d: string?; +let d: ?string; let e: ?(string | number); let f: !string; -let g: string!; +let g: !string; let h: !(string | number); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.snap index bc35ce5fc7d..7f845c09a23 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/error-recovery/jsdoc_only_types.ts --- # Input @@ -27,10 +29,10 @@ let h: !(string | number); +* function b(x: ?) {} -let c: ?string; --let d: string?; +-let d: ?string; -let e: ?(string | number); -let f: !string; --let g: string!; +-let g: !string; -let h: !(string | number); +let c: +?string diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/interface2/break.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/interface2/break.ts index 579bb27c4f3..3bf95b1df83 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/interface2/break.ts +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/interface2/break.ts @@ -1,7 +1,7 @@ export interface Environment1 extends GenericEnvironment< SomeType, AnotherType, - YetAnotherType + YetAnotherType, > { m(): void; }; @@ -12,7 +12,7 @@ export class Environment2 extends GenericEnvironment< DifferentType1, DifferentType2, DifferentType3, - DifferentType4 + DifferentType4, > { m() {}; }; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/interface2/break.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/interface2/break.ts.snap index 0aafee6722c..5104cc03914 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/interface2/break.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/interface2/break.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/interface2/break.ts --- # Input @@ -8,7 +10,7 @@ source: crates/rome_js_formatter/tests/prettier_tests.rs export interface Environment1 extends GenericEnvironment< SomeType, AnotherType, - YetAnotherType + YetAnotherType, > { m(): void; }; @@ -19,7 +21,7 @@ export class Environment2 extends GenericEnvironment< DifferentType1, DifferentType2, DifferentType3, - DifferentType4 + DifferentType4, > { m() {}; }; @@ -79,7 +81,30 @@ export interface ExtendsLongOneWithGenerics extends Bar< SomeLongTypeSomeLongTyp ```diff --- Prettier +++ Rome -@@ -68,14 +68,14 @@ +@@ -1,5 +1,8 @@ +-export interface Environment1 +- extends GenericEnvironment { ++export interface Environment1 extends GenericEnvironment< ++ SomeType, ++ AnotherType, ++ YetAnotherType, ++> { + m(): void; + } + export class Environment2 extends GenericEnvironment< +@@ -9,9 +12,9 @@ + DifferentType1, + DifferentType2, + DifferentType3, +- DifferentType4 ++ DifferentType4, + > { +- m() {} ++ m() {}; + } + + // Declare Interface Break +@@ -68,14 +71,14 @@ interface ExtendsMany extends ASingleGenericInterface< @@ -102,7 +127,7 @@ export interface ExtendsLongOneWithGenerics extends Bar< SomeLongTypeSomeLongTyp x: string; } -@@ -97,6 +97,6 @@ +@@ -97,6 +100,6 @@ export interface ExtendsLongOneWithGenerics extends Bar< @@ -117,8 +142,11 @@ export interface ExtendsLongOneWithGenerics extends Bar< SomeLongTypeSomeLongTyp # Output ```js -export interface Environment1 - extends GenericEnvironment { +export interface Environment1 extends GenericEnvironment< + SomeType, + AnotherType, + YetAnotherType, +> { m(): void; } export class Environment2 extends GenericEnvironment< @@ -128,9 +156,9 @@ export class Environment2 extends GenericEnvironment< DifferentType1, DifferentType2, DifferentType3, - DifferentType4 + DifferentType4, > { - m() {} + m() {}; } // Declare Interface Break @@ -222,4 +250,21 @@ export interface ExtendsLongOneWithGenerics ``` +# Errors +``` +error[SyntaxError]: expected a type parameter but instead found '>' + ┌─ break.ts:5:1 + │ +5 │ > { + │ ^ Expected a type parameter here + +error[SyntaxError]: expected a type parameter but instead found '>' + ┌─ break.ts:16:1 + │ +16 │ > { + │ ^ Expected a type parameter here + + +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts new file mode 100644 index 00000000000..22648828e01 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts @@ -0,0 +1,6 @@ +type loremIpsumFooBazBar1 = 'Multiline string\ + Multiline string' + +type loremIpsumFooBazBar2 = 'Multiline string\ + Multiline string\ + Multiline string' diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts.prettier-snap new file mode 100644 index 00000000000..73c3e12f412 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts.prettier-snap @@ -0,0 +1,7 @@ +type loremIpsumFooBazBar1 = "Multiline string\ + Multiline string"; + +type loremIpsumFooBazBar2 = + "Multiline string\ + Multiline string\ + Multiline string"; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts.snap new file mode 100644 index 00000000000..553bece6606 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/literal/multiline.ts.snap @@ -0,0 +1,47 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/literal/multiline.ts +--- + +# Input + +```js +type loremIpsumFooBazBar1 = 'Multiline string\ + Multiline string' + +type loremIpsumFooBazBar2 = 'Multiline string\ + Multiline string\ + Multiline string' +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,7 +1,6 @@ + type loremIpsumFooBazBar1 = "Multiline string\ + Multiline string"; + +-type loremIpsumFooBazBar2 = +- "Multiline string\ ++type loremIpsumFooBazBar2 = "Multiline string\ + Multiline string\ + Multiline string"; +``` + +# Output + +```js +type loremIpsumFooBazBar1 = "Multiline string\ + Multiline string"; + +type loremIpsumFooBazBar2 = "Multiline string\ + Multiline string\ + Multiline string"; +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts new file mode 100644 index 00000000000..e10c347fb64 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts @@ -0,0 +1,6 @@ +// https://github.com/typescript-eslint/typescript-eslint/pull/4382 +function decorator() {} +@decorator +class Foo { + bar(baz: typeof this) {} +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts.prettier-snap new file mode 100644 index 00000000000..e10c347fb64 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts.prettier-snap @@ -0,0 +1,6 @@ +// https://github.com/typescript-eslint/typescript-eslint/pull/4382 +function decorator() {} +@decorator +class Foo { + bar(baz: typeof this) {} +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts.snap new file mode 100644 index 00000000000..e9c459e11a2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/decorators.ts.snap @@ -0,0 +1,46 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/typeof-this/decorators.ts +--- + +# Input + +```js +// https://github.com/typescript-eslint/typescript-eslint/pull/4382 +function decorator() {} +@decorator +class Foo { + bar(baz: typeof this) {} +} +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,5 +1,6 @@ + // https://github.com/typescript-eslint/typescript-eslint/pull/4382 + function decorator() {} ++ + @decorator + class Foo { + bar(baz: typeof this) {} +``` + +# Output + +```js +// https://github.com/typescript-eslint/typescript-eslint/pull/4382 +function decorator() {} + +@decorator +class Foo { + bar(baz: typeof this) {} +} +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/typeof-this.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/typeof-this.ts new file mode 100644 index 00000000000..7f3c4f11d4c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/typeof-this.ts @@ -0,0 +1,3 @@ +// https://github.com/typescript-eslint/typescript-eslint/pull/4382 +let self: typeof this; +let foo: typeof this.foo; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/typeof-this.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/typeof-this.ts.prettier-snap new file mode 100644 index 00000000000..7f3c4f11d4c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeof-this/typeof-this.ts.prettier-snap @@ -0,0 +1,3 @@ +// https://github.com/typescript-eslint/typescript-eslint/pull/4382 +let self: typeof this; +let foo: typeof this.foo; From ede488eceec89694d00c82c61b86396a50c7c666 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 20 Sep 2022 11:36:45 +0100 Subject: [PATCH 4/4] refactor(rome_js_analyze): `useOptionalChain` to nursery group (#3253) --- .../src/analyzers/correctness.rs | 3 +- .../rome_js_analyze/src/analyzers/nursery.rs | 3 +- .../use_optional_chain.rs | 2 +- .../complexLogicalAndCases.ts | 0 .../complexLogicalAndCases.ts.snap | 6 +- .../useOptionalChain/logicalAndCases.js | 0 .../useOptionalChain/logicalAndCases.js.snap | 406 +++++++++--------- .../useOptionalChain/nullishAndLogicalOr.ts | 0 .../nullishAndLogicalOr.ts.snap | 226 +++++----- .../useOptionalChain/validCases.ts | 0 .../useOptionalChain/validCases.ts.snap | 0 .../src/configuration/linter/rules.rs | 16 +- editors/vscode/configuration_schema.json | 20 +- npm/backend-jsonrpc/src/workspace.ts | 2 +- website/src/docs/lint/rules/index.md | 15 +- .../src/docs/lint/rules/useOptionalChain.md | 50 ++- 16 files changed, 372 insertions(+), 377 deletions(-) rename crates/rome_js_analyze/src/analyzers/{correctness => nursery}/use_optional_chain.rs (99%) rename crates/rome_js_analyze/tests/specs/{correctness => nursery}/useOptionalChain/complexLogicalAndCases.ts (100%) rename crates/rome_js_analyze/tests/specs/{correctness => nursery}/useOptionalChain/complexLogicalAndCases.ts.snap (89%) rename crates/rome_js_analyze/tests/specs/{correctness => nursery}/useOptionalChain/logicalAndCases.js (100%) rename crates/rome_js_analyze/tests/specs/{correctness => nursery}/useOptionalChain/logicalAndCases.js.snap (91%) rename crates/rome_js_analyze/tests/specs/{correctness => nursery}/useOptionalChain/nullishAndLogicalOr.ts (100%) rename crates/rome_js_analyze/tests/specs/{correctness => nursery}/useOptionalChain/nullishAndLogicalOr.ts.snap (87%) rename crates/rome_js_analyze/tests/specs/{correctness => nursery}/useOptionalChain/validCases.ts (100%) rename crates/rome_js_analyze/tests/specs/{correctness => nursery}/useOptionalChain/validCases.ts.snap (100%) diff --git a/crates/rome_js_analyze/src/analyzers/correctness.rs b/crates/rome_js_analyze/src/analyzers/correctness.rs index 3694d391112..b367a21a910 100644 --- a/crates/rome_js_analyze/src/analyzers/correctness.rs +++ b/crates/rome_js_analyze/src/analyzers/correctness.rs @@ -17,11 +17,10 @@ mod no_unnecessary_continue; mod no_unsafe_negation; mod no_unused_template_literal; mod use_block_statements; -mod use_optional_chain; mod use_simplified_logic_expression; mod use_single_case_statement; mod use_single_var_declarator; mod use_template; mod use_valid_typeof; mod use_while; -declare_group! { pub (crate) Correctness { name : "correctness" , rules : [self :: no_async_promise_executor :: NoAsyncPromiseExecutor , self :: no_comment_text :: NoCommentText , self :: no_compare_neg_zero :: NoCompareNegZero , self :: no_debugger :: NoDebugger , self :: no_delete :: NoDelete , self :: no_double_equals :: NoDoubleEquals , self :: no_empty_pattern :: NoEmptyPattern , self :: no_extra_boolean_cast :: NoExtraBooleanCast , self :: no_implicit_boolean :: NoImplicitBoolean , self :: no_multiple_spaces_in_regular_expression_literals :: NoMultipleSpacesInRegularExpressionLiterals , self :: no_shadow_restricted_names :: NoShadowRestrictedNames , self :: no_sparse_array :: NoSparseArray , self :: no_unnecessary_continue :: NoUnnecessaryContinue , self :: no_unsafe_negation :: NoUnsafeNegation , self :: no_unused_template_literal :: NoUnusedTemplateLiteral , self :: use_block_statements :: UseBlockStatements , self :: use_optional_chain :: UseOptionalChain , self :: use_simplified_logic_expression :: UseSimplifiedLogicExpression , self :: use_single_case_statement :: UseSingleCaseStatement , self :: use_single_var_declarator :: UseSingleVarDeclarator , self :: use_template :: UseTemplate , self :: use_valid_typeof :: UseValidTypeof , self :: use_while :: UseWhile ,] } } +declare_group! { pub (crate) Correctness { name : "correctness" , rules : [self :: no_async_promise_executor :: NoAsyncPromiseExecutor , self :: no_comment_text :: NoCommentText , self :: no_compare_neg_zero :: NoCompareNegZero , self :: no_debugger :: NoDebugger , self :: no_delete :: NoDelete , self :: no_double_equals :: NoDoubleEquals , self :: no_empty_pattern :: NoEmptyPattern , self :: no_extra_boolean_cast :: NoExtraBooleanCast , self :: no_implicit_boolean :: NoImplicitBoolean , self :: no_multiple_spaces_in_regular_expression_literals :: NoMultipleSpacesInRegularExpressionLiterals , self :: no_shadow_restricted_names :: NoShadowRestrictedNames , self :: no_sparse_array :: NoSparseArray , self :: no_unnecessary_continue :: NoUnnecessaryContinue , self :: no_unsafe_negation :: NoUnsafeNegation , self :: no_unused_template_literal :: NoUnusedTemplateLiteral , self :: use_block_statements :: UseBlockStatements , self :: use_simplified_logic_expression :: UseSimplifiedLogicExpression , self :: use_single_case_statement :: UseSingleCaseStatement , self :: use_single_var_declarator :: UseSingleVarDeclarator , self :: use_template :: UseTemplate , self :: use_valid_typeof :: UseValidTypeof , self :: use_while :: UseWhile ,] } } diff --git a/crates/rome_js_analyze/src/analyzers/nursery.rs b/crates/rome_js_analyze/src/analyzers/nursery.rs index b7f72cb1b12..786c87cd235 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery.rs @@ -3,4 +3,5 @@ use rome_analyze::declare_group; mod no_new_symbol; mod no_unreachable; -declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_new_symbol :: NoNewSymbol , self :: no_unreachable :: NoUnreachable ,] } } +mod use_optional_chain; +declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_new_symbol :: NoNewSymbol , self :: no_unreachable :: NoUnreachable , self :: use_optional_chain :: UseOptionalChain ,] } } diff --git a/crates/rome_js_analyze/src/analyzers/correctness/use_optional_chain.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_optional_chain.rs similarity index 99% rename from crates/rome_js_analyze/src/analyzers/correctness/use_optional_chain.rs rename to crates/rome_js_analyze/src/analyzers/nursery/use_optional_chain.rs index f16e093d9b5..f4216366dfc 100644 --- a/crates/rome_js_analyze/src/analyzers/correctness/use_optional_chain.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_optional_chain.rs @@ -76,7 +76,7 @@ declare_rule! { pub(crate) UseOptionalChain { version: "0.10.0", name: "useOptionalChain", - recommended: true, + recommended: false, } } diff --git a/crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/complexLogicalAndCases.ts b/crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/complexLogicalAndCases.ts similarity index 100% rename from crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/complexLogicalAndCases.ts rename to crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/complexLogicalAndCases.ts diff --git a/crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/complexLogicalAndCases.ts.snap b/crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/complexLogicalAndCases.ts.snap similarity index 89% rename from crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/complexLogicalAndCases.ts.snap rename to crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/complexLogicalAndCases.ts.snap index 471ce5d31a6..ab657351f93 100644 --- a/crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/complexLogicalAndCases.ts.snap +++ b/crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/complexLogicalAndCases.ts.snap @@ -13,7 +13,7 @@ foo && foo[typeof bar] && foo[typeof bar].baz; # Diagnostics ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ complexLogicalAndCases.ts:2:1 │ 2 │ foo && foo[bar as string] && foo[bar as string].baz; @@ -31,7 +31,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ complexLogicalAndCases.ts:3:1 │ 3 │ foo && foo[1 + 2] && foo[1 + 2].baz; @@ -49,7 +49,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ complexLogicalAndCases.ts:4:1 │ 4 │ foo && foo[typeof bar] && foo[typeof bar].baz; diff --git a/crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/logicalAndCases.js b/crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/logicalAndCases.js similarity index 100% rename from crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/logicalAndCases.js rename to crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/logicalAndCases.js diff --git a/crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/logicalAndCases.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/logicalAndCases.js.snap similarity index 91% rename from crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/logicalAndCases.js.snap rename to crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/logicalAndCases.js.snap index fb89198aa8d..929d2653c8e 100644 --- a/crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/logicalAndCases.js.snap +++ b/crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/logicalAndCases.js.snap @@ -393,7 +393,7 @@ foo && foo[bar] && /*0*/foo/*1*/?./*2*/[/*3*/bar/*4*/]/*5*/?./*6*/[/*7*/baz/*8*/ # Diagnostics ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:4:1 │ 4 │ foo && foo.bar @@ -414,7 +414,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:5:1 │ 5 │ foo.bar && foo.bar.baz @@ -435,7 +435,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:6:1 │ 6 │ foo && foo() @@ -456,7 +456,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:7:1 │ 7 │ foo.bar && foo.bar() @@ -477,7 +477,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:8:1 │ 8 │ foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz @@ -498,7 +498,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:9:1 │ 9 │ foo.bar && foo.bar.baz && foo.bar.baz.buzz @@ -519,7 +519,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:12:1 │ 12 │ foo && foo.bar && foo.bar.baz.buzz @@ -540,7 +540,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:13:1 │ 13 │ foo.bar && foo.bar.baz.buzz @@ -561,7 +561,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:16:1 │ 16 │ foo && foo.bar && foo.bar.baz && foo.bar.baz && foo.bar.baz.buzz @@ -582,7 +582,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:17:1 │ 17 │ foo.bar && foo.bar.baz && foo.bar.baz && foo.bar.baz.buzz @@ -603,7 +603,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:20:1 │ 20 │ foo && foo[bar] && foo[bar].baz && foo[bar].baz.buzz @@ -624,7 +624,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:23:1 │ 23 │ foo && foo[bar].baz && foo[bar].baz.buzz @@ -645,7 +645,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:26:1 │ 26 │ foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz() @@ -666,7 +666,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:27:1 │ 27 │ foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz && foo.bar.baz.buzz() @@ -687,7 +687,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:28:1 │ 28 │ foo.bar && foo.bar.baz && foo.bar.baz.buzz && foo.bar.baz.buzz() @@ -708,7 +708,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:31:1 │ 31 │ foo && foo.bar && foo.bar.baz.buzz() @@ -729,7 +729,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:32:1 │ 32 │ foo.bar && foo.bar.baz.buzz() @@ -750,7 +750,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:35:1 │ 35 │ foo && foo.bar && foo.bar.baz.buzz && foo.bar.baz.buzz() @@ -771,7 +771,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:38:1 │ 38 │ foo && foo.bar() && foo.bar().baz && foo.bar().baz.buzz && foo.bar().baz.buzz() @@ -792,7 +792,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:41:1 │ 41 │ foo && foo.bar && foo.bar.baz && foo.bar.baz[buzz]() @@ -813,7 +813,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:42:1 │ 42 │ foo && foo.bar && foo.bar.baz && foo.bar.baz[buzz] && foo.bar.baz[buzz]() @@ -834,7 +834,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:45:1 │ 45 │ foo && foo?.bar && foo?.bar.baz && foo?.bar.baz[buzz] && foo?.bar.baz[buzz]() @@ -855,7 +855,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:46:1 │ 46 │ foo && foo?.bar.baz && foo?.bar.baz[buzz] @@ -876,7 +876,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:47:1 │ 47 │ foo && foo?.() && foo?.().bar @@ -897,7 +897,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:48:1 │ 48 │ foo.bar && foo.bar?.() && foo.bar?.().baz @@ -918,7 +918,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:54:1 │ 54 │ foo && foo.bar && bing @@ -939,7 +939,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:55:1 │ 55 │ foo.bar && foo.bar.baz && bing @@ -960,7 +960,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:56:1 │ 56 │ foo && foo() && bing @@ -981,7 +981,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:57:1 │ 57 │ foo.bar && foo.bar() && bing @@ -1002,7 +1002,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:58:1 │ 58 │ foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz && bing @@ -1023,7 +1023,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:59:1 │ 59 │ foo.bar && foo.bar.baz && foo.bar.baz.buzz && bing @@ -1044,7 +1044,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:62:1 │ 62 │ foo && foo.bar && foo.bar.baz.buzz && bing @@ -1065,7 +1065,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:63:1 │ 63 │ foo.bar && foo.bar.baz.buzz && bing @@ -1086,7 +1086,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:66:1 │ 66 │ foo && foo.bar && foo.bar.baz && foo.bar.baz && foo.bar.baz.buzz && bing @@ -1107,7 +1107,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:67:1 │ 67 │ foo.bar && foo.bar.baz && foo.bar.baz && foo.bar.baz.buzz && bing @@ -1128,7 +1128,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:70:1 │ 70 │ foo && foo[bar] && foo[bar].baz && foo[bar].baz.buzz && bing @@ -1149,7 +1149,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:73:1 │ 73 │ foo && foo[bar].baz && foo[bar].baz.buzz && bing @@ -1170,7 +1170,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:76:1 │ 76 │ foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz() && bing @@ -1191,7 +1191,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:77:1 │ 77 │ foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz && foo.bar.baz.buzz() && bing @@ -1212,7 +1212,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:78:1 │ 78 │ foo.bar && foo.bar.baz && foo.bar.baz.buzz && foo.bar.baz.buzz() && bing @@ -1233,7 +1233,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:81:1 │ 81 │ foo && foo.bar && foo.bar.baz.buzz() && bing @@ -1254,7 +1254,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:82:1 │ 82 │ foo.bar && foo.bar.baz.buzz() && bing @@ -1275,7 +1275,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:85:1 │ 85 │ foo && foo.bar && foo.bar.baz.buzz && foo.bar.baz.buzz() && bing @@ -1296,7 +1296,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:88:1 │ 88 │ foo && foo.bar() && foo.bar().baz && foo.bar().baz.buzz && foo.bar().baz.buzz() && bing @@ -1317,7 +1317,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:91:1 │ 91 │ foo && foo.bar && foo.bar.baz && foo.bar.baz[buzz]() && bing @@ -1338,7 +1338,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:92:1 │ 92 │ foo && foo.bar && foo.bar.baz && foo.bar.baz[buzz] && foo.bar.baz[buzz]() && bing @@ -1359,7 +1359,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:95:1 │ 95 │ foo && foo?.bar && foo?.bar.baz && foo?.bar.baz[buzz] && foo?.bar.baz[buzz]() && bing @@ -1380,7 +1380,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:96:1 │ 96 │ foo && foo?.bar.baz && foo?.bar.baz[buzz] && bing @@ -1401,7 +1401,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:97:1 │ 97 │ foo && foo?.() && foo?.().bar && bing @@ -1422,7 +1422,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:98:1 │ 98 │ foo.bar && foo.bar?.() && foo.bar?.().baz && bing @@ -1443,7 +1443,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:101:1 │ 101 │ foo && foo.bar && bing.bong @@ -1464,7 +1464,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:102:1 │ 102 │ foo.bar && foo.bar.baz && bing.bong @@ -1485,7 +1485,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:103:1 │ 103 │ foo && foo() && bing.bong @@ -1506,7 +1506,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:104:1 │ 104 │ foo.bar && foo.bar() && bing.bong @@ -1527,7 +1527,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:105:1 │ 105 │ foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz && bing.bong @@ -1548,7 +1548,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:106:1 │ 106 │ foo.bar && foo.bar.baz && foo.bar.baz.buzz && bing.bong @@ -1569,7 +1569,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:109:1 │ 109 │ foo && foo.bar && foo.bar.baz.buzz && bing.bong @@ -1590,7 +1590,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:110:1 │ 110 │ foo.bar && foo.bar.baz.buzz && bing.bong @@ -1611,7 +1611,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:113:1 │ 113 │ foo && foo.bar && foo.bar.baz && foo.bar.baz && foo.bar.baz.buzz && bing.bong @@ -1632,7 +1632,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:114:1 │ 114 │ foo.bar && foo.bar.baz && foo.bar.baz && foo.bar.baz.buzz && bing.bong @@ -1653,7 +1653,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:117:1 │ 117 │ foo && foo[bar] && foo[bar].baz && foo[bar].baz.buzz && bing.bong @@ -1674,7 +1674,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:120:1 │ 120 │ foo && foo[bar].baz && foo[bar].baz.buzz && bing.bong @@ -1695,7 +1695,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:123:1 │ 123 │ foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz() && bing.bong @@ -1716,7 +1716,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:124:1 │ 124 │ foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz && foo.bar.baz.buzz() && bing.bong @@ -1737,7 +1737,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:125:1 │ 125 │ foo.bar && foo.bar.baz && foo.bar.baz.buzz && foo.bar.baz.buzz() && bing.bong @@ -1758,7 +1758,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:128:1 │ 128 │ foo && foo.bar && foo.bar.baz.buzz() && bing.bong @@ -1779,7 +1779,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:129:1 │ 129 │ foo.bar && foo.bar.baz.buzz() && bing.bong @@ -1800,7 +1800,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:132:1 │ 132 │ foo && foo.bar && foo.bar.baz.buzz && foo.bar.baz.buzz() && bing.bong @@ -1821,7 +1821,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:135:1 │ 135 │ foo && foo.bar() && foo.bar().baz && foo.bar().baz.buzz && foo.bar().baz.buzz() && bing.bong @@ -1842,7 +1842,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:138:1 │ 138 │ foo && foo.bar && foo.bar.baz && foo.bar.baz[buzz]() && bing.bong @@ -1863,7 +1863,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:139:1 │ 139 │ foo && foo.bar && foo.bar.baz && foo.bar.baz[buzz] && foo.bar.baz[buzz]() && bing.bong @@ -1884,7 +1884,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:142:1 │ 142 │ foo && foo?.bar && foo?.bar.baz && foo?.bar.baz[buzz] && foo?.bar.baz[buzz]() && bing.bong @@ -1905,7 +1905,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:143:1 │ 143 │ foo && foo?.bar.baz && foo?.bar.baz[buzz] && bing.bong @@ -1926,7 +1926,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:144:1 │ 144 │ foo && foo?.() && foo?.().bar && bing.bong @@ -1947,7 +1947,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:145:1 │ 145 │ foo.bar && foo.bar?.() && foo.bar?.().baz && bing.bong @@ -1968,7 +1968,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:149:1 │ 149 │ foo !== null && foo.bar @@ -1989,7 +1989,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:150:1 │ 150 │ foo.bar !== null && foo.bar.baz @@ -2010,7 +2010,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:151:1 │ 151 │ foo !== null && foo() @@ -2031,7 +2031,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:152:1 │ 152 │ foo.bar !== null && foo.bar() @@ -2052,7 +2052,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:153:1 │ 153 │ foo !== null && foo.bar !== null && foo.bar.baz !== null && foo.bar.baz.buzz @@ -2073,7 +2073,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:154:1 │ 154 │ foo.bar !== null && foo.bar.baz !== null && foo.bar.baz.buzz @@ -2094,7 +2094,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:157:1 │ 157 │ foo !== null && foo.bar !== null && foo.bar.baz.buzz @@ -2115,7 +2115,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:158:1 │ 158 │ foo.bar !== null && foo.bar.baz.buzz @@ -2136,7 +2136,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:161:1 │ 161 │ foo !== null && foo.bar !== null && foo.bar.baz !== null && foo.bar.baz !== null && foo.bar.baz.buzz @@ -2157,7 +2157,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:162:1 │ 162 │ foo.bar !== null && foo.bar.baz !== null && foo.bar.baz !== null && foo.bar.baz.buzz @@ -2178,7 +2178,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:165:1 │ 165 │ foo !== null && foo[bar] !== null && foo[bar].baz !== null && foo[bar].baz.buzz @@ -2199,7 +2199,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:168:1 │ 168 │ foo !== null && foo[bar].baz !== null && foo[bar].baz.buzz @@ -2220,7 +2220,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:171:1 │ 171 │ foo !== null && foo.bar !== null && foo.bar.baz !== null && foo.bar.baz.buzz() @@ -2241,7 +2241,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:172:1 │ 172 │ foo !== null && foo.bar !== null && foo.bar.baz !== null && foo.bar.baz.buzz !== null && foo.bar.baz.buzz() @@ -2262,7 +2262,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:173:1 │ 173 │ foo.bar !== null && foo.bar.baz !== null && foo.bar.baz.buzz !== null && foo.bar.baz.buzz() @@ -2283,7 +2283,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:176:1 │ 176 │ foo !== null && foo.bar !== null && foo.bar.baz.buzz() @@ -2304,7 +2304,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:177:1 │ 177 │ foo.bar !== null && foo.bar.baz.buzz() @@ -2325,7 +2325,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:180:1 │ 180 │ foo !== null && foo.bar !== null && foo.bar.baz.buzz !== null && foo.bar.baz.buzz() @@ -2346,7 +2346,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:183:1 │ 183 │ foo !== null && foo.bar() !== null && foo.bar().baz !== null && foo.bar().baz.buzz !== null && foo.bar().baz.buzz() @@ -2367,7 +2367,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:186:1 │ 186 │ foo !== null && foo.bar !== null && foo.bar.baz !== null && foo.bar.baz[buzz]() @@ -2388,7 +2388,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:187:1 │ 187 │ foo !== null && foo.bar !== null && foo.bar.baz !== null && foo.bar.baz[buzz] !== null && foo.bar.baz[buzz]() @@ -2409,7 +2409,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:190:1 │ 190 │ foo !== null && foo?.bar !== null && foo?.bar.baz !== null && foo?.bar.baz[buzz] !== null && foo?.bar.baz[buzz]() @@ -2430,7 +2430,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:191:1 │ 191 │ foo !== null && foo?.bar.baz !== null && foo?.bar.baz[buzz] @@ -2451,7 +2451,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:192:1 │ 192 │ foo !== null && foo?.() !== null && foo?.().bar @@ -2472,7 +2472,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:193:1 │ 193 │ foo.bar !== null && foo.bar?.() !== null && foo.bar?.().baz @@ -2493,7 +2493,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:196:1 │ 196 │ foo !== undefined && foo.bar @@ -2514,7 +2514,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:197:1 │ 197 │ foo.bar !== undefined && foo.bar.baz @@ -2535,7 +2535,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:198:1 │ 198 │ foo !== undefined && foo() @@ -2556,7 +2556,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:199:1 │ 199 │ foo.bar !== undefined && foo.bar() @@ -2577,7 +2577,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:200:1 │ 200 │ foo !== undefined && foo.bar !== undefined && foo.bar.baz !== undefined && foo.bar.baz.buzz @@ -2598,7 +2598,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:201:1 │ 201 │ foo.bar !== undefined && foo.bar.baz !== undefined && foo.bar.baz.buzz @@ -2619,7 +2619,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:204:1 │ 204 │ foo !== undefined && foo.bar !== undefined && foo.bar.baz.buzz @@ -2640,7 +2640,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:205:1 │ 205 │ foo.bar !== undefined && foo.bar.baz.buzz @@ -2661,7 +2661,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:208:1 │ 208 │ foo !== undefined && foo.bar !== undefined && foo.bar.baz !== undefined && foo.bar.baz !== undefined && foo.bar.baz.buzz @@ -2682,7 +2682,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:209:1 │ 209 │ foo.bar !== undefined && foo.bar.baz !== undefined && foo.bar.baz !== undefined && foo.bar.baz.buzz @@ -2703,7 +2703,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:212:1 │ 212 │ foo !== undefined && foo[bar] !== undefined && foo[bar].baz !== undefined && foo[bar].baz.buzz @@ -2724,7 +2724,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:215:1 │ 215 │ foo !== undefined && foo[bar].baz !== undefined && foo[bar].baz.buzz @@ -2745,7 +2745,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:218:1 │ 218 │ foo !== undefined && foo.bar !== undefined && foo.bar.baz !== undefined && foo.bar.baz.buzz() @@ -2766,7 +2766,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:219:1 │ 219 │ foo !== undefined && foo.bar !== undefined && foo.bar.baz !== undefined && foo.bar.baz.buzz !== undefined && foo.bar.baz.buzz() @@ -2787,7 +2787,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:220:1 │ 220 │ foo.bar !== undefined && foo.bar.baz !== undefined && foo.bar.baz.buzz !== undefined && foo.bar.baz.buzz() @@ -2808,7 +2808,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:223:1 │ 223 │ foo !== undefined && foo.bar !== undefined && foo.bar.baz.buzz() @@ -2829,7 +2829,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:224:1 │ 224 │ foo.bar !== undefined && foo.bar.baz.buzz() @@ -2850,7 +2850,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:227:1 │ 227 │ foo !== undefined && foo.bar !== undefined && foo.bar.baz.buzz !== undefined && foo.bar.baz.buzz() @@ -2871,7 +2871,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:230:1 │ 230 │ foo !== undefined && foo.bar() !== undefined && foo.bar().baz !== undefined && foo.bar().baz.buzz !== undefined && foo.bar().baz.buzz() @@ -2892,7 +2892,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:233:1 │ 233 │ foo !== undefined && foo.bar !== undefined && foo.bar.baz !== undefined && foo.bar.baz[buzz]() @@ -2913,7 +2913,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:234:1 │ 234 │ foo !== undefined && foo.bar !== undefined && foo.bar.baz !== undefined && foo.bar.baz[buzz] !== undefined && foo.bar.baz[buzz]() @@ -2934,7 +2934,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:237:1 │ 237 │ foo !== undefined && foo?.bar !== undefined && foo?.bar.baz !== undefined && foo?.bar.baz[buzz] !== undefined && foo?.bar.baz[buzz]() @@ -2955,7 +2955,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:238:1 │ 238 │ foo !== undefined && foo?.bar.baz !== undefined && foo?.bar.baz[buzz] @@ -2976,7 +2976,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:239:1 │ 239 │ foo !== undefined && foo?.() !== undefined && foo?.().bar @@ -2997,7 +2997,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:240:1 │ 240 │ foo.bar !== undefined && foo.bar?.() !== undefined && foo.bar?.().baz @@ -3018,7 +3018,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:243:1 │ 243 │ foo != null && foo.bar @@ -3039,7 +3039,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:244:1 │ 244 │ foo.bar != null && foo.bar.baz @@ -3060,7 +3060,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:245:1 │ 245 │ foo != null && foo() @@ -3081,7 +3081,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:246:1 │ 246 │ foo.bar != null && foo.bar() @@ -3102,7 +3102,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:247:1 │ 247 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz @@ -3123,7 +3123,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:248:1 │ 248 │ foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz @@ -3144,7 +3144,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:251:1 │ 251 │ foo != null && foo.bar != null && foo.bar.baz.buzz @@ -3165,7 +3165,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:252:1 │ 252 │ foo.bar != null && foo.bar.baz.buzz @@ -3186,7 +3186,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:255:1 │ 255 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz != null && foo.bar.baz.buzz @@ -3207,7 +3207,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:256:1 │ 256 │ foo.bar != null && foo.bar.baz != null && foo.bar.baz != null && foo.bar.baz.buzz @@ -3228,7 +3228,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:259:1 │ 259 │ foo != null && foo[bar] != null && foo[bar].baz != null && foo[bar].baz.buzz @@ -3249,7 +3249,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:262:1 │ 262 │ foo != null && foo[bar].baz != null && foo[bar].baz.buzz @@ -3270,7 +3270,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:265:1 │ 265 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz() @@ -3291,7 +3291,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:266:1 │ 266 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() @@ -3312,7 +3312,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:267:1 │ 267 │ foo.bar != null && foo.bar.baz != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() @@ -3333,7 +3333,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:270:1 │ 270 │ foo != null && foo.bar != null && foo.bar.baz.buzz() @@ -3354,7 +3354,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:271:1 │ 271 │ foo.bar != null && foo.bar.baz.buzz() @@ -3375,7 +3375,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:274:1 │ 274 │ foo != null && foo.bar != null && foo.bar.baz.buzz != null && foo.bar.baz.buzz() @@ -3396,7 +3396,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:277:1 │ 277 │ foo != null && foo.bar() != null && foo.bar().baz != null && foo.bar().baz.buzz != null && foo.bar().baz.buzz() @@ -3417,7 +3417,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:280:1 │ 280 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz[buzz]() @@ -3438,7 +3438,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:281:1 │ 281 │ foo != null && foo.bar != null && foo.bar.baz != null && foo.bar.baz[buzz] != null && foo.bar.baz[buzz]() @@ -3459,7 +3459,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:284:1 │ 284 │ foo != null && foo?.bar != null && foo?.bar.baz != null && foo?.bar.baz[buzz] != null && foo?.bar.baz[buzz]() @@ -3480,7 +3480,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:285:1 │ 285 │ foo != null && foo?.bar.baz != null && foo?.bar.baz[buzz] @@ -3501,7 +3501,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:286:1 │ 286 │ foo != null && foo?.() != null && foo?.().bar @@ -3522,7 +3522,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:287:1 │ 287 │ foo.bar != null && foo.bar?.() != null && foo.bar?.().baz @@ -3543,7 +3543,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:290:1 │ 290 │ foo != undefined && foo.bar @@ -3564,7 +3564,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:291:1 │ 291 │ foo.bar != undefined && foo.bar.baz @@ -3585,7 +3585,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:292:1 │ 292 │ foo != undefined && foo() @@ -3606,7 +3606,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:293:1 │ 293 │ foo.bar != undefined && foo.bar() @@ -3627,7 +3627,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:294:1 │ 294 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz @@ -3648,7 +3648,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:295:1 │ 295 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz @@ -3669,7 +3669,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:298:1 │ 298 │ foo != undefined && foo.bar != undefined && foo.bar.baz.buzz @@ -3690,7 +3690,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:299:1 │ 299 │ foo.bar != undefined && foo.bar.baz.buzz @@ -3711,7 +3711,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:302:1 │ 302 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz @@ -3732,7 +3732,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:303:1 │ 303 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz @@ -3753,7 +3753,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:306:1 │ 306 │ foo != undefined && foo[bar] != undefined && foo[bar].baz != undefined && foo[bar].baz.buzz @@ -3774,7 +3774,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:309:1 │ 309 │ foo != undefined && foo[bar].baz != undefined && foo[bar].baz.buzz @@ -3795,7 +3795,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:312:1 │ 312 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz() @@ -3816,7 +3816,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:313:1 │ 313 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() @@ -3837,7 +3837,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:314:1 │ 314 │ foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() @@ -3858,7 +3858,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:317:1 │ 317 │ foo != undefined && foo.bar != undefined && foo.bar.baz.buzz() @@ -3879,7 +3879,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:318:1 │ 318 │ foo.bar != undefined && foo.bar.baz.buzz() @@ -3900,7 +3900,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:321:1 │ 321 │ foo != undefined && foo.bar != undefined && foo.bar.baz.buzz != undefined && foo.bar.baz.buzz() @@ -3921,7 +3921,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:324:1 │ 324 │ foo != undefined && foo.bar() != undefined && foo.bar().baz != undefined && foo.bar().baz.buzz != undefined && foo.bar().baz.buzz() @@ -3942,7 +3942,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:327:1 │ 327 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz[buzz]() @@ -3963,7 +3963,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:328:1 │ 328 │ foo != undefined && foo.bar != undefined && foo.bar.baz != undefined && foo.bar.baz[buzz] != undefined && foo.bar.baz[buzz]() @@ -3984,7 +3984,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:331:1 │ 331 │ foo != undefined && foo?.bar != undefined && foo?.bar.baz != undefined && foo?.bar.baz[buzz] != undefined && foo?.bar.baz[buzz]() @@ -4005,7 +4005,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:332:1 │ 332 │ foo != undefined && foo?.bar.baz != undefined && foo?.bar.baz[buzz] @@ -4026,7 +4026,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:333:1 │ 333 │ foo != undefined && foo?.() != undefined && foo?.().bar @@ -4047,7 +4047,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:334:1 │ 334 │ foo.bar != undefined && foo.bar?.() != undefined && foo.bar?.().baz @@ -4068,7 +4068,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:337:1 │ 337 │ foo && foo.#bar @@ -4089,7 +4089,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:338:1 │ 338 │ foo.#bar && foo.#bar.#baz @@ -4110,7 +4110,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:339:1 │ 339 │ foo.#bar && foo.#bar() @@ -4131,7 +4131,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:340:1 │ 340 │ foo && foo.#bar && foo.#bar.#baz && foo.#bar.#baz.#buzz @@ -4152,7 +4152,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:341:1 │ 341 │ foo.#bar && foo.#bar.#baz && foo.#bar.#baz.#buzz @@ -4173,7 +4173,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:344:1 │ 344 │ foo && foo.bar && foo.bar.baz || baz && baz.bar && baz.bar.foo @@ -4194,7 +4194,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:344:34 │ 344 │ foo && foo.bar && foo.bar.baz || baz && baz.bar && baz.bar.foo @@ -4215,7 +4215,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:347:1 │ 347 │ foo && foo.bar != null && foo.bar.baz !== undefined && foo.bar.baz.buzz; @@ -4236,7 +4236,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:349:1 │ 349 │ foo.bar && foo.bar.baz != null && foo.bar.baz.qux !== undefined && foo.bar.baz.qux.buzz; @@ -4257,7 +4257,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:352:1 │ 352 │ foo && foo.bar(baz => ); @@ -4278,7 +4278,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:353:1 │ 353 │ foo && foo.bar(baz => typeof baz); @@ -4299,7 +4299,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:354:1 │ 354 │ foo && foo["some long string"] && foo["some long string"].baz @@ -4320,7 +4320,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:355:1 │ 355 │ foo && foo[`some long string`] && foo[`some long string`].baz @@ -4341,7 +4341,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:356:1 │ 356 │ foo && foo['some long string'] && foo['some long string'].baz; @@ -4362,7 +4362,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:359:1 │ 359 │ foo && foo[123] && foo[123].baz; @@ -4383,7 +4383,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:360:1 │ 360 │ foo && foo[true] && foo[true].baz; @@ -4404,7 +4404,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:361:1 │ 361 │ foo && foo[null] && foo[null].baz; @@ -4425,7 +4425,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:362:1 │ 362 │ foo && foo[12n] && foo[12n].baz; @@ -4446,7 +4446,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:363:1 │ 363 │ foo && foo[/\w+/] && foo[/\w+/].baz; @@ -4467,7 +4467,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:367:1 │ 367 │ ┌ foo && foo.bar(/* comment */a, @@ -4490,7 +4490,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:372:1 │ 372 │ foo && foo.bar != null; @@ -4511,7 +4511,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:373:1 │ 373 │ foo && foo.bar != undefined; @@ -4532,7 +4532,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:374:1 │ 374 │ foo && foo.bar != null && baz; @@ -4553,7 +4553,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:377:1 │ 377 │ foo && foo?.(); @@ -4574,7 +4574,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:378:1 │ 378 │ foo.bar && foo.bar?.(); @@ -4595,7 +4595,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:381:1 │ 381 │ foo && foo.bar && /*0*/foo/*1*/./*2*/bar/*3*/./*4*/baz/*5*/; @@ -4616,7 +4616,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:382:1 │ 382 │ foo && foo[bar] && /*0*/foo/*1*/[/*2*/bar/*3*/]/*4*/[/*5*/baz/*6*/]/*7*/; @@ -4636,7 +4636,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ logicalAndCases.js:384:1 │ 384 │ foo && foo[bar] && /*0*/foo/*1*/?./*2*/[/*3*/bar/*4*/]/*5*/?./*6*/[/*7*/baz/*8*/]/*9*/; diff --git a/crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/nullishAndLogicalOr.ts b/crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/nullishAndLogicalOr.ts similarity index 100% rename from crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/nullishAndLogicalOr.ts rename to crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/nullishAndLogicalOr.ts diff --git a/crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/nullishAndLogicalOr.ts.snap b/crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/nullishAndLogicalOr.ts.snap similarity index 87% rename from crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/nullishAndLogicalOr.ts.snap rename to crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/nullishAndLogicalOr.ts.snap index a76e051ed13..1d27da6b2c5 100644 --- a/crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/nullishAndLogicalOr.ts.snap +++ b/crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/nullishAndLogicalOr.ts.snap @@ -161,7 +161,7 @@ if ((this ?? {}).#bar) { foo.bar; } # Diagnostics ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:1:1 │ 1 │ (foo || {}).bar; @@ -179,7 +179,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:2:1 │ 2 │ (foo || ({})).bar; @@ -198,7 +198,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:3:1 │ 3 │ (await foo || {}).bar; @@ -218,7 +218,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:4:1 │ 4 │ (foo1?.foo2 || {}).foo3; @@ -239,7 +239,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:5:1 │ 5 │ ((() => foo())() || {}).bar; @@ -260,7 +260,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:6:13 │ 6 │ const foo = (bar || {}).baz; @@ -281,7 +281,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:7:1 │ 7 │ (foo.bar || {})[baz]; @@ -302,7 +302,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:9:1 │ 9 │ ((foo1 || {}).foo2 || {}).foo3; @@ -323,7 +323,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:10:1 │ 10 │ (foo || undefined || {}).bar; @@ -344,7 +344,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:12:1 │ 12 │ (foo() || bar || {}).baz; @@ -365,7 +365,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:13:1 │ 13 │ ((foo1 ? foo2 : foo3) || {}).foo4; @@ -386,7 +386,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:15:12 │ 15 │ if (foo) { (foo || {}).bar; } @@ -407,7 +407,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:16:5 │ 16 │ if ((foo || {}).bar) { foo.bar; } @@ -428,7 +428,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:18:1 │ 18 │ (undefined && foo || {}).bar; @@ -449,7 +449,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:19:1 │ 19 │ (foo ?? {}).bar; @@ -470,7 +470,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:20:1 │ 20 │ (foo ?? ({})).bar; @@ -491,7 +491,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:21:1 │ 21 │ (await foo ?? {}).bar; @@ -512,7 +512,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:23:1 │ 23 │ (foo1?.foo2 ?? {}).foo3; @@ -533,7 +533,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:24:1 │ 24 │ ((() => foo())() ?? {}).bar; @@ -554,7 +554,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:25:13 │ 25 │ const foo = (bar ?? {}).baz; @@ -575,7 +575,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:26:1 │ 26 │ (foo.bar ?? {})[baz]; @@ -596,7 +596,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:27:1 │ 27 │ ((foo1 ?? {}).foo2 ?? {}).foo3; @@ -617,7 +617,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:29:1 │ 29 │ (foo ?? undefined ?? {}).bar; @@ -638,7 +638,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:30:1 │ 30 │ (foo() ?? bar ?? {}).baz; @@ -659,7 +659,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:31:1 │ 31 │ ((foo1 ? foo2 : foo3) ?? {}).foo4; @@ -680,7 +680,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:33:12 │ 33 │ if (foo) { (foo ?? {}).bar; } @@ -701,7 +701,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:34:5 │ 34 │ if ((foo ?? {}).bar) { foo.bar; } @@ -722,7 +722,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:36:1 │ 36 │ (undefined && foo ?? {}).bar; @@ -743,7 +743,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:37:1 │ 37 │ (a > b || {}).bar; @@ -764,7 +764,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:38:1 │ 38 │ (((typeof x) as string) || {}).bar; @@ -785,7 +785,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:40:1 │ 40 │ (void foo() || {}).bar; @@ -806,7 +806,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:41:1 │ 41 │ ((a ? b : c) || {}).bar; @@ -827,7 +827,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:43:1 │ 43 │ ((a instanceof Error) || {}).bar; @@ -848,7 +848,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:44:1 │ 44 │ ((a << b) || {}).bar; @@ -869,7 +869,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:45:1 │ 45 │ ((foo ** 2) || {}).bar; @@ -890,7 +890,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:46:1 │ 46 │ (foo ** 2 || {}).bar; @@ -911,7 +911,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:47:1 │ 47 │ (foo++ || {}).bar; @@ -932,7 +932,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:48:1 │ 48 │ (+foo || {}).bar; @@ -953,7 +953,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:51:1 │ 51 │ (foo || {}).#bar; @@ -974,7 +974,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:52:1 │ 52 │ (foo || ({})).#bar; @@ -995,7 +995,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:53:1 │ 53 │ (await foo || {}).#bar; @@ -1016,7 +1016,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:54:1 │ 54 │ (foo1?.foo2 || {}).#foo3; @@ -1037,7 +1037,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:55:1 │ 55 │ ((() => foo())() || {}).#bar; @@ -1058,7 +1058,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:56:13 │ 56 │ const foo = (bar || {}).#baz; @@ -1079,7 +1079,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:57:1 │ 57 │ (foo.bar || {})[baz]; @@ -1100,7 +1100,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:59:1 │ 59 │ ((foo1 || {}).#foo2 || {}).#foo3; @@ -1121,7 +1121,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:60:1 │ 60 │ (foo || undefined || {}).#bar; @@ -1142,7 +1142,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:62:1 │ 62 │ (foo() || bar || {}).#baz; @@ -1163,7 +1163,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:63:1 │ 63 │ ((foo1 ? foo2 : foo3) || {}).#foo4; @@ -1184,7 +1184,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:65:12 │ 65 │ if (foo) { (foo || {}).#bar; } @@ -1205,7 +1205,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:66:5 │ 66 │ if ((foo || {}).#bar) { foo.bar; } @@ -1226,7 +1226,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:68:1 │ 68 │ (undefined && foo || {}).#bar; @@ -1247,7 +1247,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:69:1 │ 69 │ (foo ?? {}).#bar; @@ -1268,7 +1268,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:70:1 │ 70 │ (foo ?? ({})).#bar; @@ -1289,7 +1289,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:71:1 │ 71 │ (await foo ?? {}).#bar; @@ -1310,7 +1310,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:73:1 │ 73 │ (foo1?.foo2 ?? {}).#foo3; @@ -1331,7 +1331,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:74:1 │ 74 │ ((() => foo())() ?? {}).#bar; @@ -1352,7 +1352,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:75:13 │ 75 │ const foo = (bar ?? {}).#baz; @@ -1373,7 +1373,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:76:1 │ 76 │ (foo.bar ?? {})[baz]; @@ -1394,7 +1394,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:77:1 │ 77 │ ((foo1 ?? {}).#foo2 ?? {}).#foo3; @@ -1415,7 +1415,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:79:1 │ 79 │ (foo ?? undefined ?? {}).#bar; @@ -1436,7 +1436,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:80:1 │ 80 │ (foo() ?? bar ?? {}).#baz; @@ -1457,7 +1457,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:81:1 │ 81 │ ((foo1 ? foo2 : foo3) ?? {}).#foo4; @@ -1478,7 +1478,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:83:12 │ 83 │ if (foo) { (foo ?? {}).#bar; } @@ -1499,7 +1499,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:84:5 │ 84 │ if ((foo ?? {}).#bar) { foo.bar; } @@ -1520,7 +1520,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:86:1 │ 86 │ (undefined && foo ?? {}).#bar; @@ -1541,7 +1541,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:87:1 │ 87 │ (a > b || {}).#bar; @@ -1562,7 +1562,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:88:1 │ 88 │ (((typeof x) as string) || {}).#bar; @@ -1583,7 +1583,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:90:1 │ 90 │ (void foo() || {}).#bar; @@ -1604,7 +1604,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:91:1 │ 91 │ ((a ? b : c) || {}).#bar; @@ -1625,7 +1625,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:93:1 │ 93 │ ((a instanceof Error) || {}).#bar; @@ -1646,7 +1646,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:94:1 │ 94 │ ((a << b) || {}).#bar; @@ -1667,7 +1667,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:95:1 │ 95 │ ((foo ** 2) || {}).#bar; @@ -1688,7 +1688,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:96:1 │ 96 │ (foo ** 2 || {}).#bar; @@ -1709,7 +1709,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:97:1 │ 97 │ (foo++ || {}).#bar; @@ -1730,7 +1730,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:98:1 │ 98 │ (+foo || {}).#bar; @@ -1751,7 +1751,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:102:1 │ 102 │ (this || {}).bar; @@ -1772,7 +1772,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:103:1 │ 103 │ (this || ({})).bar; @@ -1793,7 +1793,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:104:1 │ 104 │ (await this || {}).bar; @@ -1814,7 +1814,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:105:13 │ 105 │ const foo = (this || {}).baz; @@ -1835,7 +1835,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:107:1 │ 107 │ ((this || {}).foo2 || {}).foo3; @@ -1856,7 +1856,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:109:12 │ 109 │ if (foo) { (this || {}).bar; } @@ -1877,7 +1877,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:110:5 │ 110 │ if ((this || {}).bar) { foo.bar; } @@ -1898,7 +1898,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:112:1 │ 112 │ (undefined && this || {}).bar; @@ -1919,7 +1919,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:113:1 │ 113 │ (this ?? {}).bar; @@ -1940,7 +1940,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:114:1 │ 114 │ (this ?? ({})).bar; @@ -1961,7 +1961,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:115:1 │ 115 │ (await this ?? {}).bar; @@ -1982,7 +1982,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:117:13 │ 117 │ const foo = (this ?? {}).baz; @@ -2003,7 +2003,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:118:1 │ 118 │ ((this ?? {}).foo2 ?? {}).foo3; @@ -2024,7 +2024,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:120:12 │ 120 │ if (foo) { (this ?? {}).bar; } @@ -2045,7 +2045,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:121:5 │ 121 │ if ((this ?? {}).bar) { foo.bar; } @@ -2066,7 +2066,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:123:1 │ 123 │ (undefined && this ?? {}).bar; @@ -2087,7 +2087,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:124:1 │ 124 │ (((typeof this) as string) || {}).bar; @@ -2108,7 +2108,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:127:1 │ 127 │ (this || {}).#bar; @@ -2129,7 +2129,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:128:1 │ 128 │ (this || ({})).#bar; @@ -2150,7 +2150,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:129:1 │ 129 │ (await this || {}).#bar; @@ -2171,7 +2171,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:130:13 │ 130 │ const foo = (this || {}).#baz; @@ -2192,7 +2192,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:132:1 │ 132 │ ((this || {}).#foo2 || {}).#foo3; @@ -2213,7 +2213,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:134:12 │ 134 │ if (foo) { (this || {}).#bar; } @@ -2234,7 +2234,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:135:5 │ 135 │ if ((this || {}).#bar) { foo.bar; } @@ -2255,7 +2255,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:137:1 │ 137 │ (undefined && this || {}).#bar; @@ -2276,7 +2276,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:138:1 │ 138 │ (this ?? {}).#bar; @@ -2297,7 +2297,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:139:1 │ 139 │ (this ?? ({})).#bar; @@ -2318,7 +2318,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:140:1 │ 140 │ (await this ?? {}).#bar; @@ -2339,7 +2339,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:142:13 │ 142 │ const foo = (this ?? {}).#baz; @@ -2360,7 +2360,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:143:1 │ 143 │ ((this ?? {}).#foo2 ?? {}).#foo3; @@ -2381,7 +2381,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:145:12 │ 145 │ if (foo) { (this ?? {}).#bar; } @@ -2402,7 +2402,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:146:5 │ 146 │ if ((this ?? {}).#bar) { foo.bar; } @@ -2423,7 +2423,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:148:1 │ 148 │ (undefined && this ?? {}).#bar; @@ -2444,7 +2444,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:149:1 │ 149 │ (((typeof this) as string) || {}).#bar; @@ -2465,7 +2465,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:150:1 │ 150 │ (new foo || {}).bar; @@ -2485,7 +2485,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:151:1 │ 151 │ (foo() || {}).bar; @@ -2504,7 +2504,7 @@ Suggested fix: Change to an optional chain. ``` ``` -warning[correctness/useOptionalChain]: Change to an optional chain. +warning[nursery/useOptionalChain]: Change to an optional chain. ┌─ nullishAndLogicalOr.ts:152:1 │ 152 │ ((foo || {}).bar() || {}).baz; diff --git a/crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/validCases.ts b/crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/validCases.ts similarity index 100% rename from crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/validCases.ts rename to crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/validCases.ts diff --git a/crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/validCases.ts.snap b/crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/validCases.ts.snap similarity index 100% rename from crates/rome_js_analyze/tests/specs/correctness/useOptionalChain/validCases.ts.snap rename to crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/validCases.ts.snap diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs index 5e7bf136aaa..bb8a22ed0c3 100644 --- a/crates/rome_service/src/configuration/linter/rules.rs +++ b/crates/rome_service/src/configuration/linter/rules.rs @@ -215,7 +215,6 @@ struct CorrectnessSchema { no_unsafe_negation: Option, no_unused_template_literal: Option, use_block_statements: Option, - use_optional_chain: Option, use_simplified_logic_expression: Option, use_single_case_statement: Option, use_single_var_declarator: Option, @@ -225,7 +224,7 @@ struct CorrectnessSchema { } impl Correctness { const CATEGORY_NAME: &'static str = "correctness"; - pub(crate) const CATEGORY_RULES: [&'static str; 29] = [ + pub(crate) const CATEGORY_RULES: [&'static str; 28] = [ "noArguments", "noAsyncPromiseExecutor", "noCatchAssign", @@ -248,7 +247,6 @@ impl Correctness { "noUnsafeNegation", "noUnusedTemplateLiteral", "useBlockStatements", - "useOptionalChain", "useSimplifiedLogicExpression", "useSingleCaseStatement", "useSingleVarDeclarator", @@ -256,7 +254,7 @@ impl Correctness { "useValidTypeof", "useWhile", ]; - const RECOMMENDED_RULES: [&'static str; 29] = [ + const RECOMMENDED_RULES: [&'static str; 28] = [ "noArguments", "noAsyncPromiseExecutor", "noCatchAssign", @@ -279,7 +277,6 @@ impl Correctness { "noUnsafeNegation", "noUnusedTemplateLiteral", "useBlockStatements", - "useOptionalChain", "useSimplifiedLogicExpression", "useSingleCaseStatement", "useSingleVarDeclarator", @@ -287,7 +284,7 @@ impl Correctness { "useValidTypeof", "useWhile", ]; - const RECOMMENDED_RULES_AS_FILTERS: [RuleFilter<'static>; 29] = [ + const RECOMMENDED_RULES_AS_FILTERS: [RuleFilter<'static>; 28] = [ RuleFilter::Rule("correctness", Self::CATEGORY_RULES[0]), RuleFilter::Rule("correctness", Self::CATEGORY_RULES[1]), RuleFilter::Rule("correctness", Self::CATEGORY_RULES[2]), @@ -316,7 +313,6 @@ impl Correctness { RuleFilter::Rule("correctness", Self::CATEGORY_RULES[25]), RuleFilter::Rule("correctness", Self::CATEGORY_RULES[26]), RuleFilter::Rule("correctness", Self::CATEGORY_RULES[27]), - RuleFilter::Rule("correctness", Self::CATEGORY_RULES[28]), ]; pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } pub(crate) fn get_enabled_rules(&self) -> IndexSet { @@ -343,7 +339,7 @@ impl Correctness { pub(crate) fn is_recommended_rule(rule_name: &str) -> bool { Self::RECOMMENDED_RULES.contains(&rule_name) } - pub(crate) fn recommended_rules_as_filters() -> [RuleFilter<'static>; 29] { + pub(crate) fn recommended_rules_as_filters() -> [RuleFilter<'static>; 28] { Self::RECOMMENDED_RULES_AS_FILTERS } } @@ -392,15 +388,17 @@ struct NurserySchema { no_unreachable: Option, no_unused_variables: Option, use_camel_case: Option, + use_optional_chain: Option, } impl Nursery { const CATEGORY_NAME: &'static str = "nursery"; - pub(crate) const CATEGORY_RULES: [&'static str; 5] = [ + pub(crate) const CATEGORY_RULES: [&'static str; 6] = [ "noDangerouslySetInnerHtml", "noNewSymbol", "noUnreachable", "noUnusedVariables", "useCamelCase", + "useOptionalChain", ]; const RECOMMENDED_RULES: [&'static str; 0] = []; const RECOMMENDED_RULES_AS_FILTERS: [RuleFilter<'static>; 0] = []; diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index 39e35c875c5..dac8d9128d1 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -271,16 +271,6 @@ } ] }, - "useOptionalChain": { - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, "useSimplifiedLogicExpression": { "anyOf": [ { @@ -547,6 +537,16 @@ "type": "null" } ] + }, + "useOptionalChain": { + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] } } }, diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index 44c251b2cc7..521ad1f36de 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -144,7 +144,6 @@ export interface Correctness { */ recommended?: boolean; useBlockStatements?: RuleConfiguration; - useOptionalChain?: RuleConfiguration; useSimplifiedLogicExpression?: RuleConfiguration; useSingleCaseStatement?: RuleConfiguration; useSingleVarDeclarator?: RuleConfiguration; @@ -165,6 +164,7 @@ export interface Nursery { */ recommended?: boolean; useCamelCase?: RuleConfiguration; + useOptionalChain?: RuleConfiguration; } /** * A list of rules that belong to this group diff --git a/website/src/docs/lint/rules/index.md b/website/src/docs/lint/rules/index.md index 5c27efca887..ac11607c922 100644 --- a/website/src/docs/lint/rules/index.md +++ b/website/src/docs/lint/rules/index.md @@ -193,14 +193,6 @@ Requires following curly brace conventions. JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.
-

- useOptionalChain (since v0.10.0) - - recommended -

-Enforce using concise optional chain instead of chained logical expressions. -
-

useSimplifiedLogicExpression (since v0.7.0) @@ -295,6 +287,13 @@ Disallow unused variables.

Enforce camel case naming convention.
+
+

+ useOptionalChain (since v0.10.0) + +

+Enforce using concise optional chain instead of chained logical expressions. +

Style

diff --git a/website/src/docs/lint/rules/useOptionalChain.md b/website/src/docs/lint/rules/useOptionalChain.md index 7aee93c8890..37a49dc130d 100644 --- a/website/src/docs/lint/rules/useOptionalChain.md +++ b/website/src/docs/lint/rules/useOptionalChain.md @@ -5,8 +5,6 @@ layout: layouts/rule.liquid # useOptionalChain (since v0.10.0) -> This rule is recommended by Rome. - Enforce using concise optional chain instead of chained logical expressions. TypeScript 3.7 added support for the optional chain operator. @@ -22,11 +20,11 @@ It is much safer than relying upon logical operator chaining; which chains on an foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz ``` -{% raw %}
error[correctness/useOptionalChain]: Change to an optional chain.
-   correctness/useOptionalChain.js:1:1
+{% raw %}
warning[nursery/useOptionalChain]: Change to an optional chain.
+   nursery/useOptionalChain.js:1:1
   
-1  foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz
-   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+1  foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz
+   -------------------------------------------------
 
 Suggested fix: Change to an optional chain.
     | @@ -1 +1 @@
@@ -39,11 +37,11 @@ foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz
 foo.bar && foo.bar.baz.buzz
 ```
 
-{% raw %}
error[correctness/useOptionalChain]: Change to an optional chain.
-   correctness/useOptionalChain.js:1:1
+{% raw %}
warning[nursery/useOptionalChain]: Change to an optional chain.
+   nursery/useOptionalChain.js:1:1
   
-1  foo.bar && foo.bar.baz.buzz
-   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+1  foo.bar && foo.bar.baz.buzz
+   ---------------------------
 
 Suggested fix: Change to an optional chain.
     | @@ -1 +1 @@
@@ -56,11 +54,11 @@ foo.bar && foo.bar.baz.buzz
 foo !== undefined && foo.bar != undefined && foo.bar.baz !== null && foo.bar.baz.buzz
 ```
 
-{% raw %}
error[correctness/useOptionalChain]: Change to an optional chain.
-   correctness/useOptionalChain.js:1:1
+{% raw %}
warning[nursery/useOptionalChain]: Change to an optional chain.
+   nursery/useOptionalChain.js:1:1
   
-1  foo !== undefined && foo.bar != undefined && foo.bar.baz !== null && foo.bar.baz.buzz
-   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+1  foo !== undefined && foo.bar != undefined && foo.bar.baz !== null && foo.bar.baz.buzz
+   -------------------------------------------------------------------------------------
 
 Suggested fix: Change to an optional chain.
     | @@ -1 +1 @@
@@ -73,11 +71,11 @@ foo !== undefined && foo.bar != undefined && foo.bar.baz !== null && foo.bar.baz
 ((foo || {}).bar || {}).baz;
 ```
 
-{% raw %}
error[correctness/useOptionalChain]: Change to an optional chain.
-   correctness/useOptionalChain.js:1:1
+{% raw %}
warning[nursery/useOptionalChain]: Change to an optional chain.
+   nursery/useOptionalChain.js:1:1
   
-1  ((foo || {}).bar || {}).baz;
-   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+1  ((foo || {}).bar || {}).baz;
+   ---------------------------
 
 Suggested fix: Change to an optional chain.
     | @@ -1 +1 @@
@@ -90,11 +88,11 @@ foo !== undefined && foo.bar != undefined && foo.bar.baz !== null && foo.bar.baz
 (await (foo1 || {}).foo2 || {}).foo3;
 ```
 
-{% raw %}
error[correctness/useOptionalChain]: Change to an optional chain.
-   correctness/useOptionalChain.js:1:1
+{% raw %}
warning[nursery/useOptionalChain]: Change to an optional chain.
+   nursery/useOptionalChain.js:1:1
   
-1  (await (foo1 || {}).foo2 || {}).foo3;
-   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+1  (await (foo1 || {}).foo2 || {}).foo3;
+   ------------------------------------
 
 Suggested fix: Change to an optional chain.
     | @@ -1 +1 @@
@@ -107,11 +105,11 @@ foo !== undefined && foo.bar != undefined && foo.bar.baz !== null && foo.bar.baz
 (((typeof x) as string) || {}).bar;
 ```
 
-{% raw %}
error[correctness/useOptionalChain]: Change to an optional chain.
-   correctness/useOptionalChain.js:1:1
+{% raw %}
warning[nursery/useOptionalChain]: Change to an optional chain.
+   nursery/useOptionalChain.js:1:1
   
-1  (((typeof x) as string) || {}).bar;
-   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+1  (((typeof x) as string) || {}).bar;
+   ----------------------------------
 
 Suggested fix: Change to an optional chain.
     | @@ -1 +1 @@