Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(biome_fs): configuration resolution
Browse files Browse the repository at this point in the history
Sec-ant committed Mar 23, 2024
1 parent 95974a1 commit 0389c06
Showing 14 changed files with 257 additions and 104 deletions.
30 changes: 24 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -9,6 +9,30 @@ New entries must be placed in a section entitled `Unreleased`.
Read
our [guidelines for writing a good changelog entry](https://github.com/biomejs/biome/blob/main/CONTRIBUTING.md#changelog).

## Unreleased

### Analyzer

### CLI

- Fix configuration resolution. Biome is now able to correctly find the `biome.jsonc` configuration file when `--config-path` is explicitly set. Contributed by @Sec-ant

### Configuration

### Editors

### Formatter

### JavaScript APIs

### Linter

#### New features

- Add rule [noEvolvingAny](https://biomejs.dev/linter/rules/no-evolving-any) to disallow variables from evolving into `any` type through reassignments. Contributed by @fujiyamaorange

### Parser

## 1.6.2 (2024-03-22)

### Analyzer
@@ -47,12 +71,6 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b

### Linter

#### New features

- Add rule [noEvolvingAny](https://biomejs.dev/linter/rules/no-evolving-any) to disallow variables from evolving into `any` type through reassignments.

Contributed by @fujiyamaorange

#### Bug fixes

- Rule `noUndeclaredDependencies` now also validates `peerDependencies` and `optionalDependencies` ([#2122](https://github.com/biomejs/biome/issues/2122)). Contributed by @Sec-ant
2 changes: 1 addition & 1 deletion crates/biome_cli/src/cli_options.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ pub struct CliOptions {
#[bpaf(long("verbose"), switch, fallback(false))]
pub verbose: bool,

/// Set the directory of the biome.json configuration file and disable default configuration file resolution.
/// Set the directory of the biome.json or biome.jsonc configuration file and disable default configuration file resolution.
#[bpaf(long("config-path"), argument("PATH"), optional)]
pub config_path: Option<String>,

55 changes: 55 additions & 0 deletions crates/biome_cli/tests/cases/config_path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
use crate::run_cli;
use crate::snap_test::{assert_cli_snapshot, SnapshotPayload};
use biome_console::BufferConsole;
use biome_fs::MemoryFileSystem;
use biome_service::DynRef;
use bpaf::Args;
use std::path::Path;

#[test]
fn set_config_path() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let file_path = Path::new("src/index.js");
fs.insert(file_path.into(), "a['b'] = 42;".as_bytes());

let config_path = Path::new("config/biome.jsonc");
fs.insert(
config_path.into(),
r#"
{
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": false
},
"formatter": {
"enabled": true,
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
}
}"#
.as_bytes(),
);

let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from([("check"), ("--config-path=config"), ("src")].as_slice()),
);

assert!(result.is_err(), "run_cli returned {result:?}");

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"set_config_path",
fs,
console,
result,
));
}
1 change: 1 addition & 0 deletions crates/biome_cli/tests/cases/mod.rs
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
mod biome_json_support;
mod config_extends;
mod config_path;
mod cts_files;
mod diagnostics;
mod handle_astro_files;
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
---
## `config/biome.jsonc`

```jsonc

{
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": false
},
"formatter": {
"enabled": true,
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
}
}
```

## `src/index.js`

```js
a['b'] = 42;
```

# Termination Message

```block
check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Some errors were emitted while running checks.
```

# Emitted Messages

```block
src/index.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i Formatter would have printed the following content:
1 │ - a['b']··=··42;
1 │ + a['b']·=·42;
2 │ +
```

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
```
Original file line number Diff line number Diff line change
@@ -79,8 +79,8 @@ Global options applied to all commands
output is determined to be incompatible
--use-server Connect to a running instance of the Biome daemon server.
--verbose Print additional diagnostics, and some diagnostics show more information.
--config-path=PATH Set the directory of the biome.json configuration file and disable default
configuration file resolution.
--config-path=PATH Set the directory of the biome.json or biome.jsonc configuration file and
disable default configuration file resolution.
--max-diagnostics=NUMBER Cap the amount of diagnostics displayed.
[default: 20]
--skip-errors Skip over files containing syntax errors instead of emitting an error diagnostic.
@@ -119,5 +119,3 @@ Available options:
-h, --help Prints help information
```


Original file line number Diff line number Diff line change
@@ -81,8 +81,8 @@ Global options applied to all commands
output is determined to be incompatible
--use-server Connect to a running instance of the Biome daemon server.
--verbose Print additional diagnostics, and some diagnostics show more information.
--config-path=PATH Set the directory of the biome.json configuration file and disable default
configuration file resolution.
--config-path=PATH Set the directory of the biome.json or biome.jsonc configuration file and
disable default configuration file resolution.
--max-diagnostics=NUMBER Cap the amount of diagnostics displayed.
[default: 20]
--skip-errors Skip over files containing syntax errors instead of emitting an error diagnostic.
@@ -114,5 +114,3 @@ Available options:
-h, --help Prints help information
```


Original file line number Diff line number Diff line change
@@ -71,8 +71,8 @@ Global options applied to all commands
output is determined to be incompatible
--use-server Connect to a running instance of the Biome daemon server.
--verbose Print additional diagnostics, and some diagnostics show more information.
--config-path=PATH Set the directory of the biome.json configuration file and disable default
configuration file resolution.
--config-path=PATH Set the directory of the biome.json or biome.jsonc configuration file and
disable default configuration file resolution.
--max-diagnostics=NUMBER Cap the amount of diagnostics displayed.
[default: 20]
--skip-errors Skip over files containing syntax errors instead of emitting an error diagnostic.
@@ -121,5 +121,3 @@ Available options:
-h, --help Prints help information
```


Original file line number Diff line number Diff line change
@@ -33,8 +33,8 @@ Global options applied to all commands
output is determined to be incompatible
--use-server Connect to a running instance of the Biome daemon server.
--verbose Print additional diagnostics, and some diagnostics show more information.
--config-path=PATH Set the directory of the biome.json configuration file and disable default
configuration file resolution.
--config-path=PATH Set the directory of the biome.json or biome.jsonc configuration file and
disable default configuration file resolution.
--max-diagnostics=NUMBER Cap the amount of diagnostics displayed.
[default: 20]
--skip-errors Skip over files containing syntax errors instead of emitting an error diagnostic.
@@ -70,5 +70,3 @@ Available options:
-h, --help Prints help information
```


Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@ Global options applied to all commands
output is determined to be incompatible
--use-server Connect to a running instance of the Biome daemon server.
--verbose Print additional diagnostics, and some diagnostics show more information.
--config-path=PATH Set the directory of the biome.json configuration file and disable default
configuration file resolution.
--config-path=PATH Set the directory of the biome.json or biome.jsonc configuration file and
disable default configuration file resolution.
--max-diagnostics=NUMBER Cap the amount of diagnostics displayed.
[default: 20]
--skip-errors Skip over files containing syntax errors instead of emitting an error diagnostic.
@@ -43,5 +43,3 @@ Available commands:
and map the Prettier's configuration into Biome's configuration file.
```


Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@ Global options applied to all commands
output is determined to be incompatible
--use-server Connect to a running instance of the Biome daemon server.
--verbose Print additional diagnostics, and some diagnostics show more information.
--config-path=PATH Set the directory of the biome.json configuration file and disable default
configuration file resolution.
--config-path=PATH Set the directory of the biome.json or biome.jsonc configuration file and
disable default configuration file resolution.
--max-diagnostics=NUMBER Cap the amount of diagnostics displayed.
[default: 20]
--skip-errors Skip over files containing syntax errors instead of emitting an error diagnostic.
@@ -41,5 +41,3 @@ Available options:
-h, --help Prints help information
```


Loading

0 comments on commit 0389c06

Please sign in to comment.