eslint-plugin-jsdoc 59.0.1 → 59.1.0
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/README.md +1 -0
- package/dist/buildForbidRuleDefinition.cjs +34 -13
- package/dist/buildForbidRuleDefinition.cjs.map +1 -1
- package/dist/buildForbidRuleDefinition.d.ts +10 -6
- package/dist/cjs/buildForbidRuleDefinition.d.ts +10 -6
- package/dist/cjs/rules/noRestrictedSyntax.d.ts +1 -1
- package/dist/cjs/rules/requiredTags.d.ts +2 -0
- package/dist/generateDocs.cjs +1 -1
- package/dist/generateDocs.cjs.map +1 -1
- package/dist/generateRule.cjs +5 -0
- package/dist/generateRule.cjs.map +1 -1
- package/dist/index-cjs.cjs +3 -0
- package/dist/index-cjs.cjs.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +41 -72
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.d.ts +1 -1
- package/dist/rules/noUndefinedTypes.cjs +1 -1
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requiredTags.cjs +74 -0
- package/dist/rules/requiredTags.cjs.map +1 -0
- package/dist/rules/requiredTags.d.ts +3 -0
- package/dist/rules.d.ts +20 -0
- package/package.json +1 -1
- package/src/buildForbidRuleDefinition.js +36 -13
- package/src/index-cjs.js +3 -0
- package/src/index.js +3 -0
- package/src/rules/noRestrictedSyntax.js +47 -82
- package/src/rules/noUndefinedTypes.js +1 -1
- package/src/rules/requiredTags.js +85 -0
- package/src/rules.d.ts +20 -0
|
@@ -1,59 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
buildForbidRuleDefinition,
|
|
3
|
+
} from '../buildForbidRuleDefinition.js';
|
|
2
4
|
|
|
3
|
-
export default
|
|
4
|
-
context,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
utils,
|
|
10
|
-
}) => {
|
|
11
|
-
if (!context.options.length) {
|
|
12
|
-
report('Rule `no-restricted-syntax` is missing a `contexts` option.');
|
|
13
|
-
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const {
|
|
18
|
-
contexts,
|
|
19
|
-
} = context.options[0];
|
|
5
|
+
export default buildForbidRuleDefinition({
|
|
6
|
+
getContexts (context, report) {
|
|
7
|
+
if (!context.options.length) {
|
|
8
|
+
report('Rule `no-restricted-syntax` is missing a `contexts` option.');
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
20
11
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = utils.findContext(contexts, comment);
|
|
12
|
+
const {
|
|
13
|
+
contexts,
|
|
14
|
+
} = context.options[0];
|
|
25
15
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)?.message ??
|
|
35
|
-
'Syntax is restricted: {{context}}' +
|
|
36
|
-
(comment ? ' with {{comment}}' : '');
|
|
37
|
-
|
|
38
|
-
report(message, null, null, comment ? {
|
|
39
|
-
comment,
|
|
40
|
-
context: contextStr,
|
|
41
|
-
} : {
|
|
42
|
-
context: contextStr,
|
|
43
|
-
});
|
|
44
|
-
}, {
|
|
45
|
-
contextSelected: true,
|
|
46
|
-
meta: {
|
|
47
|
-
docs: {
|
|
48
|
-
description: 'Reports when certain comment structures are present.',
|
|
49
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-restricted-syntax.md#repos-sticky-header',
|
|
50
|
-
},
|
|
51
|
-
schema: [
|
|
52
|
-
{
|
|
53
|
-
additionalProperties: false,
|
|
54
|
-
properties: {
|
|
55
|
-
contexts: {
|
|
56
|
-
description: `Set this to an array of strings representing the AST context (or an object with
|
|
16
|
+
return contexts;
|
|
17
|
+
},
|
|
18
|
+
schema: [
|
|
19
|
+
{
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
properties: {
|
|
22
|
+
contexts: {
|
|
23
|
+
description: `Set this to an array of strings representing the AST context (or an object with
|
|
57
24
|
\`context\` and \`comment\` properties) where you wish the rule to be applied.
|
|
58
25
|
|
|
59
26
|
\`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
|
|
@@ -70,38 +37,36 @@ aliases \`@func\` or \`@method\`) (including those associated with an \`@interfa
|
|
|
70
37
|
|
|
71
38
|
See the ["AST and Selectors"](../#advanced-ast-and-selectors)
|
|
72
39
|
section of our Advanced docs for more on the expected format.`,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
},
|
|
40
|
+
items: {
|
|
41
|
+
anyOf: [
|
|
42
|
+
{
|
|
43
|
+
type: 'string',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
properties: {
|
|
48
|
+
comment: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
},
|
|
51
|
+
context: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
},
|
|
54
|
+
message: {
|
|
55
|
+
type: 'string',
|
|
90
56
|
},
|
|
91
|
-
type: 'object',
|
|
92
57
|
},
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
58
|
+
type: 'object',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
96
61
|
},
|
|
62
|
+
type: 'array',
|
|
97
63
|
},
|
|
98
|
-
required: [
|
|
99
|
-
'contexts',
|
|
100
|
-
],
|
|
101
|
-
type: 'object',
|
|
102
64
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
65
|
+
required: [
|
|
66
|
+
'contexts',
|
|
67
|
+
],
|
|
68
|
+
type: 'object',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-restricted-syntax.md#repos-sticky-header',
|
|
107
72
|
});
|
|
@@ -115,7 +115,7 @@ export default iterateJsdoc(({
|
|
|
115
115
|
const allComments = sourceCode.getAllComments();
|
|
116
116
|
const comments = allComments
|
|
117
117
|
.filter((comment) => {
|
|
118
|
-
return (
|
|
118
|
+
return (/^\*(?!\*)/v).test(comment.value);
|
|
119
119
|
})
|
|
120
120
|
.map((commentNode) => {
|
|
121
121
|
return parseComment(commentNode, '');
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildForbidRuleDefinition,
|
|
3
|
+
} from '../buildForbidRuleDefinition.js';
|
|
4
|
+
|
|
5
|
+
export default buildForbidRuleDefinition({
|
|
6
|
+
description: 'Requires tags be present, optionally for specific contexts',
|
|
7
|
+
getContexts (context, report) {
|
|
8
|
+
// Transformed options to this option in `modifyContext`:
|
|
9
|
+
if (!context.options[0].contexts) {
|
|
10
|
+
report('Rule `required-tags` is missing a `tags` option.');
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
contexts,
|
|
16
|
+
} = context.options[0];
|
|
17
|
+
|
|
18
|
+
return contexts;
|
|
19
|
+
},
|
|
20
|
+
modifyContext (context) {
|
|
21
|
+
const tags = /** @type {(string|{tag: string, context: string})[]} */ (
|
|
22
|
+
context.options?.[0]?.tags
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const cntxts = tags?.map((tag) => {
|
|
26
|
+
const tagName = typeof tag === 'string' ? tag : tag.tag;
|
|
27
|
+
return {
|
|
28
|
+
comment: `JsdocBlock:not(*:has(JsdocTag[tag=${
|
|
29
|
+
tagName
|
|
30
|
+
}]))`,
|
|
31
|
+
context: typeof tag === 'string' ? 'any' : tag.context,
|
|
32
|
+
message: `Missing required tag "${tagName}"`,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Reproduce context object with our own `contexts`
|
|
37
|
+
const propertyDescriptors = Object.getOwnPropertyDescriptors(context);
|
|
38
|
+
return Object.create(
|
|
39
|
+
Object.getPrototypeOf(context),
|
|
40
|
+
{
|
|
41
|
+
...propertyDescriptors,
|
|
42
|
+
options: {
|
|
43
|
+
...propertyDescriptors.options,
|
|
44
|
+
value: [
|
|
45
|
+
{
|
|
46
|
+
contexts: cntxts,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
schema: [
|
|
54
|
+
{
|
|
55
|
+
additionalProperties: false,
|
|
56
|
+
properties: {
|
|
57
|
+
tags: {
|
|
58
|
+
description: `May be an array of either strings or objects with
|
|
59
|
+
a string \`tag\` property and \`context\` string property.`,
|
|
60
|
+
items: {
|
|
61
|
+
anyOf: [
|
|
62
|
+
{
|
|
63
|
+
type: 'string',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
properties: {
|
|
67
|
+
context: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
},
|
|
70
|
+
tag: {
|
|
71
|
+
type: 'string',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
type: 'object',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
type: 'array',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
type: 'object',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/required-tags.md#repos-sticky-header',
|
|
85
|
+
});
|
package/src/rules.d.ts
CHANGED
|
@@ -2580,6 +2580,26 @@ export interface Rules {
|
|
|
2580
2580
|
/** Requires a type for `@yields` tags */
|
|
2581
2581
|
"jsdoc/require-yields-type": [];
|
|
2582
2582
|
|
|
2583
|
+
/** Requires tags be present, optionally for specific contexts */
|
|
2584
|
+
"jsdoc/required-tags":
|
|
2585
|
+
| []
|
|
2586
|
+
| [
|
|
2587
|
+
{
|
|
2588
|
+
/**
|
|
2589
|
+
* May be an array of either strings or objects with
|
|
2590
|
+
* a string `tag` property and `context` string property.
|
|
2591
|
+
*/
|
|
2592
|
+
tags?: (
|
|
2593
|
+
| string
|
|
2594
|
+
| {
|
|
2595
|
+
context?: string;
|
|
2596
|
+
tag?: string;
|
|
2597
|
+
[k: string]: unknown;
|
|
2598
|
+
}
|
|
2599
|
+
)[];
|
|
2600
|
+
}
|
|
2601
|
+
];
|
|
2602
|
+
|
|
2583
2603
|
/** Sorts tags by a specified sequence according to tag name, optionally adding line breaks between tag groups. */
|
|
2584
2604
|
"jsdoc/sort-tags":
|
|
2585
2605
|
| []
|