From 87f80ff6be5e2a132b583a9c380fff5db3cb2b07 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 20 Aug 2022 11:31:33 -0400 Subject: feat(unstable): initial support for npm specifiers (#15484) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartek IwaƄczuk --- cli/lsp/cache.rs | 4 ++-- cli/lsp/diagnostics.rs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'cli/lsp') diff --git a/cli/lsp/cache.rs b/cli/lsp/cache.rs index 77f356486..c4512a803 100644 --- a/cli/lsp/cache.rs +++ b/cli/lsp/cache.rs @@ -67,7 +67,7 @@ impl CacheMetadata { &self, specifier: &ModuleSpecifier, ) -> Option>> { - if specifier.scheme() == "file" { + if specifier.scheme() == "file" || specifier.scheme() == "npm" { return None; } let version = self @@ -83,7 +83,7 @@ impl CacheMetadata { } fn refresh(&self, specifier: &ModuleSpecifier) -> Option { - if specifier.scheme() == "file" { + if specifier.scheme() == "file" || specifier.scheme() == "npm" { return None; } let cache_filename = self.cache.get_cache_filename(specifier)?; diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index 7c5ab936a..aef5ae889 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -14,6 +14,7 @@ use super::tsc::TsServer; use crate::args::LintConfig; use crate::diagnostics; +use crate::npm::NpmPackageReference; use deno_ast::MediaType; use deno_core::anyhow::anyhow; @@ -846,6 +847,8 @@ fn diagnose_resolved( .push(DenoDiagnostic::NoAssertType.to_lsp_diagnostic(&range)), } } + } else if NpmPackageReference::from_specifier(specifier).is_ok() { + // ignore npm specifiers for now } else { // When the document is not available, it means that it cannot be found // in the cache or locally on the disk, so we want to issue a diagnostic -- cgit v1.2.3