Skip to content

Commit b772003

Browse files
JoshuaKGoldbergbrettz9
authored andcommitted
switched to are-docs-informative package
1 parent 9bc2406 commit b772003

File tree

3 files changed

+24
-33
lines changed

3 files changed

+24
-33
lines changed

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
},
77
"dependencies": {
88
"@es-joy/jsdoccomment": "~0.37.0",
9+
"are-docs-informative": "^0.0.1",
910
"comment-parser": "1.3.1",
1011
"debug": "^4.3.4",
1112
"escape-string-regexp": "^4.0.0",

src/rules/informativeDocs.js

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import {
2+
areDocsInformative,
3+
} from 'are-docs-informative';
14
import iterateJsdoc from '../iterateJsdoc';
25

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

69-
const normalizeWord = (word) => {
70-
const wordLower = word.toLowerCase();
71-
72-
return aliases[wordLower] ?? wordLower;
73-
};
74-
75-
const splitTextIntoWords = (...names) => {
76-
return names.flatMap((name) => {
77-
return name
78-
.replace(/\W+/gu, ' ')
79-
.replace(/([a-z])([A-Z])/gu, '$1 $2')
80-
.trim()
81-
.split(' ');
82-
})
83-
.map(normalizeWord);
84-
};
85-
8672
const descriptionIsRedundant = (text, extraName = '') => {
87-
if (!text) {
88-
return false;
89-
}
90-
91-
const split = splitTextIntoWords(text);
92-
const words = new Set(split);
93-
94-
for (const nameWord of splitTextIntoWords(...nodeNames, extraName)) {
95-
words.delete(nameWord);
96-
}
97-
98-
for (const uselessWord of uselessWords) {
99-
words.delete(uselessWord);
100-
}
101-
102-
return !words.size;
73+
return Boolean(text) && !areDocsInformative(text, [
74+
extraName, nodeNames,
75+
].filter(Boolean).join(' '), {
76+
aliases,
77+
uselessWords,
78+
});
10379
};
10480

10581
const {

0 commit comments

Comments
 (0)