diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-01-24 21:07:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 21:07:00 +0100 |
commit | e1c51f3c0d595542fe471359916df2a7b6be5484 (patch) | |
tree | cb213509a20a46a208f6623b4012c9f4845bf3c8 /cli/args/mod.rs | |
parent | abd96105300a7729a4d8eb69af2e81dd6307a163 (diff) |
feat(fmt): add ability to configure semicolons (#17292)
Allows to change behavior of `deno fmt` to use "ASI" setting for
semicolons instead of always prefering them, this is done
by "--options-semi=asi" flag or `"semi": "asi"` setting
in the config file.
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r-- | cli/args/mod.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index a81c84b59..6d81ae2af 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -15,6 +15,7 @@ pub use config_file::FmtOptionsConfig; pub use config_file::JsxImportSourceConfig; pub use config_file::LintRulesConfig; pub use config_file::ProseWrap; +pub use config_file::SemiColons; pub use config_file::TsConfig; pub use config_file::TsConfigForEmit; pub use config_file::TsConfigType; @@ -199,6 +200,15 @@ fn resolve_fmt_options( _ => unreachable!(), }); } + + if let Some(semi_colons) = &fmt_flags.semi_colons { + options.semi_colons = Some(match semi_colons.as_str() { + "prefer" => SemiColons::Prefer, + "asi" => SemiColons::Asi, + // validators in `flags.rs` makes other values unreachable + _ => unreachable!(), + }); + } } options |