are-docs-informative
Advanced tools
Comparing version 0.0.0 to 0.0.1
@@ -1,4 +0,9 @@ | ||
import { InformativeDocsOptions } from "./types.js"; | ||
export * from "./types.js"; | ||
export declare function areDocsInformative(docs: string | string[], name: string | string[], { aliases, uselessWords, }?: InformativeDocsOptions): boolean; | ||
//# sourceMappingURL=index.d.ts.map | ||
interface InformativeDocsOptions { | ||
aliases?: Record<string, string[]>; | ||
existingName?: string | string[]; | ||
uselessWords?: string[]; | ||
} | ||
declare function areDocsInformative(docs: string | string[], name: string | string[], { aliases, uselessWords, }?: InformativeDocsOptions): boolean; | ||
export { InformativeDocsOptions, areDocsInformative }; |
@@ -1,34 +0,31 @@ | ||
export * from "./types.js"; | ||
const defaultAliases = { | ||
a: ["an", "our"], | ||
// src/index.ts | ||
var defaultAliases = { | ||
a: ["an", "our"] | ||
}; | ||
const defaultUselessWords = ["a", "an", "i", "in", "of", "s", "the"]; | ||
export function areDocsInformative(docs, name, { aliases = defaultAliases, uselessWords = defaultUselessWords, } = {}) { | ||
const docsWords = new Set(splitTextIntoWords(docs)); | ||
const nameWords = splitTextIntoWords(name); | ||
for (const nameWord of nameWords) { | ||
docsWords.delete(nameWord); | ||
} | ||
for (const uselessWord of uselessWords) { | ||
docsWords.delete(uselessWord); | ||
} | ||
return !!docsWords.size; | ||
function normalizeWord(word) { | ||
const wordLower = word.toLowerCase(); | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
return aliases[wordLower] ?? wordLower; | ||
} | ||
function splitTextIntoWords(text) { | ||
return (typeof text === "string" ? [text] : text) | ||
.flatMap((name) => { | ||
return name | ||
.replace(/\W+/gu, " ") | ||
.replace(/([a-z])([A-Z])/gu, "$1 $2") | ||
.trim() | ||
.split(" "); | ||
}) | ||
.flatMap(normalizeWord) | ||
.filter(Boolean); | ||
} | ||
var defaultUselessWords = ["a", "an", "i", "in", "of", "s", "the"]; | ||
function areDocsInformative(docs, name, { | ||
aliases = defaultAliases, | ||
uselessWords = defaultUselessWords | ||
} = {}) { | ||
const docsWords = new Set(splitTextIntoWords(docs)); | ||
const nameWords = splitTextIntoWords(name); | ||
for (const nameWord of nameWords) { | ||
docsWords.delete(nameWord); | ||
} | ||
for (const uselessWord of uselessWords) { | ||
docsWords.delete(uselessWord); | ||
} | ||
return !!docsWords.size; | ||
function normalizeWord(word) { | ||
const wordLower = word.toLowerCase(); | ||
return aliases[wordLower] ?? wordLower; | ||
} | ||
function splitTextIntoWords(text) { | ||
return (typeof text === "string" ? [text] : text).flatMap((name2) => { | ||
return name2.replace(/\W+/gu, " ").replace(/([a-z])([A-Z])/gu, "$1 $2").trim().split(" "); | ||
}).flatMap(normalizeWord).filter(Boolean); | ||
} | ||
} | ||
//# sourceMappingURL=index.js.map | ||
export { | ||
areDocsInformative | ||
}; |
{ | ||
"name": "are-docs-informative", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Checks whether a documentation description introduces any new information.", | ||
@@ -12,2 +12,12 @@ "repository": { | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": { | ||
"import": "./lib/index.d.ts", | ||
"require": "./lib/index.d.cts" | ||
}, | ||
"import": "./lib/index.js", | ||
"require": "./lib/index.cjs" | ||
} | ||
}, | ||
"main": "./lib/index.js", | ||
@@ -22,2 +32,3 @@ "files": [ | ||
"build": "tsc", | ||
"build:full": "tsup src/index.ts --clean --format cjs,esm --outDir lib --dts && cp lib/index.d.ts lib/index.d.cts", | ||
"format": "prettier \"**/*\" --ignore-unknown", | ||
@@ -71,2 +82,3 @@ "format:write": "pnpm format --write", | ||
"should-semantic-release": "^0.1.0", | ||
"tsup": "^6.7.0", | ||
"typescript": "^5.0.0", | ||
@@ -73,0 +85,0 @@ "vitest": "^0.29.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93
11081
36
7