eslint-plugin-jsdoc 57.2.1 → 58.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/dist/buildRejectOrPreferRuleDefinition.cjs +349 -0
- package/dist/buildRejectOrPreferRuleDefinition.cjs.map +1 -0
- package/dist/buildRejectOrPreferRuleDefinition.d.ts +9 -0
- package/dist/cjs/buildRejectOrPreferRuleDefinition.d.ts +8 -0
- package/dist/cjs/rules/checkTypes.d.ts +6 -1
- package/dist/index-cjs.cjs +33 -3
- package/dist/index-cjs.cjs.map +1 -1
- package/dist/index-esm.cjs +29 -1
- package/dist/index-esm.cjs.map +1 -1
- package/dist/index-esm.d.ts +28 -2
- package/dist/index.cjs +61 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +28 -2
- package/dist/rules/checkTypes.cjs +73 -379
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkTypes.d.ts +6 -1
- package/dist/rules.d.ts +9 -3
- package/package.json +1 -1
- package/src/buildRejectOrPreferRuleDefinition.js +472 -0
- package/src/index-cjs.js +35 -3
- package/src/index-esm.js +36 -1
- package/src/index.js +68 -4
- package/src/rules/checkTypes.js +82 -511
- package/src/rules.d.ts +9 -3
package/src/index.js
CHANGED
|
@@ -7,6 +7,9 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
buildForbidRuleDefinition,
|
|
9
9
|
} from './buildForbidRuleDefinition.js';
|
|
10
|
+
import {
|
|
11
|
+
buildRejectOrPreferRuleDefinition,
|
|
12
|
+
} from './buildRejectOrPreferRuleDefinition.js';
|
|
10
13
|
import {
|
|
11
14
|
getJsdocProcessorPlugin,
|
|
12
15
|
} from './getJsdocProcessorPlugin.js';
|
|
@@ -113,6 +116,33 @@ index.rules = {
|
|
|
113
116
|
'no-restricted-syntax': noRestrictedSyntax,
|
|
114
117
|
'no-types': noTypes,
|
|
115
118
|
'no-undefined-types': noUndefinedTypes,
|
|
119
|
+
'reject-any-type': buildRejectOrPreferRuleDefinition({
|
|
120
|
+
description: 'Reports use of `any` or `*` type',
|
|
121
|
+
overrideSettings: {
|
|
122
|
+
'*': {
|
|
123
|
+
message: 'Prefer a more specific type to `*`',
|
|
124
|
+
replacement: false,
|
|
125
|
+
unifyParentAndChildTypeChecks: true,
|
|
126
|
+
},
|
|
127
|
+
any: {
|
|
128
|
+
message: 'Prefer a more specific type to `any`',
|
|
129
|
+
replacement: false,
|
|
130
|
+
unifyParentAndChildTypeChecks: true,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/reject-any-type.md#repos-sticky-header',
|
|
134
|
+
}),
|
|
135
|
+
'reject-function-type': buildRejectOrPreferRuleDefinition({
|
|
136
|
+
description: 'Reports use of `Function` type',
|
|
137
|
+
overrideSettings: {
|
|
138
|
+
Function: {
|
|
139
|
+
message: 'Prefer a more specific type to `Function`',
|
|
140
|
+
replacement: false,
|
|
141
|
+
unifyParentAndChildTypeChecks: true,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/reject-function-type.md#repos-sticky-header',
|
|
145
|
+
}),
|
|
116
146
|
'require-asterisk-prefix': requireAsteriskPrefix,
|
|
117
147
|
'require-description': requireDescription,
|
|
118
148
|
'require-description-complete-sentence': requireDescriptionCompleteSentence,
|
|
@@ -128,7 +158,7 @@ index.rules = {
|
|
|
128
158
|
message: '@next should have a type',
|
|
129
159
|
},
|
|
130
160
|
],
|
|
131
|
-
description: 'Requires a type for
|
|
161
|
+
description: 'Requires a type for `@next` tags',
|
|
132
162
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-next-type.md#repos-sticky-header',
|
|
133
163
|
}),
|
|
134
164
|
'require-param': requireParam,
|
|
@@ -153,7 +183,7 @@ index.rules = {
|
|
|
153
183
|
message: '@throws should have a type',
|
|
154
184
|
},
|
|
155
185
|
],
|
|
156
|
-
description: 'Requires a type for
|
|
186
|
+
description: 'Requires a type for `@throws` tags',
|
|
157
187
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-throws-type.md#repos-sticky-header',
|
|
158
188
|
}),
|
|
159
189
|
'require-yields': requireYields,
|
|
@@ -166,7 +196,7 @@ index.rules = {
|
|
|
166
196
|
message: '@yields should have a type',
|
|
167
197
|
},
|
|
168
198
|
],
|
|
169
|
-
description: 'Requires a type for
|
|
199
|
+
description: 'Requires a type for `@yields` tags',
|
|
170
200
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields-type.md#repos-sticky-header',
|
|
171
201
|
}),
|
|
172
202
|
'sort-tags': sortTags,
|
|
@@ -224,6 +254,8 @@ const createRecommendedRuleset = (warnOrError, flatName) => {
|
|
|
224
254
|
'jsdoc/no-restricted-syntax': 'off',
|
|
225
255
|
'jsdoc/no-types': 'off',
|
|
226
256
|
'jsdoc/no-undefined-types': warnOrError,
|
|
257
|
+
'jsdoc/reject-any-type': warnOrError,
|
|
258
|
+
'jsdoc/reject-function-type': warnOrError,
|
|
227
259
|
'jsdoc/require-asterisk-prefix': 'off',
|
|
228
260
|
'jsdoc/require-description': 'off',
|
|
229
261
|
'jsdoc/require-description-complete-sentence': 'off',
|
|
@@ -609,7 +641,7 @@ export default index;
|
|
|
609
641
|
* settings?: Partial<import('./iterateJsdoc.js').Settings>,
|
|
610
642
|
* rules?: {[key in keyof import('./rules.d.ts').Rules]?: import('eslint').Linter.RuleEntry<import('./rules.d.ts').Rules[key]>},
|
|
611
643
|
* extraRuleDefinitions?: {
|
|
612
|
-
* forbid
|
|
644
|
+
* forbid?: {
|
|
613
645
|
* [contextName: string]: {
|
|
614
646
|
* description?: string,
|
|
615
647
|
* url?: string,
|
|
@@ -619,6 +651,19 @@ export default index;
|
|
|
619
651
|
* comment: string
|
|
620
652
|
* })[]
|
|
621
653
|
* }
|
|
654
|
+
* },
|
|
655
|
+
* preferTypes?: {
|
|
656
|
+
* [typeName: string]: {
|
|
657
|
+
* description: string,
|
|
658
|
+
* overrideSettings: {
|
|
659
|
+
* [typeNodeName: string]: {
|
|
660
|
+
* message: string,
|
|
661
|
+
* replacement?: false|string,
|
|
662
|
+
* unifyParentAndChildTypeChecks?: boolean,
|
|
663
|
+
* }
|
|
664
|
+
* },
|
|
665
|
+
* url: string,
|
|
666
|
+
* }
|
|
622
667
|
* }
|
|
623
668
|
* }
|
|
624
669
|
* }
|
|
@@ -712,6 +757,25 @@ export const jsdoc = function (cfg) {
|
|
|
712
757
|
});
|
|
713
758
|
}
|
|
714
759
|
}
|
|
760
|
+
|
|
761
|
+
if (cfg.extraRuleDefinitions.preferTypes) {
|
|
762
|
+
for (const [
|
|
763
|
+
typeName,
|
|
764
|
+
{
|
|
765
|
+
description,
|
|
766
|
+
overrideSettings,
|
|
767
|
+
url,
|
|
768
|
+
},
|
|
769
|
+
] of Object.entries(cfg.extraRuleDefinitions.preferTypes)) {
|
|
770
|
+
outputConfig.plugins.jsdoc.rules[`prefer-type-${typeName}`] =
|
|
771
|
+
buildRejectOrPreferRuleDefinition({
|
|
772
|
+
description,
|
|
773
|
+
overrideSettings,
|
|
774
|
+
typeName,
|
|
775
|
+
url,
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
}
|
|
715
779
|
}
|
|
716
780
|
}
|
|
717
781
|
|