eslint-plugin-crisp 1.0.25 → 1.0.27
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
CHANGED
|
@@ -19,33 +19,47 @@ module.exports = {
|
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
checkNode(param, jsdocParams[i], jsdocParams);
|
|
29
|
-
}
|
|
22
|
+
// This rule assumes that function params and JSDoc params match \
|
|
23
|
+
// (enforced by jsdoc/require-param)
|
|
24
|
+
const parsed = doctrine.parse(jsDocComment.value, {
|
|
25
|
+
unwrap: true,
|
|
26
|
+
sloppy: true,
|
|
27
|
+
tags: ["param"]
|
|
30
28
|
});
|
|
29
|
+
const jsdocParams = parsed.tags;
|
|
30
|
+
|
|
31
|
+
let i = 0;
|
|
32
|
+
|
|
33
|
+
if (jsdocParams.length) {
|
|
34
|
+
node.params.forEach((param) => {
|
|
35
|
+
i = checkNode(param, jsdocParams, i);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function checkNode(node, jsdocParams, i) {
|
|
40
|
+
jsdocParam = jsdocParams[i];
|
|
41
|
+
|
|
42
|
+
if (node.type === "ObjectPattern") {
|
|
43
|
+
i++;
|
|
31
44
|
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
node.properties.forEach((property) => {
|
|
46
|
+
i = checkNode(property.value, jsdocParams, i);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return i;
|
|
50
|
+
} else if (node.type === "AssignmentPattern" && jsdocParam.type.type !== "OptionalType") {
|
|
34
51
|
context.report({
|
|
35
52
|
node,
|
|
36
53
|
message: "Optional parameters in JSDoc should be surrounded by brackets"
|
|
37
54
|
});
|
|
38
|
-
} else if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return nameSegments[nameSegments.length - 1] === property.key.name;
|
|
43
|
-
});
|
|
44
|
-
if (nestedJsdocParam) {
|
|
45
|
-
checkNode(property.value, nestedJsdocParam, jsdocParams);
|
|
46
|
-
}
|
|
55
|
+
} else if (jsdocParam.type.type === "OptionalType" && node.type !== "AssignmentPattern") {
|
|
56
|
+
context.report({
|
|
57
|
+
node,
|
|
58
|
+
message: "Non-optional parameters in JSDoc should not be surrounded by brackets"
|
|
47
59
|
});
|
|
48
60
|
}
|
|
61
|
+
|
|
62
|
+
return i + 1;
|
|
49
63
|
}
|
|
50
64
|
}
|
|
51
65
|
|