mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
chore: deprecate lint itests (#25655)
This commit is contained in:
parent
acc32e1cee
commit
36a1a79f17
123 changed files with 814 additions and 299 deletions
|
@ -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 = <div>hello</div>;
|
||||
"#,
|
||||
)
|
||||
.run()
|
||||
.assert_matches_text(
|
||||
r#"error[no-unused-vars]: `data` is never used
|
||||
--> [WILDLINE]$deno$stdin.jsx:2:7
|
||||
|
|
||||
2 | const data = <div>hello</div>;
|
||||
| ^^^^
|
||||
= hint: If this is intentional, prefix it with an underscore like `_data`
|
||||
|
||||
docs: https://lint.deno.land/rules/no-unused-vars
|
||||
|
||||
|
||||
Found 1 problem
|
||||
Checked 1 file
|
||||
"#,
|
||||
)
|
||||
.assert_exit_code(1);
|
||||
}
|
|
@ -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"]
|
||||
|
|
5
tests/specs/lint/all/__test__.jsonc
Normal file
5
tests/specs/lint/all/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint file1.js file2.ts ignored_file.ts",
|
||||
"output": "expected.out",
|
||||
"exitCode": 1
|
||||
}
|
5
tests/specs/lint/compact/__test__.jsonc
Normal file
5
tests/specs/lint/compact/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint --compact file1.js ignored_file.tss",
|
||||
"output": "expected_compact.out",
|
||||
"exitCode": 1
|
||||
}
|
2
tests/specs/lint/compact/file1.js
Normal file
2
tests/specs/lint/compact/file1.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
// deno-lint-ignore
|
||||
while (false) {}
|
5
tests/specs/lint/glob/__test__.jsonc
Normal file
5
tests/specs/lint/glob/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint --ignore=without_config/malformed.js,with_config/ without_config/",
|
||||
"output": "expected_glob.out",
|
||||
"exitCode": 1
|
||||
}
|
2
tests/specs/lint/glob/without_config/file1.js
Normal file
2
tests/specs/lint/glob/without_config/file1.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
// deno-lint-ignore
|
||||
while (false) {}
|
6
tests/specs/lint/glob/without_config/file2.ts
Normal file
6
tests/specs/lint/glob/without_config/file2.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
try {
|
||||
await Deno.open("./some/file.txt");
|
||||
} catch (_e) {}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
function _foo(): any {}
|
3
tests/specs/lint/glob/without_config/ignored_file.ts
Normal file
3
tests/specs/lint/glob/without_config/ignored_file.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
function foo(): any {}
|
5
tests/specs/lint/ignore/__test__.jsonc
Normal file
5
tests/specs/lint/ignore/__test__.jsonc
Normal file
|
@ -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
|
||||
}
|
2
tests/specs/lint/ignore/without_config/file1.js
Normal file
2
tests/specs/lint/ignore/without_config/file1.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
// deno-lint-ignore
|
||||
while (false) {}
|
6
tests/specs/lint/ignore/without_config/file2.ts
Normal file
6
tests/specs/lint/ignore/without_config/file2.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
try {
|
||||
await Deno.open("./some/file.txt");
|
||||
} catch (_e) {}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
function _foo(): any {}
|
3
tests/specs/lint/ignore/without_config/ignored_file.ts
Normal file
3
tests/specs/lint/ignore/without_config/ignored_file.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
function foo(): any {}
|
4
tests/specs/lint/ignore/without_config/malformed.js
Normal file
4
tests/specs/lint/ignore/without_config/malformed.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
// deno-fmt-ignore-file
|
||||
|
||||
// intentionally malformed file
|
||||
export class A B C
|
5
tests/specs/lint/ignore_unexplicit_files/__test__.jsonc
Normal file
5
tests/specs/lint/ignore_unexplicit_files/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint --ignore=./",
|
||||
"output": "lint.out",
|
||||
"exitCode": 1
|
||||
}
|
1
tests/specs/lint/ignore_unexplicit_files/lint.out
Normal file
1
tests/specs/lint/ignore_unexplicit_files/lint.out
Normal file
|
@ -0,0 +1 @@
|
|||
error: No target files found.
|
5
tests/specs/lint/json/__test__.jsonc
Normal file
5
tests/specs/lint/json/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint --json file1.js file2.ts ignored_file.ts malformed.js",
|
||||
"output": "expected_json.out",
|
||||
"exitCode": 1
|
||||
}
|
2
tests/specs/lint/json/file1.js
Normal file
2
tests/specs/lint/json/file1.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
// deno-lint-ignore
|
||||
while (false) {}
|
6
tests/specs/lint/json/file2.ts
Normal file
6
tests/specs/lint/json/file2.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
try {
|
||||
await Deno.open("./some/file.txt");
|
||||
} catch (_e) {}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
function _foo(): any {}
|
3
tests/specs/lint/json/ignored_file.ts
Normal file
3
tests/specs/lint/json/ignored_file.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
function foo(): any {}
|
4
tests/specs/lint/json/malformed.js
Normal file
4
tests/specs/lint/json/malformed.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
// deno-fmt-ignore-file
|
||||
|
||||
// intentionally malformed file
|
||||
export class A B C
|
16
tests/specs/lint/jsx/__test__.jsonc
Normal file
16
tests/specs/lint/jsx/__test__.jsonc
Normal file
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
1
tests/specs/lint/jsx/main.jsx
Normal file
1
tests/specs/lint/jsx/main.jsx
Normal file
|
@ -0,0 +1 @@
|
|||
const data = <div>hello</div>;
|
12
tests/specs/lint/jsx/main_unix.out
Normal file
12
tests/specs/lint/jsx/main_unix.out
Normal file
|
@ -0,0 +1,12 @@
|
|||
error[no-unused-vars]: `data` is never used
|
||||
--> [WILDCARD]lint/jsx/main.jsx:1:7
|
||||
|
|
||||
1 | const data = <div>hello</div>;
|
||||
| ^^^^
|
||||
= hint: If this is intentional, prefix it with an underscore like `_data`
|
||||
|
||||
docs: https://lint.deno.land/rules/no-unused-vars
|
||||
|
||||
|
||||
Found 1 problem
|
||||
Checked 1 file
|
12
tests/specs/lint/jsx/main_windows.out
Normal file
12
tests/specs/lint/jsx/main_windows.out
Normal file
|
@ -0,0 +1,12 @@
|
|||
error[no-unused-vars]: `data` is never used
|
||||
--> [WILDCARD]lint\jsx\main.jsx:1:7
|
||||
|
|
||||
1 | const data = <div>hello</div>;
|
||||
| ^^^^
|
||||
= hint: If this is intentional, prefix it with an underscore like `_data`
|
||||
|
||||
docs: https://lint.deno.land/rules/no-unused-vars
|
||||
|
||||
|
||||
Found 1 problem
|
||||
Checked 1 file
|
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
const a = 2;
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"lint": {
|
||||
"exclude": ["!excluded.ts"]
|
||||
},
|
||||
"exclude": ["excluded.ts", "actually_excluded.ts"]
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
const a = 2;
|
|
@ -0,0 +1 @@
|
|||
const a = 1;
|
|
@ -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
|
|
@ -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
|
5
tests/specs/lint/quiet/__test__.jsonc
Normal file
5
tests/specs/lint/quiet/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint --quiet ",
|
||||
"output": "expected_quiet.out",
|
||||
"exitCode": 1
|
||||
}
|
2
tests/specs/lint/quiet/file1.js
Normal file
2
tests/specs/lint/quiet/file1.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
// deno-lint-ignore
|
||||
while (false) {}
|
5
tests/specs/lint/rules/__test__.jsonc
Normal file
5
tests/specs/lint/rules/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint --rules",
|
||||
"output": "expected_rules.out",
|
||||
"exitCode": 0
|
||||
}
|
5
tests/specs/lint/rules_quiet/__test__.jsonc
Normal file
5
tests/specs/lint/rules_quiet/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint --rules -q",
|
||||
"output": "expected_rules.out",
|
||||
"exitCode": 0
|
||||
}
|
2
tests/specs/lint/rules_quiet/expected_rules.out
Normal file
2
tests/specs/lint/rules_quiet/expected_rules.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
Available rules:
|
||||
[WILDCARD]
|
5
tests/specs/lint/stdin/__test__.jsonc
Normal file
5
tests/specs/lint/stdin/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint main.ts",
|
||||
"output": "expected_from_stdin.out",
|
||||
"exitCode": 1
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
error[no-explicit-any]: `any` type is not allowed
|
||||
--> [WILDCARD]$deno$stdin.ts:1:9
|
||||
--> [WILDCARD]main.ts:1:9
|
||||
|
|
||||
1 | let _a: any;
|
||||
| ^^^
|
1
tests/specs/lint/stdin/main.ts
Normal file
1
tests/specs/lint/stdin/main.ts
Normal file
|
@ -0,0 +1 @@
|
|||
let _a: any;
|
5
tests/specs/lint/stdin_json/__test__.jsonc
Normal file
5
tests/specs/lint/stdin_json/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint --json main.ts",
|
||||
"output": "expected_from_stdin_json.out",
|
||||
"exitCode": 1
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
"version": 1,
|
||||
"diagnostics": [
|
||||
{
|
||||
"filename": "[WILDCARD]$deno$stdin.ts",
|
||||
"filename": "[WILDCARD]main.ts",
|
||||
"range": {
|
||||
"start": {
|
||||
"line": 1,
|
1
tests/specs/lint/stdin_json/main.ts
Normal file
1
tests/specs/lint/stdin_json/main.ts
Normal file
|
@ -0,0 +1 @@
|
|||
let _a: any;
|
5
tests/specs/lint/with_config/__test__.jsonc
Normal file
5
tests/specs/lint/with_config/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint --config Deno.jsonc with_config/",
|
||||
"output": "with_config.out",
|
||||
"exitCode": 1
|
||||
}
|
4
tests/specs/lint/with_config/with_config/a.ts
Normal file
4
tests/specs/lint/with_config/with_config/a.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
// TODO: foo
|
||||
function add(a: number, b: number): number {
|
||||
return a + b;
|
||||
}
|
4
tests/specs/lint/with_config/with_config/b.ts
Normal file
4
tests/specs/lint/with_config/with_config/b.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
// TODO: this file should be ignored
|
||||
function subtract(a: number, b: number): number {
|
||||
return a - b;
|
||||
}
|
10
tests/specs/lint/with_config_and_flags/Deno.jsonc
Normal file
10
tests/specs/lint/with_config_and_flags/Deno.jsonc
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"lint": {
|
||||
"include": ["with_config/"],
|
||||
"exclude": ["with_config/b.ts"],
|
||||
"rules": {
|
||||
"tags": ["recommended"],
|
||||
"include": ["ban-untagged-todo"]
|
||||
}
|
||||
}
|
||||
}
|
5
tests/specs/lint/with_config_and_flags/__test__.jsonc
Normal file
5
tests/specs/lint/with_config_and_flags/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint --config Deno.jsonc --ignore=with_config/a.ts",
|
||||
"output": "with_config_and_flags.out",
|
||||
"exitCode": 1
|
||||
}
|
4
tests/specs/lint/with_config_and_flags/with_config/a.ts
Normal file
4
tests/specs/lint/with_config_and_flags/with_config/a.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
// TODO: foo
|
||||
function add(a: number, b: number): number {
|
||||
return a + b;
|
||||
}
|
4
tests/specs/lint/with_config_and_flags/with_config/b.ts
Normal file
4
tests/specs/lint/with_config_and_flags/with_config/b.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
// TODO: this file should be ignored
|
||||
function subtract(a: number, b: number): number {
|
||||
return a - b;
|
||||
}
|
5
tests/specs/lint/with_config_without_args/__test__.jsonc
Normal file
5
tests/specs/lint/with_config_without_args/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "lint --config Deno.no_tags.jsonc with_config/",
|
||||
"output": "with_config_without_tags.out",
|
||||
"exitCode": 1
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
// TODO: foo
|
||||
function add(a: number, b: number): number {
|
||||
return a + b;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
// TODO: this file should be ignored
|
||||
function subtract(a: number, b: number): number {
|
||||
return a - b;
|
||||
}
|
16
tests/specs/lint/with_glob_config/__test__.jsonc
Normal file
16
tests/specs/lint/with_glob_config/__test__.jsonc
Normal file
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
function foo() {
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
94
tests/specs/lint/with_glob_config/with_glob_config_unix.out
Normal file
94
tests/specs/lint/with_glob_config/with_glob_config_unix.out
Normal file
|
@ -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
|
|
@ -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
|
16
tests/specs/lint/with_glob_config_and_flags/__test__.jsonc
Normal file
16
tests/specs/lint/with_glob_config_and_flags/__test__.jsonc
Normal file
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
11
tests/specs/lint/with_glob_config_and_flags/deno.glob.json
Normal file
11
tests/specs/lint/with_glob_config_and_flags/deno.glob.json
Normal file
|
@ -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"]
|
||||
}
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
function foo() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
function foo() {
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
function foo() {
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
function foo() {
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
function foo() {
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
function foo() {
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
function foo() {
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
function foo() {
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
function foo() {
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
function foo() {
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue