eslint-plugin-jsdoc 65.3.1 → 65.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/rules/noDefaults.js +19 -0
package/package.json
CHANGED
package/src/rules/noDefaults.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @param {import('eslint').Rule.Node|null} node
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
const isAccessor = (node) => {
|
|
8
|
+
const methodNode = node?.type === 'FunctionExpression' ? node.parent : node;
|
|
9
|
+
|
|
10
|
+
return [
|
|
11
|
+
'get', 'set',
|
|
12
|
+
].includes(/** @type {{kind?: string}} */ (methodNode)?.kind ?? '');
|
|
13
|
+
};
|
|
14
|
+
|
|
3
15
|
export default iterateJsdoc(({
|
|
4
16
|
context,
|
|
17
|
+
node,
|
|
5
18
|
utils,
|
|
6
19
|
}) => {
|
|
7
20
|
const {
|
|
@@ -26,6 +39,12 @@ export default iterateJsdoc(({
|
|
|
26
39
|
}
|
|
27
40
|
}
|
|
28
41
|
|
|
42
|
+
// A getter or setter has no initializer which a `@default` could repeat;
|
|
43
|
+
// its `@default` documents the default value of the property
|
|
44
|
+
if (isAccessor(node)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
29
48
|
const defaultTags = utils.getPresentTags([
|
|
30
49
|
'default', 'defaultvalue',
|
|
31
50
|
]);
|