Skip to content

Commit

Permalink
[flow] add '--no-autoimports' flag
Browse files Browse the repository at this point in the history
Summary: Changelog: [internal]

Reviewed By: gkz

Differential Revision:
D69668539

------------------------------------------------------------------------
(from 21ee15b05c8e3ce35e5c12526d44185de47cc499)

fbshipit-source-id: 136a0cf6a176e3141de7db9994509f2759a2439f
  • Loading branch information
panagosg7 authored and facebook-github-bot committed Feb 18, 2025
1 parent 95569af commit facfef4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/commands/commandUtils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ module Options_flags = struct
estimate_recheck_time: bool option;
long_lived_workers: bool option;
distributed: bool;
no_autoimports: bool;
}
end

Expand Down Expand Up @@ -981,7 +982,8 @@ let options_flags =
include_suppressions
estimate_recheck_time
long_lived_workers
distributed =
distributed
no_autoimports =
(match merge_timeout with
| Some timeout when timeout < 0 ->
Exit.(exit ~msg:"--merge-timeout must be non-negative" Commandline_usage_error)
Expand Down Expand Up @@ -1009,6 +1011,7 @@ let options_flags =
estimate_recheck_time;
long_lived_workers;
distributed;
no_autoimports;
}
in
fun prev ->
Expand Down Expand Up @@ -1057,6 +1060,7 @@ let options_flags =
|> flag "--estimate-recheck-time" (optional bool) ~doc:"" ~env:"FLOW_ESTIMATE_RECHECK_TIME"
|> flag "--long-lived-workers" (optional bool) ~doc:"" ~env:"FLOW_LONG_LIVED_WORKERS"
|> flag "--distributed" truthy ~doc:""
|> flag "--no-autoimports" truthy ~doc:"Disable auto-imports"
)

let saved_state_flags =
Expand Down Expand Up @@ -1484,7 +1488,9 @@ let make_options
opt_automatic_require_default =
Base.Option.value (FlowConfig.automatic_require_default flowconfig) ~default:false;
opt_format;
opt_autoimports = Base.Option.value (FlowConfig.autoimports flowconfig) ~default:true;
opt_autoimports =
(not options_flags.no_autoimports)
&& Base.Option.value (FlowConfig.autoimports flowconfig) ~default:true;
opt_autoimports_min_characters =
Base.Option.value (FlowConfig.autoimports_min_characters flowconfig) ~default:0;
opt_autoimports_ranked_by_usage = FlowConfig.autoimports_ranked_by_usage flowconfig;
Expand Down
2 changes: 2 additions & 0 deletions src/common/test_utils/test_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ let make_options_flags
?estimate_recheck_time
?long_lived_workers
?(distributed = false)
?(no_autoimports = false)
() =
{
CommandUtils.Options_flags.all;
Expand All @@ -57,6 +58,7 @@ let make_options_flags
estimate_recheck_time;
long_lived_workers;
distributed;
no_autoimports;
}

let make_saved_state_flags
Expand Down

0 comments on commit facfef4

Please sign in to comment.