@@ -33,38 +33,39 @@ export default iterateJsdoc(({
3333 }
3434
3535 const startsWithHyphen = ( / ^ \s * - / u) . test ( desc ) ;
36- if ( always ) {
37- if ( ! startsWithHyphen ) {
38- report ( `There must be a hyphen before @${ targetTagName } description.` , ( fixer ) => {
39- const lineIndex = /** @type {import('../iterateJsdoc.js').Integer } */ (
40- jsdocTag . line
41- ) ;
42- const sourceLines = sourceCode . getText ( jsdocNode ) . split ( '\n' ) ;
43-
44- // Get start index of description, accounting for multi-line descriptions
45- const description = desc . split ( '\n' ) [ 0 ] ;
46- const descriptionIndex = sourceLines [ lineIndex ] . lastIndexOf ( description ) ;
36+ let lines = 0 ;
37+ for ( const {
38+ tokens,
39+ } of jsdocTag . source ) {
40+ if ( tokens . description ) {
41+ break ;
42+ }
4743
48- const replacementLine = sourceLines [ lineIndex ]
49- . slice ( 0 , descriptionIndex ) + '- ' + description ;
50- sourceLines . splice ( lineIndex , 1 , replacementLine ) ;
51- const replacement = sourceLines . join ( '\n' ) ;
44+ lines ++ ;
45+ }
5246
53- return fixer . replaceText ( jsdocNode , replacement ) ;
54- } , jsdocTag ) ;
47+ if ( always ) {
48+ if ( ! startsWithHyphen ) {
49+ utils . reportJSDoc (
50+ `There must be a hyphen before @${ targetTagName } description.` ,
51+ {
52+ line : jsdocTag . source [ 0 ] . number + lines ,
53+ } ,
54+ ( ) => {
55+ for ( const {
56+ tokens,
57+ } of jsdocTag . source ) {
58+ if ( tokens . description ) {
59+ tokens . description = tokens . description . replace (
60+ / ^ ( \s * ) / u, '$1- ' ,
61+ ) ;
62+ break ;
63+ }
64+ }
65+ }
66+ ) ;
5567 }
5668 } else if ( startsWithHyphen ) {
57- let lines = 0 ;
58- for ( const {
59- tokens,
60- } of jsdocTag . source ) {
61- if ( tokens . description ) {
62- break ;
63- }
64-
65- lines ++ ;
66- }
67-
6869 utils . reportJSDoc (
6970 `There must be no hyphen before @${ targetTagName } description.` ,
7071 {
0 commit comments