Expected behavior
JSDocs allows us to specify a default required value for a constant in @property and @param. I need this in some cases, like if the value is a constant and refers to the output of some arithmetic or a private variable. I can say @property {number} NAME=3, and this will be parsed as a "required" argument/param with default value 3. This has been supported in JSDocs since version 3.3.0. jsdoc/jsdoc#791 (comment)
I think I should be allowed to do default value declarations of this kind while using eslint-plugin-jsdoc and not be stopped by syntax errors.
Actual behavior
The eslint-plugin-jsdoc parser throws on this, saying "Syntax error in namepath: NAME=3".
Note that, in contrast, eslint-plugin-jsdoc allows @property {number} [NAME=3], which declares the "optional" default value instead of the "required" default value. This is because there's a regex that detects the pattern square open bracket + name + equal sign and then extracts just the name.
My current workaround is to set valid-types to "warn".
ESLint Config
rules: {
'jsdoc/valid-types': 'error'
}
ESLint sample
/** Some annoying set of bitmasks or something.
*
* @property {number} BITMASK_VALUE_A=16 - blah blah
* @property {number} BITMASK_VALUE_B=32 - the other thing
*/
const MY_BITMASK_CONSTANT = {
BITMASK_VALUE_A: 1 << 4,
BITMASK_VALUE_B: somePrivateVariableHere
};
Environment
- Node version: v24.14.0
- ESLint version: v10.0.3
eslint-plugin-jsdoc version: 62.7.1
Expected behavior
JSDocs allows us to specify a default required value for a constant in
@propertyand@param. I need this in some cases, like if the value is a constant and refers to the output of some arithmetic or a private variable. I can say@property {number} NAME=3, and this will be parsed as a "required" argument/param with default value 3. This has been supported in JSDocs since version 3.3.0. jsdoc/jsdoc#791 (comment)I think I should be allowed to do default value declarations of this kind while using eslint-plugin-jsdoc and not be stopped by syntax errors.
Actual behavior
The eslint-plugin-jsdoc parser throws on this, saying "Syntax error in namepath: NAME=3".
Note that, in contrast, eslint-plugin-jsdoc allows
@property {number} [NAME=3], which declares the "optional" default value instead of the "required" default value. This is because there's a regex that detects the pattern square open bracket + name + equal sign and then extracts just the name.My current workaround is to set valid-types to "warn".
ESLint Config
ESLint sample
Environment
eslint-plugin-jsdocversion: 62.7.1