From c3b168f5a2a076af011cb7eae0674b52075fb094 Mon Sep 17 00:00:00 2001 From: HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> Date: Tue, 9 Jul 2024 04:50:47 +0300 Subject: fix: add warning for invalid unstable feature use in deno.json/jsonc (#24120) --- cli/args/mod.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'cli/args') diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 950ba72e2..04a011196 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -1660,6 +1660,34 @@ impl CliOptions { }); } + if !from_config_file.is_empty() { + // collect unstable granular flags + let mut all_valid_unstable_flags: Vec<&str> = + crate::UNSTABLE_GRANULAR_FLAGS + .iter() + .map(|granular_flag| granular_flag.0) + .collect(); + + let mut another_unstable_flags = + Vec::from(["sloppy-imports", "byonm", "bare-node-builtins"]); + // add more unstable flags to the same vector holding granular flags + all_valid_unstable_flags.append(&mut another_unstable_flags); + + // check and warn if the unstable flag of config file isn't supported, by + // iterating through the vector holding the unstable flags + for unstable_value_from_config_file in &from_config_file { + if !all_valid_unstable_flags + .contains(&unstable_value_from_config_file.as_str()) + { + log::warn!( + "{} '{}' isn't a valid unstable feature", + colors::yellow("Warning"), + unstable_value_from_config_file + ); + } + } + } + from_config_file } -- cgit v1.2.3