2021-06-27 13:27:36 -04:00
|
|
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
|
|
|
use crate::itest;
|
|
|
|
use test_util as util;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn ignore_unexplicit_files() {
|
|
|
|
let output = util::deno_cmd()
|
|
|
|
.current_dir(util::root_path())
|
|
|
|
.env("NO_COLOR", "1")
|
|
|
|
.arg("lint")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--ignore=./")
|
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(!output.status.success());
|
|
|
|
assert_eq!(
|
|
|
|
String::from_utf8_lossy(&output.stderr),
|
|
|
|
"error: No target files found.\n"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
itest!(all {
|
2021-10-04 12:16:49 -04:00
|
|
|
args: "lint lint/without_config/file1.js lint/without_config/file2.ts lint/without_config/ignored_file.ts",
|
2021-06-27 13:27:36 -04:00
|
|
|
output: "lint/expected.out",
|
|
|
|
exit_code: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(quiet {
|
2021-10-04 12:16:49 -04:00
|
|
|
args: "lint --quiet lint/without_config/file1.js",
|
2021-06-27 13:27:36 -04:00
|
|
|
output: "lint/expected_quiet.out",
|
|
|
|
exit_code: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(json {
|
2021-10-04 12:16:49 -04:00
|
|
|
args:
|
|
|
|
"lint --json lint/without_config/file1.js lint/without_config/file2.ts lint/without_config/ignored_file.ts lint/without_config/malformed.js",
|
|
|
|
output: "lint/expected_json.out",
|
|
|
|
exit_code: 1,
|
|
|
|
});
|
2021-06-27 13:27:36 -04:00
|
|
|
|
|
|
|
itest!(ignore {
|
2021-09-03 11:01:58 -04:00
|
|
|
args:
|
2021-10-04 12:16:49 -04:00
|
|
|
"lint --ignore=lint/without_config/file1.js,lint/without_config/malformed.js,lint/without_config/lint_with_config/ lint/without_config/",
|
2021-06-27 13:27:36 -04:00
|
|
|
output: "lint/expected_ignore.out",
|
|
|
|
exit_code: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(glob {
|
2021-10-04 12:16:49 -04:00
|
|
|
args: "lint --ignore=lint/without_config/malformed.js,lint/with_config/ lint/without_config/",
|
2021-06-27 13:27:36 -04:00
|
|
|
output: "lint/expected_glob.out",
|
|
|
|
exit_code: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(stdin {
|
2021-09-03 11:01:58 -04:00
|
|
|
args: "lint -",
|
2021-06-27 13:27:36 -04:00
|
|
|
input: Some("let _a: any;"),
|
|
|
|
output: "lint/expected_from_stdin.out",
|
|
|
|
exit_code: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(stdin_json {
|
2021-09-03 11:01:58 -04:00
|
|
|
args: "lint --json -",
|
2021-06-27 13:27:36 -04:00
|
|
|
input: Some("let _a: any;"),
|
|
|
|
output: "lint/expected_from_stdin_json.out",
|
|
|
|
exit_code: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(rules {
|
2021-09-03 11:01:58 -04:00
|
|
|
args: "lint --rules",
|
2021-06-27 13:27:36 -04:00
|
|
|
output: "lint/expected_rules.out",
|
|
|
|
exit_code: 0,
|
|
|
|
});
|
|
|
|
|
|
|
|
// Make sure that the rules are printed if quiet option is enabled.
|
|
|
|
itest!(rules_quiet {
|
2021-09-03 11:01:58 -04:00
|
|
|
args: "lint --rules -q",
|
2021-06-27 13:27:36 -04:00
|
|
|
output: "lint/expected_rules.out",
|
|
|
|
exit_code: 0,
|
|
|
|
});
|
2021-09-03 11:01:58 -04:00
|
|
|
|
|
|
|
itest!(lint_with_config {
|
2021-10-04 12:16:49 -04:00
|
|
|
args: "lint --config lint/Deno.jsonc lint/with_config/",
|
|
|
|
output: "lint/with_config.out",
|
2021-09-03 11:01:58 -04:00
|
|
|
exit_code: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
// Check if CLI flags take precedence
|
|
|
|
itest!(lint_with_config_and_flags {
|
2021-10-04 12:16:49 -04:00
|
|
|
args: "lint --config lint/Deno.jsonc --ignore=lint/with_config/a.ts",
|
|
|
|
output: "lint/with_config_and_flags.out",
|
2021-09-03 11:01:58 -04:00
|
|
|
exit_code: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(lint_with_malformed_config {
|
|
|
|
args: "lint --config lint/Deno.malformed.jsonc",
|
2021-10-04 12:16:49 -04:00
|
|
|
output: "lint/with_malformed_config.out",
|
2021-09-03 11:01:58 -04:00
|
|
|
exit_code: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(lint_with_malformed_config2 {
|
|
|
|
args: "lint --config lint/Deno.malformed2.jsonc",
|
2021-10-04 12:16:49 -04:00
|
|
|
output: "lint/with_malformed_config2.out",
|
2021-09-03 11:01:58 -04:00
|
|
|
exit_code: 1,
|
|
|
|
});
|