gajus / eslint-plugin-jsdoc

JSDoc specific linting rules for ESLint.
Other
1.08k stars 155 forks source link

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

Closed btxtiger closed 9 months ago

btxtiger commented 9 months 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 9 months 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 9 months 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.