Skip to content

Commit d3aac63

Browse files
feat(cli): add parsing arguments (#7723)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 188a767 commit d3aac63

File tree

57 files changed

+3679
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3679
-38
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@biomejs/biome": minor
3+
---
4+
5+
Added `--css-parse-css-modules` CLI flag to control whether CSS Modules syntax is enabled.
6+
7+
You can now enable or disable CSS Modules parsing directly from the command line:
8+
9+
```shell
10+
biome check --css-parse-css-modules=true file.module.css
11+
biome format --css-parse-css-modules=true file.module.css
12+
biome lint --css-parse-css-modules=true file.module.css
13+
biome ci --css-parse-css-modules=true file.module.css
14+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@biomejs/biome": minor
3+
---
4+
5+
Added `--css-parse-tailwind-directives` CLI flag to control whether Tailwind CSS 4.0 directives and functions are enabled.
6+
7+
You can now enable or disable Tailwind CSS 4.0 directive parsing directly from the command line:
8+
9+
```shell
10+
biome check --css-parse-tailwind-directives=true file.css
11+
biome format --css-parse-tailwind-directives=true file.css
12+
biome lint --css-parse-tailwind-directives=true file.css
13+
biome ci --css-parse-tailwind-directives=true file.css
14+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@biomejs/biome": minor
3+
---
4+
5+
Added `--json-parse-allow-comments` CLI flag to control whether comments are allowed in JSON files.
6+
7+
You can now enable or disable comment parsing in JSON files directly from the command line:
8+
9+
```shell
10+
biome check --json-parse-allow-comments=true file.json
11+
biome format --json-parse-allow-comments=true file.json
12+
biome lint --json-parse-allow-comments=true file.json
13+
biome ci --json-parse-allow-comments=true file.json
14+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@biomejs/biome": minor
3+
---
4+
5+
Added `--json-parse-allow-trailing-commas` CLI flag to control whether trailing commas are allowed in JSON files.
6+
7+
You can now enable or disable trailing comma parsing in JSON files directly from the command line:
8+
9+
```shell
10+
biome check --json-parse-allow-trailing-commas=true file.json
11+
biome format --json-parse-allow-trailing-commas=true file.json
12+
biome lint --json-parse-allow-trailing-commas=true file.json
13+
biome ci --json-parse-allow-trailing-commas=true file.json
14+
```

crates/biome_cli/src/commands/check.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use crate::commands::{CommandRunner, get_files_to_process_with_cli_options};
44
use crate::{CliDiagnostic, Execution, TraversalMode};
55
use biome_configuration::analyzer::LinterEnabled;
66
use biome_configuration::analyzer::assist::{AssistConfiguration, AssistEnabled};
7-
use biome_configuration::formatter::FormatterEnabled;
7+
use biome_configuration::css::CssParserConfiguration;
8+
use biome_configuration::formatter::{FormatWithErrorsEnabled, FormatterEnabled};
9+
use biome_configuration::json::JsonParserConfiguration;
810
use biome_configuration::{Configuration, FormatterConfiguration, LinterConfiguration};
911
use biome_console::Console;
1012
use biome_deserialize::Merge;
@@ -26,6 +28,9 @@ pub(crate) struct CheckCommandPayload {
2628
pub(crate) staged: bool,
2729
pub(crate) changed: bool,
2830
pub(crate) since: Option<String>,
31+
pub(crate) format_with_errors: Option<FormatWithErrorsEnabled>,
32+
pub(crate) json_parser: Option<JsonParserConfiguration>,
33+
pub(crate) css_parser: Option<CssParserConfiguration>,
2934
}
3035

3136
impl LoadEditorConfig for CheckCommandPayload {
@@ -61,6 +66,9 @@ impl CommandRunner for CheckCommandPayload {
6166
if self.formatter_enabled.is_some() {
6267
formatter.enabled = self.formatter_enabled;
6368
}
69+
if self.format_with_errors.is_some() {
70+
formatter.format_with_errors = self.format_with_errors;
71+
}
6472

6573
let linter = configuration
6674
.linter
@@ -78,6 +86,16 @@ impl CommandRunner for CheckCommandPayload {
7886
assist.enabled = self.assist_enabled;
7987
}
8088

89+
let css = configuration.css.get_or_insert_with(Default::default);
90+
if self.css_parser.is_some() {
91+
css.parser.merge_with(self.css_parser.clone());
92+
}
93+
94+
let json = configuration.json.get_or_insert_with(Default::default);
95+
if self.json_parser.is_some() {
96+
json.parser.merge_with(self.json_parser.clone())
97+
}
98+
8199
if let Some(mut conf) = self.configuration.clone() {
82100
if let Some(linter) = conf.linter.as_mut() {
83101
// Don't overwrite rules from the CLI configuration.

crates/biome_cli/src/commands/ci.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ use crate::commands::{CommandRunner, LoadEditorConfig};
44
use crate::{CliDiagnostic, Execution};
55
use biome_configuration::analyzer::LinterEnabled;
66
use biome_configuration::analyzer::assist::{AssistConfiguration, AssistEnabled};
7-
use biome_configuration::formatter::FormatterEnabled;
8-
use biome_configuration::{Configuration, FormatterConfiguration, LinterConfiguration};
7+
use biome_configuration::css::CssParserConfiguration;
8+
use biome_configuration::formatter::{FormatWithErrorsEnabled, FormatterEnabled};
9+
use biome_configuration::json::JsonParserConfiguration;
10+
use biome_configuration::{
11+
Configuration, CssConfiguration, FormatterConfiguration, JsonConfiguration, LinterConfiguration,
12+
};
913
use biome_console::Console;
1014
use biome_deserialize::Merge;
1115
use biome_fs::FileSystem;
@@ -22,6 +26,9 @@ pub(crate) struct CiCommandPayload {
2226
pub(crate) configuration: Option<Configuration>,
2327
pub(crate) changed: bool,
2428
pub(crate) since: Option<String>,
29+
pub(crate) format_with_errors: Option<FormatWithErrorsEnabled>,
30+
pub(crate) json_parser: Option<JsonParserConfiguration>,
31+
pub(crate) css_parser: Option<CssParserConfiguration>,
2532
}
2633

2734
impl LoadEditorConfig for CiCommandPayload {
@@ -56,6 +63,7 @@ impl CommandRunner for CiCommandPayload {
5663

5764
if self.formatter_enabled.is_some() {
5865
formatter.enabled = self.formatter_enabled;
66+
formatter.format_with_errors = self.format_with_errors;
5967
}
6068

6169
let linter = configuration
@@ -66,6 +74,20 @@ impl CommandRunner for CiCommandPayload {
6674
linter.enabled = self.linter_enabled;
6775
}
6876

77+
let json = configuration
78+
.json
79+
.get_or_insert_with(JsonConfiguration::default);
80+
if self.json_parser.is_some() {
81+
json.parser.clone_from(&self.json_parser)
82+
}
83+
84+
let css = configuration
85+
.css
86+
.get_or_insert_with(CssConfiguration::default);
87+
if self.css_parser.is_some() {
88+
css.parser.clone_from(&self.css_parser);
89+
}
90+
6991
let assist = configuration
7092
.assist
7193
.get_or_insert_with(AssistConfiguration::default);

crates/biome_cli/src/commands/format.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::cli_options::CliOptions;
22
use crate::commands::{CommandRunner, LoadEditorConfig, get_files_to_process_with_cli_options};
33
use crate::{CliDiagnostic, Execution, TraversalMode};
4-
use biome_configuration::css::CssFormatterConfiguration;
4+
use biome_configuration::css::{CssFormatterConfiguration, CssParserConfiguration};
55
use biome_configuration::graphql::GraphqlFormatterConfiguration;
66
use biome_configuration::html::HtmlFormatterConfiguration;
77
use biome_configuration::javascript::JsFormatterConfiguration;
8-
use biome_configuration::json::JsonFormatterConfiguration;
8+
use biome_configuration::json::{JsonFormatterConfiguration, JsonParserConfiguration};
99
use biome_configuration::vcs::VcsConfiguration;
1010
use biome_configuration::{Configuration, FilesConfiguration, FormatterConfiguration};
1111
use biome_console::Console;
@@ -31,6 +31,8 @@ pub(crate) struct FormatCommandPayload {
3131
pub(crate) staged: bool,
3232
pub(crate) changed: bool,
3333
pub(crate) since: Option<String>,
34+
pub(crate) json_parser: Option<JsonParserConfiguration>,
35+
pub(crate) css_parser: Option<CssParserConfiguration>,
3436
}
3537

3638
impl LoadEditorConfig for FormatCommandPayload {
@@ -73,10 +75,15 @@ impl CommandRunner for FormatCommandPayload {
7375

7476
formatter.enabled = Some(true.into());
7577
}
78+
let css = configuration.css.get_or_insert_with(Default::default);
7679
if self.css_formatter.is_some() {
77-
let css = configuration.css.get_or_insert_with(Default::default);
7880
css.formatter.merge_with(self.css_formatter.clone());
7981
}
82+
83+
if self.css_parser.is_some() {
84+
css.parser.merge_with(self.css_parser.clone());
85+
}
86+
8087
if self.graphql_formatter.is_some() {
8188
let graphql = configuration.graphql.get_or_insert_with(Default::default);
8289
graphql.formatter.merge_with(self.graphql_formatter.clone());
@@ -94,10 +101,14 @@ impl CommandRunner for FormatCommandPayload {
94101
.formatter
95102
.merge_with(self.javascript_formatter.clone());
96103
}
104+
let json = configuration.json.get_or_insert_with(Default::default);
105+
97106
if self.json_formatter.is_some() {
98-
let json = configuration.json.get_or_insert_with(Default::default);
99107
json.formatter.merge_with(self.json_formatter.clone());
100108
}
109+
if self.json_parser.is_some() {
110+
json.parser.merge_with(self.json_parser.clone())
111+
}
101112

102113
configuration
103114
.files

crates/biome_cli/src/commands/lint.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use crate::cli_options::CliOptions;
33
use crate::commands::{CommandRunner, get_files_to_process_with_cli_options};
44
use crate::{CliDiagnostic, Execution, TraversalMode};
55
use biome_configuration::analyzer::AnalyzerSelector;
6-
use biome_configuration::css::CssLinterConfiguration;
6+
use biome_configuration::css::{CssLinterConfiguration, CssParserConfiguration};
77
use biome_configuration::graphql::GraphqlLinterConfiguration;
88
use biome_configuration::javascript::JsLinterConfiguration;
9-
use biome_configuration::json::JsonLinterConfiguration;
9+
use biome_configuration::json::{JsonLinterConfiguration, JsonParserConfiguration};
1010
use biome_configuration::vcs::VcsConfiguration;
1111
use biome_configuration::{Configuration, FilesConfiguration, LinterConfiguration};
1212
use biome_console::Console;
@@ -36,6 +36,8 @@ pub(crate) struct LintCommandPayload {
3636
pub(crate) json_linter: Option<JsonLinterConfiguration>,
3737
pub(crate) css_linter: Option<CssLinterConfiguration>,
3838
pub(crate) graphql_linter: Option<GraphqlLinterConfiguration>,
39+
pub(crate) json_parser: Option<JsonParserConfiguration>,
40+
pub(crate) css_parser: Option<CssParserConfiguration>,
3941
}
4042

4143
impl CommandRunner for LintCommandPayload {
@@ -71,10 +73,13 @@ impl CommandRunner for LintCommandPayload {
7173
..Default::default()
7274
});
7375

76+
let css = fs_configuration.css.get_or_insert_with(Default::default);
7477
if self.css_linter.is_some() {
75-
let css = fs_configuration.css.get_or_insert_with(Default::default);
7678
css.linter.merge_with(self.css_linter.clone());
7779
}
80+
if self.css_parser.is_some() {
81+
css.parser.merge_with(self.css_parser.clone());
82+
}
7883

7984
if self.graphql_linter.is_some() {
8085
let graphql = fs_configuration
@@ -88,10 +93,13 @@ impl CommandRunner for LintCommandPayload {
8893
.get_or_insert_with(Default::default);
8994
javascript.linter.merge_with(self.javascript_linter.clone());
9095
}
96+
let json = fs_configuration.json.get_or_insert_with(Default::default);
9197
if self.json_linter.is_some() {
92-
let json = fs_configuration.json.get_or_insert_with(Default::default);
9398
json.linter.merge_with(self.json_linter.clone());
9499
}
100+
if self.json_parser.is_some() {
101+
json.parser.merge_with(self.json_parser.clone());
102+
}
95103

96104
Ok(fs_configuration)
97105
}

crates/biome_cli/src/commands/mod.rs

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,31 @@ use crate::{
99
};
1010
use biome_configuration::analyzer::assist::AssistEnabled;
1111
use biome_configuration::analyzer::{AnalyzerSelector, LinterEnabled};
12-
use biome_configuration::css::{CssFormatterConfiguration, CssLinterConfiguration};
13-
use biome_configuration::formatter::FormatterEnabled;
12+
use biome_configuration::css::{
13+
CssFormatterConfiguration, CssLinterConfiguration, CssParserConfiguration,
14+
};
15+
use biome_configuration::formatter::{FormatWithErrorsEnabled, FormatterEnabled};
1416
use biome_configuration::graphql::{GraphqlFormatterConfiguration, GraphqlLinterConfiguration};
1517
use biome_configuration::html::{HtmlFormatterConfiguration, html_formatter_configuration};
1618
use biome_configuration::javascript::{JsFormatterConfiguration, JsLinterConfiguration};
17-
use biome_configuration::json::{JsonFormatterConfiguration, JsonLinterConfiguration};
19+
use biome_configuration::json::{
20+
JsonFormatterConfiguration, JsonLinterConfiguration, JsonParserConfiguration,
21+
};
1822
use biome_configuration::vcs::VcsConfiguration;
1923
use biome_configuration::{BiomeDiagnostic, Configuration};
2024
use biome_configuration::{
2125
FilesConfiguration, FormatterConfiguration, LinterConfiguration, configuration,
22-
css::css_formatter_configuration, css::css_linter_configuration, files_configuration,
23-
formatter_configuration, graphql::graphql_formatter_configuration,
24-
graphql::graphql_linter_configuration, javascript::js_formatter_configuration,
25-
javascript::js_linter_configuration, json::json_formatter_configuration,
26-
json::json_linter_configuration, linter_configuration, vcs::vcs_configuration,
26+
css::{css_formatter_configuration, css_linter_configuration, css_parser_configuration},
27+
files_configuration, formatter_configuration,
28+
graphql::graphql_formatter_configuration,
29+
graphql::graphql_linter_configuration,
30+
javascript::js_formatter_configuration,
31+
javascript::js_linter_configuration,
32+
json::json_formatter_configuration,
33+
json::json_linter_configuration,
34+
json::json_parser_configuration,
35+
linter_configuration,
36+
vcs::vcs_configuration,
2737
};
2838
use biome_console::{Console, ConsoleExt, markup};
2939
use biome_deserialize::Merge;
@@ -146,6 +156,17 @@ pub enum BiomeCommand {
146156
#[bpaf(long("enforce-assist"), argument("true|false"), fallback(true))]
147157
enforce_assist: bool,
148158

159+
/// Whether formatting should be allowed to proceed if a given file
160+
/// has syntax errors
161+
#[bpaf(long("format-with-errors"), argument("true|false"))]
162+
format_with_errors: Option<FormatWithErrorsEnabled>,
163+
164+
#[bpaf(external(json_parser_configuration), optional, hide_usage)]
165+
json_parser: Option<JsonParserConfiguration>,
166+
167+
#[bpaf(external(css_parser_configuration), optional, hide_usage, hide)]
168+
css_parser: Option<CssParserConfiguration>,
169+
149170
#[bpaf(external(configuration), hide_usage, optional)]
150171
configuration: Option<Configuration>,
151172
#[bpaf(external, hide_usage)]
@@ -209,6 +230,12 @@ pub enum BiomeCommand {
209230
#[bpaf(long("reason"), argument("STRING"))]
210231
suppression_reason: Option<String>,
211232

233+
#[bpaf(external(json_parser_configuration), optional, hide_usage)]
234+
json_parser: Option<JsonParserConfiguration>,
235+
236+
#[bpaf(external(css_parser_configuration), optional, hide_usage, hide)]
237+
css_parser: Option<CssParserConfiguration>,
238+
212239
#[bpaf(external(linter_configuration), hide_usage, optional)]
213240
linter_configuration: Option<LinterConfiguration>,
214241

@@ -294,12 +321,18 @@ pub enum BiomeCommand {
294321
#[bpaf(external(json_formatter_configuration), optional, hide_usage)]
295322
json_formatter: Option<JsonFormatterConfiguration>,
296323

297-
#[bpaf(external(css_formatter_configuration), optional, hide_usage, hide)]
298-
css_formatter: Option<CssFormatterConfiguration>,
324+
#[bpaf(external(json_parser_configuration), optional, hide_usage)]
325+
json_parser: Option<JsonParserConfiguration>,
326+
327+
#[bpaf(external(css_parser_configuration), optional, hide_usage, hide)]
328+
css_parser: Option<CssParserConfiguration>,
299329

300330
#[bpaf(external(graphql_formatter_configuration), optional, hide_usage, hide)]
301331
graphql_formatter: Option<GraphqlFormatterConfiguration>,
302332

333+
#[bpaf(external(css_formatter_configuration), optional, hide_usage, hide)]
334+
css_formatter: Option<CssFormatterConfiguration>,
335+
303336
#[bpaf(external(html_formatter_configuration), optional, hide_usage, hide)]
304337
html_formatter: Option<HtmlFormatterConfiguration>,
305338

@@ -365,6 +398,17 @@ pub enum BiomeCommand {
365398
#[bpaf(long("assist-enabled"), argument("true|false"), optional)]
366399
assist_enabled: Option<AssistEnabled>,
367400

401+
/// Whether formatting should be allowed to proceed if a given file
402+
/// has syntax errors
403+
#[bpaf(long("format-with-errors"), argument("true|false"))]
404+
format_with_errors: Option<FormatWithErrorsEnabled>,
405+
406+
#[bpaf(external(json_parser_configuration), optional, hide_usage)]
407+
json_parser: Option<JsonParserConfiguration>,
408+
409+
#[bpaf(external(css_parser_configuration), optional, hide_usage, hide)]
410+
css_parser: Option<CssParserConfiguration>,
411+
368412
/// Allows enforcing assist, and make the CLI fail if some actions aren't applied. Defaults to `true`.
369413
#[bpaf(long("enforce-assist"), argument("true|false"), fallback(true))]
370414
enforce_assist: bool,

0 commit comments

Comments
 (0)