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
|
@@ -4,52 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
var _buildForbidRuleDefinition = require("../buildForbidRuleDefinition.cjs");
|
|
8
|
+
var _default = exports.default = (0, _buildForbidRuleDefinition.buildForbidRuleDefinition)({
|
|
9
|
+
getContexts(context, report) {
|
|
10
|
+
if (!context.options.length) {
|
|
11
|
+
report('Rule `no-restricted-syntax` is missing a `contexts` option.');
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const {
|
|
15
|
+
contexts
|
|
16
|
+
} = context.options[0];
|
|
17
|
+
return contexts;
|
|
13
18
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const {
|
|
22
|
-
contexts
|
|
23
|
-
} = context.options[0];
|
|
24
|
-
const {
|
|
25
|
-
contextStr,
|
|
26
|
-
foundContext
|
|
27
|
-
} = utils.findContext(contexts, comment);
|
|
28
|
-
|
|
29
|
-
// We are not on the *particular* matching context/comment, so don't assume
|
|
30
|
-
// we need reporting
|
|
31
|
-
if (!foundContext) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const message = /** @type {import('../iterateJsdoc.js').ContextObject} */foundContext?.message ?? 'Syntax is restricted: {{context}}' + (comment ? ' with {{comment}}' : '');
|
|
35
|
-
report(message, null, null, comment ? {
|
|
36
|
-
comment,
|
|
37
|
-
context: contextStr
|
|
38
|
-
} : {
|
|
39
|
-
context: contextStr
|
|
40
|
-
});
|
|
41
|
-
}, {
|
|
42
|
-
contextSelected: true,
|
|
43
|
-
meta: {
|
|
44
|
-
docs: {
|
|
45
|
-
description: 'Reports when certain comment structures are present.',
|
|
46
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-restricted-syntax.md#repos-sticky-header'
|
|
47
|
-
},
|
|
48
|
-
schema: [{
|
|
49
|
-
additionalProperties: false,
|
|
50
|
-
properties: {
|
|
51
|
-
contexts: {
|
|
52
|
-
description: `Set this to an array of strings representing the AST context (or an object with
|
|
19
|
+
schema: [{
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
properties: {
|
|
22
|
+
contexts: {
|
|
23
|
+
description: `Set this to an array of strings representing the AST context (or an object with
|
|
53
24
|
\`context\` and \`comment\` properties) where you wish the rule to be applied.
|
|
54
25
|
|
|
55
26
|
\`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
|
|
@@ -66,34 +37,32 @@ aliases \`@func\` or \`@method\`) (including those associated with an \`@interfa
|
|
|
66
37
|
|
|
67
38
|
See the ["AST and Selectors"](../#advanced-ast-and-selectors)
|
|
68
39
|
section of our Advanced docs for more on the expected format.`,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
context: {
|
|
79
|
-
type: 'string'
|
|
80
|
-
},
|
|
81
|
-
message: {
|
|
82
|
-
type: 'string'
|
|
83
|
-
}
|
|
40
|
+
items: {
|
|
41
|
+
anyOf: [{
|
|
42
|
+
type: 'string'
|
|
43
|
+
}, {
|
|
44
|
+
additionalProperties: false,
|
|
45
|
+
properties: {
|
|
46
|
+
comment: {
|
|
47
|
+
type: 'string'
|
|
84
48
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
49
|
+
context: {
|
|
50
|
+
type: 'string'
|
|
51
|
+
},
|
|
52
|
+
message: {
|
|
53
|
+
type: 'string'
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
type: 'object'
|
|
57
|
+
}]
|
|
58
|
+
},
|
|
59
|
+
type: 'array'
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
required: ['contexts'],
|
|
63
|
+
type: 'object'
|
|
64
|
+
}],
|
|
65
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-restricted-syntax.md#repos-sticky-header'
|
|
97
66
|
});
|
|
98
67
|
module.exports = exports.default;
|
|
99
68
|
//# sourceMappingURL=noRestrictedSyntax.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noRestrictedSyntax.cjs","names":["
|
|
1
|
+
{"version":3,"file":"noRestrictedSyntax.cjs","names":["_buildForbidRuleDefinition","require","_default","exports","default","buildForbidRuleDefinition","getContexts","context","report","options","length","contexts","schema","additionalProperties","properties","description","items","anyOf","type","comment","message","required","url","module"],"sources":["../../src/rules/noRestrictedSyntax.js"],"sourcesContent":["import {\n buildForbidRuleDefinition,\n} from '../buildForbidRuleDefinition.js';\n\nexport default buildForbidRuleDefinition({\n getContexts (context, report) {\n if (!context.options.length) {\n report('Rule `no-restricted-syntax` is missing a `contexts` option.');\n return false;\n }\n\n const {\n contexts,\n } = context.options[0];\n\n return contexts;\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n description: `Set this to an array of strings representing the AST context (or an object with\n\\`context\\` and \\`comment\\` properties) where you wish the rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nUse the \\`message\\` property to indicate the specific error to be shown when an\nerror is reported for that context being found. Defaults to\n\\`\"Syntax is restricted: {{context}}\"\\`, or with a comment, to\n\\`\"Syntax is restricted: {{context}} with {{comment}}\"\\`.\n\nSet to \\`\"any\"\\` if you want the rule to apply to any JSDoc block throughout\nyour files (as is necessary for finding function blocks not attached to a\nfunction declaration or expression, i.e., \\`@callback\\` or \\`@function\\` (or its\naliases \\`@func\\` or \\`@method\\`) (including those associated with an \\`@interface\\`).\n\nSee the [\"AST and Selectors\"](../#advanced-ast-and-selectors)\nsection of our Advanced docs for more on the expected format.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n required: [\n 'contexts',\n ],\n type: 'object',\n },\n ],\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-restricted-syntax.md#repos-sticky-header',\n});\n"],"mappings":";;;;;;AAAA,IAAAA,0BAAA,GAAAC,OAAA;AAEyC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE1B,IAAAC,oDAAyB,EAAC;EACvCC,WAAWA,CAAEC,OAAO,EAAEC,MAAM,EAAE;IAC5B,IAAI,CAACD,OAAO,CAACE,OAAO,CAACC,MAAM,EAAE;MAC3BF,MAAM,CAAC,6DAA6D,CAAC;MACrE,OAAO,KAAK;IACd;IAEA,MAAM;MACJG;IACF,CAAC,GAAGJ,OAAO,CAACE,OAAO,CAAC,CAAC,CAAC;IAEtB,OAAOE,QAAQ;EACjB,CAAC;EACDC,MAAM,EAAE,CACN;IACEC,oBAAoB,EAAE,KAAK;IAC3BC,UAAU,EAAE;MACVH,QAAQ,EAAE;QACRI,WAAW,EAAE;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8DAA8D;QACpDC,KAAK,EAAE;UACLC,KAAK,EAAE,CACL;YACEC,IAAI,EAAE;UACR,CAAC,EACD;YACEL,oBAAoB,EAAE,KAAK;YAC3BC,UAAU,EAAE;cACVK,OAAO,EAAE;gBACPD,IAAI,EAAE;cACR,CAAC;cACDX,OAAO,EAAE;gBACPW,IAAI,EAAE;cACR,CAAC;cACDE,OAAO,EAAE;gBACPF,IAAI,EAAE;cACR;YACF,CAAC;YACDA,IAAI,EAAE;UACR,CAAC;QAEL,CAAC;QACDA,IAAI,EAAE;MACR;IACF,CAAC;IACDG,QAAQ,EAAE,CACR,UAAU,CACX;IACDH,IAAI,EAAE;EACR,CAAC,CACF;EACDI,GAAG,EAAE;AACP,CAAC,CAAC;AAAAC,MAAA,CAAApB,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _buildForbidRuleDefinition = require("../buildForbidRuleDefinition.cjs");
|
|
8
|
+
var _default = exports.default = (0, _buildForbidRuleDefinition.buildForbidRuleDefinition)({
|
|
9
|
+
description: 'Requires tags be present, optionally for specific contexts',
|
|
10
|
+
getContexts(context, report) {
|
|
11
|
+
// Transformed options to this option in `modifyContext`:
|
|
12
|
+
if (!context.options[0].contexts) {
|
|
13
|
+
report('Rule `require-tags` is missing a `tags` option.');
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const {
|
|
17
|
+
contexts
|
|
18
|
+
} = context.options[0];
|
|
19
|
+
return contexts;
|
|
20
|
+
},
|
|
21
|
+
modifyContext(context) {
|
|
22
|
+
const tags = /** @type {(string|{tag: string, context: string})[]} */
|
|
23
|
+
context.options?.[0]?.tags;
|
|
24
|
+
const cntxts = tags?.map(tag => {
|
|
25
|
+
const tagName = typeof tag === 'string' ? tag : tag.tag;
|
|
26
|
+
return {
|
|
27
|
+
comment: `JsdocBlock:not(*:has(JsdocTag[tag=${tagName}]))`,
|
|
28
|
+
context: typeof tag === 'string' ? 'any' : tag.context,
|
|
29
|
+
message: `Missing required tag "${tagName}"`
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Reproduce context object with our own `contexts`
|
|
34
|
+
const propertyDescriptors = Object.getOwnPropertyDescriptors(context);
|
|
35
|
+
return Object.create(Object.getPrototypeOf(context), {
|
|
36
|
+
...propertyDescriptors,
|
|
37
|
+
options: {
|
|
38
|
+
...propertyDescriptors.options,
|
|
39
|
+
value: [{
|
|
40
|
+
contexts: cntxts
|
|
41
|
+
}]
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
schema: [{
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
properties: {
|
|
48
|
+
tags: {
|
|
49
|
+
description: `May be an array of either strings or objects with
|
|
50
|
+
a string \`tag\` property and \`context\` string property.`,
|
|
51
|
+
items: {
|
|
52
|
+
anyOf: [{
|
|
53
|
+
type: 'string'
|
|
54
|
+
}, {
|
|
55
|
+
properties: {
|
|
56
|
+
context: {
|
|
57
|
+
type: 'string'
|
|
58
|
+
},
|
|
59
|
+
tag: {
|
|
60
|
+
type: 'string'
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
type: 'object'
|
|
64
|
+
}]
|
|
65
|
+
},
|
|
66
|
+
type: 'array'
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
type: 'object'
|
|
70
|
+
}],
|
|
71
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-tags.md#repos-sticky-header'
|
|
72
|
+
});
|
|
73
|
+
module.exports = exports.default;
|
|
74
|
+
//# sourceMappingURL=requireTags.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requireTags.cjs","names":["_buildForbidRuleDefinition","require","_default","exports","default","buildForbidRuleDefinition","description","getContexts","context","report","options","contexts","modifyContext","tags","cntxts","map","tag","tagName","comment","message","propertyDescriptors","Object","getOwnPropertyDescriptors","create","getPrototypeOf","value","schema","additionalProperties","properties","items","anyOf","type","url","module"],"sources":["../../src/rules/requireTags.js"],"sourcesContent":["import {\n buildForbidRuleDefinition,\n} from '../buildForbidRuleDefinition.js';\n\nexport default buildForbidRuleDefinition({\n description: 'Requires tags be present, optionally for specific contexts',\n getContexts (context, report) {\n // Transformed options to this option in `modifyContext`:\n if (!context.options[0].contexts) {\n report('Rule `require-tags` is missing a `tags` option.');\n return false;\n }\n\n const {\n contexts,\n } = context.options[0];\n\n return contexts;\n },\n modifyContext (context) {\n const tags = /** @type {(string|{tag: string, context: string})[]} */ (\n context.options?.[0]?.tags\n );\n\n const cntxts = tags?.map((tag) => {\n const tagName = typeof tag === 'string' ? tag : tag.tag;\n return {\n comment: `JsdocBlock:not(*:has(JsdocTag[tag=${\n tagName\n }]))`,\n context: typeof tag === 'string' ? 'any' : tag.context,\n message: `Missing required tag \"${tagName}\"`,\n };\n });\n\n // Reproduce context object with our own `contexts`\n const propertyDescriptors = Object.getOwnPropertyDescriptors(context);\n return Object.create(\n Object.getPrototypeOf(context),\n {\n ...propertyDescriptors,\n options: {\n ...propertyDescriptors.options,\n value: [\n {\n contexts: cntxts,\n },\n ],\n },\n },\n );\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n tags: {\n description: `May be an array of either strings or objects with\na string \\`tag\\` property and \\`context\\` string property.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n properties: {\n context: {\n type: 'string',\n },\n tag: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-tags.md#repos-sticky-header',\n});\n"],"mappings":";;;;;;AAAA,IAAAA,0BAAA,GAAAC,OAAA;AAEyC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE1B,IAAAC,oDAAyB,EAAC;EACvCC,WAAW,EAAE,4DAA4D;EACzEC,WAAWA,CAAEC,OAAO,EAAEC,MAAM,EAAE;IAC5B;IACA,IAAI,CAACD,OAAO,CAACE,OAAO,CAAC,CAAC,CAAC,CAACC,QAAQ,EAAE;MAChCF,MAAM,CAAC,iDAAiD,CAAC;MACzD,OAAO,KAAK;IACd;IAEA,MAAM;MACJE;IACF,CAAC,GAAGH,OAAO,CAACE,OAAO,CAAC,CAAC,CAAC;IAEtB,OAAOC,QAAQ;EACjB,CAAC;EACDC,aAAaA,CAAEJ,OAAO,EAAE;IACtB,MAAMK,IAAI,GAAG;IACXL,OAAO,CAACE,OAAO,GAAG,CAAC,CAAC,EAAEG,IACvB;IAED,MAAMC,MAAM,GAAGD,IAAI,EAAEE,GAAG,CAAEC,GAAG,IAAK;MAChC,MAAMC,OAAO,GAAG,OAAOD,GAAG,KAAK,QAAQ,GAAGA,GAAG,GAAGA,GAAG,CAACA,GAAG;MACvD,OAAO;QACLE,OAAO,EAAE,qCACPD,OAAO,KACJ;QACLT,OAAO,EAAE,OAAOQ,GAAG,KAAK,QAAQ,GAAG,KAAK,GAAGA,GAAG,CAACR,OAAO;QACtDW,OAAO,EAAE,yBAAyBF,OAAO;MAC3C,CAAC;IACH,CAAC,CAAC;;IAEF;IACA,MAAMG,mBAAmB,GAAGC,MAAM,CAACC,yBAAyB,CAACd,OAAO,CAAC;IACrE,OAAOa,MAAM,CAACE,MAAM,CAClBF,MAAM,CAACG,cAAc,CAAChB,OAAO,CAAC,EAC9B;MACE,GAAGY,mBAAmB;MACtBV,OAAO,EAAE;QACP,GAAGU,mBAAmB,CAACV,OAAO;QAC9Be,KAAK,EAAE,CACL;UACEd,QAAQ,EAAEG;QACZ,CAAC;MAEL;IACF,CACF,CAAC;EACH,CAAC;EACDY,MAAM,EAAE,CACN;IACEC,oBAAoB,EAAE,KAAK;IAC3BC,UAAU,EAAE;MACVf,IAAI,EAAE;QACJP,WAAW,EAAE;AACvB,2DAA2D;QACjDuB,KAAK,EAAE;UACLC,KAAK,EAAE,CACL;YACEC,IAAI,EAAE;UACR,CAAC,EACD;YACEH,UAAU,EAAE;cACVpB,OAAO,EAAE;gBACPuB,IAAI,EAAE;cACR,CAAC;cACDf,GAAG,EAAE;gBACHe,IAAI,EAAE;cACR;YACF,CAAC;YACDA,IAAI,EAAE;UACR,CAAC;QAEL,CAAC;QACDA,IAAI,EAAE;MACR;IACF,CAAC;IACDA,IAAI,EAAE;EACR,CAAC,CACF;EACDC,GAAG,EAAE;AACP,CAAC,CAAC;AAAAC,MAAA,CAAA9B,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
|
package/dist/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
|
| []
|
package/package.json
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import iterateJsdoc from './iterateJsdoc.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {(string|{
|
|
5
|
+
* comment: string,
|
|
6
|
+
* context: string,
|
|
7
|
+
* message?: string
|
|
8
|
+
* })[]} Contexts
|
|
9
|
+
*/
|
|
10
|
+
|
|
3
11
|
/**
|
|
4
12
|
* @param {{
|
|
5
|
-
* contexts
|
|
6
|
-
* comment: string,
|
|
7
|
-
* context: string,
|
|
8
|
-
* message: string
|
|
9
|
-
* })[],
|
|
13
|
+
* contexts?: Contexts,
|
|
10
14
|
* description?: string,
|
|
11
|
-
*
|
|
15
|
+
* getContexts?: (
|
|
16
|
+
* ctxt: import('eslint').Rule.RuleContext,
|
|
17
|
+
* report: import('./iterateJsdoc.js').Report
|
|
18
|
+
* ) => Contexts|false,
|
|
19
|
+
* contextName?: string,
|
|
20
|
+
* modifyContext?: (context: import('eslint').Rule.RuleContext) => import('eslint').Rule.RuleContext,
|
|
21
|
+
* schema?: import('eslint').Rule.RuleMetaData['schema']
|
|
12
22
|
* url?: string,
|
|
13
23
|
* }} cfg
|
|
14
24
|
* @returns {import('@eslint/core').RuleDefinition<
|
|
@@ -17,22 +27,35 @@ import iterateJsdoc from './iterateJsdoc.js';
|
|
|
17
27
|
*/
|
|
18
28
|
export const buildForbidRuleDefinition = ({
|
|
19
29
|
contextName,
|
|
20
|
-
contexts,
|
|
30
|
+
contexts: cntxts,
|
|
21
31
|
description,
|
|
32
|
+
getContexts,
|
|
33
|
+
modifyContext,
|
|
34
|
+
schema,
|
|
22
35
|
url,
|
|
23
36
|
}) => {
|
|
24
37
|
return iterateJsdoc(({
|
|
25
|
-
|
|
38
|
+
context,
|
|
26
39
|
info: {
|
|
27
40
|
comment,
|
|
28
41
|
},
|
|
29
42
|
report,
|
|
30
43
|
utils,
|
|
31
44
|
}) => {
|
|
45
|
+
/** @type {Contexts|boolean|undefined} */
|
|
46
|
+
let contexts = cntxts;
|
|
47
|
+
|
|
48
|
+
if (getContexts) {
|
|
49
|
+
contexts = getContexts(context, report);
|
|
50
|
+
if (!contexts) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
32
55
|
const {
|
|
33
56
|
contextStr,
|
|
34
57
|
foundContext,
|
|
35
|
-
} = utils.findContext(contexts, comment);
|
|
58
|
+
} = utils.findContext(/** @type {Contexts} */ (contexts), comment);
|
|
36
59
|
|
|
37
60
|
// We are not on the *particular* matching context/comment, so don't assume
|
|
38
61
|
// we need reporting
|
|
@@ -59,10 +82,10 @@ export const buildForbidRuleDefinition = ({
|
|
|
59
82
|
description: description ?? contextName ?? 'Reports when certain comment structures are present.',
|
|
60
83
|
url: url ?? 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/advanced.md#user-content-advanced-creating-your-own-rules',
|
|
61
84
|
},
|
|
62
|
-
schema: [],
|
|
85
|
+
schema: schema ?? [],
|
|
63
86
|
type: 'suggestion',
|
|
64
87
|
},
|
|
65
|
-
modifyContext: (context) => {
|
|
88
|
+
modifyContext: modifyContext ?? (getContexts ? undefined : (context) => {
|
|
66
89
|
// Reproduce context object with our own `contexts`
|
|
67
90
|
const propertyDescriptors = Object.getOwnPropertyDescriptors(context);
|
|
68
91
|
return Object.create(
|
|
@@ -73,13 +96,13 @@ export const buildForbidRuleDefinition = ({
|
|
|
73
96
|
...propertyDescriptors.options,
|
|
74
97
|
value: [
|
|
75
98
|
{
|
|
76
|
-
contexts,
|
|
99
|
+
contexts: cntxts,
|
|
77
100
|
},
|
|
78
101
|
],
|
|
79
102
|
},
|
|
80
103
|
},
|
|
81
104
|
);
|
|
82
|
-
},
|
|
105
|
+
}),
|
|
83
106
|
nonGlobalSettings: true,
|
|
84
107
|
});
|
|
85
108
|
};
|
package/src/index-cjs.js
CHANGED
|
@@ -56,6 +56,7 @@ import requireReturns from './rules/requireReturns.js';
|
|
|
56
56
|
import requireReturnsCheck from './rules/requireReturnsCheck.js';
|
|
57
57
|
import requireReturnsDescription from './rules/requireReturnsDescription.js';
|
|
58
58
|
import requireReturnsType from './rules/requireReturnsType.js';
|
|
59
|
+
import requireTags from './rules/requireTags.js';
|
|
59
60
|
import requireTemplate from './rules/requireTemplate.js';
|
|
60
61
|
import requireThrows from './rules/requireThrows.js';
|
|
61
62
|
import requireYields from './rules/requireYields.js';
|
|
@@ -178,6 +179,7 @@ index.rules = {
|
|
|
178
179
|
'require-returns-check': requireReturnsCheck,
|
|
179
180
|
'require-returns-description': requireReturnsDescription,
|
|
180
181
|
'require-returns-type': requireReturnsType,
|
|
182
|
+
'require-tags': requireTags,
|
|
181
183
|
'require-template': requireTemplate,
|
|
182
184
|
'require-throws': requireThrows,
|
|
183
185
|
'require-throws-description': buildForbidRuleDefinition({
|
|
@@ -304,6 +306,7 @@ const createRecommendedRuleset = (warnOrError, flatName) => {
|
|
|
304
306
|
'jsdoc/require-returns-check': warnOrError,
|
|
305
307
|
'jsdoc/require-returns-description': warnOrError,
|
|
306
308
|
'jsdoc/require-returns-type': warnOrError,
|
|
309
|
+
'jsdoc/require-tags': 'off',
|
|
307
310
|
'jsdoc/require-template': 'off',
|
|
308
311
|
'jsdoc/require-throws': 'off',
|
|
309
312
|
'jsdoc/require-throws-description': 'off',
|
package/src/index.js
CHANGED
|
@@ -62,6 +62,7 @@ import requireReturns from './rules/requireReturns.js';
|
|
|
62
62
|
import requireReturnsCheck from './rules/requireReturnsCheck.js';
|
|
63
63
|
import requireReturnsDescription from './rules/requireReturnsDescription.js';
|
|
64
64
|
import requireReturnsType from './rules/requireReturnsType.js';
|
|
65
|
+
import requireTags from './rules/requireTags.js';
|
|
65
66
|
import requireTemplate from './rules/requireTemplate.js';
|
|
66
67
|
import requireThrows from './rules/requireThrows.js';
|
|
67
68
|
import requireYields from './rules/requireYields.js';
|
|
@@ -184,6 +185,7 @@ index.rules = {
|
|
|
184
185
|
'require-returns-check': requireReturnsCheck,
|
|
185
186
|
'require-returns-description': requireReturnsDescription,
|
|
186
187
|
'require-returns-type': requireReturnsType,
|
|
188
|
+
'require-tags': requireTags,
|
|
187
189
|
'require-template': requireTemplate,
|
|
188
190
|
'require-throws': requireThrows,
|
|
189
191
|
'require-throws-description': buildForbidRuleDefinition({
|
|
@@ -310,6 +312,7 @@ const createRecommendedRuleset = (warnOrError, flatName) => {
|
|
|
310
312
|
'jsdoc/require-returns-check': warnOrError,
|
|
311
313
|
'jsdoc/require-returns-description': warnOrError,
|
|
312
314
|
'jsdoc/require-returns-type': warnOrError,
|
|
315
|
+
'jsdoc/require-tags': 'off',
|
|
313
316
|
'jsdoc/require-template': 'off',
|
|
314
317
|
'jsdoc/require-throws': 'off',
|
|
315
318
|
'jsdoc/require-throws-description': 'off',
|
|
@@ -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
|
});
|