Skip to content

Commit 9c04b88

Browse files
authored
fix(lint): skip module graph validation (#30815)
We should just skip module graph validation here. Someone can verify it via other sub commands and this is only used for `no-slow-types`.
1 parent 3e01e4b commit 9c04b88

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

cli/graph_util.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ pub struct CreateGraphOptions<'a> {
385385
pub npm_caching: NpmCachingStrategy,
386386
}
387387

388+
pub struct CreatePublishGraphOptions<'a> {
389+
pub packages: &'a [JsrPackageConfig],
390+
pub build_fast_check_graph: bool,
391+
pub validate_graph: bool,
392+
}
393+
388394
pub struct ModuleGraphCreator {
389395
options: Arc<CliOptions>,
390396
module_graph_builder: Arc<ModuleGraphBuilder>,
@@ -436,10 +442,9 @@ impl ModuleGraphCreator {
436442
.await
437443
}
438444

439-
pub async fn create_and_validate_publish_graph(
445+
pub async fn create_publish_graph(
440446
&self,
441-
package_configs: &[JsrPackageConfig],
442-
build_fast_check_graph: bool,
447+
options: CreatePublishGraphOptions<'_>,
443448
) -> Result<ModuleGraph, AnyError> {
444449
struct PublishLoader(CliDenoGraphLoader);
445450

@@ -485,7 +490,7 @@ impl ModuleGraphCreator {
485490
}
486491

487492
let mut roots = Vec::new();
488-
for package_config in package_configs {
493+
for package_config in options.packages {
489494
roots.extend(package_config.config_file.resolve_export_value_urls()?);
490495
}
491496

@@ -502,15 +507,18 @@ impl ModuleGraphCreator {
502507
npm_caching: self.options.default_npm_caching_strategy(),
503508
})
504509
.await?;
505-
self.graph_valid(&graph)?;
510+
if options.validate_graph {
511+
self.graph_valid(&graph)?;
512+
}
506513
if self.options.type_check_mode().is_true()
507514
&& !graph_has_external_remote(&graph)
508515
{
509516
self.type_check_graph(graph.clone())?;
510517
}
511518

512-
if build_fast_check_graph {
513-
let fast_check_workspace_members = package_configs
519+
if options.build_fast_check_graph {
520+
let fast_check_workspace_members = options
521+
.packages
514522
.iter()
515523
.map(|p| config_to_deno_graph_workspace_member(&p.config_file))
516524
.collect::<Result<Vec<_>, _>>()?;

cli/tools/lint/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use crate::cache::Caches;
4545
use crate::cache::IncrementalCache;
4646
use crate::colors;
4747
use crate::factory::CliFactory;
48+
use crate::graph_util::CreatePublishGraphOptions;
4849
use crate::graph_util::ModuleGraphCreator;
4950
use crate::sys::CliSys;
5051
use crate::tools::fmt::run_parallelized;
@@ -435,7 +436,11 @@ impl WorkspaceLinter {
435436
self.workspace_module_graph = Some(
436437
async move {
437438
module_graph_creator
438-
.create_and_validate_publish_graph(&packages, true)
439+
.create_publish_graph(CreatePublishGraphOptions {
440+
packages: &packages,
441+
build_fast_check_graph: true,
442+
validate_graph: false,
443+
})
439444
.await
440445
.map(Rc::new)
441446
.map_err(Rc::new)

cli/tools/publish/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ use crate::args::PublishFlags;
4949
use crate::args::jsr_api_url;
5050
use crate::args::jsr_url;
5151
use crate::factory::CliFactory;
52+
use crate::graph_util::CreatePublishGraphOptions;
5253
use crate::graph_util::ModuleGraphCreator;
5354
use crate::http_util::HttpClient;
5455
use crate::registry;
@@ -294,10 +295,11 @@ impl PublishPreparer {
294295
let build_fast_check_graph = !allow_slow_types;
295296
let graph = self
296297
.module_graph_creator
297-
.create_and_validate_publish_graph(
298-
package_configs,
298+
.create_publish_graph(CreatePublishGraphOptions {
299+
packages: package_configs,
299300
build_fast_check_graph,
300-
)
301+
validate_graph: true,
302+
})
301303
.await?;
302304

303305
// todo(dsherret): move to lint rule

tests/specs/lint/no_slow_types/b.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export function addB(a: number, b: number) {
33
}
44

55
export * from "./d.ts";
6+
export * from "./non-existent.ts"; // should not cause a linting error

0 commit comments

Comments
 (0)