diff --git a/src/comments.mjs b/src/comments.mjs index bc1b8a643..55ab20144 100644 --- a/src/comments.mjs +++ b/src/comments.mjs @@ -553,10 +553,17 @@ function handleFunction( enclosingNode.body && locStart(comment) > argumentsLocEnd && locEnd(comment) < locStart(enclosingNode.body); - const nextCharIndex = getNextNonSpaceNonCommentCharacterIndex( + let nextCharIndex = getNextNonSpaceNonCommentCharacterIndex( text, locEnd(comment) ); + // skip the trailing comma of the argument list, if any + if (text.charAt(nextCharIndex) === ",") { + nextCharIndex = getNextNonSpaceNonCommentCharacterIndex( + text, + nextCharIndex + 1 + ); + } // we additionally need to check if this isn't a trailing argument comment, // by checking the next character isn't ")" if ( diff --git a/tests/comments/__snapshots__/jsfmt.spec.mjs.snap b/tests/comments/__snapshots__/jsfmt.spec.mjs.snap index 5adfe5f8c..81ecd709c 100644 --- a/tests/comments/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/comments/__snapshots__/jsfmt.spec.mjs.snap @@ -4763,6 +4763,55 @@ if ( ================================================================================ `; +exports[`last-parameter.php 1`] = ` +====================================options===================================== +parsers: ["php"] +printWidth: 80 + | printWidth +=====================================input====================================== +