Eslint-plugin-jsdoc: [require-param] Add `contexts`-option

Created on 11 Apr 2020  路  7Comments  路  Source: gajus/eslint-plugin-jsdoc

I'm working with TypeScript and I'd like to require @param-tags in interface-methods (context: TSMethodSignature).

interface ITest {
    /**
     * Test description.
     */
    TestMethod(id: number): void;
}

Sadly the require-param rule doesn't allow me to specify a custom contexts-array.

released

All 7 comments

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

The release is available on:

Your semantic-release bot :package::rocket:

@brettz9 wow - that was fast!
Thank you so much for taking care 馃槃

Thanks for the idea and well thought-out suggestions! Also happened to be pretty easy to add given our existing infrastructure for handling contexts/exemptedBy...

@brettz9 since updating eslint-plugin-json to the most recent version I get an error when enabling require-param for MethodDefinitions:

Cannot read property 'map' of undefined\nOccurred while linting test.js:9

Is there some way I can debug the rule?

You could go into eslint-plugin-json source and log (and that would be helpful so the error can at least be cleared up for others), particularly if running eslint from the command line.

But I'm not actually sure there is a use case for adding it on MethodDefinition (unless targeting say MethodDefinition > FunctionExpression) since the AST seems it will also have FunctionExpression, at least for regular class methods.

Thank you very much for the info - running it from command line actually helped me very much!
I had an incorrect context in the array chich caused that at this piece of code:
https://github.com/gajus/eslint-plugin-jsdoc/blob/bd432f68bb57d91dd49a9ddc1fbaf69ff7aa4678/src/jsdocUtils.js#L36-L37
functionNode.params was undefined.

Sorry for the confusion - looks like I ducked up my eslint-configuration :')

Edit:
Also using this rule for MethodDefinitions seems to be incorrect - again sorry for the confusion 馃槄

No worries. if you find a legitimate context without this that needs handling of course we can change the code.

Was this page helpful?
0 / 5 - 0 ratings