Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(check-line-alignment): avoid adding whitespace if hyphen at end of line #986

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 () {}
`,
},
],
};