diff --git a/CHANGELOG.md b/CHANGELOG.md index e27bfefaf5af..e104a0de324b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b #### Bug fixes +- Don't parse the files that don't end with the json extension as JSON files in the `.vscode` directory ([#4391](https://github.com/biomejs/biome/issues/4391)). Contributed by @Conaclos + - `biome migrate eslint` now correctly resolves scoped package named `eslint-config` with a path. Contributed by @Conaclos @@ -119,7 +121,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b `noUndeclaredVariables` is inspired by the [no-undef ESLint rule](https://eslint.org/docs/latest/rules/no-undef). It reports all references that are not bound to any declarations within a module. Node.js, JavaScript and TypeScript globals are ignored. - Bioem provides the `javascript.globals` option to list additional globals that should be ignored by the rule. + Biome provides the `javascript.globals` option to list additional globals that should be ignored by the rule. In TypeScript projects, developers often use global declaration files to declare global types. Biome is currently unable to detect these global types. diff --git a/crates/biome_cli/tests/cases/overrides_formatter.rs b/crates/biome_cli/tests/cases/overrides_formatter.rs index 8cfeb75088bb..49514c1d3a6e 100644 --- a/crates/biome_cli/tests/cases/overrides_formatter.rs +++ b/crates/biome_cli/tests/cases/overrides_formatter.rs @@ -772,6 +772,9 @@ fn allow_trailing_commas_on_well_known_files() { }"#, ); + let vscode_text_file = Path::new(".vscode/any.text"); + fs.insert(vscode_text_file.into(), "any text"); + let other_json = Path::new("other.json"); fs.insert( other_json.into(), @@ -788,7 +791,7 @@ fn allow_trailing_commas_on_well_known_files() { "check", other_json.as_os_str().to_str().unwrap(), tsconfig.as_os_str().to_str().unwrap(), - vscode_settings.as_os_str().to_str().unwrap(), + ".vscode/", ] .as_slice(), ), diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/allow_trailing_commas_on_well_known_files.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/allow_trailing_commas_on_well_known_files.snap index 1cb939e702e3..83b93b28c684 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/allow_trailing_commas_on_well_known_files.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/allow_trailing_commas_on_well_known_files.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs expression: content +snapshot_kind: text --- ## `biome.json` @@ -19,6 +20,12 @@ expression: content } ``` +## `.vscode/any.text` + +```text +any text +``` + ## `.vscode/settings.json` ```json diff --git a/crates/biome_json_syntax/src/file_source.rs b/crates/biome_json_syntax/src/file_source.rs index 277f0d30e544..02978cee9192 100644 --- a/crates/biome_json_syntax/src/file_source.rs +++ b/crates/biome_json_syntax/src/file_source.rs @@ -214,7 +214,9 @@ impl JsonFileSource { return Ok(Self::json_allow_comments()); } if let Some(Component::Normal(parent_dir)) = path.components().rev().nth(1) { - if Self::is_well_known_json_allow_comments_directory(parent_dir) { + if Self::is_well_known_json_allow_comments_directory(parent_dir) + && file_name.as_encoded_bytes().ends_with(b".json") + { return Ok(Self::json_allow_comments()); } }