Skip to content

Commit f420121

Browse files
committed
fix(check-line-alignment): avoid adding whitespace if hyphen at end of line; fixes #983
1 parent f62f51a commit f420121

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,6 +2864,12 @@ const fn = ( lorem, sit ) => {};
28642864
*/
28652865
const fn = ( a, b ) => {};
28662866
// "jsdoc/check-line-alignment": ["error"|"warn", "always"]
2867+
2868+
/**
2869+
* @param {string|string[]|TemplateResult|TemplateResult[]} event.detail.description -
2870+
* Notification description
2871+
*/
2872+
function quux () {}
28672873
````
28682874

28692875

src/rules/checkLineAlignment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const checkNotAlignedPerTag = (utils, tag, customSpacings) => {
6666

6767
const postHyphenSpacing = customSpacings?.postHyphen ?? 1;
6868
const exactHyphenSpacing = new RegExp(`^\\s*-\\s{${postHyphenSpacing},${postHyphenSpacing}}(?!\\s)`, 'u');
69-
const hasNoHyphen = !(/^\s*-/u).test(tokens.description);
69+
const hasNoHyphen = !(/^\s*-(?!$)/u).test(tokens.description);
7070
const hasExactHyphenSpacing = exactHyphenSpacing.test(
7171
tokens.description,
7272
);

test/rules/assertions/checkLineAlignment.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,5 +1909,14 @@ export default {
19091909
'always',
19101910
],
19111911
},
1912+
{
1913+
code: `
1914+
/**
1915+
* @param {string|string[]|TemplateResult|TemplateResult[]} event.detail.description -
1916+
* Notification description
1917+
*/
1918+
function quux () {}
1919+
`,
1920+
},
19121921
],
19131922
};

0 commit comments

Comments
 (0)