summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/lint_tests.rs44
-rw-r--r--cli/tests/testdata/lint/Deno.jsonc12
-rw-r--r--cli/tests/testdata/lint/Deno.malformed.jsonc13
-rw-r--r--cli/tests/testdata/lint/Deno.malformed2.jsonc13
-rw-r--r--cli/tests/testdata/lint/lint_with_config.out18
-rw-r--r--cli/tests/testdata/lint/lint_with_config/a.ts4
-rw-r--r--cli/tests/testdata/lint/lint_with_config/b.ts4
-rw-r--r--cli/tests/testdata/lint/lint_with_config_and_flags.out18
-rw-r--r--cli/tests/testdata/lint/lint_with_malformed_config.out4
-rw-r--r--cli/tests/testdata/lint/lint_with_malformed_config2.out4
10 files changed, 125 insertions, 9 deletions
diff --git a/cli/tests/integration/lint_tests.rs b/cli/tests/integration/lint_tests.rs
index 3eb9657ed..b11cc5b9a 100644
--- a/cli/tests/integration/lint_tests.rs
+++ b/cli/tests/integration/lint_tests.rs
@@ -24,59 +24,85 @@ fn ignore_unexplicit_files() {
}
itest!(all {
- args: "lint --unstable lint/file1.js lint/file2.ts lint/ignored_file.ts",
+ args: "lint lint/file1.js lint/file2.ts lint/ignored_file.ts",
output: "lint/expected.out",
exit_code: 1,
});
itest!(quiet {
- args: "lint --unstable --quiet lint/file1.js",
+ args: "lint --quiet lint/file1.js",
output: "lint/expected_quiet.out",
exit_code: 1,
});
itest!(json {
args:
- "lint --unstable --json lint/file1.js lint/file2.ts lint/ignored_file.ts lint/malformed.js",
+ "lint --json lint/file1.js lint/file2.ts lint/ignored_file.ts lint/malformed.js",
output: "lint/expected_json.out",
exit_code: 1,
});
itest!(ignore {
- args: "lint --unstable --ignore=lint/file1.js,lint/malformed.js lint/",
+ args:
+ "lint --ignore=lint/file1.js,lint/malformed.js,lint/lint_with_config/ lint/",
output: "lint/expected_ignore.out",
exit_code: 1,
});
itest!(glob {
- args: "lint --unstable --ignore=lint/malformed.js lint/",
+ args: "lint --ignore=lint/malformed.js,lint/lint_with_config/ lint/",
output: "lint/expected_glob.out",
exit_code: 1,
});
itest!(stdin {
- args: "lint --unstable -",
+ args: "lint -",
input: Some("let _a: any;"),
output: "lint/expected_from_stdin.out",
exit_code: 1,
});
itest!(stdin_json {
- args: "lint --unstable --json -",
+ args: "lint --json -",
input: Some("let _a: any;"),
output: "lint/expected_from_stdin_json.out",
exit_code: 1,
});
itest!(rules {
- args: "lint --unstable --rules",
+ args: "lint --rules",
output: "lint/expected_rules.out",
exit_code: 0,
});
// Make sure that the rules are printed if quiet option is enabled.
itest!(rules_quiet {
- args: "lint --unstable --rules -q",
+ args: "lint --rules -q",
output: "lint/expected_rules.out",
exit_code: 0,
});
+
+itest!(lint_with_config {
+ args: "lint --config lint/Deno.jsonc lint/lint_with_config/",
+ output: "lint/lint_with_config.out",
+ exit_code: 1,
+});
+
+// Check if CLI flags take precedence
+itest!(lint_with_config_and_flags {
+ args: "lint --config lint/Deno.jsonc --ignore=lint/lint_with_config/a.ts",
+ output: "lint/lint_with_config_and_flags.out",
+ exit_code: 1,
+});
+
+itest!(lint_with_malformed_config {
+ args: "lint --config lint/Deno.malformed.jsonc",
+ output: "lint/lint_with_malformed_config.out",
+ exit_code: 1,
+});
+
+itest!(lint_with_malformed_config2 {
+ args: "lint --config lint/Deno.malformed2.jsonc",
+ output: "lint/lint_with_malformed_config2.out",
+ exit_code: 1,
+});
diff --git a/cli/tests/testdata/lint/Deno.jsonc b/cli/tests/testdata/lint/Deno.jsonc
new file mode 100644
index 000000000..dc0a12eab
--- /dev/null
+++ b/cli/tests/testdata/lint/Deno.jsonc
@@ -0,0 +1,12 @@
+{
+ "lint": {
+ "files": {
+ "include": ["lint/lint_with_config/"],
+ "exclude": ["lint/lint_with_config/b.ts"]
+ },
+ "rules": {
+ "tags": ["recommended"],
+ "include": ["ban-untagged-todo"]
+ }
+ }
+}
diff --git a/cli/tests/testdata/lint/Deno.malformed.jsonc b/cli/tests/testdata/lint/Deno.malformed.jsonc
new file mode 100644
index 000000000..c6225d6a9
--- /dev/null
+++ b/cli/tests/testdata/lint/Deno.malformed.jsonc
@@ -0,0 +1,13 @@
+{
+ "lint": {
+ "files": {
+ "include": ["lint/lint_with_config/"],
+ "exclude": ["lint/lint_with_config/b.ts"]
+ },
+ "dont_know_this_field": {},
+ "rules": {
+ "tags": ["recommended"],
+ "include": ["ban-untagged-todo"]
+ }
+ }
+}
diff --git a/cli/tests/testdata/lint/Deno.malformed2.jsonc b/cli/tests/testdata/lint/Deno.malformed2.jsonc
new file mode 100644
index 000000000..473dafc4b
--- /dev/null
+++ b/cli/tests/testdata/lint/Deno.malformed2.jsonc
@@ -0,0 +1,13 @@
+{
+ "lint": {
+ "files": {
+ "include": ["lint/lint_with_config/"],
+ "exclude": ["lint/lint_with_config/b.ts"],
+ "dont_know_this_field": {}
+ },
+ "rules": {
+ "tags": ["recommended"],
+ "include": ["ban-untagged-todo"]
+ }
+ }
+}
diff --git a/cli/tests/testdata/lint/lint_with_config.out b/cli/tests/testdata/lint/lint_with_config.out
new file mode 100644
index 000000000..ea4581af8
--- /dev/null
+++ b/cli/tests/testdata/lint/lint_with_config.out
@@ -0,0 +1,18 @@
+(ban-untagged-todo) TODO should be tagged with (@username) or (#issue)
+// TODO: foo
+^^^^^^^^^^^^
+ at [WILDCARD]a.ts:1:0
+
+ hint: Add a user tag or issue reference to the TODO comment, e.g. TODO(@djones), TODO(djones), TODO(#123)
+ help: for further information visit https://lint.deno.land/#ban-untagged-todo
+
+(no-unused-vars) `add` is never used
+function add(a: number, b: number): number {
+ ^^^
+ at [WILDCARD]a.ts:2:9
+
+ hint: If this is intentional, prefix it with an underscore like `_add`
+ help: for further information visit https://lint.deno.land/#no-unused-vars
+
+Found 2 problems
+Checked 1 file
diff --git a/cli/tests/testdata/lint/lint_with_config/a.ts b/cli/tests/testdata/lint/lint_with_config/a.ts
new file mode 100644
index 000000000..c378218a3
--- /dev/null
+++ b/cli/tests/testdata/lint/lint_with_config/a.ts
@@ -0,0 +1,4 @@
+// TODO: foo
+function add(a: number, b: number): number {
+ return a + b;
+}
diff --git a/cli/tests/testdata/lint/lint_with_config/b.ts b/cli/tests/testdata/lint/lint_with_config/b.ts
new file mode 100644
index 000000000..d5647067e
--- /dev/null
+++ b/cli/tests/testdata/lint/lint_with_config/b.ts
@@ -0,0 +1,4 @@
+// TODO: this file should be ignored
+function subtract(a: number, b: number): number {
+ return a - b;
+}
diff --git a/cli/tests/testdata/lint/lint_with_config_and_flags.out b/cli/tests/testdata/lint/lint_with_config_and_flags.out
new file mode 100644
index 000000000..0a409343e
--- /dev/null
+++ b/cli/tests/testdata/lint/lint_with_config_and_flags.out
@@ -0,0 +1,18 @@
+(ban-untagged-todo) TODO should be tagged with (@username) or (#issue)
+// TODO: this file should be ignored
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ at [WILDCARD]b.ts:1:0
+
+ hint: Add a user tag or issue reference to the TODO comment, e.g. TODO(@djones), TODO(djones), TODO(#123)
+ help: for further information visit https://lint.deno.land/#ban-untagged-todo
+
+(no-unused-vars) `subtract` is never used
+function subtract(a: number, b: number): number {
+ ^^^^^^^^
+ at [WILDCARD]b.ts:2:9
+
+ hint: If this is intentional, prefix it with an underscore like `_subtract`
+ help: for further information visit https://lint.deno.land/#no-unused-vars
+
+Found 2 problems
+Checked 1 file
diff --git a/cli/tests/testdata/lint/lint_with_malformed_config.out b/cli/tests/testdata/lint/lint_with_malformed_config.out
new file mode 100644
index 000000000..88fb8c457
--- /dev/null
+++ b/cli/tests/testdata/lint/lint_with_malformed_config.out
@@ -0,0 +1,4 @@
+error: Failed to parse "lint" configuration
+
+Caused by:
+ unknown field `dont_know_this_field`, expected `rules` or `files`
diff --git a/cli/tests/testdata/lint/lint_with_malformed_config2.out b/cli/tests/testdata/lint/lint_with_malformed_config2.out
new file mode 100644
index 000000000..11e878f00
--- /dev/null
+++ b/cli/tests/testdata/lint/lint_with_malformed_config2.out
@@ -0,0 +1,4 @@
+error: Failed to parse "lint" configuration
+
+Caused by:
+ unknown field `dont_know_this_field`, expected `include` or `exclude`