diff --git a/README.md b/README.md index 2631b212e..a7a054495 100644 --- a/README.md +++ b/README.md @@ -2864,6 +2864,12 @@ const fn = ( lorem, sit ) => {}; */ const fn = ( a, b ) => {}; // "jsdoc/check-line-alignment": ["error"|"warn", "always"] + +/** + * @param {string|string[]|TemplateResult|TemplateResult[]} event.detail.description - + * Notification description + */ +function quux () {} ```` diff --git a/src/rules/checkLineAlignment.js b/src/rules/checkLineAlignment.js index fb20a0632..12435bc54 100644 --- a/src/rules/checkLineAlignment.js +++ b/src/rules/checkLineAlignment.js @@ -66,7 +66,7 @@ const checkNotAlignedPerTag = (utils, tag, customSpacings) => { const postHyphenSpacing = customSpacings?.postHyphen ?? 1; const exactHyphenSpacing = new RegExp(`^\\s*-\\s{${postHyphenSpacing},${postHyphenSpacing}}(?!\\s)`, 'u'); - const hasNoHyphen = !(/^\s*-/u).test(tokens.description); + const hasNoHyphen = !(/^\s*-(?!$)/u).test(tokens.description); const hasExactHyphenSpacing = exactHyphenSpacing.test( tokens.description, ); diff --git a/test/rules/assertions/checkLineAlignment.js b/test/rules/assertions/checkLineAlignment.js index 83c83b182..1e928e447 100644 --- a/test/rules/assertions/checkLineAlignment.js +++ b/test/rules/assertions/checkLineAlignment.js @@ -1909,5 +1909,14 @@ export default { 'always', ], }, + { + code: ` + /** + * @param {string|string[]|TemplateResult|TemplateResult[]} event.detail.description - + * Notification description + */ + function quux () {} + `, + }, ], };