diff options
author | Brenley Dueck <brenleydueck@gmail.com> | 2022-10-25 07:21:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-25 14:21:20 +0200 |
commit | a189c5393e1b106687736635fea0b8aeca283826 (patch) | |
tree | 6c0119266f77611e1ba8146ee394f8e10cf8b3c4 /cli/tests | |
parent | ac5fcf626a77db7795f7ab2b4f15e4ecb3270171 (diff) |
feat(lint): add a report lint config setting (#16045)
Builds off this PR to add a "report" setting to deno.json which can be
"pretty", "compact", or "json".
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/lint_tests.rs | 12 | ||||
-rw-r--r-- | cli/tests/testdata/lint/Deno.compact.format.jsonc | 13 | ||||
-rw-r--r-- | cli/tests/testdata/lint/with_malformed_config.out | 2 | ||||
-rw-r--r-- | cli/tests/testdata/lint/with_report_config_compact.out | 4 | ||||
-rw-r--r-- | cli/tests/testdata/lint/with_report_config_override.out | 41 |
5 files changed, 71 insertions, 1 deletions
diff --git a/cli/tests/integration/lint_tests.rs b/cli/tests/integration/lint_tests.rs index afcdc6e40..70a3cbbd4 100644 --- a/cli/tests/integration/lint_tests.rs +++ b/cli/tests/integration/lint_tests.rs @@ -95,7 +95,19 @@ itest!(lint_with_config { exit_code: 1, }); +itest!(lint_with_report_config { + args: "lint --config lint/Deno.compact.format.jsonc lint/with_config/", + output: "lint/with_report_config_compact.out", + exit_code: 1, +}); + // Check if CLI flags take precedence +itest!(lint_with_report_config_override { + args: "lint --config lint/Deno.compact.format.jsonc lint/with_config/ --json", + output: "lint/with_report_config_override.out", + exit_code: 1, +}); + itest!(lint_with_config_and_flags { args: "lint --config lint/Deno.jsonc --ignore=lint/with_config/a.ts", output: "lint/with_config_and_flags.out", diff --git a/cli/tests/testdata/lint/Deno.compact.format.jsonc b/cli/tests/testdata/lint/Deno.compact.format.jsonc new file mode 100644 index 000000000..24b159ca6 --- /dev/null +++ b/cli/tests/testdata/lint/Deno.compact.format.jsonc @@ -0,0 +1,13 @@ +{ + "lint": { + "files": { + "include": ["with_config/"], + "exclude": ["with_config/b.ts"] + }, + "rules": { + "tags": ["recommended"], + "include": ["ban-untagged-todo"] + }, + "report": "compact" + } +} diff --git a/cli/tests/testdata/lint/with_malformed_config.out b/cli/tests/testdata/lint/with_malformed_config.out index 88fb8c457..3aa491065 100644 --- a/cli/tests/testdata/lint/with_malformed_config.out +++ b/cli/tests/testdata/lint/with_malformed_config.out @@ -1,4 +1,4 @@ error: Failed to parse "lint" configuration Caused by: - unknown field `dont_know_this_field`, expected `rules` or `files` + unknown field `dont_know_this_field`, expected one of `rules`, `files`, `report` diff --git a/cli/tests/testdata/lint/with_report_config_compact.out b/cli/tests/testdata/lint/with_report_config_compact.out new file mode 100644 index 000000000..fe1241264 --- /dev/null +++ b/cli/tests/testdata/lint/with_report_config_compact.out @@ -0,0 +1,4 @@ +[WILDCARD]a.ts: line 1, col 1 - TODO should be tagged with (@username) or (#issue) (ban-untagged-todo) +[WILDCARD]a.ts: line 2, col 10 - `add` is never used (no-unused-vars) +Found 2 problems +Checked 1 file diff --git a/cli/tests/testdata/lint/with_report_config_override.out b/cli/tests/testdata/lint/with_report_config_override.out new file mode 100644 index 000000000..ac633d911 --- /dev/null +++ b/cli/tests/testdata/lint/with_report_config_override.out @@ -0,0 +1,41 @@ +{ + "diagnostics": [ + { + "range": { + "start": { + "line": 1, + "col": 0, + "bytePos": 0 + }, + "end": { + "line": 1, + "col": 12, + "bytePos": 12 + } + }, + "filename": "[WILDCARD]a.ts", + "message": "TODO should be tagged with (@username) or (#issue)", + "code": "ban-untagged-todo", + "hint": "Add a user tag or issue reference to the TODO comment, e.g. TODO(@djones), TODO(djones), TODO(#123)" + }, + { + "range": { + "start": { + "line": 2, + "col": 9, + "bytePos": 22 + }, + "end": { + "line": 2, + "col": 12, + "bytePos": 25 + } + }, + "filename": "[WILDCARD]a.ts", + "message": "`add` is never used", + "code": "no-unused-vars", + "hint": "If this is intentional, prefix it with an underscore like `_add`" + } + ], + "errors": [] +} |