diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-06-08 14:06:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-08 14:06:20 +0200 |
commit | 0e9da7e731cea3a073812c22da30d87209537a88 (patch) | |
tree | 016a4ab0f7a1c57fbf94668e49a8e33845000f44 /cli/flags.rs | |
parent | 62adc63934d8be52b90512ad0e8165d9dd36eafc (diff) |
feat: "deno lint" subcommand (#6125)
Diffstat (limited to 'cli/flags.rs')
-rw-r--r-- | cli/flags.rs | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index 9bf838bfa..d4e17b903 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -50,6 +50,9 @@ pub enum DenoSubcommand { root: Option<PathBuf>, force: bool, }, + Lint { + files: Vec<String>, + }, Repl, Run { script: String, @@ -260,6 +263,8 @@ pub fn flags_from_vec_safe(args: Vec<String>) -> clap::Result<Flags> { upgrade_parse(&mut flags, m); } else if let Some(m) = matches.subcommand_matches("doc") { doc_parse(&mut flags, m); + } else if let Some(m) = matches.subcommand_matches("lint") { + lint_parse(&mut flags, m); } else { repl_parse(&mut flags, &matches); } @@ -302,18 +307,19 @@ If the flag is set, restrict these messages to errors.", .global(true), ) .subcommand(bundle_subcommand()) + .subcommand(cache_subcommand()) .subcommand(completions_subcommand()) + .subcommand(doc_subcommand()) .subcommand(eval_subcommand()) - .subcommand(cache_subcommand()) .subcommand(fmt_subcommand()) .subcommand(info_subcommand()) .subcommand(install_subcommand()) + .subcommand(lint_subcommand()) .subcommand(repl_subcommand()) .subcommand(run_subcommand()) .subcommand(test_subcommand()) .subcommand(types_subcommand()) .subcommand(upgrade_subcommand()) - .subcommand(doc_subcommand()) .long_about(DENO_HELP) .after_help(ENV_VARIABLES_HELP) } @@ -579,6 +585,16 @@ fn doc_parse(flags: &mut Flags, matches: &clap::ArgMatches) { }; } +fn lint_parse(flags: &mut Flags, matches: &clap::ArgMatches) { + unstable_arg_parse(flags, matches); + let files = matches + .values_of("files") + .unwrap() + .map(String::from) + .collect(); + flags.subcommand = DenoSubcommand::Lint { files }; +} + fn types_subcommand<'a, 'b>() -> App<'a, 'b> { SubCommand::with_name("types") .arg(unstable_arg()) @@ -889,6 +905,25 @@ Show documentation for runtime built-ins: ) } +fn lint_subcommand<'a, 'b>() -> App<'a, 'b> { + SubCommand::with_name("lint") + .about("Lint source files") + .long_about( + "Lint JavaScript/TypeScript source code. + deno lint myfile1.ts myfile2.js + +Ignore diagnostics on next line preceding it with an ignore comment and code: + // deno-lint-ignore no-explicit-any", + ) + .arg(unstable_arg()) + .arg( + Arg::with_name("files") + .takes_value(true) + .required(true) + .min_values(1), + ) +} + fn permission_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { app .arg( |