Skip to content

Commit

Permalink
refactor(cli): don't consider files that don't end with the json exte…
Browse files Browse the repository at this point in the history
…nsion as JSON files (#4595)
  • Loading branch information
Conaclos authored Nov 19, 2024
1 parent 2648fa4 commit 80921c0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion crates/biome_cli/tests/cases/overrides_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
snapshot_kind: text
---
## `biome.json`

Expand All @@ -19,6 +20,12 @@ expression: content
}
```

## `.vscode/any.text`

```text
any text
```

## `.vscode/settings.json`

```json
Expand Down
4 changes: 3 additions & 1 deletion crates/biome_json_syntax/src/file_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down

0 comments on commit 80921c0

Please sign in to comment.