From 36a1a79f175b2df31d8ba5d7e121239c3b7e74ea Mon Sep 17 00:00:00 2001 From: HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> Date: Mon, 16 Sep 2024 20:45:25 +0300 Subject: chore: deprecate lint itests (#25655) --- tests/integration/lint_tests.rs | 267 --------------------- tests/integration/mod.rs | 2 - tests/specs/lint/all/__test__.jsonc | 5 + tests/specs/lint/all/expected.out | 3 + tests/specs/lint/all/file1.js | 2 + tests/specs/lint/all/file2.ts | 6 + tests/specs/lint/all/ignored_file.ts | 3 + tests/specs/lint/compact/__test__.jsonc | 5 + tests/specs/lint/compact/expected_compact.out | 4 + tests/specs/lint/compact/file1.js | 2 + tests/specs/lint/glob/__test__.jsonc | 5 + tests/specs/lint/glob/expected_glob.out | 3 + tests/specs/lint/glob/with_config/a.ts | 4 + tests/specs/lint/glob/with_config/b.ts | 4 + tests/specs/lint/glob/without_config/file1.js | 2 + tests/specs/lint/glob/without_config/file2.ts | 6 + .../specs/lint/glob/without_config/ignored_file.ts | 3 + tests/specs/lint/glob/without_config/malformed.js | 4 + tests/specs/lint/ignore/__test__.jsonc | 5 + tests/specs/lint/ignore/expected_ignore.out | 3 + tests/specs/lint/ignore/without_config/file1.js | 2 + tests/specs/lint/ignore/without_config/file2.ts | 6 + .../lint/ignore/without_config/ignored_file.ts | 3 + .../specs/lint/ignore/without_config/malformed.js | 4 + .../lint/ignore_unexplicit_files/__test__.jsonc | 5 + tests/specs/lint/ignore_unexplicit_files/lint.out | 1 + tests/specs/lint/json/__test__.jsonc | 5 + tests/specs/lint/json/expected_json.out | 65 +++++ tests/specs/lint/json/file1.js | 2 + tests/specs/lint/json/file2.ts | 6 + tests/specs/lint/json/ignored_file.ts | 3 + tests/specs/lint/json/malformed.js | 4 + tests/specs/lint/jsx/__test__.jsonc | 16 ++ tests/specs/lint/jsx/main.jsx | 1 + tests/specs/lint/jsx/main_unix.out | 12 + tests/specs/lint/jsx/main_windows.out | 12 + .../__test__.jsonc | 16 ++ .../actually_excluded.ts | 1 + .../deno.json | 6 + .../excluded.ts | 1 + .../main.ts | 1 + .../main_unix.out | 24 ++ .../main_windows.out | 24 ++ tests/specs/lint/quiet/__test__.jsonc | 5 + tests/specs/lint/quiet/expected_quiet.out | 20 ++ tests/specs/lint/quiet/file1.js | 2 + tests/specs/lint/rules/__test__.jsonc | 5 + tests/specs/lint/rules/expected_rules.out | 2 + tests/specs/lint/rules_quiet/__test__.jsonc | 5 + tests/specs/lint/rules_quiet/expected_rules.out | 2 + tests/specs/lint/stdin/__test__.jsonc | 5 + tests/specs/lint/stdin/expected_from_stdin.out | 12 + tests/specs/lint/stdin/main.ts | 1 + tests/specs/lint/stdin_json/__test__.jsonc | 5 + .../lint/stdin_json/expected_from_stdin_json.out | 24 ++ tests/specs/lint/stdin_json/main.ts | 1 + tests/specs/lint/with_config/Deno.jsonc | 10 + tests/specs/lint/with_config/__test__.jsonc | 5 + tests/specs/lint/with_config/with_config.out | 22 ++ tests/specs/lint/with_config/with_config/a.ts | 4 + tests/specs/lint/with_config/with_config/b.ts | 4 + tests/specs/lint/with_config_and_flags/Deno.jsonc | 10 + .../lint/with_config_and_flags/__test__.jsonc | 5 + .../lint/with_config_and_flags/with_config/a.ts | 4 + .../lint/with_config_and_flags/with_config/b.ts | 4 + .../with_config_and_flags.out | 22 ++ .../with_config_without_args/Deno.no_tags.jsonc | 15 ++ .../lint/with_config_without_args/__test__.jsonc | 5 + .../lint/with_config_without_args/with_config/a.ts | 4 + .../lint/with_config_without_args/with_config/b.ts | 4 + .../with_config_without_tags.out | 22 ++ tests/specs/lint/with_glob_config/__test__.jsonc | 16 ++ tests/specs/lint/with_glob_config/deno.glob.json | 11 + tests/specs/lint/with_glob_config/glob/data/tes.ts | 2 + .../specs/lint/with_glob_config/glob/data/test1.js | 2 + .../specs/lint/with_glob_config/glob/data/test1.ts | 2 + .../lint/with_glob_config/glob/data/test12.ts | 2 + .../lint/with_glob_config/glob/nested/fizz/bar.ts | 2 + .../lint/with_glob_config/glob/nested/fizz/bazz.ts | 2 + .../lint/with_glob_config/glob/nested/fizz/fizz.ts | 2 + .../lint/with_glob_config/glob/nested/fizz/foo.ts | 2 + .../lint/with_glob_config/glob/nested/foo/bar.ts | 2 + .../lint/with_glob_config/glob/nested/foo/bazz.ts | 2 + .../lint/with_glob_config/glob/nested/foo/fizz.ts | 2 + .../lint/with_glob_config/glob/nested/foo/foo.ts | 2 + .../specs/lint/with_glob_config/glob/pages/[id].ts | 2 + .../with_glob_config/with_glob_config_unix.out | 94 ++++++++ .../with_glob_config/with_glob_config_windows.out | 94 ++++++++ .../lint/with_glob_config_and_flags/__test__.jsonc | 16 ++ .../lint/with_glob_config_and_flags/deno.glob.json | 11 + .../with_glob_config_and_flags/glob/data/tes.ts | 2 + .../with_glob_config_and_flags/glob/data/test1.js | 2 + .../with_glob_config_and_flags/glob/data/test1.ts | 2 + .../with_glob_config_and_flags/glob/data/test12.ts | 2 + .../glob/nested/fizz/bar.ts | 2 + .../glob/nested/fizz/bazz.ts | 2 + .../glob/nested/fizz/fizz.ts | 2 + .../glob/nested/fizz/foo.ts | 2 + .../glob/nested/foo/bar.ts | 2 + .../glob/nested/foo/bazz.ts | 2 + .../glob/nested/foo/fizz.ts | 2 + .../glob/nested/foo/foo.ts | 2 + .../with_glob_config_and_flags/glob/pages/[id].ts | 2 + .../with_glob_config_and_flags_unix.out | 114 +++++++++ .../with_glob_config_and_flags_windows.out | 114 +++++++++ .../with_malformed_config/Deno.malformed.jsonc | 11 + .../lint/with_malformed_config/__test__.jsonc | 5 + .../with_malformed_config.out | 4 + .../with_malformed_config2/Deno.malformed2.jsonc | 11 + .../lint/with_malformed_config2/__test__.jsonc | 5 + .../with_malformed_config2.out | 4 + .../with_report_config/Deno.compact.format.jsonc | 11 + tests/specs/lint/with_report_config/__test__.jsonc | 5 + .../specs/lint/with_report_config/with_config/a.ts | 4 + .../specs/lint/with_report_config/with_config/b.ts | 4 + .../with_report_config_compact.out | 4 + .../Deno.compact.format.jsonc | 11 + .../with_report_config_override/__test__.jsonc | 5 + .../with_report_config_override/with_config/a.ts | 4 + .../with_report_config_override/with_config/b.ts | 4 + .../with_report_config_override.out | 42 ++++ tests/testdata/lint/Deno.compact.format.jsonc | 11 - tests/testdata/lint/Deno.jsonc | 10 - tests/testdata/lint/Deno.malformed.jsonc | 11 - tests/testdata/lint/Deno.malformed2.jsonc | 11 - tests/testdata/lint/Deno.no_tags.jsonc | 15 -- tests/testdata/lint/deno.glob.json | 11 - tests/testdata/lint/expected.out | 3 - tests/testdata/lint/expected_compact.out | 4 - tests/testdata/lint/expected_from_stdin.out | 12 - tests/testdata/lint/expected_from_stdin_json.out | 24 -- tests/testdata/lint/expected_glob.out | 3 - tests/testdata/lint/expected_ignore.out | 3 - tests/testdata/lint/expected_json.out | 65 ----- tests/testdata/lint/expected_quiet.out | 20 -- tests/testdata/lint/expected_rules.out | 2 - tests/testdata/lint/expected_verbose.out | 3 - tests/testdata/lint/glob/data/tes.ts | 3 - tests/testdata/lint/glob/data/test1.js | 3 - tests/testdata/lint/glob/data/test1.ts | 3 - tests/testdata/lint/glob/data/test12.ts | 3 - tests/testdata/lint/glob/nested/fizz/bar.ts | 3 - tests/testdata/lint/glob/nested/fizz/bazz.ts | 3 - tests/testdata/lint/glob/nested/fizz/fizz.ts | 2 - tests/testdata/lint/glob/nested/fizz/foo.ts | 3 - tests/testdata/lint/glob/nested/foo/bar.ts | 3 - tests/testdata/lint/glob/nested/foo/bazz.ts | 3 - tests/testdata/lint/glob/nested/foo/fizz.ts | 3 - tests/testdata/lint/glob/nested/foo/foo.ts | 3 - tests/testdata/lint/glob/pages/[id].ts | 3 - tests/testdata/lint/with_config.out | 22 -- tests/testdata/lint/with_config/a.ts | 4 - tests/testdata/lint/with_config/b.ts | 4 - tests/testdata/lint/with_config_and_flags.out | 22 -- tests/testdata/lint/with_config_without_tags.out | 22 -- tests/testdata/lint/with_malformed_config.out | 4 - tests/testdata/lint/with_malformed_config2.out | 4 - tests/testdata/lint/with_report_config_compact.out | 4 - .../testdata/lint/with_report_config_override.out | 42 ---- tests/testdata/lint/without_config/file1.js | 2 - tests/testdata/lint/without_config/file2.ts | 6 - tests/testdata/lint/without_config/ignored_file.ts | 3 - tests/testdata/lint/without_config/malformed.js | 4 - tools/lint.js | 1 - 164 files changed, 1174 insertions(+), 659 deletions(-) delete mode 100644 tests/integration/lint_tests.rs create mode 100644 tests/specs/lint/all/__test__.jsonc create mode 100644 tests/specs/lint/all/expected.out create mode 100644 tests/specs/lint/all/file1.js create mode 100644 tests/specs/lint/all/file2.ts create mode 100644 tests/specs/lint/all/ignored_file.ts create mode 100644 tests/specs/lint/compact/__test__.jsonc create mode 100644 tests/specs/lint/compact/expected_compact.out create mode 100644 tests/specs/lint/compact/file1.js create mode 100644 tests/specs/lint/glob/__test__.jsonc create mode 100644 tests/specs/lint/glob/expected_glob.out create mode 100644 tests/specs/lint/glob/with_config/a.ts create mode 100644 tests/specs/lint/glob/with_config/b.ts create mode 100644 tests/specs/lint/glob/without_config/file1.js create mode 100644 tests/specs/lint/glob/without_config/file2.ts create mode 100644 tests/specs/lint/glob/without_config/ignored_file.ts create mode 100644 tests/specs/lint/glob/without_config/malformed.js create mode 100644 tests/specs/lint/ignore/__test__.jsonc create mode 100644 tests/specs/lint/ignore/expected_ignore.out create mode 100644 tests/specs/lint/ignore/without_config/file1.js create mode 100644 tests/specs/lint/ignore/without_config/file2.ts create mode 100644 tests/specs/lint/ignore/without_config/ignored_file.ts create mode 100644 tests/specs/lint/ignore/without_config/malformed.js create mode 100644 tests/specs/lint/ignore_unexplicit_files/__test__.jsonc create mode 100644 tests/specs/lint/ignore_unexplicit_files/lint.out create mode 100644 tests/specs/lint/json/__test__.jsonc create mode 100644 tests/specs/lint/json/expected_json.out create mode 100644 tests/specs/lint/json/file1.js create mode 100644 tests/specs/lint/json/file2.ts create mode 100644 tests/specs/lint/json/ignored_file.ts create mode 100644 tests/specs/lint/json/malformed.js create mode 100644 tests/specs/lint/jsx/__test__.jsonc create mode 100644 tests/specs/lint/jsx/main.jsx create mode 100644 tests/specs/lint/jsx/main_unix.out create mode 100644 tests/specs/lint/jsx/main_windows.out create mode 100644 tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/__test__.jsonc create mode 100644 tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/actually_excluded.ts create mode 100644 tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/deno.json create mode 100644 tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/excluded.ts create mode 100644 tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main.ts create mode 100644 tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main_unix.out create mode 100644 tests/specs/lint/opt_out_top_level_exclude_via_lint_inexclude/main_windows.out create mode 100644 tests/specs/lint/quiet/__test__.jsonc create mode 100644 tests/specs/lint/quiet/expected_quiet.out create mode 100644 tests/specs/lint/quiet/file1.js create mode 100644 tests/specs/lint/rules/__test__.jsonc create mode 100644 tests/specs/lint/rules/expected_rules.out create mode 100644 tests/specs/lint/rules_quiet/__test__.jsonc create mode 100644 tests/specs/lint/rules_quiet/expected_rules.out create mode 100644 tests/specs/lint/stdin/__test__.jsonc create mode 100644 tests/specs/lint/stdin/expected_from_stdin.out create mode 100644 tests/specs/lint/stdin/main.ts create mode 100644 tests/specs/lint/stdin_json/__test__.jsonc create mode 100644 tests/specs/lint/stdin_json/expected_from_stdin_json.out create mode 100644 tests/specs/lint/stdin_json/main.ts create mode 100644 tests/specs/lint/with_config/Deno.jsonc create mode 100644 tests/specs/lint/with_config/__test__.jsonc create mode 100644 tests/specs/lint/with_config/with_config.out create mode 100644 tests/specs/lint/with_config/with_config/a.ts create mode 100644 tests/specs/lint/with_config/with_config/b.ts create mode 100644 tests/specs/lint/with_config_and_flags/Deno.jsonc create mode 100644 tests/specs/lint/with_config_and_flags/__test__.jsonc create mode 100644 tests/specs/lint/with_config_and_flags/with_config/a.ts create mode 100644 tests/specs/lint/with_config_and_flags/with_config/b.ts create mode 100644 tests/specs/lint/with_config_and_flags/with_config_and_flags.out create mode 100644 tests/specs/lint/with_config_without_args/Deno.no_tags.jsonc create mode 100644 tests/specs/lint/with_config_without_args/__test__.jsonc create mode 100644 tests/specs/lint/with_config_without_args/with_config/a.ts create mode 100644 tests/specs/lint/with_config_without_args/with_config/b.ts create mode 100644 tests/specs/lint/with_config_without_args/with_config_without_tags.out create mode 100644 tests/specs/lint/with_glob_config/__test__.jsonc create mode 100644 tests/specs/lint/with_glob_config/deno.glob.json create mode 100644 tests/specs/lint/with_glob_config/glob/data/tes.ts create mode 100644 tests/specs/lint/with_glob_config/glob/data/test1.js create mode 100644 tests/specs/lint/with_glob_config/glob/data/test1.ts create mode 100644 tests/specs/lint/with_glob_config/glob/data/test12.ts create mode 100644 tests/specs/lint/with_glob_config/glob/nested/fizz/bar.ts create mode 100644 tests/specs/lint/with_glob_config/glob/nested/fizz/bazz.ts create mode 100644 tests/specs/lint/with_glob_config/glob/nested/fizz/fizz.ts create mode 100644 tests/specs/lint/with_glob_config/glob/nested/fizz/foo.ts create mode 100644 tests/specs/lint/with_glob_config/glob/nested/foo/bar.ts create mode 100644 tests/specs/lint/with_glob_config/glob/nested/foo/bazz.ts create mode 100644 tests/specs/lint/with_glob_config/glob/nested/foo/fizz.ts create mode 100644 tests/specs/lint/with_glob_config/glob/nested/foo/foo.ts create mode 100644 tests/specs/lint/with_glob_config/glob/pages/[id].ts create mode 100644 tests/specs/lint/with_glob_config/with_glob_config_unix.out create mode 100644 tests/specs/lint/with_glob_config/with_glob_config_windows.out create mode 100644 tests/specs/lint/with_glob_config_and_flags/__test__.jsonc create mode 100644 tests/specs/lint/with_glob_config_and_flags/deno.glob.json create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/data/tes.ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/data/test1.js create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/data/test1.ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/data/test12.ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/bar.ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/bazz.ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/fizz.ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/nested/fizz/foo.ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/bar.ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/bazz.ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/fizz.ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/nested/foo/foo.ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/glob/pages/[id].ts create mode 100644 tests/specs/lint/with_glob_config_and_flags/with_glob_config_and_flags_unix.out create mode 100644 tests/specs/lint/with_glob_config_and_flags/with_glob_config_and_flags_windows.out create mode 100644 tests/specs/lint/with_malformed_config/Deno.malformed.jsonc create mode 100644 tests/specs/lint/with_malformed_config/__test__.jsonc create mode 100644 tests/specs/lint/with_malformed_config/with_malformed_config.out create mode 100644 tests/specs/lint/with_malformed_config2/Deno.malformed2.jsonc create mode 100644 tests/specs/lint/with_malformed_config2/__test__.jsonc create mode 100644 tests/specs/lint/with_malformed_config2/with_malformed_config2.out create mode 100644 tests/specs/lint/with_report_config/Deno.compact.format.jsonc create mode 100644 tests/specs/lint/with_report_config/__test__.jsonc create mode 100644 tests/specs/lint/with_report_config/with_config/a.ts create mode 100644 tests/specs/lint/with_report_config/with_config/b.ts create mode 100644 tests/specs/lint/with_report_config/with_report_config_compact.out create mode 100644 tests/specs/lint/with_report_config_override/Deno.compact.format.jsonc create mode 100644 tests/specs/lint/with_report_config_override/__test__.jsonc create mode 100644 tests/specs/lint/with_report_config_override/with_config/a.ts create mode 100644 tests/specs/lint/with_report_config_override/with_config/b.ts create mode 100644 tests/specs/lint/with_report_config_override/with_report_config_override.out delete mode 100644 tests/testdata/lint/Deno.compact.format.jsonc delete mode 100644 tests/testdata/lint/Deno.jsonc delete mode 100644 tests/testdata/lint/Deno.malformed.jsonc delete mode 100644 tests/testdata/lint/Deno.malformed2.jsonc delete mode 100644 tests/testdata/lint/Deno.no_tags.jsonc delete mode 100644 tests/testdata/lint/deno.glob.json delete mode 100644 tests/testdata/lint/expected.out delete mode 100644 tests/testdata/lint/expected_compact.out delete mode 100644 tests/testdata/lint/expected_from_stdin.out delete mode 100644 tests/testdata/lint/expected_from_stdin_json.out delete mode 100644 tests/testdata/lint/expected_glob.out delete mode 100644 tests/testdata/lint/expected_ignore.out delete mode 100644 tests/testdata/lint/expected_json.out delete mode 100644 tests/testdata/lint/expected_quiet.out delete mode 100644 tests/testdata/lint/expected_rules.out delete mode 100644 tests/testdata/lint/expected_verbose.out delete mode 100644 tests/testdata/lint/glob/data/tes.ts delete mode 100644 tests/testdata/lint/glob/data/test1.js delete mode 100644 tests/testdata/lint/glob/data/test1.ts delete mode 100644 tests/testdata/lint/glob/data/test12.ts delete mode 100644 tests/testdata/lint/glob/nested/fizz/bar.ts delete mode 100644 tests/testdata/lint/glob/nested/fizz/bazz.ts delete mode 100644 tests/testdata/lint/glob/nested/fizz/fizz.ts delete mode 100644 tests/testdata/lint/glob/nested/fizz/foo.ts delete mode 100644 tests/testdata/lint/glob/nested/foo/bar.ts delete mode 100644 tests/testdata/lint/glob/nested/foo/bazz.ts delete mode 100644 tests/testdata/lint/glob/nested/foo/fizz.ts delete mode 100644 tests/testdata/lint/glob/nested/foo/foo.ts delete mode 100644 tests/testdata/lint/glob/pages/[id].ts delete mode 100644 tests/testdata/lint/with_config.out delete mode 100644 tests/testdata/lint/with_config/a.ts delete mode 100644 tests/testdata/lint/with_config/b.ts delete mode 100644 tests/testdata/lint/with_config_and_flags.out delete mode 100644 tests/testdata/lint/with_config_without_tags.out delete mode 100644 tests/testdata/lint/with_malformed_config.out delete mode 100644 tests/testdata/lint/with_malformed_config2.out delete mode 100644 tests/testdata/lint/with_report_config_compact.out delete mode 100644 tests/testdata/lint/with_report_config_override.out delete mode 100644 tests/testdata/lint/without_config/file1.js delete mode 100644 tests/testdata/lint/without_config/file2.ts delete mode 100644 tests/testdata/lint/without_config/ignored_file.ts delete mode 100644 tests/testdata/lint/without_config/malformed.js diff --git a/tests/integration/lint_tests.rs b/tests/integration/lint_tests.rs deleted file mode 100644 index b47a98da4..000000000 --- a/tests/integration/lint_tests.rs +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -use deno_core::serde_json::json; -use test_util::assert_contains; -use test_util::assert_not_contains; -use test_util::itest; -use test_util::TestContext; -use test_util::TestContextBuilder; - -itest!(ignore_unexplicit_files { - args: "lint --ignore=./", - output_str: Some("error: No target files found.\n"), - exit_code: 1, -}); - -itest!(all { - args: "lint lint/without_config/file1.js lint/without_config/file2.ts lint/without_config/ignored_file.ts", - output: "lint/expected.out", - exit_code: 1, -}); - -itest!(quiet { - args: "lint --quiet lint/without_config/file1.js", - output: "lint/expected_quiet.out", - exit_code: 1, -}); - -itest!(json { - 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, -}); - -itest!(compact { - args: - "lint --compact lint/without_config/file1.js lint/without_config/ignored_file.tss", - output: "lint/expected_compact.out", - exit_code: 1, -}); - -itest!(ignore { - args: - "lint --ignore=lint/without_config/file1.js,lint/without_config/malformed.js,lint/without_config/lint_with_config/ lint/without_config/", - output: "lint/expected_ignore.out", - exit_code: 1, -}); - -itest!(glob { - args: "lint --ignore=lint/without_config/malformed.js,lint/with_config/ lint/without_config/", - output: "lint/expected_glob.out", - exit_code: 1, -}); - -itest!(stdin { - args: "lint -", - input: Some("let _a: any;"), - output: "lint/expected_from_stdin.out", - exit_code: 1, -}); - -itest!(stdin_json { - args: "lint --json -", - input: Some("let _a: any;"), - output: "lint/expected_from_stdin_json.out", - exit_code: 1, -}); - -itest!(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 --rules -q", - output: "lint/expected_rules.out", - exit_code: 0, -}); - -itest!(lint_with_config { - args: "lint --config lint/Deno.jsonc lint/with_config/", - output: "lint/with_config.out", - 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", - exit_code: 1, -}); - -itest!(lint_with_config_without_tags { - args: "lint --config lint/Deno.no_tags.jsonc lint/with_config/", - output: "lint/with_config_without_tags.out", - exit_code: 1, -}); - -itest!(lint_with_malformed_config { - args: "lint --config lint/Deno.malformed.jsonc", - output: "lint/with_malformed_config.out", - exit_code: 1, -}); - -itest!(lint_with_malformed_config2 { - args: "lint --config lint/Deno.malformed2.jsonc", - output: "lint/with_malformed_config2.out", - exit_code: 1, -}); - -#[test] -fn lint_with_glob_config() { - let context = TestContextBuilder::new().cwd("lint").build(); - - let cmd_output = context - .new_command() - .args("lint --config deno.glob.json") - .run(); - - cmd_output.assert_exit_code(1); - - let output = cmd_output.combined_output(); - if cfg!(windows) { - assert_contains!(output, r"glob\nested\fizz\fizz.ts:1:10"); - assert_contains!(output, r"glob\pages\[id].ts:1:10"); - assert_contains!(output, r"glob\nested\fizz\bar.ts:1:10"); - assert_contains!(output, r"glob\nested\foo\foo.ts:1:10"); - assert_contains!(output, r"glob\data\test1.js:1:10"); - assert_contains!(output, r"glob\nested\foo\bar.ts:1:10"); - assert_contains!(output, r"glob\nested\foo\fizz.ts:1:10"); - assert_contains!(output, r"glob\nested\fizz\foo.ts:1:10"); - assert_contains!(output, r"glob\data\test1.ts:1:10"); - } else { - assert_contains!(output, "glob/nested/fizz/fizz.ts:1:10"); - assert_contains!(output, "glob/pages/[id].ts:1:10"); - assert_contains!(output, "glob/nested/fizz/bar.ts:1:10"); - assert_contains!(output, "glob/nested/foo/foo.ts:1:10"); - assert_contains!(output, "glob/data/test1.js:1:10"); - assert_contains!(output, "glob/nested/foo/bar.ts:1:10"); - assert_contains!(output, "glob/nested/foo/fizz.ts:1:10"); - assert_contains!(output, "glob/nested/fizz/foo.ts:1:10"); - assert_contains!(output, "glob/data/test1.ts:1:10"); - } - assert_contains!(output, "Found 9 problems"); - assert_contains!(output, "Checked 9 files"); -} - -#[test] -fn lint_with_glob_config_and_flags() { - let context = TestContextBuilder::new().cwd("lint").build(); - - let cmd_output = context - .new_command() - .args("lint --config deno.glob.json --ignore=glob/nested/**/bar.ts") - .run(); - - cmd_output.assert_exit_code(1); - - let output = cmd_output.combined_output(); - if cfg!(windows) { - assert_contains!(output, r"glob\nested\fizz\fizz.ts:1:10"); - assert_contains!(output, r"glob\pages\[id].ts:1:10"); - assert_contains!(output, r"glob\nested\fizz\bazz.ts:1:10"); - assert_contains!(output, r"glob\nested\foo\foo.ts:1:10"); - assert_contains!(output, r"glob\data\test1.js:1:10"); - assert_contains!(output, r"glob\nested\foo\bazz.ts:1:10"); - assert_contains!(output, r"glob\nested\foo\fizz.ts:1:10"); - assert_contains!(output, r"glob\nested\fizz\foo.ts:1:10"); - assert_contains!(output, r"glob\data\test1.ts:1:10"); - } else { - assert_contains!(output, "glob/nested/fizz/fizz.ts:1:10"); - assert_contains!(output, "glob/pages/[id].ts:1:10"); - assert_contains!(output, "glob/nested/fizz/bazz.ts:1:10"); - assert_contains!(output, "glob/nested/foo/foo.ts:1:10"); - assert_contains!(output, "glob/data/test1.js:1:10"); - assert_contains!(output, "glob/nested/foo/bazz.ts:1:10"); - assert_contains!(output, "glob/nested/foo/fizz.ts:1:10"); - assert_contains!(output, "glob/nested/fizz/foo.ts:1:10"); - assert_contains!(output, "glob/data/test1.ts:1:10"); - } - assert_contains!(output, "Found 9 problems"); - assert_contains!(output, "Checked 9 files"); - - let cmd_output = context - .new_command() - .args("lint --config deno.glob.json glob/data/test1.?s") - .run(); - - cmd_output.assert_exit_code(1); - - let output = cmd_output.combined_output(); - if cfg!(windows) { - assert_contains!(output, r"glob\data\test1.js:1:10"); - assert_contains!(output, r"glob\data\test1.ts:1:10"); - } else { - assert_contains!(output, "glob/data/test1.js:1:10"); - assert_contains!(output, "glob/data/test1.ts:1:10"); - } - assert_contains!(output, "Found 2 problems"); - assert_contains!(output, "Checked 2 files"); -} - -#[test] -fn opt_out_top_level_exclude_via_lint_unexclude() { - let context = TestContextBuilder::new().use_temp_cwd().build(); - let temp_dir = context.temp_dir().path(); - temp_dir.join("deno.json").write_json(&json!({ - "lint": { - "exclude": [ "!excluded.ts" ] - }, - "exclude": [ "excluded.ts", "actually_excluded.ts" ] - })); - - temp_dir.join("main.ts").write("const a = 1;"); - temp_dir.join("excluded.ts").write("const a = 2;"); - temp_dir.join("actually_excluded.ts").write("const a = 2;"); - - let output = context.new_command().arg("lint").run(); - output.assert_exit_code(1); - let output = output.combined_output(); - assert_contains!(output, "main.ts"); - assert_contains!(output, "excluded.ts"); - assert_not_contains!(output, "actually_excluded.ts"); -} - -#[test] -fn lint_stdin_jsx() { - TestContext::default() - .new_command() - .args("lint --ext=jsx -") - .stdin_text( - r#" -const data =
hello
; -"#, - ) - .run() - .assert_matches_text( - r#"error[no-unused-vars]: `data` is never used - --> [WILDLINE]$deno$stdin.jsx:2:7 - | -2 | const data =
hello
; - | ^^^^ - = 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 -"#, - ) - .assert_exit_code(1); -} diff --git a/tests/integration/mod.rs b/tests/integration/mod.rs index 5cbe2a2ff..37c750228 100644 --- a/tests/integration/mod.rs +++ b/tests/integration/mod.rs @@ -35,8 +35,6 @@ mod js_unit_tests; mod jsr; #[path = "jupyter_tests.rs"] mod jupyter; -#[path = "lint_tests.rs"] -mod lint; #[path = "lsp_tests.rs"] mod lsp; #[path = "node_unit_tests.rs"] 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 =
hello
; 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 =
hello
; + | ^^^^ + = 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 =
hello
; + | ^^^^ + = 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": [] +} diff --git a/tests/testdata/lint/Deno.compact.format.jsonc b/tests/testdata/lint/Deno.compact.format.jsonc deleted file mode 100644 index f3487501a..000000000 --- a/tests/testdata/lint/Deno.compact.format.jsonc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "lint": { - "include": ["with_config/"], - "exclude": ["with_config/b.ts"], - "rules": { - "tags": ["recommended"], - "include": ["ban-untagged-todo"] - }, - "report": "compact" - } -} diff --git a/tests/testdata/lint/Deno.jsonc b/tests/testdata/lint/Deno.jsonc deleted file mode 100644 index e9c03cca4..000000000 --- a/tests/testdata/lint/Deno.jsonc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "lint": { - "include": ["with_config/"], - "exclude": ["with_config/b.ts"], - "rules": { - "tags": ["recommended"], - "include": ["ban-untagged-todo"] - } - } -} diff --git a/tests/testdata/lint/Deno.malformed.jsonc b/tests/testdata/lint/Deno.malformed.jsonc deleted file mode 100644 index fa71cd851..000000000 --- a/tests/testdata/lint/Deno.malformed.jsonc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "lint": { - "include": ["with_config/"], - "exclude": ["with_config/b.ts"], - "dont_know_this_field": {}, - "rules": { - "tags": ["recommended"], - "include": ["ban-untagged-todo"] - } - } -} diff --git a/tests/testdata/lint/Deno.malformed2.jsonc b/tests/testdata/lint/Deno.malformed2.jsonc deleted file mode 100644 index fa71cd851..000000000 --- a/tests/testdata/lint/Deno.malformed2.jsonc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "lint": { - "include": ["with_config/"], - "exclude": ["with_config/b.ts"], - "dont_know_this_field": {}, - "rules": { - "tags": ["recommended"], - "include": ["ban-untagged-todo"] - } - } -} diff --git a/tests/testdata/lint/Deno.no_tags.jsonc b/tests/testdata/lint/Deno.no_tags.jsonc deleted file mode 100644 index b63600a90..000000000 --- a/tests/testdata/lint/Deno.no_tags.jsonc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "lint": { - "include": [ - "with_config/" - ], - "exclude": [ - "with_config/b.ts" - ], - "rules": { - "include": [ - "ban-untagged-todo" - ] - } - } -} diff --git a/tests/testdata/lint/deno.glob.json b/tests/testdata/lint/deno.glob.json deleted file mode 100644 index f6781b0d8..000000000 --- a/tests/testdata/lint/deno.glob.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "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/testdata/lint/expected.out b/tests/testdata/lint/expected.out deleted file mode 100644 index eb8a2651a..000000000 --- a/tests/testdata/lint/expected.out +++ /dev/null @@ -1,3 +0,0 @@ -[WILDCARD] -Found 3 problems -Checked 3 files diff --git a/tests/testdata/lint/expected_compact.out b/tests/testdata/lint/expected_compact.out deleted file mode 100644 index d1b2b922b..000000000 --- a/tests/testdata/lint/expected_compact.out +++ /dev/null @@ -1,4 +0,0 @@ -[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/testdata/lint/expected_from_stdin.out b/tests/testdata/lint/expected_from_stdin.out deleted file mode 100644 index 735b271f5..000000000 --- a/tests/testdata/lint/expected_from_stdin.out +++ /dev/null @@ -1,12 +0,0 @@ -error[no-explicit-any]: `any` type is not allowed - --> [WILDCARD]$deno$stdin.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/testdata/lint/expected_from_stdin_json.out b/tests/testdata/lint/expected_from_stdin_json.out deleted file mode 100644 index 27b215b43..000000000 --- a/tests/testdata/lint/expected_from_stdin_json.out +++ /dev/null @@ -1,24 +0,0 @@ -{ - "version": 1, - "diagnostics": [ - { - "filename": "[WILDCARD]$deno$stdin.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/testdata/lint/expected_glob.out b/tests/testdata/lint/expected_glob.out deleted file mode 100644 index eb8a2651a..000000000 --- a/tests/testdata/lint/expected_glob.out +++ /dev/null @@ -1,3 +0,0 @@ -[WILDCARD] -Found 3 problems -Checked 3 files diff --git a/tests/testdata/lint/expected_ignore.out b/tests/testdata/lint/expected_ignore.out deleted file mode 100644 index b5f78ee04..000000000 --- a/tests/testdata/lint/expected_ignore.out +++ /dev/null @@ -1,3 +0,0 @@ -[WILDCARD] -Found 1 problem -Checked 2 files diff --git a/tests/testdata/lint/expected_json.out b/tests/testdata/lint/expected_json.out deleted file mode 100644 index 6712c891a..000000000 --- a/tests/testdata/lint/expected_json.out +++ /dev/null @@ -1,65 +0,0 @@ -{ - "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/testdata/lint/expected_quiet.out b/tests/testdata/lint/expected_quiet.out deleted file mode 100644 index 91c1a29cf..000000000 --- a/tests/testdata/lint/expected_quiet.out +++ /dev/null @@ -1,20 +0,0 @@ -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/testdata/lint/expected_rules.out b/tests/testdata/lint/expected_rules.out deleted file mode 100644 index 4afab7b9b..000000000 --- a/tests/testdata/lint/expected_rules.out +++ /dev/null @@ -1,2 +0,0 @@ -Available rules: -[WILDCARD] diff --git a/tests/testdata/lint/expected_verbose.out b/tests/testdata/lint/expected_verbose.out deleted file mode 100644 index eb8a2651a..000000000 --- a/tests/testdata/lint/expected_verbose.out +++ /dev/null @@ -1,3 +0,0 @@ -[WILDCARD] -Found 3 problems -Checked 3 files diff --git a/tests/testdata/lint/glob/data/tes.ts b/tests/testdata/lint/glob/data/tes.ts deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/data/tes.ts +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/glob/data/test1.js b/tests/testdata/lint/glob/data/test1.js deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/data/test1.js +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/glob/data/test1.ts b/tests/testdata/lint/glob/data/test1.ts deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/data/test1.ts +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/glob/data/test12.ts b/tests/testdata/lint/glob/data/test12.ts deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/data/test12.ts +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/glob/nested/fizz/bar.ts b/tests/testdata/lint/glob/nested/fizz/bar.ts deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/nested/fizz/bar.ts +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/glob/nested/fizz/bazz.ts b/tests/testdata/lint/glob/nested/fizz/bazz.ts deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/nested/fizz/bazz.ts +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/glob/nested/fizz/fizz.ts b/tests/testdata/lint/glob/nested/fizz/fizz.ts deleted file mode 100644 index 6940729e9..000000000 --- a/tests/testdata/lint/glob/nested/fizz/fizz.ts +++ /dev/null @@ -1,2 +0,0 @@ -function foo() { -} diff --git a/tests/testdata/lint/glob/nested/fizz/foo.ts b/tests/testdata/lint/glob/nested/fizz/foo.ts deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/nested/fizz/foo.ts +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/glob/nested/foo/bar.ts b/tests/testdata/lint/glob/nested/foo/bar.ts deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/nested/foo/bar.ts +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/glob/nested/foo/bazz.ts b/tests/testdata/lint/glob/nested/foo/bazz.ts deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/nested/foo/bazz.ts +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/glob/nested/foo/fizz.ts b/tests/testdata/lint/glob/nested/foo/fizz.ts deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/nested/foo/fizz.ts +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/glob/nested/foo/foo.ts b/tests/testdata/lint/glob/nested/foo/foo.ts deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/nested/foo/foo.ts +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/glob/pages/[id].ts b/tests/testdata/lint/glob/pages/[id].ts deleted file mode 100644 index 26f07fba5..000000000 --- a/tests/testdata/lint/glob/pages/[id].ts +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - -} \ No newline at end of file diff --git a/tests/testdata/lint/with_config.out b/tests/testdata/lint/with_config.out deleted file mode 100644 index f527bb712..000000000 --- a/tests/testdata/lint/with_config.out +++ /dev/null @@ -1,22 +0,0 @@ -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/testdata/lint/with_config/a.ts b/tests/testdata/lint/with_config/a.ts deleted file mode 100644 index c378218a3..000000000 --- a/tests/testdata/lint/with_config/a.ts +++ /dev/null @@ -1,4 +0,0 @@ -// TODO: foo -function add(a: number, b: number): number { - return a + b; -} diff --git a/tests/testdata/lint/with_config/b.ts b/tests/testdata/lint/with_config/b.ts deleted file mode 100644 index d5647067e..000000000 --- a/tests/testdata/lint/with_config/b.ts +++ /dev/null @@ -1,4 +0,0 @@ -// TODO: this file should be ignored -function subtract(a: number, b: number): number { - return a - b; -} diff --git a/tests/testdata/lint/with_config_and_flags.out b/tests/testdata/lint/with_config_and_flags.out deleted file mode 100644 index 78e21ef8d..000000000 --- a/tests/testdata/lint/with_config_and_flags.out +++ /dev/null @@ -1,22 +0,0 @@ -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/testdata/lint/with_config_without_tags.out b/tests/testdata/lint/with_config_without_tags.out deleted file mode 100644 index f527bb712..000000000 --- a/tests/testdata/lint/with_config_without_tags.out +++ /dev/null @@ -1,22 +0,0 @@ -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/testdata/lint/with_malformed_config.out b/tests/testdata/lint/with_malformed_config.out deleted file mode 100644 index 1c0f0fff6..000000000 --- a/tests/testdata/lint/with_malformed_config.out +++ /dev/null @@ -1,4 +0,0 @@ -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/testdata/lint/with_malformed_config2.out b/tests/testdata/lint/with_malformed_config2.out deleted file mode 100644 index 1c0f0fff6..000000000 --- a/tests/testdata/lint/with_malformed_config2.out +++ /dev/null @@ -1,4 +0,0 @@ -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/testdata/lint/with_report_config_compact.out b/tests/testdata/lint/with_report_config_compact.out deleted file mode 100644 index fe1241264..000000000 --- a/tests/testdata/lint/with_report_config_compact.out +++ /dev/null @@ -1,4 +0,0 @@ -[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/testdata/lint/with_report_config_override.out b/tests/testdata/lint/with_report_config_override.out deleted file mode 100644 index ad32e3123..000000000 --- a/tests/testdata/lint/with_report_config_override.out +++ /dev/null @@ -1,42 +0,0 @@ -{ - "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": [] -} diff --git a/tests/testdata/lint/without_config/file1.js b/tests/testdata/lint/without_config/file1.js deleted file mode 100644 index 737f26818..000000000 --- a/tests/testdata/lint/without_config/file1.js +++ /dev/null @@ -1,2 +0,0 @@ -// deno-lint-ignore -while (false) {} diff --git a/tests/testdata/lint/without_config/file2.ts b/tests/testdata/lint/without_config/file2.ts deleted file mode 100644 index 73c612c35..000000000 --- a/tests/testdata/lint/without_config/file2.ts +++ /dev/null @@ -1,6 +0,0 @@ -try { - await Deno.open("./some/file.txt"); -} catch (_e) {} - -// deno-lint-ignore no-explicit-any -function _foo(): any {} diff --git a/tests/testdata/lint/without_config/ignored_file.ts b/tests/testdata/lint/without_config/ignored_file.ts deleted file mode 100644 index 97befafa3..000000000 --- a/tests/testdata/lint/without_config/ignored_file.ts +++ /dev/null @@ -1,3 +0,0 @@ -// deno-lint-ignore-file - -function foo(): any {} diff --git a/tests/testdata/lint/without_config/malformed.js b/tests/testdata/lint/without_config/malformed.js deleted file mode 100644 index 9b64da898..000000000 --- a/tests/testdata/lint/without_config/malformed.js +++ /dev/null @@ -1,4 +0,0 @@ -// deno-fmt-ignore-file - -// intentionally malformed file -export class A B C \ No newline at end of file diff --git a/tools/lint.js b/tools/lint.js index bcbf1c27e..e914fe159 100755 --- a/tools/lint.js +++ b/tools/lint.js @@ -210,7 +210,6 @@ async function ensureNoNewITests() { "jsr_tests.rs": 0, "js_unit_tests.rs": 0, "jupyter_tests.rs": 0, - "lint_tests.rs": 18, // Read the comment above. Please don't increase these numbers! "lsp_tests.rs": 0, "node_compat_tests.rs": 0, -- cgit v1.2.3