summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorsouldzin <4908127+souldzin@users.noreply.github.com>2020-08-13 10:30:46 -0500
committerGitHub <noreply@github.com>2020-08-13 17:30:46 +0200
commitd6cee706955f300086f41f9318d23631f64f036b (patch)
tree61ff94128f1f4a03af2574a488d04301bbfcf3f7 /cli/tests
parent08ab4d46ca1860da16b5250fe3872cefbe682637 (diff)
feat: Add "--json" flag to deno lint (#6940)
Co-authored-by: JackSkylark <jdslaughter44@gmail.com>
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration_tests.rs11
-rw-r--r--cli/tests/lint/expected_ignore.out2
-rw-r--r--cli/tests/lint/expected_json.out43
-rw-r--r--cli/tests/lint/malformed.js4
4 files changed, 57 insertions, 3 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index bb7ba0d6f..6e487d12f 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -2216,14 +2216,21 @@ itest!(deno_lint {
exit_code: 1,
});
+itest!(deno_lint_json {
+ args:
+ "lint --unstable --json lint/file1.js lint/file2.ts lint/ignored_file.ts lint/malformed.js",
+ output: "lint/expected_json.out",
+ exit_code: 1,
+});
+
itest!(deno_lint_ignore {
- args: "lint --unstable --ignore=lint/file1.js lint/",
+ args: "lint --unstable --ignore=lint/file1.js,lint/malformed.js lint/",
output: "lint/expected_ignore.out",
exit_code: 1,
});
itest!(deno_lint_glob {
- args: "lint --unstable lint/",
+ args: "lint --unstable --ignore=lint/malformed.js lint/",
output: "lint/expected_glob.out",
exit_code: 1,
});
diff --git a/cli/tests/lint/expected_ignore.out b/cli/tests/lint/expected_ignore.out
index 6041d1c6a..02b9d917c 100644
--- a/cli/tests/lint/expected_ignore.out
+++ b/cli/tests/lint/expected_ignore.out
@@ -1,2 +1,2 @@
[WILDCARD]
-Found 1 problems
+Found 1 problem
diff --git a/cli/tests/lint/expected_json.out b/cli/tests/lint/expected_json.out
new file mode 100644
index 000000000..b4ce63395
--- /dev/null
+++ b/cli/tests/lint/expected_json.out
@@ -0,0 +1,43 @@
+{
+ "diagnostics": [
+ {
+ "location": {
+ "filename": "[WILDCARD]",
+ "line": 1,
+ "col": 0
+ },
+ "message": "Ignore directive requires lint rule code",
+ "code": "ban-untagged-ignore",
+ "line_src": "// deno-lint-ignore",
+ "snippet_length": 19
+ },
+ {
+ "location": {
+ "filename": "[WILDCARD]",
+ "line": 2,
+ "col": 14
+ },
+ "message": "Empty block statement",
+ "code": "no-empty",
+ "line_src": "while (false) {}",
+ "snippet_length": 2
+ },
+ {
+ "location": {
+ "filename": "[WILDCARD]",
+ "line": 3,
+ "col": 12
+ },
+ "message": "Empty block statement",
+ "code": "no-empty",
+ "line_src": "} catch (e) {}",
+ "snippet_length": 2
+ }
+ ],
+ "errors": [
+ {
+ "file_path": "[WILDCARD]malformed.js",
+ "message": "Expected RBrace, got None at [WILDCARD]malformed.js:4:15"
+ }
+ ]
+}
diff --git a/cli/tests/lint/malformed.js b/cli/tests/lint/malformed.js
new file mode 100644
index 000000000..5ad4650d6
--- /dev/null
+++ b/cli/tests/lint/malformed.js
@@ -0,0 +1,4 @@
+// deno-fmt-ignore-file
+
+// intentionally malformed file
+export class A { \ No newline at end of file