eslint-plugin-jsdoc 59.0.2 → 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/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/requiredTags.js +85 -0
- package/src/rules.d.ts +20 -0
|
@@ -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
|
| []
|