diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-10-12 00:02:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-12 00:02:33 +0200 |
commit | f332d72f1653ec03b64a80d8d4949dce5564cc99 (patch) | |
tree | 500e6d5d523f1cf66898985d5b7134c32cc270d8 /cli/lsp/analysis.rs | |
parent | 5bad8e17734ef8cc1f19df292d553cc1327638f3 (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/lsp/analysis.rs')
-rw-r--r-- | cli/lsp/analysis.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs index a0718e8b3..b5fca62f4 100644 --- a/cli/lsp/analysis.rs +++ b/cli/lsp/analysis.rs @@ -5,8 +5,10 @@ use super::tsc; use crate::ast; use crate::ast::Location; +use crate::config_file::LintConfig; use crate::lsp::documents::DocumentData; use crate::tools::lint::create_linter; +use crate::tools::lint::get_configured_rules; use deno_ast::swc::ast as swc_ast; use deno_ast::swc::common::comments::Comment; @@ -28,7 +30,6 @@ use deno_core::serde_json::json; use deno_core::url; use deno_core::ModuleResolutionError; use deno_core::ModuleSpecifier; -use deno_lint::rules; use import_map::ImportMap; use lspower::lsp; use lspower::lsp::Position; @@ -196,9 +197,11 @@ fn as_lsp_range(range: &deno_lint::diagnostic::Range) -> Range { pub fn get_lint_references( parsed_source: &deno_ast::ParsedSource, + maybe_lint_config: Option<&LintConfig>, ) -> Result<Vec<Reference>, AnyError> { let syntax = deno_ast::get_syntax(parsed_source.media_type()); - let lint_rules = rules::get_recommended_rules(); + let lint_rules = + get_configured_rules(maybe_lint_config, vec![], vec![], vec![])?; let linter = create_linter(syntax, lint_rules); // TODO(dsherret): do not re-parse here again let (_, lint_diagnostics) = linter.lint( @@ -1350,7 +1353,7 @@ mod tests { MediaType::TypeScript, ) .unwrap(); - let actual = get_lint_references(&parsed_module).unwrap(); + let actual = get_lint_references(&parsed_module, None).unwrap(); assert_eq!( actual, |