mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix: update deno_lint and swc (#21718)
Co-authored-by: David Sherret <dsherret@gmail.com>
This commit is contained in:
parent
741afc4b94
commit
69959aa01f
14 changed files with 320 additions and 300 deletions
|
@ -56,7 +56,7 @@
|
||||||
"ext/websocket/autobahn/reports"
|
"ext/websocket/autobahn/reports"
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"https://plugins.dprint.dev/typescript-0.88.7.wasm",
|
"https://plugins.dprint.dev/typescript-0.88.8.wasm",
|
||||||
"https://plugins.dprint.dev/json-0.19.1.wasm",
|
"https://plugins.dprint.dev/json-0.19.1.wasm",
|
||||||
"https://plugins.dprint.dev/markdown-0.16.3.wasm",
|
"https://plugins.dprint.dev/markdown-0.16.3.wasm",
|
||||||
"https://plugins.dprint.dev/toml-0.5.4.wasm",
|
"https://plugins.dprint.dev/toml-0.5.4.wasm",
|
||||||
|
|
2
.github/workflows/ci.generate.ts
vendored
2
.github/workflows/ci.generate.ts
vendored
|
@ -426,6 +426,8 @@ const ci = {
|
||||||
env: {
|
env: {
|
||||||
CARGO_TERM_COLOR: "always",
|
CARGO_TERM_COLOR: "always",
|
||||||
RUST_BACKTRACE: "full",
|
RUST_BACKTRACE: "full",
|
||||||
|
// disable anyhow's library backtrace
|
||||||
|
RUST_LIB_BACKTRACE: 0,
|
||||||
},
|
},
|
||||||
steps: skipJobsIfPrAndMarkedSkip([
|
steps: skipJobsIfPrAndMarkedSkip([
|
||||||
reconfigureWindowsStorage,
|
reconfigureWindowsStorage,
|
||||||
|
|
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
|
@ -113,6 +113,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
RUST_BACKTRACE: full
|
RUST_BACKTRACE: full
|
||||||
|
RUST_LIB_BACKTRACE: 0
|
||||||
steps:
|
steps:
|
||||||
- name: Reconfigure Windows Storage
|
- name: Reconfigure Windows Storage
|
||||||
if: '!(matrix.skip) && (startsWith(matrix.os, ''windows'') && !endsWith(matrix.os, ''-xl''))'
|
if: '!(matrix.skip) && (startsWith(matrix.os, ''windows'') && !endsWith(matrix.os, ''-xl''))'
|
||||||
|
|
355
Cargo.lock
generated
355
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -40,7 +40,7 @@ license = "MIT"
|
||||||
repository = "https://github.com/denoland/deno"
|
repository = "https://github.com/denoland/deno"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
deno_ast = { version = "0.31.6", features = ["transpiling"] }
|
deno_ast = { version = "1.0.1", features = ["transpiling"] }
|
||||||
deno_core = { version = "0.244.0" }
|
deno_core = { version = "0.244.0" }
|
||||||
|
|
||||||
deno_runtime = { version = "0.138.0", path = "./runtime" }
|
deno_runtime = { version = "0.138.0", path = "./runtime" }
|
||||||
|
|
|
@ -60,16 +60,18 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_gra
|
||||||
deno_cache_dir = "=0.6.1"
|
deno_cache_dir = "=0.6.1"
|
||||||
deno_config = "=0.6.5"
|
deno_config = "=0.6.5"
|
||||||
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||||
deno_doc = { version = "=0.85.0", features = ["html"] }
|
deno_doc = { version = "=0.89.0", features = ["html"] }
|
||||||
deno_emit = "=0.32.0"
|
deno_emit = "=0.33.0"
|
||||||
deno_graph = "=0.62.2"
|
deno_graph = "=0.63.0"
|
||||||
deno_lint = { version = "=0.52.2", features = ["docs"] }
|
deno_lint = { version = "=0.53.0", features = ["docs"] }
|
||||||
deno_lockfile.workspace = true
|
deno_lockfile.workspace = true
|
||||||
deno_npm = "0.15.3"
|
deno_npm = "=0.15.3"
|
||||||
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot", "include_js_files_for_snapshotting"] }
|
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot", "include_js_files_for_snapshotting"] }
|
||||||
deno_semver = "0.5.1"
|
# todo(dsherret): investigate https://github.com/denoland/deno_semver/commit/98f9174baef199809295077b3b68c9fa58defb9b causing
|
||||||
|
# lsp_completions_auto_import_and_quick_fix_with_import_map to fail when bumping this version
|
||||||
|
deno_semver = "=0.5.1"
|
||||||
deno_task_shell = "=0.14.0"
|
deno_task_shell = "=0.14.0"
|
||||||
eszip = "=0.56.0"
|
eszip = "=0.57.0"
|
||||||
napi_sym.workspace = true
|
napi_sym.workspace = true
|
||||||
|
|
||||||
async-trait.workspace = true
|
async-trait.workspace = true
|
||||||
|
@ -91,7 +93,7 @@ dotenvy = "0.15.7"
|
||||||
dprint-plugin-json = "=0.19.1"
|
dprint-plugin-json = "=0.19.1"
|
||||||
dprint-plugin-jupyter = "=0.1.2"
|
dprint-plugin-jupyter = "=0.1.2"
|
||||||
dprint-plugin-markdown = "=0.16.3"
|
dprint-plugin-markdown = "=0.16.3"
|
||||||
dprint-plugin-typescript = "=0.88.7"
|
dprint-plugin-typescript = "=0.88.8"
|
||||||
encoding_rs.workspace = true
|
encoding_rs.workspace = true
|
||||||
env_logger = "=0.10.0"
|
env_logger = "=0.10.0"
|
||||||
fancy-regex = "=0.10.0"
|
fancy-regex = "=0.10.0"
|
||||||
|
@ -100,7 +102,7 @@ flate2.workspace = true
|
||||||
fs3.workspace = true
|
fs3.workspace = true
|
||||||
glob = "0.3.1"
|
glob = "0.3.1"
|
||||||
hex.workspace = true
|
hex.workspace = true
|
||||||
import_map = { version = "=0.18.0", features = ["ext"] }
|
import_map = { version = "=0.18.1", features = ["ext"] }
|
||||||
indexmap.workspace = true
|
indexmap.workspace = true
|
||||||
jsonc-parser = { version = "=0.23.0", features = ["serde"] }
|
jsonc-parser = { version = "=0.23.0", features = ["serde"] }
|
||||||
lazy-regex.workspace = true
|
lazy-regex.workspace = true
|
||||||
|
|
11
cli/cache/module_info.rs
vendored
11
cli/cache/module_info.rs
vendored
|
@ -6,11 +6,9 @@ use deno_ast::MediaType;
|
||||||
use deno_ast::ModuleSpecifier;
|
use deno_ast::ModuleSpecifier;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_graph::CapturingModuleParser;
|
|
||||||
use deno_graph::DefaultModuleAnalyzer;
|
use deno_graph::DefaultModuleAnalyzer;
|
||||||
use deno_graph::ModuleInfo;
|
use deno_graph::ModuleInfo;
|
||||||
use deno_graph::ModuleParser;
|
use deno_graph::ModuleParser;
|
||||||
use deno_graph::ParsedSourceStore;
|
|
||||||
use deno_runtime::deno_webstorage::rusqlite::params;
|
use deno_runtime::deno_webstorage::rusqlite::params;
|
||||||
|
|
||||||
use super::cache_db::CacheDB;
|
use super::cache_db::CacheDB;
|
||||||
|
@ -115,19 +113,18 @@ impl ModuleInfoCache {
|
||||||
|
|
||||||
pub fn as_module_analyzer<'a>(
|
pub fn as_module_analyzer<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
parser: Option<&'a dyn ModuleParser>,
|
parser: &'a dyn ModuleParser,
|
||||||
store: &'a dyn ParsedSourceStore,
|
|
||||||
) -> ModuleInfoCacheModuleAnalyzer<'a> {
|
) -> ModuleInfoCacheModuleAnalyzer<'a> {
|
||||||
ModuleInfoCacheModuleAnalyzer {
|
ModuleInfoCacheModuleAnalyzer {
|
||||||
module_info_cache: self,
|
module_info_cache: self,
|
||||||
parser: CapturingModuleParser::new(parser, store),
|
parser,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ModuleInfoCacheModuleAnalyzer<'a> {
|
pub struct ModuleInfoCacheModuleAnalyzer<'a> {
|
||||||
module_info_cache: &'a ModuleInfoCache,
|
module_info_cache: &'a ModuleInfoCache,
|
||||||
parser: CapturingModuleParser<'a>,
|
parser: &'a dyn ModuleParser,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> deno_graph::ModuleAnalyzer for ModuleInfoCacheModuleAnalyzer<'a> {
|
impl<'a> deno_graph::ModuleAnalyzer for ModuleInfoCacheModuleAnalyzer<'a> {
|
||||||
|
@ -156,7 +153,7 @@ impl<'a> deno_graph::ModuleAnalyzer for ModuleInfoCacheModuleAnalyzer<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise, get the module info from the parsed source cache
|
// otherwise, get the module info from the parsed source cache
|
||||||
let analyzer = DefaultModuleAnalyzer::new(&self.parser);
|
let analyzer = DefaultModuleAnalyzer::new(self.parser);
|
||||||
let module_info = analyzer.analyze(specifier, source, media_type)?;
|
let module_info = analyzer.analyze(specifier, source, media_type)?;
|
||||||
|
|
||||||
// then attempt to cache it
|
// then attempt to cache it
|
||||||
|
|
30
cli/cache/parsed_source.rs
vendored
30
cli/cache/parsed_source.rs
vendored
|
@ -9,6 +9,7 @@ use deno_ast::ParsedSource;
|
||||||
use deno_core::parking_lot::Mutex;
|
use deno_core::parking_lot::Mutex;
|
||||||
use deno_graph::CapturingModuleParser;
|
use deno_graph::CapturingModuleParser;
|
||||||
use deno_graph::ModuleParser;
|
use deno_graph::ModuleParser;
|
||||||
|
use deno_graph::ParseOptions;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct ParsedSourceCache {
|
pub struct ParsedSourceCache {
|
||||||
|
@ -37,7 +38,13 @@ impl ParsedSourceCache {
|
||||||
) -> deno_core::anyhow::Result<ParsedSource, deno_ast::Diagnostic> {
|
) -> deno_core::anyhow::Result<ParsedSource, deno_ast::Diagnostic> {
|
||||||
let parser = self.as_capturing_parser();
|
let parser = self.as_capturing_parser();
|
||||||
// this will conditionally parse because it's using a CapturingModuleParser
|
// this will conditionally parse because it's using a CapturingModuleParser
|
||||||
parser.parse_module(specifier, source, media_type)
|
parser.parse_module(ParseOptions {
|
||||||
|
specifier,
|
||||||
|
source,
|
||||||
|
media_type,
|
||||||
|
// don't bother enabling because this method is currently only used for emitting
|
||||||
|
scope_analysis: false,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Frees the parsed source from memory.
|
/// Frees the parsed source from memory.
|
||||||
|
@ -50,10 +57,6 @@ impl ParsedSourceCache {
|
||||||
pub fn as_capturing_parser(&self) -> CapturingModuleParser {
|
pub fn as_capturing_parser(&self) -> CapturingModuleParser {
|
||||||
CapturingModuleParser::new(None, self)
|
CapturingModuleParser::new(None, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_store(self: &Arc<Self>) -> Arc<dyn deno_graph::ParsedSourceStore> {
|
|
||||||
self.clone()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// It's ok that this is racy since in non-LSP situations
|
/// It's ok that this is racy since in non-LSP situations
|
||||||
|
@ -76,4 +79,21 @@ impl deno_graph::ParsedSourceStore for ParsedSourceCache {
|
||||||
) -> Option<ParsedSource> {
|
) -> Option<ParsedSource> {
|
||||||
self.sources.lock().get(specifier).cloned()
|
self.sources.lock().get(specifier).cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_scope_analysis_parsed_source(
|
||||||
|
&self,
|
||||||
|
specifier: &deno_graph::ModuleSpecifier,
|
||||||
|
) -> Option<ParsedSource> {
|
||||||
|
let mut sources = self.sources.lock();
|
||||||
|
let parsed_source = sources.get(specifier)?;
|
||||||
|
if parsed_source.has_scope_analysis() {
|
||||||
|
Some(parsed_source.clone())
|
||||||
|
} else {
|
||||||
|
// upgrade to have scope analysis
|
||||||
|
let parsed_source = sources.remove(specifier).unwrap();
|
||||||
|
let parsed_source = parsed_source.into_with_scope_analysis();
|
||||||
|
sources.insert(specifier.clone(), parsed_source.clone());
|
||||||
|
Some(parsed_source)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ use crate::util::path::specifier_to_file_path;
|
||||||
use crate::util::sync::TaskQueue;
|
use crate::util::sync::TaskQueue;
|
||||||
use crate::util::sync::TaskQueuePermit;
|
use crate::util::sync::TaskQueuePermit;
|
||||||
|
|
||||||
|
use deno_config::ConfigFile;
|
||||||
use deno_core::anyhow::bail;
|
use deno_core::anyhow::bail;
|
||||||
use deno_core::anyhow::Context;
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::custom_error;
|
use deno_core::error::custom_error;
|
||||||
|
@ -32,7 +33,6 @@ use deno_graph::source::Loader;
|
||||||
use deno_graph::source::ResolveError;
|
use deno_graph::source::ResolveError;
|
||||||
use deno_graph::GraphKind;
|
use deno_graph::GraphKind;
|
||||||
use deno_graph::Module;
|
use deno_graph::Module;
|
||||||
use deno_graph::ModuleAnalyzer;
|
|
||||||
use deno_graph::ModuleError;
|
use deno_graph::ModuleError;
|
||||||
use deno_graph::ModuleGraph;
|
use deno_graph::ModuleGraph;
|
||||||
use deno_graph::ModuleGraphError;
|
use deno_graph::ModuleGraphError;
|
||||||
|
@ -193,8 +193,11 @@ pub fn graph_lock_or_exit(graph: &ModuleGraph, lockfile: &mut Lockfile) {
|
||||||
pub struct CreateGraphOptions<'a> {
|
pub struct CreateGraphOptions<'a> {
|
||||||
pub graph_kind: GraphKind,
|
pub graph_kind: GraphKind,
|
||||||
pub roots: Vec<ModuleSpecifier>,
|
pub roots: Vec<ModuleSpecifier>,
|
||||||
pub loader: &'a mut dyn Loader,
|
/// Whether to do fast check on workspace members. This is mostly only
|
||||||
pub analyzer: &'a dyn ModuleAnalyzer,
|
/// useful when publishing.
|
||||||
|
pub workspace_fast_check: bool,
|
||||||
|
/// Specify `None` to use the default CLI loader.
|
||||||
|
pub loader: Option<&'a mut dyn Loader>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ModuleGraphBuilder {
|
pub struct ModuleGraphBuilder {
|
||||||
|
@ -261,14 +264,12 @@ impl ModuleGraphBuilder {
|
||||||
roots: Vec<ModuleSpecifier>,
|
roots: Vec<ModuleSpecifier>,
|
||||||
loader: &mut dyn Loader,
|
loader: &mut dyn Loader,
|
||||||
) -> Result<deno_graph::ModuleGraph, AnyError> {
|
) -> Result<deno_graph::ModuleGraph, AnyError> {
|
||||||
let store = self.parsed_source_cache.as_store();
|
|
||||||
let analyzer = self.module_info_cache.as_module_analyzer(None, &*store);
|
|
||||||
self
|
self
|
||||||
.create_graph_with_options(CreateGraphOptions {
|
.create_graph_with_options(CreateGraphOptions {
|
||||||
graph_kind,
|
graph_kind,
|
||||||
roots,
|
roots,
|
||||||
loader,
|
loader: Some(loader),
|
||||||
analyzer: &analyzer,
|
workspace_fast_check: false,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -277,14 +278,23 @@ impl ModuleGraphBuilder {
|
||||||
&self,
|
&self,
|
||||||
options: CreateGraphOptions<'_>,
|
options: CreateGraphOptions<'_>,
|
||||||
) -> Result<deno_graph::ModuleGraph, AnyError> {
|
) -> Result<deno_graph::ModuleGraph, AnyError> {
|
||||||
let maybe_imports = self.options.to_maybe_imports()?;
|
enum MutLoaderRef<'a> {
|
||||||
let maybe_workspace_config = self.options.maybe_workspace_config();
|
Borrowed(&'a mut dyn Loader),
|
||||||
let workspace_members = if let Some(wc) = maybe_workspace_config {
|
Owned(cache::FetchCacher),
|
||||||
workspace_config_to_workspace_members(wc)?
|
}
|
||||||
} else {
|
|
||||||
vec![]
|
|
||||||
};
|
|
||||||
|
|
||||||
|
impl<'a> MutLoaderRef<'a> {
|
||||||
|
pub fn as_mut_loader(&mut self) -> &mut dyn Loader {
|
||||||
|
match self {
|
||||||
|
Self::Borrowed(loader) => *loader,
|
||||||
|
Self::Owned(loader) => loader,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let parser = self.parsed_source_cache.as_capturing_parser();
|
||||||
|
let analyzer = self.module_info_cache.as_module_analyzer(&parser);
|
||||||
|
let maybe_imports = self.options.to_maybe_imports()?;
|
||||||
let cli_resolver = self.resolver.clone();
|
let cli_resolver = self.resolver.clone();
|
||||||
let graph_resolver = cli_resolver.as_graph_resolver();
|
let graph_resolver = cli_resolver.as_graph_resolver();
|
||||||
let graph_npm_resolver = cli_resolver.as_graph_npm_resolver();
|
let graph_npm_resolver = cli_resolver.as_graph_npm_resolver();
|
||||||
|
@ -292,22 +302,28 @@ impl ModuleGraphBuilder {
|
||||||
.maybe_file_watcher_reporter
|
.maybe_file_watcher_reporter
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|r| r.as_reporter());
|
.map(|r| r.as_reporter());
|
||||||
|
let mut loader = match options.loader {
|
||||||
|
Some(loader) => MutLoaderRef::Borrowed(loader),
|
||||||
|
None => MutLoaderRef::Owned(self.create_graph_loader()),
|
||||||
|
};
|
||||||
|
|
||||||
let mut graph = ModuleGraph::new(options.graph_kind);
|
let mut graph = ModuleGraph::new(options.graph_kind);
|
||||||
self
|
self
|
||||||
.build_graph_with_npm_resolution(
|
.build_graph_with_npm_resolution(
|
||||||
&mut graph,
|
&mut graph,
|
||||||
options.roots,
|
options.roots,
|
||||||
options.loader,
|
loader.as_mut_loader(),
|
||||||
deno_graph::BuildOptions {
|
deno_graph::BuildOptions {
|
||||||
is_dynamic: false,
|
is_dynamic: false,
|
||||||
imports: maybe_imports,
|
imports: maybe_imports,
|
||||||
resolver: Some(graph_resolver),
|
resolver: Some(graph_resolver),
|
||||||
file_system: Some(&DenoGraphFsAdapter(self.fs.as_ref())),
|
file_system: Some(&DenoGraphFsAdapter(self.fs.as_ref())),
|
||||||
npm_resolver: Some(graph_npm_resolver),
|
npm_resolver: Some(graph_npm_resolver),
|
||||||
module_analyzer: Some(options.analyzer),
|
module_analyzer: Some(&analyzer),
|
||||||
|
module_parser: Some(&parser),
|
||||||
reporter: maybe_file_watcher_reporter,
|
reporter: maybe_file_watcher_reporter,
|
||||||
workspace_members,
|
workspace_fast_check: options.workspace_fast_check,
|
||||||
|
workspace_members: self.get_deno_graph_workspace_members()?,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -327,17 +343,11 @@ impl ModuleGraphBuilder {
|
||||||
) -> Result<Arc<deno_graph::ModuleGraph>, AnyError> {
|
) -> Result<Arc<deno_graph::ModuleGraph>, AnyError> {
|
||||||
let mut cache = self.create_graph_loader();
|
let mut cache = self.create_graph_loader();
|
||||||
let maybe_imports = self.options.to_maybe_imports()?;
|
let maybe_imports = self.options.to_maybe_imports()?;
|
||||||
let maybe_workspace_config = self.options.maybe_workspace_config();
|
|
||||||
let workspace_members = if let Some(wc) = maybe_workspace_config {
|
|
||||||
workspace_config_to_workspace_members(wc)?
|
|
||||||
} else {
|
|
||||||
vec![]
|
|
||||||
};
|
|
||||||
let cli_resolver = self.resolver.clone();
|
let cli_resolver = self.resolver.clone();
|
||||||
let graph_resolver = cli_resolver.as_graph_resolver();
|
let graph_resolver = cli_resolver.as_graph_resolver();
|
||||||
let graph_npm_resolver = cli_resolver.as_graph_npm_resolver();
|
let graph_npm_resolver = cli_resolver.as_graph_npm_resolver();
|
||||||
let store = self.parsed_source_cache.as_store();
|
let parser = self.parsed_source_cache.as_capturing_parser();
|
||||||
let analyzer = self.module_info_cache.as_module_analyzer(None, &*store);
|
let analyzer = self.module_info_cache.as_module_analyzer(&parser);
|
||||||
let graph_kind = self.options.type_check_mode().as_graph_kind();
|
let graph_kind = self.options.type_check_mode().as_graph_kind();
|
||||||
let mut graph = ModuleGraph::new(graph_kind);
|
let mut graph = ModuleGraph::new(graph_kind);
|
||||||
let maybe_file_watcher_reporter = self
|
let maybe_file_watcher_reporter = self
|
||||||
|
@ -357,8 +367,10 @@ impl ModuleGraphBuilder {
|
||||||
resolver: Some(graph_resolver),
|
resolver: Some(graph_resolver),
|
||||||
npm_resolver: Some(graph_npm_resolver),
|
npm_resolver: Some(graph_npm_resolver),
|
||||||
module_analyzer: Some(&analyzer),
|
module_analyzer: Some(&analyzer),
|
||||||
|
module_parser: Some(&parser),
|
||||||
reporter: maybe_file_watcher_reporter,
|
reporter: maybe_file_watcher_reporter,
|
||||||
workspace_members,
|
workspace_fast_check: false,
|
||||||
|
workspace_members: self.get_deno_graph_workspace_members()?,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -391,6 +403,30 @@ impl ModuleGraphBuilder {
|
||||||
Ok(graph)
|
Ok(graph)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_deno_graph_workspace_members(
|
||||||
|
&self,
|
||||||
|
) -> Result<Vec<deno_graph::WorkspaceMember>, AnyError> {
|
||||||
|
let maybe_workspace_config = self.options.maybe_workspace_config();
|
||||||
|
if let Some(wc) = maybe_workspace_config {
|
||||||
|
workspace_config_to_workspace_members(wc)
|
||||||
|
} else {
|
||||||
|
Ok(
|
||||||
|
self
|
||||||
|
.options
|
||||||
|
.maybe_config_file()
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|c| match config_to_workspace_member(c) {
|
||||||
|
Ok(m) => Some(vec![m]),
|
||||||
|
Err(e) => {
|
||||||
|
log::debug!("Deno config was not a package: {:#}", e);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.unwrap_or_default(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn build_graph_with_npm_resolution<'a>(
|
pub async fn build_graph_with_npm_resolution<'a>(
|
||||||
&self,
|
&self,
|
||||||
graph: &mut ModuleGraph,
|
graph: &mut ModuleGraph,
|
||||||
|
@ -435,7 +471,7 @@ impl ModuleGraphBuilder {
|
||||||
.strip_prefix("jsr:")
|
.strip_prefix("jsr:")
|
||||||
.and_then(|value| PackageNv::from_str(value).ok())
|
.and_then(|value| PackageNv::from_str(value).ok())
|
||||||
{
|
{
|
||||||
graph.packages.add(key, value);
|
graph.packages.add_nv(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -777,36 +813,34 @@ pub fn workspace_config_to_workspace_members(
|
||||||
.members
|
.members
|
||||||
.iter()
|
.iter()
|
||||||
.map(|member| {
|
.map(|member| {
|
||||||
workspace_member_config_try_into_workspace_member(member).with_context(
|
config_to_workspace_member(&member.config_file).with_context(|| {
|
||||||
|| {
|
|
||||||
format!(
|
format!(
|
||||||
"Failed to resolve configuration for '{}' workspace member at '{}'",
|
"Failed to resolve configuration for '{}' workspace member at '{}'",
|
||||||
member.member_name,
|
member.member_name,
|
||||||
member.config_file.specifier.as_str()
|
member.config_file.specifier.as_str()
|
||||||
)
|
)
|
||||||
},
|
})
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn workspace_member_config_try_into_workspace_member(
|
fn config_to_workspace_member(
|
||||||
config: &deno_config::WorkspaceMemberConfig,
|
config: &ConfigFile,
|
||||||
) -> Result<deno_graph::WorkspaceMember, AnyError> {
|
) -> Result<deno_graph::WorkspaceMember, AnyError> {
|
||||||
let nv = deno_semver::package::PackageNv {
|
let nv = deno_semver::package::PackageNv {
|
||||||
name: config.package_name.clone(),
|
name: match &config.json.name {
|
||||||
version: deno_semver::Version::parse_standard(&config.package_version)?,
|
Some(name) => name.clone(),
|
||||||
|
None => bail!("Missing 'name' field in config file."),
|
||||||
|
},
|
||||||
|
version: match &config.json.version {
|
||||||
|
Some(name) => deno_semver::Version::parse_standard(name)?,
|
||||||
|
None => bail!("Missing 'version' field in config file."),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
Ok(deno_graph::WorkspaceMember {
|
Ok(deno_graph::WorkspaceMember {
|
||||||
base: ModuleSpecifier::from_directory_path(&config.path).unwrap(),
|
base: config.specifier.join("./").unwrap(),
|
||||||
nv,
|
nv,
|
||||||
exports: config
|
exports: config.to_exports_config()?.into_map(),
|
||||||
.config_file
|
|
||||||
.to_exports_config()?
|
|
||||||
.into_map()
|
|
||||||
// todo(dsherret): deno_graph should use an IndexMap
|
|
||||||
.into_iter()
|
|
||||||
.collect(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ pub fn get_lint_references(
|
||||||
parsed_source: &deno_ast::ParsedSource,
|
parsed_source: &deno_ast::ParsedSource,
|
||||||
lint_rules: Vec<&'static dyn LintRule>,
|
lint_rules: Vec<&'static dyn LintRule>,
|
||||||
) -> Result<Vec<Reference>, AnyError> {
|
) -> Result<Vec<Reference>, AnyError> {
|
||||||
let linter = create_linter(parsed_source.media_type(), lint_rules);
|
let linter = create_linter(lint_rules);
|
||||||
let lint_diagnostics = linter.lint_with_ast(parsed_source);
|
let lint_diagnostics = linter.lint_with_ast(parsed_source);
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
|
|
|
@ -138,8 +138,8 @@ impl ModuleLoadPreparer {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|r| r.as_reporter());
|
.map(|r| r.as_reporter());
|
||||||
|
|
||||||
let store = self.parsed_source_cache.as_store();
|
let parser = self.parsed_source_cache.as_capturing_parser();
|
||||||
let analyzer = self.module_info_cache.as_module_analyzer(None, &*store);
|
let analyzer = self.module_info_cache.as_module_analyzer(&parser);
|
||||||
|
|
||||||
log::debug!("Creating module graph.");
|
log::debug!("Creating module graph.");
|
||||||
let mut graph_update_permit =
|
let mut graph_update_permit =
|
||||||
|
@ -163,8 +163,10 @@ impl ModuleLoadPreparer {
|
||||||
file_system: Some(&DenoGraphFsAdapter(self.fs.as_ref())),
|
file_system: Some(&DenoGraphFsAdapter(self.fs.as_ref())),
|
||||||
resolver: Some(graph_resolver),
|
resolver: Some(graph_resolver),
|
||||||
npm_resolver: Some(graph_npm_resolver),
|
npm_resolver: Some(graph_npm_resolver),
|
||||||
|
module_parser: Some(&parser),
|
||||||
module_analyzer: Some(&analyzer),
|
module_analyzer: Some(&analyzer),
|
||||||
reporter: maybe_file_watcher_reporter,
|
reporter: maybe_file_watcher_reporter,
|
||||||
|
workspace_fast_check: false,
|
||||||
workspace_members,
|
workspace_members,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,7 +10,6 @@ use crate::display::write_json_to_stdout;
|
||||||
use crate::display::write_to_stdout_ignore_sigpipe;
|
use crate::display::write_to_stdout_ignore_sigpipe;
|
||||||
use crate::factory::CliFactory;
|
use crate::factory::CliFactory;
|
||||||
use crate::graph_util::graph_lock_or_exit;
|
use crate::graph_util::graph_lock_or_exit;
|
||||||
use crate::graph_util::CreateGraphOptions;
|
|
||||||
use crate::tsc::get_types_declaration_file_text;
|
use crate::tsc::get_types_declaration_file_text;
|
||||||
use crate::util::fs::collect_specifiers;
|
use crate::util::fs::collect_specifiers;
|
||||||
use crate::util::glob::FilePatterns;
|
use crate::util::glob::FilePatterns;
|
||||||
|
@ -20,10 +19,9 @@ use deno_core::anyhow::Context;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::futures::FutureExt;
|
use deno_core::futures::FutureExt;
|
||||||
use deno_doc as doc;
|
use deno_doc as doc;
|
||||||
use deno_graph::CapturingModuleParser;
|
|
||||||
use deno_graph::DefaultParsedSourceStore;
|
|
||||||
use deno_graph::GraphKind;
|
use deno_graph::GraphKind;
|
||||||
use deno_graph::ModuleAnalyzer;
|
use deno_graph::ModuleAnalyzer;
|
||||||
|
use deno_graph::ModuleParser;
|
||||||
use deno_graph::ModuleSpecifier;
|
use deno_graph::ModuleSpecifier;
|
||||||
use doc::DocDiagnostic;
|
use doc::DocDiagnostic;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
|
@ -35,7 +33,7 @@ use std::sync::Arc;
|
||||||
async fn generate_doc_nodes_for_builtin_types(
|
async fn generate_doc_nodes_for_builtin_types(
|
||||||
doc_flags: DocFlags,
|
doc_flags: DocFlags,
|
||||||
cli_options: &Arc<CliOptions>,
|
cli_options: &Arc<CliOptions>,
|
||||||
capturing_parser: CapturingModuleParser<'_>,
|
parser: &dyn ModuleParser,
|
||||||
analyzer: &dyn ModuleAnalyzer,
|
analyzer: &dyn ModuleAnalyzer,
|
||||||
) -> Result<IndexMap<ModuleSpecifier, Vec<doc::DocNode>>, AnyError> {
|
) -> Result<IndexMap<ModuleSpecifier, Vec<doc::DocNode>>, AnyError> {
|
||||||
let source_file_specifier =
|
let source_file_specifier =
|
||||||
|
@ -65,7 +63,7 @@ async fn generate_doc_nodes_for_builtin_types(
|
||||||
.await;
|
.await;
|
||||||
let doc_parser = doc::DocParser::new(
|
let doc_parser = doc::DocParser::new(
|
||||||
&graph,
|
&graph,
|
||||||
capturing_parser,
|
parser,
|
||||||
doc::DocParserOptions {
|
doc::DocParserOptions {
|
||||||
diagnostics: false,
|
diagnostics: false,
|
||||||
private: doc_flags.private,
|
private: doc_flags.private,
|
||||||
|
@ -80,19 +78,16 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> {
|
||||||
let factory = CliFactory::from_flags(flags).await?;
|
let factory = CliFactory::from_flags(flags).await?;
|
||||||
let cli_options = factory.cli_options();
|
let cli_options = factory.cli_options();
|
||||||
let module_info_cache = factory.module_info_cache()?;
|
let module_info_cache = factory.module_info_cache()?;
|
||||||
let source_parser = deno_graph::DefaultModuleParser::new_for_analysis();
|
let parsed_source_cache = factory.parsed_source_cache();
|
||||||
let store = DefaultParsedSourceStore::default();
|
let capturing_parser = parsed_source_cache.as_capturing_parser();
|
||||||
let analyzer =
|
let analyzer = module_info_cache.as_module_analyzer(&capturing_parser);
|
||||||
module_info_cache.as_module_analyzer(Some(&source_parser), &store);
|
|
||||||
let capturing_parser =
|
|
||||||
CapturingModuleParser::new(Some(&source_parser), &store);
|
|
||||||
|
|
||||||
let doc_nodes_by_url = match doc_flags.source_files {
|
let doc_nodes_by_url = match doc_flags.source_files {
|
||||||
DocSourceFileFlag::Builtin => {
|
DocSourceFileFlag::Builtin => {
|
||||||
generate_doc_nodes_for_builtin_types(
|
generate_doc_nodes_for_builtin_types(
|
||||||
doc_flags.clone(),
|
doc_flags.clone(),
|
||||||
cli_options,
|
cli_options,
|
||||||
capturing_parser,
|
&capturing_parser,
|
||||||
&analyzer,
|
&analyzer,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
|
@ -123,14 +118,8 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> {
|
||||||
},
|
},
|
||||||
|_, _| true,
|
|_, _| true,
|
||||||
)?;
|
)?;
|
||||||
let mut loader = module_graph_builder.create_graph_loader();
|
|
||||||
let graph = module_graph_builder
|
let graph = module_graph_builder
|
||||||
.create_graph_with_options(CreateGraphOptions {
|
.create_graph(GraphKind::TypesOnly, module_specifiers.clone())
|
||||||
graph_kind: GraphKind::TypesOnly,
|
|
||||||
roots: module_specifiers.clone(),
|
|
||||||
loader: &mut loader,
|
|
||||||
analyzer: &analyzer,
|
|
||||||
})
|
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if let Some(lockfile) = maybe_lockfile {
|
if let Some(lockfile) = maybe_lockfile {
|
||||||
|
@ -139,7 +128,7 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> {
|
||||||
|
|
||||||
let doc_parser = doc::DocParser::new(
|
let doc_parser = doc::DocParser::new(
|
||||||
&graph,
|
&graph,
|
||||||
capturing_parser,
|
&capturing_parser,
|
||||||
doc::DocParserOptions {
|
doc::DocParserOptions {
|
||||||
private: doc_flags.private,
|
private: doc_flags.private,
|
||||||
diagnostics: doc_flags.lint,
|
diagnostics: doc_flags.lint,
|
||||||
|
@ -168,7 +157,7 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> {
|
||||||
let deno_ns = generate_doc_nodes_for_builtin_types(
|
let deno_ns = generate_doc_nodes_for_builtin_types(
|
||||||
doc_flags.clone(),
|
doc_flags.clone(),
|
||||||
cli_options,
|
cli_options,
|
||||||
capturing_parser,
|
&capturing_parser,
|
||||||
&analyzer,
|
&analyzer,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
@ -23,6 +23,7 @@ use deno_core::error::AnyError;
|
||||||
use deno_core::error::JsStackFrame;
|
use deno_core::error::JsStackFrame;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_lint::diagnostic::LintDiagnostic;
|
use deno_lint::diagnostic::LintDiagnostic;
|
||||||
|
use deno_lint::linter::LintFileOptions;
|
||||||
use deno_lint::linter::Linter;
|
use deno_lint::linter::Linter;
|
||||||
use deno_lint::linter::LinterBuilder;
|
use deno_lint::linter::LinterBuilder;
|
||||||
use deno_lint::rules;
|
use deno_lint::rules;
|
||||||
|
@ -249,14 +250,10 @@ pub fn print_rules_list(json: bool, maybe_rules_tags: Option<Vec<String>>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_linter(
|
pub fn create_linter(rules: Vec<&'static dyn LintRule>) -> Linter {
|
||||||
media_type: MediaType,
|
|
||||||
rules: Vec<&'static dyn LintRule>,
|
|
||||||
) -> Linter {
|
|
||||||
LinterBuilder::default()
|
LinterBuilder::default()
|
||||||
.ignore_file_directive("deno-lint-ignore-file")
|
.ignore_file_directive("deno-lint-ignore-file")
|
||||||
.ignore_diagnostic_directive("deno-lint-ignore")
|
.ignore_diagnostic_directive("deno-lint-ignore")
|
||||||
.media_type(media_type)
|
|
||||||
.rules(rules)
|
.rules(rules)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
@ -266,12 +263,16 @@ fn lint_file(
|
||||||
source_code: String,
|
source_code: String,
|
||||||
lint_rules: Vec<&'static dyn LintRule>,
|
lint_rules: Vec<&'static dyn LintRule>,
|
||||||
) -> Result<(Vec<LintDiagnostic>, String), AnyError> {
|
) -> Result<(Vec<LintDiagnostic>, String), AnyError> {
|
||||||
let file_name = file_path.to_string_lossy().to_string();
|
let filename = file_path.to_string_lossy().to_string();
|
||||||
let media_type = MediaType::from_path(file_path);
|
let media_type = MediaType::from_path(file_path);
|
||||||
|
|
||||||
let linter = create_linter(media_type, lint_rules);
|
let linter = create_linter(lint_rules);
|
||||||
|
|
||||||
let (_, file_diagnostics) = linter.lint(file_name, source_code.clone())?;
|
let (_, file_diagnostics) = linter.lint_file(LintFileOptions {
|
||||||
|
filename,
|
||||||
|
media_type,
|
||||||
|
source_code: source_code.clone(),
|
||||||
|
})?;
|
||||||
|
|
||||||
Ok((file_diagnostics, source_code))
|
Ok((file_diagnostics, source_code))
|
||||||
}
|
}
|
||||||
|
@ -287,10 +288,13 @@ fn lint_stdin(
|
||||||
return Err(generic_error("Failed to read from stdin"));
|
return Err(generic_error("Failed to read from stdin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let linter = create_linter(MediaType::TypeScript, lint_rules);
|
let linter = create_linter(lint_rules);
|
||||||
|
|
||||||
let (_, file_diagnostics) =
|
let (_, file_diagnostics) = linter.lint_file(LintFileOptions {
|
||||||
linter.lint(STDIN_FILE_NAME.to_string(), source_code.clone())?;
|
filename: STDIN_FILE_NAME.to_string(),
|
||||||
|
source_code: source_code.clone(),
|
||||||
|
media_type: MediaType::TypeScript,
|
||||||
|
})?;
|
||||||
|
|
||||||
Ok((file_diagnostics, source_code))
|
Ok((file_diagnostics, source_code))
|
||||||
}
|
}
|
||||||
|
|
|
@ -839,7 +839,7 @@ fn analyze_jsx_pragmas(
|
||||||
|
|
||||||
let mut analyzed_pragmas = AnalyzedJsxPragmas::default();
|
let mut analyzed_pragmas = AnalyzedJsxPragmas::default();
|
||||||
|
|
||||||
for c in parsed_source.get_leading_comments().iter() {
|
for c in parsed_source.get_leading_comments()?.iter() {
|
||||||
if c.kind != CommentKind::Block {
|
if c.kind != CommentKind::Block {
|
||||||
continue; // invalid
|
continue; // invalid
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue