From 4f1c49fd28ff64b9c1a7a1ee20502652cff3132a Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 22 Apr 2023 17:56:13 -0400 Subject: [PATCH] fix(informative-docs): trim description text --- README.md | 7 +++++++ src/rules/informativeDocs.js | 3 ++- test/rules/assertions/informativeDocs.js | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e7ee052c..00c6b6e8d 100644 --- a/README.md +++ b/README.md @@ -7649,6 +7649,13 @@ function takesOne(param) {} * takes abc param */ function takesOne(param) {} + +/** + * @class + * + * @param {number} value - Some useful text + */ +function MyAmazingThing(value) {} ```` diff --git a/src/rules/informativeDocs.js b/src/rules/informativeDocs.js index 98acdb6fc..01e1f499e 100644 --- a/src/rules/informativeDocs.js +++ b/src/rules/informativeDocs.js @@ -70,7 +70,8 @@ export default iterateJsdoc(({ const nodeNames = getNamesFromNode(node); const descriptionIsRedundant = (text, extraName = '') => { - return Boolean(text) && !areDocsInformative(text, [ + const textTrimmed = text.trim(); + return Boolean(textTrimmed) && !areDocsInformative(textTrimmed, [ extraName, nodeNames, ].filter(Boolean).join(' '), { aliases, diff --git a/test/rules/assertions/informativeDocs.js b/test/rules/assertions/informativeDocs.js index ee197d9fa..bbdfbfa17 100644 --- a/test/rules/assertions/informativeDocs.js +++ b/test/rules/assertions/informativeDocs.js @@ -749,5 +749,15 @@ export default { function takesOne(param) {} `, }, + { + code: ` + /** + * @class + * + * @param {number} value - Some useful text + */ + function MyAmazingThing(value) {} + `, + }, ], };