diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-11-10 13:40:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 18:40:39 +0000 |
commit | b78c7130e9986ce41284f33a0803ecdf6dd6affd (patch) | |
tree | 5d20148c1e7f449f9d6baa05fe6604aafc2a14b3 /cli | |
parent | 882c54d5c407affb26012d81fea67cccfc214bb7 (diff) |
fix: improve `deno doc --lint` error messages (#21156)
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
Diffstat (limited to 'cli')
-rw-r--r-- | cli/Cargo.toml | 8 | ||||
-rw-r--r-- | cli/errors.rs | 2 | ||||
-rw-r--r-- | cli/tests/integration/jsr_tests.rs | 2 | ||||
-rw-r--r-- | cli/tests/testdata/doc/referenced_private_types_lint.out | 8 | ||||
-rw-r--r-- | cli/tests/testdata/jsr/deps/main.ts | 2 | ||||
-rw-r--r-- | cli/tests/testdata/jsr/module_graph/main.ts | 2 | ||||
-rw-r--r-- | cli/tests/testdata/jsr/no_module_graph/main.ts | 2 | ||||
-rw-r--r-- | cli/tests/testdata/jsr/no_module_graph/multiple.ts | 4 | ||||
-rw-r--r-- | cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0/mod.ts | 4 | ||||
-rw-r--r-- | cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0_meta.json | 15 | ||||
-rw-r--r-- | cli/tests/testdata/jsr/registry/@denotest/module_graph/1.4.0_meta.json | 4 | ||||
-rw-r--r-- | cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.0_meta.json | 6 | ||||
-rw-r--r-- | cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.1_meta.json | 6 | ||||
-rw-r--r-- | cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.2.0_meta.json | 6 | ||||
-rw-r--r-- | cli/tools/doc.rs | 4 | ||||
-rw-r--r-- | cli/tools/info.rs | 6 |
16 files changed, 54 insertions, 27 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 9356af0ac..b7aed6b12 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -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 diff --git a/cli/errors.rs b/cli/errors.rs index 0e3ff4f30..8a6062d8f 100644 --- a/cli/errors.rs +++ b/cli/errors.rs @@ -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", }, diff --git a/cli/tests/integration/jsr_tests.rs b/cli/tests/integration/jsr_tests.rs index d1706d84b..11bb585a6 100644 --- a/cli/tests/integration/jsr_tests.rs +++ b/cli/tests/integration/jsr_tests.rs @@ -69,7 +69,7 @@ fn specifiers_in_lockfile() { temp_dir.write( "main.ts", - r#"import version from "jsr:@denotest/no_module_graph@0.1/mod.ts"; + r#"import version from "jsr:@denotest/no_module_graph@0.1"; console.log(version);"#, ); diff --git a/cli/tests/testdata/doc/referenced_private_types_lint.out b/cli/tests/testdata/doc/referenced_private_types_lint.out index 3b1273e22..54f225059 100644 --- a/cli/tests/testdata/doc/referenced_private_types_lint.out +++ b/cli/tests/testdata/doc/referenced_private_types_lint.out @@ -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:///[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:///[WILDCARD]/referenced_private_types.ts:6:3 -error: Found 3 documentation diagnostics. +error: Found 3 documentation lint errors. diff --git a/cli/tests/testdata/jsr/deps/main.ts b/cli/tests/testdata/jsr/deps/main.ts index 25b13a681..f48255299 100644 --- a/cli/tests/testdata/jsr/deps/main.ts +++ b/cli/tests/testdata/jsr/deps/main.ts @@ -1,3 +1,3 @@ -import value from "jsr:@denotest/deps/mod.ts"; +import value from "jsr:@denotest/deps"; console.log(value); diff --git a/cli/tests/testdata/jsr/module_graph/main.ts b/cli/tests/testdata/jsr/module_graph/main.ts index 02052595c..c92823cc2 100644 --- a/cli/tests/testdata/jsr/module_graph/main.ts +++ b/cli/tests/testdata/jsr/module_graph/main.ts @@ -1,3 +1,3 @@ -import { Test } from "jsr:@denotest/module_graph/mod.ts"; +import { Test } from "jsr:@denotest/module_graph"; console.log(new Test()); diff --git a/cli/tests/testdata/jsr/no_module_graph/main.ts b/cli/tests/testdata/jsr/no_module_graph/main.ts index ab1e781dc..6ea030c59 100644 --- a/cli/tests/testdata/jsr/no_module_graph/main.ts +++ b/cli/tests/testdata/jsr/no_module_graph/main.ts @@ -1,4 +1,4 @@ -import version, { TestClass } from "jsr:@denotest/no_module_graph@0.1.0/mod.ts"; +import version, { TestClass } from "jsr:@denotest/no_module_graph@0.1.0"; console.log(version); console.log(new TestClass()); diff --git a/cli/tests/testdata/jsr/no_module_graph/multiple.ts b/cli/tests/testdata/jsr/no_module_graph/multiple.ts index 0df32b780..660ed8be6 100644 --- a/cli/tests/testdata/jsr/no_module_graph/multiple.ts +++ b/cli/tests/testdata/jsr/no_module_graph/multiple.ts @@ -1,5 +1,5 @@ -import version1 from "jsr:@denotest/no_module_graph@0.1.0/mod.ts"; -import version2 from "jsr:@denotest/no_module_graph@^0.2/mod.ts"; +import version1 from "jsr:@denotest/no_module_graph@0.1.0"; +import version2 from "jsr:@denotest/no_module_graph@^0.2"; console.log(version1); console.log(version2); diff --git a/cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0/mod.ts b/cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0/mod.ts index 5b860b603..4ba0d8aaf 100644 --- a/cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0/mod.ts +++ b/cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0/mod.ts @@ -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, diff --git a/cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0_meta.json b/cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0_meta.json index c6236b7df..f60c65026 100644 --- a/cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0_meta.json +++ b/cli/tests/testdata/jsr/registry/@denotest/deps/1.0.0_meta.json @@ -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]] }] } } diff --git a/cli/tests/testdata/jsr/registry/@denotest/module_graph/1.4.0_meta.json b/cli/tests/testdata/jsr/registry/@denotest/module_graph/1.4.0_meta.json index d1e9a96b9..8745d72b9 100644 --- a/cli/tests/testdata/jsr/registry/@denotest/module_graph/1.4.0_meta.json +++ b/cli/tests/testdata/jsr/registry/@denotest/module_graph/1.4.0_meta.json @@ -1,4 +1,8 @@ { + "exports": { + ".": "./mod.ts", + "./other": "./other.ts" + }, "moduleGraph1": { "/mod.ts": { "dependencies": [{ diff --git a/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.0_meta.json b/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.0_meta.json index 0967ef424..631a18d0e 100644 --- a/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.0_meta.json +++ b/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.0_meta.json @@ -1 +1,5 @@ -{} +{ + "exports": { + ".": "./mod.ts" + } +} diff --git a/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.1_meta.json b/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.1_meta.json index 0967ef424..631a18d0e 100644 --- a/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.1_meta.json +++ b/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.1_meta.json @@ -1 +1,5 @@ -{} +{ + "exports": { + ".": "./mod.ts" + } +} diff --git a/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.2.0_meta.json b/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.2.0_meta.json index 0967ef424..631a18d0e 100644 --- a/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.2.0_meta.json +++ b/cli/tests/testdata/jsr/registry/@denotest/no_module_graph/0.2.0_meta.json @@ -1 +1,5 @@ -{} +{ + "exports": { + ".": "./mod.ts" + } +} diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index 75a559af1..ff8b8d62e 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -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", @@ -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" } ); diff --git a/cli/tools/info.rs b/cli/tools/info.rs index 9321eccb7..60c2fde95 100644 --- a/cli/tools/info.rs +++ b/cli/tools/info.rs @@ -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)") } |