Skip to content

Commit

Permalink
Improve script
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Dec 18, 2023
1 parent 28fbd91 commit 48d7d8d
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions _tools/missing_explicit_types.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,49 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.

import { discoverPackages, discoverExportsByPackage} from "./packages.ts";
import { discoverExportsByPackage, discoverPackages } from "./packages.ts";
import { join } from "../path/mod.ts";
import $ from "https://deno.land/x/dax@0.36.0/mod.ts";

const packages = await discoverPackages();
const exportsByPackage = await discoverExportsByPackage(packages);

const paths = [];
for (const pkg of packages) {
const exports = exportsByPackage.get(pkg)!;
const paths = [];
for (const [_name, path] of exports) {
if (path.endsWith(".json")) {
continue;
}
paths.push(join(pkg, path));
}
if (paths.length === 0) {
continue;
}
}

const text = await $`deno doc --lint ${paths}`.printCommand().env("NO_COLOR", "1").noThrow().captureCombined().text();
const lines = text.split("\n");
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.includes("error:")) {
// ignore
} else if (line.includes("Missing JSDoc comment.")) {
i += 2;
} else {
paths.push("./types.d.ts");

const text = await $`deno doc --lint ${paths}`.printCommand().env(
"NO_COLOR",
"1",
).noThrow().captureCombined().text();
const lines = text.split("\n");
let currentMessageCount = 0;
let currentJsDocCount = 0;
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.includes("Missing JSDoc comment.")) {
currentJsDocCount++;
currentMessageCount++;
} else if (line.trimStart().startsWith("at ")) {
if (currentJsDocCount !== currentMessageCount) {
console.log(line);
} else {
i++; // skip a blank line
}
currentJsDocCount = 0;
currentMessageCount = 0;
} else {
if (line.trim().length > 0) {
currentMessageCount++;
}
console.log(line);
}
}

0 comments on commit 48d7d8d

Please sign in to comment.