summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration_tests_lsp.rs28
-rw-r--r--cli/tests/lsp/code_action_ignore_lint_params.json39
-rw-r--r--cli/tests/lsp/code_action_ignore_lint_response.json62
3 files changed, 129 insertions, 0 deletions
diff --git a/cli/tests/integration_tests_lsp.rs b/cli/tests/integration_tests_lsp.rs
index 1f58c0749..afc93764a 100644
--- a/cli/tests/integration_tests_lsp.rs
+++ b/cli/tests/integration_tests_lsp.rs
@@ -2734,3 +2734,31 @@ fn lsp_configuration_did_change() {
);
shutdown(&mut client);
}
+
+#[test]
+fn lsp_code_actions_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": "let message = 'Hello, Deno!';\nconsole.log(message);\n"
+ }
+ }),
+ );
+ let (maybe_res, maybe_err) = client
+ .write_request(
+ "textDocument/codeAction",
+ load_fixture("code_action_ignore_lint_params.json"),
+ )
+ .unwrap();
+ assert!(maybe_err.is_none());
+ assert_eq!(
+ maybe_res,
+ Some(load_fixture("code_action_ignore_lint_response.json"))
+ );
+ shutdown(&mut client);
+}
diff --git a/cli/tests/lsp/code_action_ignore_lint_params.json b/cli/tests/lsp/code_action_ignore_lint_params.json
new file mode 100644
index 000000000..7711812fd
--- /dev/null
+++ b/cli/tests/lsp/code_action_ignore_lint_params.json
@@ -0,0 +1,39 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ },
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 5
+ },
+ "end": {
+ "line": 1,
+ "character": 12
+ }
+ },
+ "context": {
+ "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": []
+ }
+ ],
+ "only": [
+ "quickfix"
+ ]
+ }
+}
diff --git a/cli/tests/lsp/code_action_ignore_lint_response.json b/cli/tests/lsp/code_action_ignore_lint_response.json
new file mode 100644
index 000000000..f5c24ec21
--- /dev/null
+++ b/cli/tests/lsp/code_action_ignore_lint_response.json
@@ -0,0 +1,62 @@
+[
+ {
+ "title": "Disable prefer-const for this line",
+ "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": 1, "character": 0 },
+ "end": { "line": 1, "character": 0 }
+ },
+ "newText": "// deno-lint-ignore prefer-const\n"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "title": "Ignore lint errors 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\n"
+ }
+ ]
+ }
+ }
+ }
+]