gajus / eslint-plugin-jsdoc

JSDoc specific linting rules for ESLint.
Other
1.1k stars 160 forks source link

require-jsdoc fixer: Insert default comment instead of empty #1163

Closed btxtiger closed 1 year ago

btxtiger commented 1 year ago

Motivation

I am using require-jsdoc to mark an error if a function is missing a comment.

image

Current behavior

When running the autofix, it will add an empty comment which is still no considered to be valid.

image

Desired behavior

When running the autofix, it should insert a configurable default comment, which fixes the error entirely, by defining a default text. This also helps to find the undocumented functions later in the IDE search.

image
brettz9 commented 1 year ago

One alternative is to use no-missing-syntax to find empty comment blocks (after they have been auto-inserted):

  'jsdoc/no-missing-syntax': ['error', {
    contexts: [
      {
        comment: 'JsdocBlock[tags.length=0][description=""]',
        context: 'FunctionDeclaration',
      },
    ],
  }]
brettz9 commented 1 year ago

I had forgotten there already is an option for jsdoc/require-jsdoc that allows adding your own custom message. Use the now documented fixerMessage option.

Closing as that should resolve, but feel free to comment further as needed.