summaryrefslogtreecommitdiff
path: root/cli/flags.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/flags.rs')
-rw-r--r--cli/flags.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index 6c58238de..537e768f2 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -57,6 +57,7 @@ pub enum DenoSubcommand {
files: Vec<String>,
ignore: Vec<String>,
rules: bool,
+ json: bool,
},
Repl,
Run {
@@ -636,10 +637,12 @@ fn lint_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
None => vec![],
};
let rules = matches.is_present("rules");
+ let json = matches.is_present("json");
flags.subcommand = DenoSubcommand::Lint {
files,
rules,
ignore,
+ json,
};
}
@@ -1008,6 +1011,9 @@ fn lint_subcommand<'a, 'b>() -> App<'a, 'b> {
deno lint --unstable
deno lint --unstable myfile1.ts myfile2.js
+Print result as JSON:
+ deno lint --unstable --json
+
List available rules:
deno lint --unstable --rules
@@ -1042,6 +1048,12 @@ Ignore linting a file by adding an ignore comment at the top of the file:
.help("Ignore linting particular source files."),
)
.arg(
+ Arg::with_name("json")
+ .long("json")
+ .help("Output lint result in JSON format.")
+ .takes_value(false),
+ )
+ .arg(
Arg::with_name("files")
.takes_value(true)
.multiple(true)
@@ -1761,6 +1773,7 @@ mod tests {
subcommand: DenoSubcommand::Lint {
files: vec!["script_1.ts".to_string(), "script_2.ts".to_string()],
rules: false,
+ json: false,
ignore: vec![],
},
unstable: true,
@@ -1780,6 +1793,7 @@ mod tests {
subcommand: DenoSubcommand::Lint {
files: vec![],
rules: false,
+ json: false,
ignore: svec!["script_1.ts", "script_2.ts"],
},
unstable: true,
@@ -1794,6 +1808,28 @@ mod tests {
subcommand: DenoSubcommand::Lint {
files: vec![],
rules: true,
+ json: false,
+ ignore: vec![],
+ },
+ unstable: true,
+ ..Flags::default()
+ }
+ );
+
+ let r = flags_from_vec_safe(svec![
+ "deno",
+ "lint",
+ "--unstable",
+ "--json",
+ "script_1.ts"
+ ]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ subcommand: DenoSubcommand::Lint {
+ files: vec!["script_1.ts".to_string()],
+ rules: false,
+ json: true,
ignore: vec![],
},
unstable: true,