diff options
author | Luca Casonato <hello@lcas.dev> | 2024-05-30 02:09:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-30 00:09:16 +0000 |
commit | e084fe10a98556d4630b54bdda2ce23b3b5b8a60 (patch) | |
tree | fe9d25aadc1fdf3884ead22f90595f1f9e1f3e55 /cli/lsp/diagnostics.rs | |
parent | 13723f267eb87f8c28ef0769cdf7e233b971326e (diff) |
feat(lint): add `no-boolean-literal-for-arguments` rule and enable `no-unused-vars` for jsx files (#24034)
* https://github.com/denoland/deno_lint/pull/1271
* https://github.com/denoland/deno_lint/pull/1277
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/lsp/diagnostics.rs')
-rw-r--r-- | cli/lsp/diagnostics.rs | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index 35da778dc..9e54c8106 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -38,6 +38,7 @@ use deno_graph::source::ResolutionMode; use deno_graph::Resolution; use deno_graph::ResolutionError; use deno_graph::SpecifierError; +use deno_lint::linter::LintConfig; use deno_lint::rules::LintRule; use deno_runtime::deno_fs; use deno_runtime::deno_node; @@ -804,12 +805,27 @@ fn generate_lint_diagnostics( continue; } let version = document.maybe_lsp_version(); - let (lint_options, lint_rules) = config + let (lint_options, lint_config, lint_rules) = config .tree .scope_for_specifier(specifier) .and_then(|s| config_data_by_scope.get(s)) - .map(|d| (d.lint_options.clone(), d.lint_rules.clone())) - .unwrap_or_default(); + .map(|d| { + ( + d.lint_options.clone(), + d.lint_config.clone(), + d.lint_rules.clone(), + ) + }) + .unwrap_or_else(|| { + ( + Arc::default(), + LintConfig { + default_jsx_factory: None, + default_jsx_fragment_factory: None, + }, + Arc::default(), + ) + }); diagnostics_vec.push(DiagnosticRecord { specifier: specifier.clone(), versioned: VersionedDiagnostics { @@ -817,6 +833,7 @@ fn generate_lint_diagnostics( diagnostics: generate_document_lint_diagnostics( &document, &lint_options, + lint_config, lint_rules.rules.clone(), ), }, @@ -828,6 +845,7 @@ fn generate_lint_diagnostics( fn generate_document_lint_diagnostics( document: &Document, lint_options: &LintOptions, + lint_config: LintConfig, lint_rules: Vec<&'static dyn LintRule>, ) -> Vec<lsp::Diagnostic> { if !lint_options.files.matches_specifier(document.specifier()) { @@ -836,7 +854,7 @@ fn generate_document_lint_diagnostics( match document.maybe_parsed_source() { Some(Ok(parsed_source)) => { if let Ok(references) = - analysis::get_lint_references(&parsed_source, lint_rules) + analysis::get_lint_references(&parsed_source, lint_rules, lint_config) { references .into_iter() |