eslint-plugin-crisp 1.5.0 → 1.5.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/recommended-vue.js +1 -0
- package/recommended.js +1 -0
- package/rules/jsdoc-align-params.js +14 -1
- package/rules/jsdoc-enforce-access.js +3 -3
package/package.json
CHANGED
package/recommended-vue.js
CHANGED
package/recommended.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const SCOPE_REGEX = /^\s*\*\s*@(public|private|protected)/;
|
|
2
|
+
const INTERNAL_REGEX = /^\s*\*\s*@internal/;
|
|
2
3
|
const GENERATOR_REGEX = /^\s*\*\s*@generator/;
|
|
3
4
|
const CLASS_REGEX = /^\s*\*\s*@class\b/;
|
|
4
5
|
const CLASSDESC_REGEX = /^\s*\*\s*@classdesc\s*(.*)/;
|
|
@@ -15,6 +16,7 @@ function parseJSDoc(jsdoc) {
|
|
|
15
16
|
let classDescription = "";
|
|
16
17
|
let description = "";
|
|
17
18
|
let scope = "";
|
|
19
|
+
let internal = false;
|
|
18
20
|
let generator = false;
|
|
19
21
|
|
|
20
22
|
for (let i = 1; i < lines.length; i++) {
|
|
@@ -33,6 +35,7 @@ function parseJSDoc(jsdoc) {
|
|
|
33
35
|
// If the line matches any of the other regexes, break out of the loop
|
|
34
36
|
if (
|
|
35
37
|
line.match(SCOPE_REGEX) ||
|
|
38
|
+
line.match(INTERNAL_REGEX) ||
|
|
36
39
|
line.match(PARAM_REGEX) ||
|
|
37
40
|
line.match(RETURN_REGEX) ||
|
|
38
41
|
line.match(YIELD_REGEX)
|
|
@@ -88,13 +91,19 @@ function parseJSDoc(jsdoc) {
|
|
|
88
91
|
scope = scopeMatch[1];
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
if (line.match(INTERNAL_REGEX)) {
|
|
95
|
+
internal = true;
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
const generatorMatch = line.match(GENERATOR_REGEX);
|
|
92
99
|
if (generatorMatch) {
|
|
93
100
|
generator = true;
|
|
94
101
|
}
|
|
95
102
|
}
|
|
96
103
|
|
|
97
|
-
return {
|
|
104
|
+
return {
|
|
105
|
+
description, scope, internal, params, returnLine, yieldLine, generator
|
|
106
|
+
};
|
|
98
107
|
}
|
|
99
108
|
|
|
100
109
|
function formatJSDoc(parsedJSDoc, indentation=0) {
|
|
@@ -123,6 +132,10 @@ function formatJSDoc(parsedJSDoc, indentation=0) {
|
|
|
123
132
|
jsdoc += indent + "* @" + parsedJSDoc.scope + "\n";
|
|
124
133
|
}
|
|
125
134
|
|
|
135
|
+
if (parsedJSDoc.internal) {
|
|
136
|
+
jsdoc += indent + "* @internal\n";
|
|
137
|
+
}
|
|
138
|
+
|
|
126
139
|
if (parsedJSDoc.generator) {
|
|
127
140
|
jsdoc += indent + "* @generator\n";
|
|
128
141
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Pre-compiled regex for access modifier check
|
|
2
|
-
const ACCESS_MODIFIER_PATTERN = /@(public|protected|private)/;
|
|
2
|
+
const ACCESS_MODIFIER_PATTERN = /@(public|protected|private|internal)/;
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
meta: {
|
|
6
6
|
type: "problem",
|
|
7
7
|
docs: {
|
|
8
|
-
description: "Enforce usage of
|
|
8
|
+
description: "Enforce usage of an access modifier in JSDoc",
|
|
9
9
|
category: "Possible Errors",
|
|
10
10
|
recommended: true,
|
|
11
11
|
},
|
|
@@ -24,7 +24,7 @@ export default {
|
|
|
24
24
|
if (!ACCESS_MODIFIER_PATTERN.test(lastComment.value)) {
|
|
25
25
|
context.report({
|
|
26
26
|
node,
|
|
27
|
-
message: "JSDoc comment should contain @public, @protected or @
|
|
27
|
+
message: "JSDoc comment should contain @public, @protected, @private or @internal",
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
}
|