eslint-plugin-jsdoc 59.0.2 → 60.0.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/requireTags.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/requireTags.cjs +74 -0
- package/dist/rules/requireTags.cjs.map +1 -0
- package/dist/rules/requireTags.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/requireTags.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 `require-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/require-tags.md#repos-sticky-header',
|
|
85
|
+
});
|
package/src/rules.d.ts
CHANGED
|
@@ -2370,6 +2370,26 @@ export interface Rules {
|
|
|
2370
2370
|
}
|
|
2371
2371
|
];
|
|
2372
2372
|
|
|
2373
|
+
/** Requires tags be present, optionally for specific contexts */
|
|
2374
|
+
"jsdoc/require-tags":
|
|
2375
|
+
| []
|
|
2376
|
+
| [
|
|
2377
|
+
{
|
|
2378
|
+
/**
|
|
2379
|
+
* May be an array of either strings or objects with
|
|
2380
|
+
* a string `tag` property and `context` string property.
|
|
2381
|
+
*/
|
|
2382
|
+
tags?: (
|
|
2383
|
+
| string
|
|
2384
|
+
| {
|
|
2385
|
+
context?: string;
|
|
2386
|
+
tag?: string;
|
|
2387
|
+
[k: string]: unknown;
|
|
2388
|
+
}
|
|
2389
|
+
)[];
|
|
2390
|
+
}
|
|
2391
|
+
];
|
|
2392
|
+
|
|
2373
2393
|
/** Requires `@template` tags be present when type parameters are used. */
|
|
2374
2394
|
"jsdoc/require-template":
|
|
2375
2395
|
| []
|