diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-09-23 15:18:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-23 19:18:52 +0000 |
commit | 33f169beb90814b7f2f62a8c0e3990722ae3db4c (patch) | |
tree | 9877fb3b7dcbfd4482afc530467c072e38601f55 /tools/jsdoc_checker.js | |
parent | e1c8d2755e23182875b8fefeb558e603dd981418 (diff) |
chore: add code generation for @types/deno (#25545)
Diffstat (limited to 'tools/jsdoc_checker.js')
-rwxr-xr-x | tools/jsdoc_checker.js | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tools/jsdoc_checker.js b/tools/jsdoc_checker.js index 720a8ed8b..241d04273 100755 --- a/tools/jsdoc_checker.js +++ b/tools/jsdoc_checker.js @@ -45,33 +45,39 @@ for (const file of project.getSourceFiles()) { } const parent = node.getFirstAncestorByKind(ts.SyntaxKind.ModuleDeclaration); + const isInterfaceOrType = + node.getKind() === ts.SyntaxKind.InterfaceDeclaration || + node.getKind() === ts.SyntaxKind.TypeAliasDeclaration; if (parent) { if (!node.isExported()) { - errors.push(getErrorPrefix(node) + "export keyword"); + errors.push(getMissingErrorPrefix(node) + "export keyword"); continue; } - } else if (!node.hasDeclareKeyword()) { - errors.push(getErrorPrefix(node) + "declare keyword"); + } else if (!isInterfaceOrType && !node.hasDeclareKeyword()) { + errors.push(getMissingErrorPrefix(node) + "declare keyword"); + continue; + } else if (isInterfaceOrType && node.hasDeclareKeyword()) { + errors.push(getErrorPrefix(node) + "has incorrect declare keyword"); continue; } const jsDoc = node.getFirstChildIfKind(ts.SyntaxKind.JSDoc); if (!jsDoc) { - errors.push(getErrorPrefix(node) + "JSDoc comment"); + errors.push(getMissingErrorPrefix(node) + "JSDoc comment"); continue; } const tags = jsDoc.getTags(); if (!tags.find((tag) => tag.getTagName() === "category")) { - errors.push(getErrorPrefix(node) + "JSDoc @category tag"); + errors.push(getMissingErrorPrefix(node) + "JSDoc @category tag"); continue; } if (unstableFiles.includes(file)) { if (!tags.find((tag) => tag.getTagName() === "experimental")) { - errors.push(getErrorPrefix(node) + "JSDoc @experimental tag"); + errors.push(getMissingErrorPrefix(node) + "JSDoc @experimental tag"); } } } @@ -81,6 +87,10 @@ if (errors.length > 0) { throw new AggregateError(errors); } +function getMissingErrorPrefix(node) { + return getErrorPrefix(node) + `is missing a `; +} + function getErrorPrefix(node) { - return `Symbol at file://${node.getSourceFile().getFilePath()}:${node.getStartLineNumber()} is missing a `; + return `Symbol at file://${node.getSourceFile().getFilePath()}:${node.getStartLineNumber()} `; } |