Skip to content

Commit

Permalink
fix: improve deno doc --lint error messages (denoland#21156)
Browse files Browse the repository at this point in the history
This also updates deno_graph, which has the JSR change to use "exports".
It's not yet useful atm, so I've made this PR a fix about the deno doc
--lint error message improvements. I'll do a follow-up PR that adds
exports to the deno.json
  • Loading branch information
dsherret committed Nov 10, 2023
1 parent 882c54d commit b78c713
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 35 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_gra
deno_cache_dir = "=0.6.1"
deno_config = "=0.5.0"
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = { version = "=0.72.2", features = ["html"] }
deno_emit = "=0.31.1"
deno_graph = "=0.59.2"
deno_doc = { version = "=0.73.0", features = ["html"] }
deno_emit = "=0.31.2"
deno_graph = "=0.60.0"
deno_lint = { version = "=0.52.2", features = ["docs"] }
deno_lockfile.workspace = true
deno_npm = "0.15.2"
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot", "exclude_runtime_main_js", "include_js_files_for_snapshotting"] }
deno_semver = "0.5.1"
deno_task_shell = "=0.14.0"
eszip = "=0.55.2"
eszip = "=0.55.3"
napi_sym.workspace = true

async-trait.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions cli/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ fn get_module_graph_error_class(err: &ModuleGraphError) -> &'static str {
| ModuleError::UnsupportedImportAttributeType { .. } => "TypeError",
ModuleError::Missing(_, _)
| ModuleError::MissingDynamic(_, _)
| ModuleError::MissingWorkspaceMemberExports { .. }
| ModuleError::UnknownExport { .. }
| ModuleError::UnknownPackage { .. }
| ModuleError::UnknownPackageReq { .. } => "NotFound",
},
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/integration/jsr_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn specifiers_in_lockfile() {

temp_dir.write(
"main.ts",
r#"import version from "jsr:@denotest/[email protected]/mod.ts";
r#"import version from "jsr:@denotest/[email protected]";
console.log(version);"#,
);
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/testdata/doc/referenced_private_types_lint.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type 'MyClass' references type 'MyInterface' which is not exported from a root module.
Missing JS documentation comment.
Missing JSDoc comment.
at file:https:///[WILDCARD]/referenced_private_types.ts:5:1

Missing JS documentation comment.
Type 'MyClass.prototype.prop' references type 'MyInterface' which is not exported from a root module.
Missing JSDoc comment.
at file:https:///[WILDCARD]/referenced_private_types.ts:6:3

error: Found 3 documentation diagnostics.
error: Found 3 documentation lint errors.
2 changes: 1 addition & 1 deletion cli/tests/testdata/jsr/deps/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import value from "jsr:@denotest/deps/mod.ts";
import value from "jsr:@denotest/deps";

console.log(value);
2 changes: 1 addition & 1 deletion cli/tests/testdata/jsr/module_graph/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Test } from "jsr:@denotest/module_graph/mod.ts";
import { Test } from "jsr:@denotest/module_graph";

console.log(new Test());
2 changes: 1 addition & 1 deletion cli/tests/testdata/jsr/no_module_graph/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import version, { TestClass } from "jsr:@denotest/[email protected]/mod.ts";
import version, { TestClass } from "jsr:@denotest/[email protected]";

console.log(version);
console.log(new TestClass());
4 changes: 2 additions & 2 deletions cli/tests/testdata/jsr/no_module_graph/multiple.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import version1 from "jsr:@denotest/[email protected]/mod.ts";
import version2 from "jsr:@denotest/no_module_graph@^0.2/mod.ts";
import version1 from "jsr:@denotest/[email protected]";
import version2 from "jsr:@denotest/no_module_graph@^0.2";

console.log(version1);
console.log(version2);
4 changes: 2 additions & 2 deletions cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0/mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Other } from "jsr:@denotest/module_graph@1/other.ts";
import version from "jsr:@denotest/no_module_graph@^0.1/mod.ts";
import { Other } from "jsr:@denotest/module_graph@1/other";
import version from "jsr:@denotest/no_module_graph@^0.1";

export default {
version,
Expand Down
15 changes: 9 additions & 6 deletions cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0_meta.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"exports": {
".": "./mod.ts"
},
"moduleGraph1": {
"/mod.ts": {
"dependencies": [{
"kind": "import",
"range": [[0, 0], [0, 62]],
"specifier": "jsr:@denotest/module_graph@1/other.ts",
"specifierRange": [[0, 22], [0, 61]]
"range": [[0, 0], [0, 59]],
"specifier": "jsr:@denotest/module_graph@1/other",
"specifierRange": [[0, 22], [0, 58]]
}, {
"kind": "import",
"range": [[1, 0], [1, 64]],
"specifier": "jsr:@denotest/no_module_graph@^0.1/mod.ts",
"specifierRange": [[1, 20], [1, 63]]
"range": [[1, 0], [1, 57]],
"specifier": "jsr:@denotest/no_module_graph@^0.1",
"specifierRange": [[1, 20], [1, 56]]
}]
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"exports": {
".": "./mod.ts",
"./other": "./other.ts"
},
"moduleGraph1": {
"/mod.ts": {
"dependencies": [{
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{}
{
"exports": {
".": "./mod.ts"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{}
{
"exports": {
".": "./mod.ts"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{}
{
"exports": {
".": "./mod.ts"
}
}
4 changes: 2 additions & 2 deletions cli/tools/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ fn check_diagnostics(diagnostics: &[DocDiagnostic]) -> Result<(), AnyError> {
for (line, diagnostics_by_col) in diagnostics_by_lc {
for (col, diagnostics) in diagnostics_by_col {
for diagnostic in diagnostics {
log::warn!("{}", diagnostic.kind);
log::warn!("{}", diagnostic.message());
}
log::warn!(
" at {}:{}:{}\n",
Expand All @@ -276,7 +276,7 @@ fn check_diagnostics(diagnostics: &[DocDiagnostic]) -> Result<(), AnyError> {
}
}
bail!(
"Found {} documentation diagnostic{}.",
"Found {} documentation lint error{}.",
colors::bold(diagnostics.len().to_string()),
if diagnostics.len() == 1 { "" } else { "s" }
);
Expand Down
6 changes: 6 additions & 0 deletions cli/tools/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,12 @@ impl<'a> GraphDisplayContext<'a> {
ModuleError::Missing(_, _) | ModuleError::MissingDynamic(_, _) => {
self.build_error_msg(specifier, "(missing)")
}
ModuleError::MissingWorkspaceMemberExports { .. } => {
self.build_error_msg(specifier, "(missing exports)")
}
ModuleError::UnknownExport { .. } => {
self.build_error_msg(specifier, "(unknown export)")
}
ModuleError::UnknownPackage { .. } => {
self.build_error_msg(specifier, "(unknown package)")
}
Expand Down

0 comments on commit b78c713

Please sign in to comment.