Skip to content

Commit

Permalink
fix(cli): lint command help (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Sep 18, 2023
1 parent 206c7a7 commit 2d8bd1b
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 40 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom
- Import sorting is safe to apply now, and it will be applied when running `check --apply` instead of `check --apply-unsafe`.

### CLI

#### Bug fixes

- Fix [#319](https://github.com/biomejs/biome/issues/319). The command `biome lint` now shows the correct options. Contributed by @ematipico

### Configuration
### Editors
### Formatter
Expand Down
16 changes: 12 additions & 4 deletions crates/biome_cli/src/commands/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ use crate::cli_options::CliOptions;
use crate::configuration::{load_configuration, LoadedConfiguration};
use crate::vcs::store_path_to_ignore_from_vcs;
use crate::{execute_mode, CliDiagnostic, CliSession, Execution, TraversalMode};
use biome_service::configuration::vcs::VcsConfiguration;
use biome_service::configuration::{FilesConfiguration, LinterConfiguration};
use biome_service::workspace::{FixFileMode, UpdateSettingsParams};
use biome_service::{Configuration, MergeWith};
use biome_service::MergeWith;
use std::ffi::OsString;
use std::path::PathBuf;

pub(crate) struct LintCommandPayload {
pub(crate) apply: bool,
pub(crate) apply_unsafe: bool,
pub(crate) cli_options: CliOptions,
pub(crate) configuration: Option<Configuration>,
pub(crate) linter_configuration: Option<LinterConfiguration>,
pub(crate) vcs_configuration: Option<VcsConfiguration>,
pub(crate) files_configuration: Option<FilesConfiguration>,
pub(crate) paths: Vec<OsString>,
pub(crate) stdin_file_path: Option<String>,
}
Expand All @@ -25,9 +29,11 @@ pub(crate) fn lint(
apply,
apply_unsafe,
cli_options,
configuration,
linter_configuration,
paths,
stdin_file_path,
vcs_configuration,
files_configuration,
} = payload;

let fix_file_mode = if apply && apply_unsafe {
Expand All @@ -50,7 +56,9 @@ pub(crate) fn lint(
} = load_configuration(&mut session, &cli_options)?
.or_diagnostic(session.app.console, cli_options.verbose)?;

fs_configuration.merge_with(configuration);
fs_configuration.merge_with(linter_configuration);
fs_configuration.merge_with(files_configuration);
fs_configuration.merge_with(vcs_configuration);

// check if support of git ignore files is enabled
let vcs_base_path = configuration_path.or(session.app.fs.working_directory());
Expand Down
14 changes: 11 additions & 3 deletions crates/biome_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use biome_service::configuration::json::JsonFormatter;
use biome_service::configuration::vcs::VcsConfiguration;
use biome_service::configuration::{
configuration, files_configuration, formatter_configuration, javascript::javascript_formatter,
json::json_formatter, vcs::vcs_configuration, FilesConfiguration, FormatterConfiguration,
JavascriptFormatter,
json::json_formatter, linter_configuration, vcs::vcs_configuration, FilesConfiguration,
FormatterConfiguration, JavascriptFormatter, LinterConfiguration,
};
use biome_service::Configuration;
use bpaf::Bpaf;
Expand Down Expand Up @@ -89,9 +89,17 @@ pub enum BiomeCommand {
#[bpaf(long("apply-unsafe"), switch)]
apply_unsafe: bool,
#[bpaf(external, hide_usage, optional)]
configuration: Option<Configuration>,
linter_configuration: Option<LinterConfiguration>,

#[bpaf(external, optional, hide_usage)]
vcs_configuration: Option<VcsConfiguration>,

#[bpaf(external, optional, hide_usage)]
files_configuration: Option<FilesConfiguration>,

#[bpaf(external, hide_usage)]
cli_options: CliOptions,

/// A file name with its extension to pass when reading from standard in, e.g. echo 'let a;' | biome lint --stdin-file-path=file.js"
#[bpaf(long("stdin-file-path"), argument("PATH"), hide_usage)]
stdin_file_path: Option<String>,
Expand Down
8 changes: 6 additions & 2 deletions crates/biome_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,22 @@ impl<'app> CliSession<'app> {
apply,
apply_unsafe,
cli_options,
configuration: rome_configuration,
linter_configuration,
paths,
stdin_file_path,
vcs_configuration,
files_configuration,
} => commands::lint::lint(
self,
LintCommandPayload {
apply_unsafe,
apply,
cli_options,
configuration: rome_configuration,
linter_configuration,
paths,
stdin_file_path,
vcs_configuration,
files_configuration,
},
),
BiomeCommand::Ci {
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_cli/tests/commands/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const UPGRADE_SEVERITY_CODE: &str = r#"if(!cond) { exprA(); } else { exprB() }"#
const NURSERY_UNSTABLE: &str = r#"if(a = b) {}"#;

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

Expand All @@ -66,7 +66,7 @@ fn check_help() {

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"check_help",
"lint_help",
fs,
console,
result,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Run various checks on a set of files.
Usage: lint [--apply] [--apply-unsafe] [PATH]...
The configuration that is contained inside the file `biome.json`
Set of properties to integrate Biome with a VCS software.
--vcs-client-kind=<git> The kind of client.
--vcs-enabled=<true|false> Whether Biome should integrate itself with the VCS client
--vcs-use-ignore-file=<true|false> Whether Biome should use the VCS ignore file. When [true],
Expand All @@ -19,38 +19,12 @@ The configuration that is contained inside the file `biome.json`
If Biome can't find the configuration, it will attempt to use the current
working directory. If no current working directory can't be found, Biome
won't use the VCS integration, and a diagnostic will be emitted
The configuration of the filesystem
--files-max-size=NUMBER The maximum allowed size for source code files in bytes. Files above
this limit will be ignored for performance reasons. Defaults to 1 MiB
--files-ignore-unknown=<true|false> Tells Biome to not emit diagnostics when handling files
that doesn't know
--indent-style=<tab|space> The indent style.
--indent-size=NUMBER The size of the indentation, 2 by default
--line-width=NUMBER What's the max width of a line. Defaults to 80.
--quote-style=<double|single> The type of quotes used in JavaScript code. Defaults to double.
--jsx-quote-style=<double|single> The type of quotes used in JSX. Defaults to double.
--quote-properties=<preserve|as-needed> When properties in objects are quoted. Defaults to asNeeded.
--trailing-comma=<all|es5|none> Print trailing commas wherever possible in multi-line comma-separated
syntactic structures. Defaults to "all".
--semicolons=<always|as-needed> Whether the formatter prints semicolons for all statements or
only in for statements where it is necessary because of ASI.
--arrow-parentheses=<always|as-needed> Whether to add non-necessary parentheses to arrow functions.
Defaults to "always".
--javascript-formatter-enabled=<true|false> Control the formatter for JavaScript (and its super
languages) files.
--javascript-formatter-indent-style=<tab|space> The indent style applied to JavaScript (and
its super languages) files.
--javascript-formatter-indent-size=NUMBER The size of the indentation applied to JavaScript
(and its super languages) files. Default to 2.
--javascript-formatter-line-width=NUMBER What's the max width of a line, applied to JavaScript
(and its super languages) files. Defaults to 80.
--json-formatter-enabled=<true|false> Control the formatter for JSON (and its super languages)
files.
--json-formatter-indent-style=<tab|space> The indent style applied to JSON (and its super languages)
files.
--json-formatter-indent-size=NUMBER The size of the indentation applied to JSON (and its super
languages) files. Default to 2.
--json-formatter-line-width=NUMBER What's the max width of a line, applied to JSON (and its
super languages) files. Defaults to 80.
Global options applied to all commands
--colors=<off|force> Set the formatting mode for markup: "off" prints everything as plain text,
Expand Down
5 changes: 5 additions & 0 deletions website/src/content/docs/internals/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom
- Import sorting is safe to apply now, and it will be applied when running `check --apply` instead of `check --apply-unsafe`.

### CLI

#### Bug fixes

- Fix [#319](https://github.com/biomejs/biome/issues/319). The command `biome lint` now shows the correct options. Contributed by @ematipico

### Configuration
### Editors
### Formatter
Expand Down

0 comments on commit 2d8bd1b

Please sign in to comment.