-
-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matching between @param definition and function parameters no longer works #1303
Comments
Do you recall what rules you were using |
If it was for |
The intention was to apply the contexts across any and all jsdoc-related rules, and I see this even when no rules defined at all in the minimal config file. At the moment the list of rules in use is this
|
Ok, but what are you trying to do with the export declarations? You said, "trying to use 'ExportNamedDeclaration' to define exclusions in global context". Which rules specifically do you need the contexts on? Defining exclusions suggests you are using the rule If you were trying to apply rules to those contexts, e.g., let's say if you always documented variable declarations, then that would be a good cause to use the global settings. (There might still be a bug with |
Not sure if these are related issues but I'm getting the same error for the following code. eslint is raising an issue for the error @param "c" does not match an existing function parameter jsdoc/check-param-names /**
* Outer
* @param a a
* @param b b
* @returns something
*/
export const outer = (
a: number,
b: string
): typeof inner => {
console.log(a);
console.log(b);
/**
* Inner
* @param c c
* @param d d
*/
const inner = (c: number, d: string): void => {
console.log(c);
console.log(d);
};
return inner;
}; Environment:
|
@sugat009 : Can you show your config? |
yeah, here you go. module.exports = {
overrides: [
{
files: ['*.ts'],
extends: [
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict-type-checked.ts
'plugin:@typescript-eslint/strict-type-checked',
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic-type-checked.ts
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:jsdoc/recommended-typescript-error',
'plugin:compat/recommended',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'jsdoc', 'compat'],
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname
},
settings: {
jsdoc: {
contexts: [
'VariableDeclaration',
'TSInterfaceDeclaration',
'TSTypeAliasDeclaration',
'TSEnumDeclaration',
'TSMethodSignature'
]
}
},
rules: {
['@typescript-eslint/explicit-module-boundary-types']: ['error', { allowedNames: ['getDatasource'] }],
['@typescript-eslint/no-confusing-void-expression']: ['error', { ignoreArrowShorthand: true }],
['@typescript-eslint/no-empty-interface']: ['error', { allowSingleExtends: true }],
['@typescript-eslint/no-namespace']: 'off',
['@typescript-eslint/no-non-null-assertion']: 'off',
['jsdoc/require-jsdoc']: ['error', {
require: {
ArrowFunctionExpression: true,
ClassDeclaration: true,
ClassExpression: true,
FunctionDeclaration: true,
FunctionExpression: true,
MethodDefinition: true,
},
publicOnly: true,
}]
}
}
]
}; |
…ion nodes so that non-function global contexts do not err; fixes gajus#1303 Also adds warning in docs for use of global settings contexts.
Ok, there were two problems here. One is that But another problem is that I think people are using global settings contexts in a way which is harmful, so I've tried to clarify things in the documentation. Using global settings contexts means that your global contexts will replace the defaults. If you only have |
🎉 This issue has been resolved in version 50.2.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Upgrading from version 48.4.0 to anything later no longer matches @param value with variable in the function definition when trying to use 'ExportNamedDeclaration' to define exclusions in global context. The function affected by this is being exported, and the message indicates "@param "xxx" does not match an existing function parameter jsdoc/check-param-names". This issue appears to be related to the change that introduced "contextDetaults" in checkParamNames for version 48.5.0:
adding these defaults
as the list of variables from function definition is not getting generated. Removing these lines restores the expected behavior.
Expected behavior
When there is mismatch on the variable name between @param definition and function definition, the following message would be provided:
Expected @param names to be "inputIds". Got "inputId" jsdoc/check-param-names
Actual behavior
Without any change in configuration but using version 48.5.0 or higher results in this message instead:
@param "inputId" does not match an existing function parameter jsdoc/check-param-names
As mentioned earlier, the change in behavior can be traced to the addition of the contextDefaults that interfere with calculation of function variables
ESLint Config
What is the minimal config that reproduces the issue?
As long as 'ExportNamedDeclaration' present the incorrect error message is returned.
Not using context for 'ExportNamedDeclaration' would provide expected message about the name mismatch.
Environment
eslint-plugin-jsdoc
version: 48.5.0+The text was updated successfully, but these errors were encountered: