summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/lsp_tests.rs34
-rw-r--r--cli/tests/testdata/lsp/code_action_ignore_lint_response.json30
-rw-r--r--cli/tests/testdata/lsp/code_action_update_ignore_lint_params.json39
-rw-r--r--cli/tests/testdata/lsp/code_action_update_ignore_lint_response.json92
4 files changed, 195 insertions, 0 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index 3d87c222d..5034b6ed6 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -3526,3 +3526,37 @@ fn lsp_code_actions_ignore_lint() {
);
shutdown(&mut client);
}
+
+/// This test exercises updating an existing deno-lint-ignore-file comment.
+#[test]
+fn lsp_code_actions_update_ignore_lint() {
+ let mut client = init("initialize_params.json");
+ did_open(
+ &mut client,
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text":
+"#!/usr/bin/env -S deno run
+// deno-lint-ignore-file camelcase
+let snake_case = 'Hello, Deno!';
+console.log(snake_case);
+",
+ }
+ }),
+ );
+ let (maybe_res, maybe_err) = client
+ .write_request(
+ "textDocument/codeAction",
+ load_fixture("code_action_update_ignore_lint_params.json"),
+ )
+ .unwrap();
+ assert!(maybe_err.is_none());
+ assert_eq!(
+ maybe_res,
+ Some(load_fixture("code_action_update_ignore_lint_response.json"))
+ );
+ shutdown(&mut client);
+}
diff --git a/cli/tests/testdata/lsp/code_action_ignore_lint_response.json b/cli/tests/testdata/lsp/code_action_ignore_lint_response.json
index f5c24ec21..d15fccca9 100644
--- a/cli/tests/testdata/lsp/code_action_ignore_lint_response.json
+++ b/cli/tests/testdata/lsp/code_action_ignore_lint_response.json
@@ -30,6 +30,36 @@
}
},
{
+ "title": "Disable prefer-const for the entire file",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": { "line": 1, "character": 5 },
+ "end": { "line": 1, "character": 12 }
+ },
+ "severity": 1,
+ "code": "prefer-const",
+ "source": "deno-lint",
+ "message": "'message' is never reassigned\nUse 'const' instead",
+ "relatedInformation": []
+ }
+ ],
+ "edit": {
+ "changes": {
+ "file:///a/file.ts": [
+ {
+ "range": {
+ "start": { "line": 0, "character": 0 },
+ "end": { "line": 0, "character": 0 }
+ },
+ "newText": "// deno-lint-ignore-file prefer-const\n"
+ }
+ ]
+ }
+ }
+ },
+ {
"title": "Ignore lint errors for the entire file",
"kind": "quickfix",
"diagnostics": [
diff --git a/cli/tests/testdata/lsp/code_action_update_ignore_lint_params.json b/cli/tests/testdata/lsp/code_action_update_ignore_lint_params.json
new file mode 100644
index 000000000..8cbf1185f
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_update_ignore_lint_params.json
@@ -0,0 +1,39 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ },
+ "range": {
+ "start": {
+ "line": 3,
+ "character": 5
+ },
+ "end": {
+ "line": 3,
+ "character": 15
+ }
+ },
+ "context": {
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 3,
+ "character": 5
+ },
+ "end": {
+ "line": 3,
+ "character": 15
+ }
+ },
+ "severity": 1,
+ "code": "prefer-const",
+ "source": "deno-lint",
+ "message": "'snake_case' is never reassigned\nUse 'const' instead",
+ "relatedInformation": []
+ }
+ ],
+ "only": [
+ "quickfix"
+ ]
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_update_ignore_lint_response.json b/cli/tests/testdata/lsp/code_action_update_ignore_lint_response.json
new file mode 100644
index 000000000..a23e719e0
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_update_ignore_lint_response.json
@@ -0,0 +1,92 @@
+[
+ {
+ "title": "Disable prefer-const for this line",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": { "line": 3, "character": 5 },
+ "end": { "line": 3, "character": 15 }
+ },
+ "severity": 1,
+ "code": "prefer-const",
+ "source": "deno-lint",
+ "message": "'snake_case' is never reassigned\nUse 'const' instead",
+ "relatedInformation": []
+ }
+ ],
+ "edit": {
+ "changes": {
+ "file:///a/file.ts": [
+ {
+ "range": {
+ "start": { "line": 3, "character": 0 },
+ "end": { "line": 3, "character": 0 }
+ },
+ "newText": "// deno-lint-ignore prefer-const\n"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "title": "Disable prefer-const for the entire file",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": { "line": 3, "character": 5 },
+ "end": { "line": 3, "character": 15 }
+ },
+ "severity": 1,
+ "code": "prefer-const",
+ "source": "deno-lint",
+ "message": "'snake_case' is never reassigned\nUse 'const' instead",
+ "relatedInformation": []
+ }
+ ],
+ "edit": {
+ "changes": {
+ "file:///a/file.ts": [
+ {
+ "range": {
+ "start": { "line": 1, "character": 34 },
+ "end": { "line": 1, "character": 34 }
+ },
+ "newText": " prefer-const"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "title": "Ignore lint errors for the entire file",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": { "line": 3, "character": 5 },
+ "end": { "line": 3, "character": 15 }
+ },
+ "severity": 1,
+ "code": "prefer-const",
+ "source": "deno-lint",
+ "message": "'snake_case' is never reassigned\nUse 'const' instead",
+ "relatedInformation": []
+ }
+ ],
+ "edit": {
+ "changes": {
+ "file:///a/file.ts": [
+ {
+ "range": {
+ "start": { "line": 0, "character": 0 },
+ "end": { "line": 0, "character": 0 }
+ },
+ "newText": "// deno-lint-ignore-file\n"
+ }
+ ]
+ }
+ }
+ }
+]