Eslint-plugin-jsdoc: Tag name autofix confused by adjacent tags

Created on 11 Jul 2019  路  2Comments  路  Source: gajus/eslint-plugin-jsdoc

As you can see below, if a fixable tag name error is preceded by tags of the same type, the autofix incorrectly targets the first tag, causing multiple autofixes to further and further scramble the first tag name:

eslint-plugin-jsdoc-fix-bug

bug help wanted released

Most helpful comment

@jaydenseric , thanks for the report, and @a-nozeret , thanks for the fix... I've liberalized the regex a little further to allow for a word boundary (\b within a RegExp) since a tag might not be followed with a space if at the end of a line.

FWIW, I also found and fixed an issue in this rule whereby we needed to treat bad tags as defined so that, if they were not defined elsewhere, they could be found for purposes of reporting and replacement.

Also, @gajus / @golopot , FWIW, I'm working on a stringifier for parsed comment JSON which, if comment-parser doesn't accept, we might put in its own repo and add as a dependency, as it should simplify working with fixers. We should be able to use it to make a fix on the parsed comment JSON and then serialize that JSON to a string to get the fixed output. Besides making for easier-to-read fixer code, it should avoid some bugs like in this issue which get introduced because we are trying to reimplement our own parsing.

All 2 comments

:tada: This issue has been resolved in version 15.3.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

@jaydenseric , thanks for the report, and @a-nozeret , thanks for the fix... I've liberalized the regex a little further to allow for a word boundary (\b within a RegExp) since a tag might not be followed with a space if at the end of a line.

FWIW, I also found and fixed an issue in this rule whereby we needed to treat bad tags as defined so that, if they were not defined elsewhere, they could be found for purposes of reporting and replacement.

Also, @gajus / @golopot , FWIW, I'm working on a stringifier for parsed comment JSON which, if comment-parser doesn't accept, we might put in its own repo and add as a dependency, as it should simplify working with fixers. We should be able to use it to make a fix on the parsed comment JSON and then serialize that JSON to a string to get the fixed output. Besides making for easier-to-read fixer code, it should avoid some bugs like in this issue which get introduced because we are trying to reimplement our own parsing.

Was this page helpful?
0 / 5 - 0 ratings