summaryrefslogtreecommitdiff
path: root/cli/tests/integration/lsp_tests.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-10-12 00:02:33 +0200
committerGitHub <noreply@github.com>2021-10-12 00:02:33 +0200
commitf332d72f1653ec03b64a80d8d4949dce5564cc99 (patch)
tree500e6d5d523f1cf66898985d5b7134c32cc270d8 /cli/tests/integration/lsp_tests.rs
parent5bad8e17734ef8cc1f19df292d553cc1327638f3 (diff)
fix(lsp): lint diagnostics respect config file (#12338)
This commit fixes problem with LSP where diagnostics coming from "deno lint" don't respect configuration file. LSP was changed to store "Option<ConfigFile>", "Option<LintConfig>" and "Option<FmtConfig>" on "Inner"; as well as storing "Option<LintConfig>" and "Option<FmtConfig>" on "StateSnapshot". Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
Diffstat (limited to 'cli/tests/integration/lsp_tests.rs')
-rw-r--r--cli/tests/integration/lsp_tests.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index 215ba1a24..3126eb31c 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -3560,3 +3560,39 @@ console.log(snake_case);
);
shutdown(&mut client);
}
+
+#[test]
+fn lsp_lint_with_config() {
+ let temp_dir = TempDir::new().expect("could not create temp dir");
+ let mut params: lsp::InitializeParams =
+ serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
+ let deno_lint_jsonc =
+ serde_json::to_vec_pretty(&load_fixture("deno.lint.jsonc")).unwrap();
+ fs::write(temp_dir.path().join("deno.lint.jsonc"), deno_lint_jsonc).unwrap();
+
+ params.root_uri = Some(Url::from_file_path(temp_dir.path()).unwrap());
+ if let Some(Value::Object(mut map)) = params.initialization_options {
+ map.insert("config".to_string(), json!("./deno.lint.jsonc"));
+ params.initialization_options = Some(Value::Object(map));
+ }
+
+ let deno_exe = deno_exe_path();
+ let mut client = LspClient::new(&deno_exe).unwrap();
+ client
+ .write_request::<_, _, Value>("initialize", params)
+ .unwrap();
+
+ let diagnostics = did_open(&mut client, load_fixture("did_open_lint.json"));
+ let diagnostics = diagnostics
+ .into_iter()
+ .flat_map(|x| x.diagnostics)
+ .collect::<Vec<_>>();
+ assert_eq!(diagnostics.len(), 3);
+ for diagnostic in diagnostics {
+ assert_eq!(
+ diagnostic.code,
+ Some(lsp::NumberOrString::String("ban-untagged-todo".to_string()))
+ );
+ }
+ shutdown(&mut client);
+}