gajus / eslint-plugin-jsdoc

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

Global functions exception list #873

Closed fab1o closed 2 years ago

fab1o commented 2 years ago

Motivation

Is there a way to globally except certain functions from being ruled?

Let say I have many different classes/files with a function toString(){} and I don't want ignore all these functions.

Is there a way I could do:

settings: {
        jsdoc: {
            ignoreFunctions: ['toString']
        }
}

Or is there a way to accomplish that with the jsdoc/require-jsdoc rule?

Current behavior

Desired behavior

Alternatives considered

brettz9 commented 2 years ago

Currently, contexts—the option which indicates where a rule should apply—is not available globally. That would be a dupe of #857.

But if your issue is simply that you do not want reporting of errors for the fact that a JSDoc block is missing above toString(), you can get that with the likes of adding this object option:

      {
        contexts: [
          'MethodDefinition[key.name!="toString"]',
          'Property[key.name!="toString"]',
        ]
      }

Just be sure that you don't have MethodDefinition: true set in the require option so that the MethodDefinition in contexts is the only one that applies.

Closing as that should resolve (or be a dupe), but feel free to comment further as necessary, and if necessary, I can reopen.