Skip to content

Commit

Permalink
fix(check-line-alignment): avoid adding whitespace if hyphen at end…
Browse files Browse the repository at this point in the history
… of line; fixes #983
  • Loading branch information
brettz9 committed Feb 11, 2023
1 parent f62f51a commit f420121
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {}
````


Expand Down
2 changes: 1 addition & 1 deletion src/rules/checkLineAlignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
9 changes: 9 additions & 0 deletions test/rules/assertions/checkLineAlignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -1909,5 +1909,14 @@ export default {
'always',
],
},
{
code: `
/**
* @param {string|string[]|TemplateResult|TemplateResult[]} event.detail.description -
* Notification description
*/
function quux () {}
`,
},
],
};

0 comments on commit f420121

Please sign in to comment.