eslint-plugin-jsdoc 65.4.1 → 65.4.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.
|
@@ -158,6 +158,14 @@ declare const _default: {
|
|
|
158
158
|
"VariableDeclarator:exit"?: ((node: import("estree").VariableDeclarator & import("eslint").Rule.NodeParentExtension) => void) | undefined;
|
|
159
159
|
};
|
|
160
160
|
meta: {
|
|
161
|
+
defaultOptions: {
|
|
162
|
+
allowedPrefixes: string[];
|
|
163
|
+
contextsAfter: string[];
|
|
164
|
+
contextsBeforeAndAfter: string[];
|
|
165
|
+
enableFixer: boolean;
|
|
166
|
+
enforceJsdocLineStyle: string;
|
|
167
|
+
lineOrBlockStyle: string;
|
|
168
|
+
}[];
|
|
161
169
|
docs: {
|
|
162
170
|
description: string;
|
|
163
171
|
url: string;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
create(context: import("eslint").Rule.RuleContext): {};
|
|
3
3
|
meta: {
|
|
4
|
+
defaultOptions: {
|
|
5
|
+
checkAllFunctionExpressions: boolean;
|
|
6
|
+
enableFixer: boolean;
|
|
7
|
+
exemptEmptyConstructors: boolean;
|
|
8
|
+
exemptEmptyFunctions: boolean;
|
|
9
|
+
exemptOverloadedImplementations: boolean;
|
|
10
|
+
fixerMessage: string;
|
|
11
|
+
skipInterveningOverloadedDeclarations: boolean;
|
|
12
|
+
}[];
|
|
4
13
|
docs: {
|
|
5
14
|
description: string;
|
|
6
15
|
recommended: boolean;
|
package/package.json
CHANGED
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"decamelize": "^7.0.0",
|
|
54
54
|
"eslint": "10.13.0",
|
|
55
55
|
"eslint-config-canonical": "^47.4.2",
|
|
56
|
+
"eslint-plugin-eslint-plugin": "^7.6.2",
|
|
56
57
|
"gitdown": "^4.1.1",
|
|
57
58
|
"glob": "^13.0.6",
|
|
58
59
|
"globals": "^17.13.0",
|
|
@@ -163,5 +164,5 @@
|
|
|
163
164
|
"test-cov": "TIMING=1 c8 --reporter text pnpm run test-no-cov",
|
|
164
165
|
"test-index": "pnpm run test-no-cov test/rules/index.js"
|
|
165
166
|
},
|
|
166
|
-
"version": "65.4.
|
|
167
|
+
"version": "65.4.2"
|
|
167
168
|
}
|
|
@@ -13,6 +13,24 @@ import {
|
|
|
13
13
|
getReducedASTNode,
|
|
14
14
|
} from '@es-joy/jsdoccomment';
|
|
15
15
|
|
|
16
|
+
const defaultAllowedPrefixes = [
|
|
17
|
+
'@ts-', '@license', '@license-end',
|
|
18
|
+
'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
// Shared by `create` and `meta.defaultOptions` so the two cannot drift.
|
|
22
|
+
// `contexts` is omitted so `settings.contexts` still applies when unset.
|
|
23
|
+
const defaultOptions = {
|
|
24
|
+
allowedPrefixes: defaultAllowedPrefixes,
|
|
25
|
+
contextsAfter: /** @type {string[]} */ ([]),
|
|
26
|
+
contextsBeforeAndAfter: [
|
|
27
|
+
'VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition',
|
|
28
|
+
],
|
|
29
|
+
enableFixer: true,
|
|
30
|
+
enforceJsdocLineStyle: 'multi',
|
|
31
|
+
lineOrBlockStyle: 'both',
|
|
32
|
+
};
|
|
33
|
+
|
|
16
34
|
/** @type {import('eslint').Rule.RuleModule} */
|
|
17
35
|
export default {
|
|
18
36
|
create (context) {
|
|
@@ -44,18 +62,14 @@ export default {
|
|
|
44
62
|
}
|
|
45
63
|
|
|
46
64
|
const {
|
|
47
|
-
allowedPrefixes =
|
|
48
|
-
'@ts-', '@license', '@license-end',
|
|
49
|
-
'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-',
|
|
50
|
-
],
|
|
65
|
+
allowedPrefixes = defaultOptions.allowedPrefixes,
|
|
51
66
|
contexts = settings.contexts || [],
|
|
52
|
-
contextsAfter =
|
|
53
|
-
contextsBeforeAndAfter =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
lineOrBlockStyle = 'both',
|
|
67
|
+
contextsAfter = defaultOptions.contextsAfter,
|
|
68
|
+
contextsBeforeAndAfter = defaultOptions.contextsBeforeAndAfter,
|
|
69
|
+
enableFixer = defaultOptions.enableFixer,
|
|
70
|
+
enforceJsdocLineStyle = defaultOptions.enforceJsdocLineStyle,
|
|
71
|
+
lineOrBlockStyle = defaultOptions.lineOrBlockStyle,
|
|
72
|
+
/* c8 ignore next -- Guard for ESLint versions that ignore meta.defaultOptions */
|
|
59
73
|
} = context.options[0] ?? {};
|
|
60
74
|
|
|
61
75
|
let reportingNonJsdoc = false;
|
|
@@ -394,6 +408,10 @@ export default {
|
|
|
394
408
|
};
|
|
395
409
|
},
|
|
396
410
|
meta: {
|
|
411
|
+
defaultOptions: [
|
|
412
|
+
defaultOptions,
|
|
413
|
+
],
|
|
414
|
+
|
|
397
415
|
docs: {
|
|
398
416
|
description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones',
|
|
399
417
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header',
|
|
@@ -379,6 +379,21 @@ const getOption = (context, baseObject, option, key) => {
|
|
|
379
379
|
)[key].default;
|
|
380
380
|
};
|
|
381
381
|
|
|
382
|
+
// Shared by `getOptions` and `meta.defaultOptions` so the two cannot drift.
|
|
383
|
+
// `contexts` is omitted so `settings.contexts` still applies, and `require` /
|
|
384
|
+
// `publicOnly` stay unset so `getOption` keeps reading their schema defaults.
|
|
385
|
+
const defaultOptions = {
|
|
386
|
+
checkAllFunctionExpressions: false,
|
|
387
|
+
enableFixer: true,
|
|
388
|
+
|
|
389
|
+
// Code defaults this to `true` (the schema `default` is stale).
|
|
390
|
+
exemptEmptyConstructors: true,
|
|
391
|
+
exemptEmptyFunctions: false,
|
|
392
|
+
exemptOverloadedImplementations: false,
|
|
393
|
+
fixerMessage: '',
|
|
394
|
+
skipInterveningOverloadedDeclarations: true,
|
|
395
|
+
};
|
|
396
|
+
|
|
382
397
|
/**
|
|
383
398
|
* @param {import('eslint').Rule.RuleContext} context
|
|
384
399
|
* @param {import('../iterateJsdoc.js').Settings} settings
|
|
@@ -402,16 +417,17 @@ const getOption = (context, baseObject, option, key) => {
|
|
|
402
417
|
*/
|
|
403
418
|
const getOptions = (context, settings) => {
|
|
404
419
|
const {
|
|
405
|
-
checkAllFunctionExpressions =
|
|
420
|
+
checkAllFunctionExpressions = defaultOptions.checkAllFunctionExpressions,
|
|
406
421
|
contexts = settings.contexts || [],
|
|
407
|
-
enableFixer =
|
|
408
|
-
exemptEmptyConstructors =
|
|
409
|
-
exemptEmptyFunctions =
|
|
410
|
-
exemptOverloadedImplementations =
|
|
411
|
-
fixerMessage =
|
|
422
|
+
enableFixer = defaultOptions.enableFixer,
|
|
423
|
+
exemptEmptyConstructors = defaultOptions.exemptEmptyConstructors,
|
|
424
|
+
exemptEmptyFunctions = defaultOptions.exemptEmptyFunctions,
|
|
425
|
+
exemptOverloadedImplementations = defaultOptions.exemptOverloadedImplementations,
|
|
426
|
+
fixerMessage = defaultOptions.fixerMessage,
|
|
412
427
|
minLineCount = undefined,
|
|
413
428
|
publicOnly,
|
|
414
|
-
skipInterveningOverloadedDeclarations =
|
|
429
|
+
skipInterveningOverloadedDeclarations = defaultOptions.skipInterveningOverloadedDeclarations,
|
|
430
|
+
/* c8 ignore next -- Guard for ESLint versions that ignore meta.defaultOptions */
|
|
415
431
|
} = context.options[0] || {};
|
|
416
432
|
|
|
417
433
|
return {
|
|
@@ -876,6 +892,10 @@ export default {
|
|
|
876
892
|
};
|
|
877
893
|
},
|
|
878
894
|
meta: {
|
|
895
|
+
defaultOptions: [
|
|
896
|
+
defaultOptions,
|
|
897
|
+
],
|
|
898
|
+
|
|
879
899
|
docs: {
|
|
880
900
|
description: 'Checks for presence of JSDoc comments, on functions and potentially other contexts (optionally limited to exports).',
|
|
881
901
|
recommended: true,
|
|
@@ -51,8 +51,11 @@ export default iterateJsdoc(({
|
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
// A `readonly` function property has no method signature
|
|
55
|
+
// equivalent (`readonly` is not allowed on methods)
|
|
54
56
|
if (parentNode?.type === 'JsdocTypeObjectField' &&
|
|
55
|
-
typeof parentNode.key === 'string'
|
|
57
|
+
typeof parentNode.key === 'string' &&
|
|
58
|
+
!parentNode.readonly
|
|
56
59
|
) {
|
|
57
60
|
utils.reportJSDoc(
|
|
58
61
|
'Found function property; prefer method signature.',
|
|
@@ -80,6 +83,7 @@ export default iterateJsdoc(({
|
|
|
80
83
|
quote: objectField.meta.quote,
|
|
81
84
|
},
|
|
82
85
|
name: /** @type {string} */ (objectField.key),
|
|
86
|
+
optional: objectField.optional,
|
|
83
87
|
parameters: nde.parameters,
|
|
84
88
|
returnType: /** @type {import('jsdoc-type-pratt-parser').RootResult} */ (
|
|
85
89
|
nde.returnType
|
|
@@ -100,7 +104,9 @@ export default iterateJsdoc(({
|
|
|
100
104
|
// @ts-expect-error Our own added API
|
|
101
105
|
parentNode.parentNode.parentNode.type === 'JsdocTypeObjectField' &&
|
|
102
106
|
// @ts-expect-error Our own added API
|
|
103
|
-
typeof parentNode.parentNode.parentNode.key === 'string'
|
|
107
|
+
typeof parentNode.parentNode.parentNode.key === 'string' &&
|
|
108
|
+
// @ts-expect-error Our own added API
|
|
109
|
+
!parentNode.parentNode.parentNode.readonly
|
|
104
110
|
) {
|
|
105
111
|
// @ts-expect-error Our own added API
|
|
106
112
|
const intersection = parentNode.parentNode;
|
|
@@ -123,6 +129,7 @@ export default iterateJsdoc(({
|
|
|
123
129
|
quote: objectField.meta.quote,
|
|
124
130
|
},
|
|
125
131
|
name: /** @type {string} */ (objectField.key),
|
|
132
|
+
optional: objectField.optional,
|
|
126
133
|
parameters: func.parameters,
|
|
127
134
|
returnType: /** @type {import('jsdoc-type-pratt-parser').RootResult} */ (
|
|
128
135
|
func.returnType
|
|
@@ -226,7 +233,7 @@ export default iterateJsdoc(({
|
|
|
226
233
|
object.elements[idx] = /** @type {import('jsdoc-type-pratt-parser').ObjectFieldResult} */ ({
|
|
227
234
|
key: nde.name,
|
|
228
235
|
meta: nde.meta,
|
|
229
|
-
optional:
|
|
236
|
+
optional: nde.optional === true,
|
|
230
237
|
readonly: false,
|
|
231
238
|
right: funcs[0],
|
|
232
239
|
type: 'JsdocTypeObjectField',
|
|
@@ -239,7 +246,7 @@ export default iterateJsdoc(({
|
|
|
239
246
|
object.elements[idx] = {
|
|
240
247
|
key: nde.name,
|
|
241
248
|
meta: nde.meta,
|
|
242
|
-
optional:
|
|
249
|
+
optional: nde.optional === true,
|
|
243
250
|
readonly: false,
|
|
244
251
|
right: {
|
|
245
252
|
elements: funcs.map((func) => {
|