diff options
author | HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> | 2024-09-16 20:45:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-16 17:45:25 +0000 |
commit | 36a1a79f175b2df31d8ba5d7e121239c3b7e74ea (patch) | |
tree | a2d1c96ba22181dc3301e3a20e4c4977f50b5d3d /tests/specs | |
parent | acc32e1cee043ef7233a94bcf5645c4a842ed13a (diff) |
chore: deprecate lint itests (#25655)
Diffstat (limited to 'tests/specs')
119 files changed, 1174 insertions, 0 deletions
diff --git a/tests/specs/lint/all/__test__.jsonc b/tests/specs/lint/all/__test__.jsonc new file mode 100644 index 000000000..0583ceca9 --- /dev/null +++ b/tests/specs/lint/all/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint file1.js file2.ts ignored_file.ts", + "output": "expected.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/all/expected.out b/tests/specs/lint/all/expected.out new file mode 100644 index 000000000..eb8a2651a --- /dev/null +++ b/tests/specs/lint/all/expected.out @@ -0,0 +1,3 @@ +[WILDCARD] +Found 3 problems +Checked 3 files diff --git a/tests/specs/lint/all/file1.js b/tests/specs/lint/all/file1.js new file mode 100644 index 000000000..737f26818 --- /dev/null +++ b/tests/specs/lint/all/file1.js @@ -0,0 +1,2 @@ +// deno-lint-ignore +while (false) {} diff --git a/tests/specs/lint/all/file2.ts b/tests/specs/lint/all/file2.ts new file mode 100644 index 000000000..73c612c35 --- /dev/null +++ b/tests/specs/lint/all/file2.ts @@ -0,0 +1,6 @@ +try { + await Deno.open("./some/file.txt"); +} catch (_e) {} + +// deno-lint-ignore no-explicit-any +function _foo(): any {} diff --git a/tests/specs/lint/all/ignored_file.ts b/tests/specs/lint/all/ignored_file.ts new file mode 100644 index 000000000..97befafa3 --- /dev/null +++ b/tests/specs/lint/all/ignored_file.ts @@ -0,0 +1,3 @@ +// deno-lint-ignore-file + +function foo(): any {} diff --git a/tests/specs/lint/compact/__test__.jsonc b/tests/specs/lint/compact/__test__.jsonc new file mode 100644 index 000000000..d5e1eef54 --- /dev/null +++ b/tests/specs/lint/compact/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --compact file1.js ignored_file.tss", + "output": "expected_compact.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/compact/expected_compact.out b/tests/specs/lint/compact/expected_compact.out new file mode 100644 index 000000000..d1b2b922b --- /dev/null +++ b/tests/specs/lint/compact/expected_compact.out @@ -0,0 +1,4 @@ +[WILDCARD]file1.js: line 1, col 1 - Ignore directive requires lint rule name(s) (ban-untagged-ignore) +[WILDCARD]file1.js: line 2, col 15 - Empty block statement (no-empty) +Found 2 problems +Checked 1 file diff --git a/tests/specs/lint/compact/file1.js b/tests/specs/lint/compact/file1.js new file mode 100644 index 000000000..737f26818 --- /dev/null +++ b/tests/specs/lint/compact/file1.js @@ -0,0 +1,2 @@ +// deno-lint-ignore +while (false) {} diff --git a/tests/specs/lint/glob/__test__.jsonc b/tests/specs/lint/glob/__test__.jsonc new file mode 100644 index 000000000..454a55804 --- /dev/null +++ b/tests/specs/lint/glob/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --ignore=without_config/malformed.js,with_config/ without_config/", + "output": "expected_glob.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/glob/expected_glob.out b/tests/specs/lint/glob/expected_glob.out new file mode 100644 index 000000000..eb8a2651a --- /dev/null +++ b/tests/specs/lint/glob/expected_glob.out @@ -0,0 +1,3 @@ +[WILDCARD] +Found 3 problems +Checked 3 files diff --git a/tests/specs/lint/glob/with_config/a.ts b/tests/specs/lint/glob/with_config/a.ts new file mode 100644 index 000000000..c378218a3 --- /dev/null +++ b/tests/specs/lint/glob/with_config/a.ts @@ -0,0 +1,4 @@ +// TODO: foo +function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/lint/glob/with_config/b.ts b/tests/specs/lint/glob/with_config/b.ts new file mode 100644 index 000000000..d5647067e --- /dev/null +++ b/tests/specs/lint/glob/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/tests/specs/lint/glob/without_config/file1.js b/tests/specs/lint/glob/without_config/file1.js new file mode 100644 index 000000000..737f26818 --- /dev/null +++ b/tests/specs/lint/glob/without_config/file1.js @@ -0,0 +1,2 @@ +// deno-lint-ignore +while (false) {} diff --git a/tests/specs/lint/glob/without_config/file2.ts b/tests/specs/lint/glob/without_config/file2.ts new file mode 100644 index 000000000..73c612c35 --- /dev/null +++ b/tests/specs/lint/glob/without_config/file2.ts @@ -0,0 +1,6 @@ +try { + await Deno.open("./some/file.txt"); +} catch (_e) {} + +// deno-lint-ignore no-explicit-any +function _foo(): any {} diff --git a/tests/specs/lint/glob/without_config/ignored_file.ts b/tests/specs/lint/glob/without_config/ignored_file.ts new file mode 100644 index 000000000..97befafa3 --- /dev/null +++ b/tests/specs/lint/glob/without_config/ignored_file.ts @@ -0,0 +1,3 @@ +// deno-lint-ignore-file + +function foo(): any {} diff --git a/tests/specs/lint/glob/without_config/malformed.js b/tests/specs/lint/glob/without_config/malformed.js new file mode 100644 index 000000000..9b64da898 --- /dev/null +++ b/tests/specs/lint/glob/without_config/malformed.js @@ -0,0 +1,4 @@ +// deno-fmt-ignore-file + +// intentionally malformed file +export class A B C
\ No newline at end of file diff --git a/tests/specs/lint/ignore/__test__.jsonc b/tests/specs/lint/ignore/__test__.jsonc new file mode 100644 index 000000000..5bbe237ce --- /dev/null +++ b/tests/specs/lint/ignore/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --ignore=without_config/file1.js,without_config/malformed.js,without_config/lint_with_config/ without_config", + "output": "expected_ignore.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/ignore/expected_ignore.out b/tests/specs/lint/ignore/expected_ignore.out new file mode 100644 index 000000000..b5f78ee04 --- /dev/null +++ b/tests/specs/lint/ignore/expected_ignore.out @@ -0,0 +1,3 @@ +[WILDCARD] +Found 1 problem +Checked 2 files diff --git a/tests/specs/lint/ignore/without_config/file1.js b/tests/specs/lint/ignore/without_config/file1.js new file mode 100644 index 000000000..737f26818 --- /dev/null +++ b/tests/specs/lint/ignore/without_config/file1.js @@ -0,0 +1,2 @@ +// deno-lint-ignore +while (false) {} diff --git a/tests/specs/lint/ignore/without_config/file2.ts b/tests/specs/lint/ignore/without_config/file2.ts new file mode 100644 index 000000000..73c612c35 --- /dev/null +++ b/tests/specs/lint/ignore/without_config/file2.ts @@ -0,0 +1,6 @@ +try { + await Deno.open("./some/file.txt"); +} catch (_e) {} + +// deno-lint-ignore no-explicit-any +function _foo(): any {} diff --git a/tests/specs/lint/ignore/without_config/ignored_file.ts b/tests/specs/lint/ignore/without_config/ignored_file.ts new file mode 100644 index 000000000..97befafa3 --- /dev/null +++ b/tests/specs/lint/ignore/without_config/ignored_file.ts @@ -0,0 +1,3 @@ +// deno-lint-ignore-file + +function foo(): any {} diff --git a/tests/specs/lint/ignore/without_config/malformed.js b/tests/specs/lint/ignore/without_config/malformed.js new file mode 100644 index 000000000..9b64da898 --- /dev/null +++ b/tests/specs/lint/ignore/without_config/malformed.js @@ -0,0 +1,4 @@ +// deno-fmt-ignore-file + +// intentionally malformed file +export class A B C
\ No newline at end of file diff --git a/tests/specs/lint/ignore_unexplicit_files/__test__.jsonc b/tests/specs/lint/ignore_unexplicit_files/__test__.jsonc new file mode 100644 index 000000000..7653c4e25 --- /dev/null +++ b/tests/specs/lint/ignore_unexplicit_files/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --ignore=./", + "output": "lint.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/ignore_unexplicit_files/lint.out b/tests/specs/lint/ignore_unexplicit_files/lint.out new file mode 100644 index 000000000..33f4ddd93 --- /dev/null +++ b/tests/specs/lint/ignore_unexplicit_files/lint.out @@ -0,0 +1 @@ +error: No target files found. diff --git a/tests/specs/lint/json/__test__.jsonc b/tests/specs/lint/json/__test__.jsonc new file mode 100644 index 000000000..fb577c0dd --- /dev/null +++ b/tests/specs/lint/json/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --json file1.js file2.ts ignored_file.ts malformed.js", + "output": "expected_json.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/json/expected_json.out b/tests/specs/lint/json/expected_json.out new file mode 100644 index 000000000..6712c891a --- /dev/null +++ b/tests/specs/lint/json/expected_json.out @@ -0,0 +1,65 @@ +{ + "version": 1, + "diagnostics": [ + { + "filename": "[WILDCARD]file1.js", + "range": { + "start": { + "line": 1, + "col": 0, + "bytePos": 0 + }, + "end": { + "line": 1, + "col": 19, + "bytePos": 19 + } + }, + "message": "Ignore directive requires lint rule name(s)", + "code": "ban-untagged-ignore", + "hint": [WILDCARD] + }, + { + "filename": "[WILDCARD]file1.js", + "range": { + "start": { + "line": 2, + "col": 14, + "bytePos": 34 + }, + "end": { + "line": 2, + "col": 16, + "bytePos": 36 + } + }, + "message": "Empty block statement", + "code": "no-empty", + "hint": [WILDCARD] + }, + { + "filename": "[WILDCARD]file2.ts", + "range": { + "start": { + "line": 3, + "col": 13, + "bytePos": 57 + }, + "end": { + "line": 3, + "col": 15, + "bytePos": 59 + } + }, + "message": "Empty block statement", + "code": "no-empty", + "hint": [WILDCARD] + } + ], + "errors": [ + { + "file_path": "[WILDCARD]malformed.js", + "message": "Expected '{', got 'B' at [WILDCARD]malformed.js:4:16\n\n export class A B C\n ~" + } + ] +} diff --git a/tests/specs/lint/json/file1.js b/tests/specs/lint/json/file1.js new file mode 100644 index 000000000..737f26818 --- /dev/null +++ b/tests/specs/lint/json/file1.js @@ -0,0 +1,2 @@ +// deno-lint-ignore +while (false) {} diff --git a/tests/specs/lint/json/file2.ts b/tests/specs/lint/json/file2.ts new file mode 100644 index 000000000..73c612c35 --- /dev/null +++ b/tests/specs/lint/json/file2.ts @@ -0,0 +1,6 @@ +try { + await Deno.open("./some/file.txt"); +} catch (_e) {} + +// deno-lint-ignore no-explicit-any +function _foo(): any {} diff --git a/tests/specs/lint/json/ignored_file.ts b/tests/specs/lint/json/ignored_file.ts new file mode 100644 index 000000000..97befafa3 --- /dev/null +++ b/tests/specs/lint/json/ignored_file.ts @@ -0,0 +1,3 @@ +// deno-lint-ignore-file + +function foo(): any {} diff --git a/tests/specs/lint/json/malformed.js b/tests/specs/lint/json/malformed.js new file mode 100644 index 000000000..9b64da898 --- /dev/null +++ b/tests/specs/lint/json/malformed.js @@ -0,0 +1,4 @@ +// deno-fmt-ignore-file + +// intentionally malformed file +export class A B C
\ No newline at end of file diff --git a/tests/specs/lint/jsx/__test__.jsonc b/tests/specs/lint/jsx/__test__.jsonc new file mode 100644 index 000000000..42dda30a5 --- /dev/null +++ b/tests/specs/lint/jsx/__test__.jsonc @@ -0,0 +1,16 @@ +{ + "steps": [ + { + "if": "windows", + "args": "lint main.jsx", + "output": "main_windows.out", + "exitCode": 1 + }, + { + "if": "unix", + "args": "lint main.jsx", + "output": "main_unix.out", + "exitCode": 1 + } + ] +} diff --git a/tests/specs/lint/jsx/main.jsx b/tests/specs/lint/jsx/main.jsx new file mode 100644 index 000000000..625e7d430 --- /dev/null +++ b/tests/specs/lint/jsx/main.jsx @@ -0,0 +1 @@ +const data = <div>hello</div>; diff --git a/tests/specs/lint/jsx/main_unix.out b/tests/specs/lint/jsx/main_unix.out new file mode 100644 index 000000000..08816e9fe --- /dev/null +++ b/tests/specs/lint/jsx/main_unix.out @@ -0,0 +1,12 @@ +error[no-unused-vars]: `data` is never used + --> [WILDCARD]lint/jsx/main.jsx:1:7 + | +1 | const data = <div>hello</div>; + | ^^^^ + = hint: If this is intentional, prefix it with an underscore like `_data` + + docs: https://lint.deno.land/rules/no-unused-vars + + +Found 1 problem +Checked 1 file diff --git a/tests/specs/lint/jsx/main_windows.out b/tests/specs/lint/jsx/main_windows.out new file mode 100644 index 000000000..ec6ebecad --- /dev/null +++ b/tests/specs/lint/jsx/main_windows.out @@ -0,0 +1,12 @@ +error[no-unused-vars]: `data` is never used + --> [WILDCARD]lint\jsx\main.jsx:1:7 + | +1 | const data = <div>hello</div>; + | ^^^^ + = hint: If this is intentional, prefix it with an underscore like `_data` + + docs: https://lint.deno.land/rules/no-unused-vars + + +Found 1 problem +Checked 1 file diff --git a/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/__test__.jsonc b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/__test__.jsonc new file mode 100644 index 000000000..ce4db1883 --- /dev/null +++ b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/__test__.jsonc @@ -0,0 +1,16 @@ +{ + "steps": [ + { + "if": "windows", + "args": "lint", + "output": "main_windows.out", + "exitCode": 1 + }, + { + "if": "unix", + "args": "lint", + "output": "main_unix.out", + "exitCode": 1 + } + ] +} diff --git a/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/actually_excluded.ts b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/actually_excluded.ts new file mode 100644 index 000000000..dd2bcc611 --- /dev/null +++ b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/actually_excluded.ts @@ -0,0 +1 @@ +const a = 2; diff --git a/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/deno.json b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/deno.json new file mode 100644 index 000000000..a7689f16d --- /dev/null +++ b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/deno.json @@ -0,0 +1,6 @@ +{ + "lint": { + "exclude": ["!excluded.ts"] + }, + "exclude": ["excluded.ts", "actually_excluded.ts"] +} diff --git a/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/excluded.ts b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/excluded.ts new file mode 100644 index 000000000..dd2bcc611 --- /dev/null +++ b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/excluded.ts @@ -0,0 +1 @@ +const a = 2; diff --git a/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main.ts b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main.ts new file mode 100644 index 000000000..54b82a09a --- /dev/null +++ b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main.ts @@ -0,0 +1 @@ +const a = 1; diff --git a/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main_unix.out b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main_unix.out new file mode 100644 index 000000000..39a3e7746 --- /dev/null +++ b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main_unix.out @@ -0,0 +1,24 @@ +[UNORDERED_START] +error[no-unused-vars]: `a` is never used + --> [WILDLINE]lint/opt_out_top_level_exclude_via_lint_inexclude/main.ts:1:7 + | +1 | const a = 1; + | ^ + = hint: If this is intentional, prefix it with an underscore like `_a` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `a` is never used + --> [WILDLINE]lint/opt_out_top_level_exclude_via_lint_inexclude/excluded.ts:1:7 + | +1 | const a = 2; + | ^ + = hint: If this is intentional, prefix it with an underscore like `_a` + + docs: https://lint.deno.land/rules/no-unused-vars +[UNORDERED_END] + + +Found 2 problems +Checked 2 files diff --git a/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main_windows.out b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main_windows.out new file mode 100644 index 000000000..8edf1133e --- /dev/null +++ b/tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main_windows.out @@ -0,0 +1,24 @@ +[UNORDERED_START] +error[no-unused-vars]: `a` is never used + --> [WILDLINE]lint\opt_out_top_level_exclude_via_lint_inexclude\main.ts:1:7 + | +1 | const a = 1; + | ^ + = hint: If this is intentional, prefix it with an underscore like `_a` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `a` is never used + --> [WILDLINE]lint\opt_out_top_level_exclude_via_lint_inexclude\excluded.ts:1:7 + | +1 | const a = 2; + | ^ + = hint: If this is intentional, prefix it with an underscore like `_a` + + docs: https://lint.deno.land/rules/no-unused-vars +[UNORDERED_END] + + +Found 2 problems +Checked 2 files diff --git a/tests/specs/lint/quiet/__test__.jsonc b/tests/specs/lint/quiet/__test__.jsonc new file mode 100644 index 000000000..44434f7a1 --- /dev/null +++ b/tests/specs/lint/quiet/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --quiet ", + "output": "expected_quiet.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/quiet/expected_quiet.out b/tests/specs/lint/quiet/expected_quiet.out new file mode 100644 index 000000000..91c1a29cf --- /dev/null +++ b/tests/specs/lint/quiet/expected_quiet.out @@ -0,0 +1,20 @@ +error[ban-untagged-ignore]: Ignore directive requires lint rule name(s) + --> [WILDCARD]file1.js:1:1 + | +1 | // deno-lint-ignore + | ^^^^^^^^^^^^^^^^^^^ + = hint: Add one or more lint rule names. E.g. // deno-lint-ignore adjacent-overload-signatures + + docs: https://lint.deno.land/rules/ban-untagged-ignore + + +error[no-empty]: Empty block statement + --> [WILDCARD]file1.js:2:15 + | +2 | while (false) {} + | ^^ + = hint: Add code or comment to the empty block + + docs: https://lint.deno.land/rules/no-empty + + diff --git a/tests/specs/lint/quiet/file1.js b/tests/specs/lint/quiet/file1.js new file mode 100644 index 000000000..737f26818 --- /dev/null +++ b/tests/specs/lint/quiet/file1.js @@ -0,0 +1,2 @@ +// deno-lint-ignore +while (false) {} diff --git a/tests/specs/lint/rules/__test__.jsonc b/tests/specs/lint/rules/__test__.jsonc new file mode 100644 index 000000000..d1b330b9a --- /dev/null +++ b/tests/specs/lint/rules/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --rules", + "output": "expected_rules.out", + "exitCode": 0 +} diff --git a/tests/specs/lint/rules/expected_rules.out b/tests/specs/lint/rules/expected_rules.out new file mode 100644 index 000000000..4afab7b9b --- /dev/null +++ b/tests/specs/lint/rules/expected_rules.out @@ -0,0 +1,2 @@ +Available rules: +[WILDCARD] diff --git a/tests/specs/lint/rules_quiet/__test__.jsonc b/tests/specs/lint/rules_quiet/__test__.jsonc new file mode 100644 index 000000000..0e7cc1a13 --- /dev/null +++ b/tests/specs/lint/rules_quiet/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --rules -q", + "output": "expected_rules.out", + "exitCode": 0 +} diff --git a/tests/specs/lint/rules_quiet/expected_rules.out b/tests/specs/lint/rules_quiet/expected_rules.out new file mode 100644 index 000000000..4afab7b9b --- /dev/null +++ b/tests/specs/lint/rules_quiet/expected_rules.out @@ -0,0 +1,2 @@ +Available rules: +[WILDCARD] diff --git a/tests/specs/lint/stdin/__test__.jsonc b/tests/specs/lint/stdin/__test__.jsonc new file mode 100644 index 000000000..f6c688c16 --- /dev/null +++ b/tests/specs/lint/stdin/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint main.ts", + "output": "expected_from_stdin.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/stdin/expected_from_stdin.out b/tests/specs/lint/stdin/expected_from_stdin.out new file mode 100644 index 000000000..f65331ebd --- /dev/null +++ b/tests/specs/lint/stdin/expected_from_stdin.out @@ -0,0 +1,12 @@ +error[no-explicit-any]: `any` type is not allowed + --> [WILDCARD]main.ts:1:9 + | +1 | let _a: any; + | ^^^ + = hint: Use a specific type other than `any` + + docs: https://lint.deno.land/rules/no-explicit-any + + +Found 1 problem +Checked 1 file diff --git a/tests/specs/lint/stdin/main.ts b/tests/specs/lint/stdin/main.ts new file mode 100644 index 000000000..8abcd79b8 --- /dev/null +++ b/tests/specs/lint/stdin/main.ts @@ -0,0 +1 @@ +let _a: any; diff --git a/tests/specs/lint/stdin_json/__test__.jsonc b/tests/specs/lint/stdin_json/__test__.jsonc new file mode 100644 index 000000000..a777147f6 --- /dev/null +++ b/tests/specs/lint/stdin_json/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --json main.ts", + "output": "expected_from_stdin_json.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/stdin_json/expected_from_stdin_json.out b/tests/specs/lint/stdin_json/expected_from_stdin_json.out new file mode 100644 index 000000000..5788248aa --- /dev/null +++ b/tests/specs/lint/stdin_json/expected_from_stdin_json.out @@ -0,0 +1,24 @@ +{ + "version": 1, + "diagnostics": [ + { + "filename": "[WILDCARD]main.ts", + "range": { + "start": { + "line": 1, + "col": 8, + "bytePos": 8 + }, + "end": { + "line": 1, + "col": 11, + "bytePos": 11 + } + }, + "message": "`any` type is not allowed", + "code": "no-explicit-any", + "hint": [WILDCARD] + } + ], + "errors": [] +} diff --git a/tests/specs/lint/stdin_json/main.ts b/tests/specs/lint/stdin_json/main.ts new file mode 100644 index 000000000..8abcd79b8 --- /dev/null +++ b/tests/specs/lint/stdin_json/main.ts @@ -0,0 +1 @@ +let _a: any; diff --git a/tests/specs/lint/with_config/Deno.jsonc b/tests/specs/lint/with_config/Deno.jsonc new file mode 100644 index 000000000..e9c03cca4 --- /dev/null +++ b/tests/specs/lint/with_config/Deno.jsonc @@ -0,0 +1,10 @@ +{ + "lint": { + "include": ["with_config/"], + "exclude": ["with_config/b.ts"], + "rules": { + "tags": ["recommended"], + "include": ["ban-untagged-todo"] + } + } +} diff --git a/tests/specs/lint/with_config/__test__.jsonc b/tests/specs/lint/with_config/__test__.jsonc new file mode 100644 index 000000000..1e9bf9751 --- /dev/null +++ b/tests/specs/lint/with_config/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --config Deno.jsonc with_config/", + "output": "with_config.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/with_config/with_config.out b/tests/specs/lint/with_config/with_config.out new file mode 100644 index 000000000..f527bb712 --- /dev/null +++ b/tests/specs/lint/with_config/with_config.out @@ -0,0 +1,22 @@ +error[ban-untagged-todo]: TODO should be tagged with (@username) or (#issue) + --> [WILDCARD]a.ts:1:1 + | +1 | // TODO: foo + | ^^^^^^^^^^^^ + = hint: Add a user tag or issue reference to the TODO comment, e.g. TODO(@djones), TODO(djones), TODO(#123) + + docs: https://lint.deno.land/rules/ban-untagged-todo + + +error[no-unused-vars]: `add` is never used + --> [WILDCARD]a.ts:2:10 + | +2 | function add(a: number, b: number): number { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_add` + + docs: https://lint.deno.land/rules/no-unused-vars + + +Found 2 problems +Checked 1 file diff --git a/tests/specs/lint/with_config/with_config/a.ts b/tests/specs/lint/with_config/with_config/a.ts new file mode 100644 index 000000000..c378218a3 --- /dev/null +++ b/tests/specs/lint/with_config/with_config/a.ts @@ -0,0 +1,4 @@ +// TODO: foo +function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/lint/with_config/with_config/b.ts b/tests/specs/lint/with_config/with_config/b.ts new file mode 100644 index 000000000..d5647067e --- /dev/null +++ b/tests/specs/lint/with_config/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/tests/specs/lint/with_config_and_flags/Deno.jsonc b/tests/specs/lint/with_config_and_flags/Deno.jsonc new file mode 100644 index 000000000..e9c03cca4 --- /dev/null +++ b/tests/specs/lint/with_config_and_flags/Deno.jsonc @@ -0,0 +1,10 @@ +{ + "lint": { + "include": ["with_config/"], + "exclude": ["with_config/b.ts"], + "rules": { + "tags": ["recommended"], + "include": ["ban-untagged-todo"] + } + } +} diff --git a/tests/specs/lint/with_config_and_flags/__test__.jsonc b/tests/specs/lint/with_config_and_flags/__test__.jsonc new file mode 100644 index 000000000..926d1983b --- /dev/null +++ b/tests/specs/lint/with_config_and_flags/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --config Deno.jsonc --ignore=with_config/a.ts", + "output": "with_config_and_flags.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/with_config_and_flags/with_config/a.ts b/tests/specs/lint/with_config_and_flags/with_config/a.ts new file mode 100644 index 000000000..c378218a3 --- /dev/null +++ b/tests/specs/lint/with_config_and_flags/with_config/a.ts @@ -0,0 +1,4 @@ +// TODO: foo +function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/lint/with_config_and_flags/with_config/b.ts b/tests/specs/lint/with_config_and_flags/with_config/b.ts new file mode 100644 index 000000000..d5647067e --- /dev/null +++ b/tests/specs/lint/with_config_and_flags/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/tests/specs/lint/with_config_and_flags/with_config_and_flags.out b/tests/specs/lint/with_config_and_flags/with_config_and_flags.out new file mode 100644 index 000000000..78e21ef8d --- /dev/null +++ b/tests/specs/lint/with_config_and_flags/with_config_and_flags.out @@ -0,0 +1,22 @@ +error[ban-untagged-todo]: TODO should be tagged with (@username) or (#issue) + --> [WILDCARD]b.ts:1:1 + | +1 | // TODO: this file should be ignored + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = hint: Add a user tag or issue reference to the TODO comment, e.g. TODO(@djones), TODO(djones), TODO(#123) + + docs: https://lint.deno.land/rules/ban-untagged-todo + + +error[no-unused-vars]: `subtract` is never used + --> [WILDCARD]b.ts:2:10 + | +2 | function subtract(a: number, b: number): number { + | ^^^^^^^^ + = hint: If this is intentional, prefix it with an underscore like `_subtract` + + docs: https://lint.deno.land/rules/no-unused-vars + + +Found 2 problems +Checked 1 file diff --git a/tests/specs/lint/with_config_without_args/Deno.no_tags.jsonc b/tests/specs/lint/with_config_without_args/Deno.no_tags.jsonc new file mode 100644 index 000000000..b63600a90 --- /dev/null +++ b/tests/specs/lint/with_config_without_args/Deno.no_tags.jsonc @@ -0,0 +1,15 @@ +{ + "lint": { + "include": [ + "with_config/" + ], + "exclude": [ + "with_config/b.ts" + ], + "rules": { + "include": [ + "ban-untagged-todo" + ] + } + } +} diff --git a/tests/specs/lint/with_config_without_args/__test__.jsonc b/tests/specs/lint/with_config_without_args/__test__.jsonc new file mode 100644 index 000000000..9a1ae7cb4 --- /dev/null +++ b/tests/specs/lint/with_config_without_args/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --config Deno.no_tags.jsonc with_config/", + "output": "with_config_without_tags.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/with_config_without_args/with_config/a.ts b/tests/specs/lint/with_config_without_args/with_config/a.ts new file mode 100644 index 000000000..c378218a3 --- /dev/null +++ b/tests/specs/lint/with_config_without_args/with_config/a.ts @@ -0,0 +1,4 @@ +// TODO: foo +function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/lint/with_config_without_args/with_config/b.ts b/tests/specs/lint/with_config_without_args/with_config/b.ts new file mode 100644 index 000000000..d5647067e --- /dev/null +++ b/tests/specs/lint/with_config_without_args/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/tests/specs/lint/with_config_without_args/with_config_without_tags.out b/tests/specs/lint/with_config_without_args/with_config_without_tags.out new file mode 100644 index 000000000..f527bb712 --- /dev/null +++ b/tests/specs/lint/with_config_without_args/with_config_without_tags.out @@ -0,0 +1,22 @@ +error[ban-untagged-todo]: TODO should be tagged with (@username) or (#issue) + --> [WILDCARD]a.ts:1:1 + | +1 | // TODO: foo + | ^^^^^^^^^^^^ + = hint: Add a user tag or issue reference to the TODO comment, e.g. TODO(@djones), TODO(djones), TODO(#123) + + docs: https://lint.deno.land/rules/ban-untagged-todo + + +error[no-unused-vars]: `add` is never used + --> [WILDCARD]a.ts:2:10 + | +2 | function add(a: number, b: number): number { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_add` + + docs: https://lint.deno.land/rules/no-unused-vars + + +Found 2 problems +Checked 1 file diff --git a/tests/specs/lint/with_glob_config/__test__.jsonc b/tests/specs/lint/with_glob_config/__test__.jsonc new file mode 100644 index 000000000..578ed2f85 --- /dev/null +++ b/tests/specs/lint/with_glob_config/__test__.jsonc @@ -0,0 +1,16 @@ +{ + "steps": [ + { + "if": "windows", + "args": "lint --config deno.glob.json", + "output": "with_glob_config_windows.out", + "exitCode": 1 + }, + { + "if": "unix", + "args": "lint --config deno.glob.json", + "output": "with_glob_config_unix.out", + "exitCode": 1 + } + ] +} diff --git a/tests/specs/lint/with_glob_config/deno.glob.json b/tests/specs/lint/with_glob_config/deno.glob.json new file mode 100644 index 000000000..f6781b0d8 --- /dev/null +++ b/tests/specs/lint/with_glob_config/deno.glob.json @@ -0,0 +1,11 @@ +{ + "lint": { + "include": [ + "glob/data/test1.?s", + "glob/nested/foo/*.ts", + "glob/nested/fizz/*.ts", + "glob/pages/[id].ts" + ], + "exclude": ["glob/nested/**/*bazz.ts"] + } +} diff --git a/tests/specs/lint/with_glob_config/glob/data/tes.ts b/tests/specs/lint/with_glob_config/glob/data/tes.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/data/tes.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/data/test1.js b/tests/specs/lint/with_glob_config/glob/data/test1.js new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/data/test1.js @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/data/test1.ts b/tests/specs/lint/with_glob_config/glob/data/test1.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/data/test1.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/data/test12.ts b/tests/specs/lint/with_glob_config/glob/data/test12.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/data/test12.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/nested/fizz/bar.ts b/tests/specs/lint/with_glob_config/glob/nested/fizz/bar.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/nested/fizz/bar.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/nested/fizz/bazz.ts b/tests/specs/lint/with_glob_config/glob/nested/fizz/bazz.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/nested/fizz/bazz.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/nested/fizz/fizz.ts b/tests/specs/lint/with_glob_config/glob/nested/fizz/fizz.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/nested/fizz/fizz.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/nested/fizz/foo.ts b/tests/specs/lint/with_glob_config/glob/nested/fizz/foo.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/nested/fizz/foo.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/nested/foo/bar.ts b/tests/specs/lint/with_glob_config/glob/nested/foo/bar.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/nested/foo/bar.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/nested/foo/bazz.ts b/tests/specs/lint/with_glob_config/glob/nested/foo/bazz.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/nested/foo/bazz.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/nested/foo/fizz.ts b/tests/specs/lint/with_glob_config/glob/nested/foo/fizz.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/nested/foo/fizz.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/nested/foo/foo.ts b/tests/specs/lint/with_glob_config/glob/nested/foo/foo.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/nested/foo/foo.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/glob/pages/[id].ts b/tests/specs/lint/with_glob_config/glob/pages/[id].ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config/glob/pages/[id].ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config/with_glob_config_unix.out b/tests/specs/lint/with_glob_config/with_glob_config_unix.out new file mode 100644 index 000000000..fad285cbe --- /dev/null +++ b/tests/specs/lint/with_glob_config/with_glob_config_unix.out @@ -0,0 +1,94 @@ +[UNORDERED_START] +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config/glob/nested/fizz/bar.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config/glob/nested/foo/foo.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config/glob/nested/fizz/foo.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config/glob/nested/foo/bar.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config/glob/data/test1.js:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config/glob/nested/foo/fizz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config/glob/nested/fizz/fizz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config/glob/pages/[id].ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config/glob/data/test1.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars +[UNORDERED_END] + + +Found 9 problems +Checked 9 files diff --git a/tests/specs/lint/with_glob_config/with_glob_config_windows.out b/tests/specs/lint/with_glob_config/with_glob_config_windows.out new file mode 100644 index 000000000..2ba078791 --- /dev/null +++ b/tests/specs/lint/with_glob_config/with_glob_config_windows.out @@ -0,0 +1,94 @@ +[UNORDERED_START] +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config\glob\nested\fizz\bar.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config\glob\nested\foo\foo.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config\glob\nested\fizz\foo.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config\glob\nested\foo\bar.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config\glob\data\test1.js:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config\glob\nested\foo\fizz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config\glob\nested\fizz\fizz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config\glob\pages\[id].ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config\glob\data\test1.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars +[UNORDERED_END] + + +Found 9 problems +Checked 9 files diff --git a/tests/specs/lint/with_glob_config_and_flags/__test__.jsonc b/tests/specs/lint/with_glob_config_and_flags/__test__.jsonc new file mode 100644 index 000000000..3aed48ee8 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/__test__.jsonc @@ -0,0 +1,16 @@ +{ + "steps": [ + { + "if": "windows", + "args": "lint --config deno.glob.json --ignore=gleb/nested/**/bar.ts", + "output": "with_glob_config_and_flags_windows.out", + "exitCode": 1 + }, + { + "if": "unix", + "args": "lint --config deno.glob.json --ignore=gleb/nested/**/bar.ts", + "output": "with_glob_config_and_flags_unix.out", + "exitCode": 1 + } + ] +} diff --git a/tests/specs/lint/with_glob_config_and_flags/deno.glob.json b/tests/specs/lint/with_glob_config_and_flags/deno.glob.json new file mode 100644 index 000000000..f6781b0d8 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/deno.glob.json @@ -0,0 +1,11 @@ +{ + "lint": { + "include": [ + "glob/data/test1.?s", + "glob/nested/foo/*.ts", + "glob/nested/fizz/*.ts", + "glob/pages/[id].ts" + ], + "exclude": ["glob/nested/**/*bazz.ts"] + } +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/data/tes.ts b/tests/specs/lint/with_glob_config_and_flags/glob/data/tes.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/data/tes.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/data/test1.js b/tests/specs/lint/with_glob_config_and_flags/glob/data/test1.js new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/data/test1.js @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/data/test1.ts b/tests/specs/lint/with_glob_config_and_flags/glob/data/test1.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/data/test1.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/data/test12.ts b/tests/specs/lint/with_glob_config_and_flags/glob/data/test12.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/data/test12.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/bar.ts b/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/bar.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/bar.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/bazz.ts b/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/bazz.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/bazz.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/fizz.ts b/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/fizz.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/fizz.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/foo.ts b/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/foo.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/foo.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/bar.ts b/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/bar.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/bar.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/bazz.ts b/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/bazz.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/bazz.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/fizz.ts b/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/fizz.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/fizz.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/foo.ts b/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/foo.ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/foo.ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/glob/pages/[id].ts b/tests/specs/lint/with_glob_config_and_flags/glob/pages/[id].ts new file mode 100644 index 000000000..6940729e9 --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/glob/pages/[id].ts @@ -0,0 +1,2 @@ +function foo() { +} diff --git a/tests/specs/lint/with_glob_config_and_flags/with_glob_config_and_flags_unix.out b/tests/specs/lint/with_glob_config_and_flags/with_glob_config_and_flags_unix.out new file mode 100644 index 000000000..9afca955b --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/with_glob_config_and_flags_unix.out @@ -0,0 +1,114 @@ +[UNORDERED_START] +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config_and_flags/glob/nested/fizz/bar.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config_and_flags/glob/nested/foo/bazz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config_and_flags/glob/nested/foo/foo.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config_and_flags/glob/data/test1.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config_and_flags/glob/nested/foo/bar.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config_and_flags/glob/nested/fizz/bazz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config_and_flags/glob/nested/fizz/fizz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config_and_flags/glob/nested/fizz/foo.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config_and_flags/glob/data/test1.js:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config_and_flags/glob/nested/foo/fizz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint/with_glob_config_and_flags/glob/pages/[id].ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars +[UNORDERED_END] + + +Found 11 problems +Checked 11 files diff --git a/tests/specs/lint/with_glob_config_and_flags/with_glob_config_and_flags_windows.out b/tests/specs/lint/with_glob_config_and_flags/with_glob_config_and_flags_windows.out new file mode 100644 index 000000000..9446796ab --- /dev/null +++ b/tests/specs/lint/with_glob_config_and_flags/with_glob_config_and_flags_windows.out @@ -0,0 +1,114 @@ +[UNORDERED_START] +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config_and_flags\glob\nested\fizz\bar.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config_and_flags\glob\nested\foo\bazz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config_and_flags\glob\nested\foo\foo.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config_and_flags\glob\data\test1.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config_and_flags\glob\nested\foo\bar.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config_and_flags\glob\nested\fizz\bazz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config_and_flags\glob\nested\fizz\fizz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config_and_flags\glob\nested\fizz\foo.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config_and_flags\glob\data\test1.js:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config_and_flags\glob\nested\foo\fizz.ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars + + +error[no-unused-vars]: `foo` is never used + --> [WILDLINE]lint\with_glob_config_and_flags\glob\pages\[id].ts:1:10 + | +1 | function foo() { + | ^^^ + = hint: If this is intentional, prefix it with an underscore like `_foo` + + docs: https://lint.deno.land/rules/no-unused-vars +[UNORDERED_END] + + +Found 11 problems +Checked 11 files diff --git a/tests/specs/lint/with_malformed_config/Deno.malformed.jsonc b/tests/specs/lint/with_malformed_config/Deno.malformed.jsonc new file mode 100644 index 000000000..fa71cd851 --- /dev/null +++ b/tests/specs/lint/with_malformed_config/Deno.malformed.jsonc @@ -0,0 +1,11 @@ +{ + "lint": { + "include": ["with_config/"], + "exclude": ["with_config/b.ts"], + "dont_know_this_field": {}, + "rules": { + "tags": ["recommended"], + "include": ["ban-untagged-todo"] + } + } +} diff --git a/tests/specs/lint/with_malformed_config/__test__.jsonc b/tests/specs/lint/with_malformed_config/__test__.jsonc new file mode 100644 index 000000000..86a47eda4 --- /dev/null +++ b/tests/specs/lint/with_malformed_config/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --config Deno.malformed.jsonc", + "output": "with_malformed_config.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/with_malformed_config/with_malformed_config.out b/tests/specs/lint/with_malformed_config/with_malformed_config.out new file mode 100644 index 000000000..1c0f0fff6 --- /dev/null +++ b/tests/specs/lint/with_malformed_config/with_malformed_config.out @@ -0,0 +1,4 @@ +error: Failed to parse "lint" configuration + +Caused by: + unknown field `dont_know_this_field`, expected one of `rules`, `include`, `exclude`, `files`, `report` diff --git a/tests/specs/lint/with_malformed_config2/Deno.malformed2.jsonc b/tests/specs/lint/with_malformed_config2/Deno.malformed2.jsonc new file mode 100644 index 000000000..fa71cd851 --- /dev/null +++ b/tests/specs/lint/with_malformed_config2/Deno.malformed2.jsonc @@ -0,0 +1,11 @@ +{ + "lint": { + "include": ["with_config/"], + "exclude": ["with_config/b.ts"], + "dont_know_this_field": {}, + "rules": { + "tags": ["recommended"], + "include": ["ban-untagged-todo"] + } + } +} diff --git a/tests/specs/lint/with_malformed_config2/__test__.jsonc b/tests/specs/lint/with_malformed_config2/__test__.jsonc new file mode 100644 index 000000000..3210f5a59 --- /dev/null +++ b/tests/specs/lint/with_malformed_config2/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --config Deno.malformed2.jsonc", + "output": "with_malformed_config2.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/with_malformed_config2/with_malformed_config2.out b/tests/specs/lint/with_malformed_config2/with_malformed_config2.out new file mode 100644 index 000000000..1c0f0fff6 --- /dev/null +++ b/tests/specs/lint/with_malformed_config2/with_malformed_config2.out @@ -0,0 +1,4 @@ +error: Failed to parse "lint" configuration + +Caused by: + unknown field `dont_know_this_field`, expected one of `rules`, `include`, `exclude`, `files`, `report` diff --git a/tests/specs/lint/with_report_config/Deno.compact.format.jsonc b/tests/specs/lint/with_report_config/Deno.compact.format.jsonc new file mode 100644 index 000000000..f3487501a --- /dev/null +++ b/tests/specs/lint/with_report_config/Deno.compact.format.jsonc @@ -0,0 +1,11 @@ +{ + "lint": { + "include": ["with_config/"], + "exclude": ["with_config/b.ts"], + "rules": { + "tags": ["recommended"], + "include": ["ban-untagged-todo"] + }, + "report": "compact" + } +} diff --git a/tests/specs/lint/with_report_config/__test__.jsonc b/tests/specs/lint/with_report_config/__test__.jsonc new file mode 100644 index 000000000..2b5c21cce --- /dev/null +++ b/tests/specs/lint/with_report_config/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --config Deno.compact.format.jsonc with_config/", + "output": "with_report_config_compact.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/with_report_config/with_config/a.ts b/tests/specs/lint/with_report_config/with_config/a.ts new file mode 100644 index 000000000..c378218a3 --- /dev/null +++ b/tests/specs/lint/with_report_config/with_config/a.ts @@ -0,0 +1,4 @@ +// TODO: foo +function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/lint/with_report_config/with_config/b.ts b/tests/specs/lint/with_report_config/with_config/b.ts new file mode 100644 index 000000000..d5647067e --- /dev/null +++ b/tests/specs/lint/with_report_config/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/tests/specs/lint/with_report_config/with_report_config_compact.out b/tests/specs/lint/with_report_config/with_report_config_compact.out new file mode 100644 index 000000000..fe1241264 --- /dev/null +++ b/tests/specs/lint/with_report_config/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/tests/specs/lint/with_report_config_override/Deno.compact.format.jsonc b/tests/specs/lint/with_report_config_override/Deno.compact.format.jsonc new file mode 100644 index 000000000..f3487501a --- /dev/null +++ b/tests/specs/lint/with_report_config_override/Deno.compact.format.jsonc @@ -0,0 +1,11 @@ +{ + "lint": { + "include": ["with_config/"], + "exclude": ["with_config/b.ts"], + "rules": { + "tags": ["recommended"], + "include": ["ban-untagged-todo"] + }, + "report": "compact" + } +} diff --git a/tests/specs/lint/with_report_config_override/__test__.jsonc b/tests/specs/lint/with_report_config_override/__test__.jsonc new file mode 100644 index 000000000..5b1739af3 --- /dev/null +++ b/tests/specs/lint/with_report_config_override/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint --config Deno.compact.format.jsonc with_config/ --json", + "output": "with_report_config_override.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/with_report_config_override/with_config/a.ts b/tests/specs/lint/with_report_config_override/with_config/a.ts new file mode 100644 index 000000000..c378218a3 --- /dev/null +++ b/tests/specs/lint/with_report_config_override/with_config/a.ts @@ -0,0 +1,4 @@ +// TODO: foo +function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/lint/with_report_config_override/with_config/b.ts b/tests/specs/lint/with_report_config_override/with_config/b.ts new file mode 100644 index 000000000..d5647067e --- /dev/null +++ b/tests/specs/lint/with_report_config_override/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/tests/specs/lint/with_report_config_override/with_report_config_override.out b/tests/specs/lint/with_report_config_override/with_report_config_override.out new file mode 100644 index 000000000..ad32e3123 --- /dev/null +++ b/tests/specs/lint/with_report_config_override/with_report_config_override.out @@ -0,0 +1,42 @@ +{ + "version": 1, + "diagnostics": [ + { + "filename": "[WILDCARD]a.ts", + "range": { + "start": { + "line": 1, + "col": 0, + "bytePos": 0 + }, + "end": { + "line": 1, + "col": 12, + "bytePos": 12 + } + }, + "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)" + }, + { + "filename": "[WILDCARD]a.ts", + "range": { + "start": { + "line": 2, + "col": 9, + "bytePos": 22 + }, + "end": { + "line": 2, + "col": 12, + "bytePos": 25 + } + }, + "message": "`add` is never used", + "code": "no-unused-vars", + "hint": "If this is intentional, prefix it with an underscore like `_add`" + } + ], + "errors": [] +} |