eslint-plugin-jsdoc
Advanced tools
Comparing version 50.3.1 to 50.3.2
@@ -155,3 +155,3 @@ { | ||
}, | ||
"version": "50.3.1" | ||
"version": "50.3.2" | ||
} |
@@ -36,34 +36,35 @@ import iterateJsdoc from '../iterateJsdoc.js'; | ||
const startsWithHyphen = (/^\s*-/u).test(desc); | ||
let lines = 0; | ||
for (const { | ||
tokens, | ||
} of jsdocTag.source) { | ||
if (tokens.description) { | ||
break; | ||
} | ||
lines++; | ||
} | ||
if (always) { | ||
if (!startsWithHyphen) { | ||
report(`There must be a hyphen before @${targetTagName} description.`, (fixer) => { | ||
const lineIndex = /** @type {import('../iterateJsdoc.js').Integer} */ ( | ||
jsdocTag.line | ||
); | ||
const sourceLines = sourceCode.getText(jsdocNode).split('\n'); | ||
// Get start index of description, accounting for multi-line descriptions | ||
const description = desc.split('\n')[0]; | ||
const descriptionIndex = sourceLines[lineIndex].lastIndexOf(description); | ||
const replacementLine = sourceLines[lineIndex] | ||
.slice(0, descriptionIndex) + '- ' + description; | ||
sourceLines.splice(lineIndex, 1, replacementLine); | ||
const replacement = sourceLines.join('\n'); | ||
return fixer.replaceText(jsdocNode, replacement); | ||
}, jsdocTag); | ||
utils.reportJSDoc( | ||
`There must be a hyphen before @${targetTagName} description.`, | ||
{ | ||
line: jsdocTag.source[0].number + lines, | ||
}, | ||
() => { | ||
for (const { | ||
tokens, | ||
} of jsdocTag.source) { | ||
if (tokens.description) { | ||
tokens.description = tokens.description.replace( | ||
/^(\s*)/u, '$1- ', | ||
); | ||
break; | ||
} | ||
} | ||
} | ||
); | ||
} | ||
} else if (startsWithHyphen) { | ||
let lines = 0; | ||
for (const { | ||
tokens, | ||
} of jsdocTag.source) { | ||
if (tokens.description) { | ||
break; | ||
} | ||
lines++; | ||
} | ||
utils.reportJSDoc( | ||
@@ -70,0 +71,0 @@ `There must be no hyphen before @${targetTagName} description.`, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33892
2085120