Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(cli): don't consider files that don't end with the json extension as JSON files #4595

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
ematipico marked this conversation as resolved.
Show resolved Hide resolved
{
return Ok(Self::json_allow_comments());
}
}
Expand Down