-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |