diff --git a/.github/workflows/release_cli.yml b/.github/workflows/release_cli.yml index d7b57af5bf16..56f9078b4ab6 100644 --- a/.github/workflows/release_cli.yml +++ b/.github/workflows/release_cli.yml @@ -230,7 +230,7 @@ jobs: run: | bash scripts/print-changelog.sh ${{ needs.build.outputs.version }} >| ${{ github.workspace }}/RELEASE_NOTES - name: Create GitHub release and tag - uses: softprops/action-gh-release@a74c6b72af54cfa997e81df42d94703d6313a2d0 # v2.0.6 + uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/.github/workflows/release_js_api.yml b/.github/workflows/release_js_api.yml index f2dfb029c366..6c8bba3008b9 100644 --- a/.github/workflows/release_js_api.yml +++ b/.github/workflows/release_js_api.yml @@ -151,7 +151,7 @@ jobs: run: | bash scripts/print-changelog.sh ${{ needs.build.outputs.version }} >| ${{ github.workspace }}/RELEASE_NOTES - name: Create GitHub release and tag - uses: softprops/action-gh-release@a74c6b72af54cfa997e81df42d94703d6313a2d0 # v2.0.6 + uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 491328aa6985..538105f44c4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,10 +45,37 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b ### Formatter +#### Enhancements + +- Add parentheses for nullcoalescing in ternaries. + + This change aligns on [Prettier 3.3.3](https://github.com/prettier/prettier/blob/main/CHANGELOG.md#333). + This adds clarity to operator precedence. + + ```diff + - foo ? bar ?? foo : baz; + + foo ? (bar ?? foo) : baz; + ``` + + Contributed by @Conaclos + #### Bug fixes - Keep the parentheses around `infer` declarations in type unions and type intersections ([#3419](https://github.com/biomejs/biome/issues/3419)). Contributed by @Conaclos +- Keep parentheses around a `yield` expression inside a type assertion. + + Previously, Biome removed parentheses around some expressions that require them inside a type assertion. + For example, in the following code, Biome now preserves the parentheses. + + ```ts + function* f() { + return (yield 0); + } + ``` + + Contributed by @Conaclos + ### JavaScript APIs ### Linter @@ -102,6 +129,14 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b Contributed by @Conaclos +- [useFilenamingConvention](https://biomejs.dev/linter/rules/use-filenaming-convention) now supports Next.js/Nuxt/Astro dynamic routes ([#3465](https://github.com/biomejs/biome/issues/3465)). + + [Next.js](https://nextjs.org/docs/pages/building-your-application/routing/dynamic-routes#catch-all-segments), [SolidStart](https://docs.solidjs.com/solid-start/building-your-application/routing#renaming-index), [Nuxt](https://nuxt.com/docs/guide/directory-structure/server#catch-all-route), and [Astro](https://docs.astro.build/en/guides/routing/#rest-parameters) support dynamic routes such as `[...slug].js` and `[[...slug]].js`. + + Biome now recognizes this syntax. `slug` must contain only alphanumeric characters. + + Contributed by @Conaclos + #### Bug fixes - Don't request alt text for elements hidden from assistive technologies ([#3316](https://github.com/biomejs/biome/issues/3316)). Contributed by @robintown diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 90e6df339c5d..691d1c052777 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,32 +4,36 @@ We can use help in a bunch of areas and any help is greatly appreciated! ## Table of Contents -* [Asking questions, making proposals](#asking-questions-making-proposals) -* [Reporting bugs](#reporting-bugs) -* [Getting Started](#getting-started) -* [Install the required tools](#install-the-required-tools) -* [Testing](#testing) - + [Debugging](#debugging) -* [Checks](#checks) -* [Crates development](#crates-development) - + [Analyzers and lint rules](#analyzers-and-lint-rules) - + [Parser](#parser) - + [Formatter](#formatter) -* [Crate dependencies](#crate-dependencies) -* [Node.js development](#nodejs-development) - + [Translations](#translations) -* [Commit messages](#commit-messages) -* [Creating pull requests](#creating-pull-requests) - + [Changelog](#changelog) - - [Writing a changelog line](#writing-a-changelog-line) - + [Documentation](#documentation) - + [Versioning](#versioning) -* [Releasing](#releasing) -* [Resources](#resources) -* [Current Members](#current-members) - + [Lead team](#lead-team) - + [Core Contributors team](#core-contributors-team) - + [Maintainers team](#maintainers-team) +- [πŸš€ Contributing](#-contributing) + - [Table of Contents](#table-of-contents) + - [Asking questions, making proposals](#asking-questions-making-proposals) + - [Reporting bugs](#reporting-bugs) + - [Getting Started](#getting-started) + - [Install the required tools](#install-the-required-tools) + - [Testing](#testing) + - [Debugging](#debugging) + - [Checks](#checks) + - [Crates development](#crates-development) + - [Create new crates](#create-new-crates) + - [Analyzers and lint rules](#analyzers-and-lint-rules) + - [Parser](#parser) + - [Formatter](#formatter) + - [Crate dependencies](#crate-dependencies) + - [Node.js development](#nodejs-development) + - [Translations](#translations) + - [Commit messages](#commit-messages) + - [Creating pull requests](#creating-pull-requests) + - [Changelog](#changelog) + - [Writing a changelog line](#writing-a-changelog-line) + - [Documentation](#documentation) + - [Versioning](#versioning) + - [Releasing](#releasing) + - [Resources](#resources) + - [Current Members](#current-members) + - [Lead team](#lead-team) + - [Core Contributors team](#core-contributors-team) + - [Maintainers team](#maintainers-team) + - [Past Maintainers](#past-maintainers) ## Asking questions, making proposals @@ -425,6 +429,7 @@ Members are listed in alphabetical order. Members are free to use the full name, ### Maintainers team +- [Carson McManus @dyc3](https://github.com/dyc3) - [Dani Guardiola @DaniGuardiola](https://github.com/DaniGuardiola) - [Justinas Delinda @minht11](https://github.com/minht11) - [Madeline GurriarΓ‘n @SuperchupuDev](https://github.com/SuperchupuDev) diff --git a/Cargo.lock b/Cargo.lock index 14ae537309cb..7c32b443b5c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -340,7 +340,7 @@ dependencies = [ "biome_json_parser", "biome_json_syntax", "biome_rowan", - "bitflags 2.5.0", + "bitflags 2.6.0", "indexmap 2.2.6", "schemars", "serde", @@ -370,7 +370,7 @@ dependencies = [ "biome_rowan", "biome_text_edit", "biome_text_size", - "bitflags 2.5.0", + "bitflags 2.6.0", "bpaf", "oxc_resolver", "schemars", @@ -534,6 +534,16 @@ dependencies = [ "unicode-bom", ] +[[package]] +name = "biome_graphql_semantic" +version = "0.0.0" +dependencies = [ + "biome_graphql_parser", + "biome_graphql_syntax", + "biome_rowan", + "rustc-hash", +] + [[package]] name = "biome_graphql_syntax" version = "0.1.0" @@ -666,7 +676,7 @@ dependencies = [ "biome_suppression", "biome_test_utils", "biome_unicode_table", - "bitflags 2.5.0", + "bitflags 2.6.0", "bitvec", "enumflags2", "insta", @@ -731,7 +741,7 @@ dependencies = [ "biome_parser", "biome_rowan", "biome_unicode_table", - "bitflags 2.5.0", + "bitflags 2.6.0", "drop_bomb", "expect-test", "indexmap 2.2.6", @@ -925,7 +935,7 @@ dependencies = [ "biome_diagnostics", "biome_rowan", "biome_unicode_table", - "bitflags 2.5.0", + "bitflags 2.6.0", "drop_bomb", "unicode-bom", ] @@ -1138,9 +1148,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitmaps" @@ -1930,7 +1940,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", "libgit2-sys", "log", @@ -1962,7 +1972,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "ignore", "walkdir", ] @@ -2229,9 +2239,9 @@ checksum = "9dbbfed4e59ba9750e15ba154fdfd9329cee16ff3df539c2666b70f58cc32105" [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -2267,7 +2277,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", "redox_syscall", ] @@ -2745,7 +2755,7 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "getopts", "memchr", "pulldown-cmark-escape", @@ -3455,6 +3465,7 @@ dependencies = [ name = "tests_macros" version = "0.0.0" dependencies = [ + "biome_string_case", "case", "globwalk", "proc-macro-error", @@ -3571,9 +3582,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" dependencies = [ "backtrace", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 876689f41fbb..a2c6c73710fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,6 +109,7 @@ biome_graphql_analyze = { version = "0.0.1", path = "./crates/biome_graph biome_graphql_factory = { version = "0.1.0", path = "./crates/biome_graphql_factory" } biome_graphql_formatter = { version = "0.1.0", path = "./crates/biome_graphql_formatter" } biome_graphql_parser = { version = "0.1.0", path = "./crates/biome_graphql_parser" } +biome_graphql_semantic = { version = "0.0.0", path = "./crates/biome_graphql_semantic" } biome_graphql_syntax = { version = "0.1.0", path = "./crates/biome_graphql_syntax" } biome_grit_factory = { version = "0.5.7", path = "./crates/biome_grit_factory" } biome_grit_formatter = { version = "0.0.0", path = "./crates/biome_grit_formatter" } @@ -156,7 +157,7 @@ tests_macros = { path = "./crates/tests_macros" } # Crates needed in the workspace anyhow = "1.0.86" -bitflags = "2.5.0" +bitflags = "2.6.0" bpaf = { version = "0.9.9", features = ["derive"] } countme = "3.0.1" crossbeam = "0.8.4" @@ -166,7 +167,7 @@ getrandom = "0.2.15" ignore = "0.4.21" indexmap = { version = "2.2.6", features = ["serde"] } insta = "1.39.0" -lazy_static = "1.4.0" +lazy_static = "1.5.0" natord = "1.0.9" oxc_resolver = "1.8.1" proc-macro2 = "1.0.86" @@ -185,7 +186,7 @@ slotmap = "1.0.7" smallvec = { version = "1.13.2", features = ["union", "const_new", "serde"] } syn = "1.0.109" termcolor = "1.4.1" -tokio = "1.38.0" +tokio = "1.38.1" tracing = { version = "0.1.40", default-features = false, features = ["std"] } tracing-subscriber = "0.3.18" unicode-bom = "2.0.3" diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index 91eecd29f672..8638d8b2a2d2 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -22,10 +22,16 @@ pub(crate) fn lint_with_guard<'ctx>( move || { let mut input = workspace_file.input()?; let mut changed = false; + let (only, skip) = + if let TraversalMode::Lint { only, skip, .. } = ctx.execution.traversal_mode() { + (only.clone(), skip.clone()) + } else { + (Vec::new(), Vec::new()) + }; if let Some(fix_mode) = ctx.execution.as_fix_file_mode() { let fix_result = workspace_file .guard() - .fix_file(*fix_mode, false) + .fix_file(*fix_mode, false, only.clone(), skip.clone()) .with_file_path_and_code( workspace_file.path.display().to_string(), category!("lint"), @@ -57,12 +63,6 @@ pub(crate) fn lint_with_guard<'ctx>( } let max_diagnostics = ctx.remaining_diagnostics.load(Ordering::Relaxed); - let (only, skip) = - if let TraversalMode::Lint { only, skip, .. } = ctx.execution.traversal_mode() { - (only.clone(), skip.clone()) - } else { - (Vec::new(), Vec::new()) - }; let pull_diagnostics_result = workspace_file .guard() .pull_diagnostics( diff --git a/crates/biome_cli/src/execute/std_in.rs b/crates/biome_cli/src/execute/std_in.rs index ecdb12d0d69d..840c882a77d5 100644 --- a/crates/biome_cli/src/execute/std_in.rs +++ b/crates/biome_cli/src/execute/std_in.rs @@ -108,12 +108,20 @@ pub(crate) fn run<'a>( return Ok(()); }; + let (only, skip) = if let TraversalMode::Lint { only, skip, .. } = mode.traversal_mode() { + (only.clone(), skip.clone()) + } else { + (Vec::new(), Vec::new()) + }; + if let Some(fix_file_mode) = mode.as_fix_file_mode() { if file_features.supports_lint() { let fix_file_result = workspace.fix_file(FixFileParams { fix_file_mode: *fix_file_mode, path: biome_path.clone(), should_format: mode.is_check() && file_features.supports_format(), + only: only.clone(), + skip: skip.clone(), })?; let code = fix_file_result.code; let output = match biome_path.extension_as_str() { @@ -156,11 +164,6 @@ pub(crate) fn run<'a>( } } - let (only, skip) = if let TraversalMode::Lint { only, skip, .. } = mode.traversal_mode() { - (only.clone(), skip.clone()) - } else { - (Vec::new(), Vec::new()) - }; if !mode.is_check_apply_unsafe() { let result = workspace.pull_diagnostics(PullDiagnosticsParams { categories: RuleCategoriesBuilder::default() diff --git a/crates/biome_cli/tests/commands/lint.rs b/crates/biome_cli/tests/commands/lint.rs index 3b641565d003..b3a7a4578f86 100644 --- a/crates/biome_cli/tests/commands/lint.rs +++ b/crates/biome_cli/tests/commands/lint.rs @@ -3806,6 +3806,46 @@ fn lint_only_group_with_disabled_rule() { )); } +#[test] +fn lint_only_write() { + let mut fs = MemoryFileSystem::default(); + let mut console = BufferConsole::default(); + let config = r#"{}"#; + let content = r#" + export const z = function (array) { + array.map((sentence) => sentence.split(" ")).flat(); + return 0; + }; + "#; + + let file_path = Path::new("check.js"); + fs.insert(file_path.into(), content.as_bytes()); + let config_path = Path::new("biome.json"); + fs.insert(config_path.into(), config.as_bytes()); + + let result = run_cli( + DynRef::Borrowed(&mut fs), + &mut console, + Args::from( + [ + ("lint"), + "--write", + "--only=complexity/useArrowFunction", + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), + ); + + assert_cli_snapshot(SnapshotPayload::new( + module_path!(), + "lint_only_write", + fs, + console, + result, + )); +} + #[test] fn lint_skip_rule() { let mut fs = MemoryFileSystem::default(); @@ -3943,6 +3983,46 @@ fn lint_skip_rule_and_group() { )); } +#[test] +fn lint_skip_write() { + let mut fs = MemoryFileSystem::default(); + let mut console = BufferConsole::default(); + let config = r#"{}"#; + let content = r#" + export const z = function (array) { + array.map((sentence) => sentence.split(" ")).flat(); + return 0; + }; + "#; + + let file_path = Path::new("check.js"); + fs.insert(file_path.into(), content.as_bytes()); + let config_path = Path::new("biome.json"); + fs.insert(config_path.into(), config.as_bytes()); + + let result = run_cli( + DynRef::Borrowed(&mut fs), + &mut console, + Args::from( + [ + ("lint"), + "--write", + "--skip=complexity/useArrowFunction", + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), + ); + + assert_cli_snapshot(SnapshotPayload::new( + module_path!(), + "lint_skip_write", + fs, + console, + result, + )); +} + #[test] fn lint_only_group_skip_rule() { let mut fs = MemoryFileSystem::default(); diff --git a/crates/biome_cli/tests/snapshots/main_commands_lint/lint_only_write.snap b/crates/biome_cli/tests/snapshots/main_commands_lint/lint_only_write.snap new file mode 100644 index 000000000000..23aac6f49400 --- /dev/null +++ b/crates/biome_cli/tests/snapshots/main_commands_lint/lint_only_write.snap @@ -0,0 +1,26 @@ +--- +source: crates/biome_cli/tests/snap_test.rs +expression: content +--- +## `biome.json` + +```json +{} +``` + +## `check.js` + +```js + + export const z = (array) => { + array.map((sentence) => sentence.split(" ")).flat(); + return 0; + }; + +``` + +# Emitted Messages + +```block +Checked 1 file in