Skip to content

Commit

Permalink
switched to are-docs-informative package
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg authored and brettz9 committed Apr 11, 2023
1 parent 9bc2406 commit b772003
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 33 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"dependencies": {
"@es-joy/jsdoccomment": "~0.37.0",
"are-docs-informative": "^0.0.1",
"comment-parser": "1.3.1",
"debug": "^4.3.4",
"escape-string-regexp": "^4.0.0",
Expand Down
42 changes: 9 additions & 33 deletions src/rules/informativeDocs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {
areDocsInformative,
} from 'are-docs-informative';
import iterateJsdoc from '../iterateJsdoc';

const defaultAliases = {
Expand Down Expand Up @@ -66,40 +69,13 @@ export default iterateJsdoc(({
} = context.options[0] || {};
const nodeNames = getNamesFromNode(node);

const normalizeWord = (word) => {
const wordLower = word.toLowerCase();

return aliases[wordLower] ?? wordLower;
};

const splitTextIntoWords = (...names) => {
return names.flatMap((name) => {
return name
.replace(/\W+/gu, ' ')
.replace(/([a-z])([A-Z])/gu, '$1 $2')
.trim()
.split(' ');
})
.map(normalizeWord);
};

const descriptionIsRedundant = (text, extraName = '') => {
if (!text) {
return false;
}

const split = splitTextIntoWords(text);
const words = new Set(split);

for (const nameWord of splitTextIntoWords(...nodeNames, extraName)) {
words.delete(nameWord);
}

for (const uselessWord of uselessWords) {
words.delete(uselessWord);
}

return !words.size;
return Boolean(text) && !areDocsInformative(text, [
extraName, nodeNames,
].filter(Boolean).join(' '), {
aliases,
uselessWords,
});
};

const {
Expand Down

0 comments on commit b772003

Please sign in to comment.