Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 9514ede

Browse files
committed
Generate config from side schema
1 parent 90bd9ba commit 9514ede

28 files changed

+278
-105
lines changed

scripts/generate-files.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ for (const pluginName in generationMap) {
137137
}
138138
// TODO: vue/max-len has also a third schema
139139
if (mainSchema) {
140+
if (sideSchema) {
141+
ruleContent += `
142+
143+
/**
144+
* Config.
145+
*/
146+
export type ${ruleNamePascalCase}Config = ${generateOptionType(sideSchema)}`;
147+
}
148+
140149
ruleContent += `
141150
142151
/**
@@ -147,7 +156,9 @@ export type ${ruleNamePascalCase}Option = ${generateOptionType(mainSchema)}
147156
/**
148157
* Options.
149158
*/
150-
export type ${ruleNamePascalCase}Options = [${ruleNamePascalCase}Option?];`;
159+
export type ${ruleNamePascalCase}Options = [${ruleNamePascalCase}Option?${
160+
sideSchema ? `, ${ruleNamePascalCase}Config?` : ''
161+
}];`;
151162
}
152163

153164
// TODO: Add side and third option

src/rules/jsdoc/check-line-alignment.d.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import type { RuleConfig } from '../rule-config';
22

3+
/**
4+
* Config.
5+
*/
6+
export type CheckLineAlignmentConfig = {
7+
customSpacings?: any;
8+
preserveMainDescriptionPostDelimiter?: boolean;
9+
tags?: any[];
10+
};
11+
312
/**
413
* Option.
514
*/
@@ -8,7 +17,7 @@ export type CheckLineAlignmentOption = 'always' | 'never';
817
/**
918
* Options.
1019
*/
11-
export type CheckLineAlignmentOptions = [CheckLineAlignmentOption?];
20+
export type CheckLineAlignmentOptions = [CheckLineAlignmentOption?, CheckLineAlignmentConfig?];
1221

1322
/**
1423
* Reports invalid alignment of JSDoc block lines.

src/rules/jsdoc/match-description.d.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ import type { RuleConfig } from '../rule-config';
44
* Option.
55
*/
66
export type MatchDescriptionOption = {
7+
/**
8+
* Set this to an array of strings representing the AST context where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
9+
*
10+
* Set to `"any"` if you want the rule to apply to any jsdoc block throughout your files.
11+
*
12+
* @see [contexts](https://github.com/gajus/eslint-plugin-jsdoc#contexts-1)
13+
*/
14+
contexts?: string[];
715
/**
816
* If you wish to override the main function description without changing the default `match-description`, you may use `mainDescription`.
917
*
@@ -16,14 +24,7 @@ export type MatchDescriptionOption = {
1624
* @see [matchDescription](https://github.com/gajus/eslint-plugin-jsdoc#matchdescription)
1725
*/
1826
matchDescription?: string;
19-
/**
20-
* Set this to an array of strings representing the AST context where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
21-
*
22-
* Set to `"any"` if you want the rule to apply to any jsdoc block throughout your files.
23-
*
24-
* @see [contexts](https://github.com/gajus/eslint-plugin-jsdoc#contexts-1)
25-
*/
26-
contexts?: string[];
27+
message?: string;
2728
/**
2829
* If you want different regular expressions to apply to tags, you may use the `tags` option object.
2930
*
@@ -40,20 +41,20 @@ export type MatchDescriptionOptions = [MatchDescriptionOption?];
4041
/**
4142
* Enforces a regular expression pattern on descriptions.
4243
*
43-
* @see [match-description](https://github.com/gajus/eslint-plugin-jsdoc#match-description)
44+
* @see [match-description](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-match-description)
4445
*/
4546
export type MatchDescriptionRuleConfig = RuleConfig<MatchDescriptionOptions>;
4647

4748
/**
4849
* Enforces a regular expression pattern on descriptions.
4950
*
50-
* @see [match-description](https://github.com/gajus/eslint-plugin-jsdoc#match-description)
51+
* @see [match-description](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-match-description)
5152
*/
5253
export interface MatchDescriptionRule {
5354
/**
5455
* Enforces a regular expression pattern on descriptions.
5556
*
56-
* @see [match-description](https://github.com/gajus/eslint-plugin-jsdoc#match-description)
57+
* @see [match-description](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-match-description)
5758
*/
5859
'jsdoc/match-description': MatchDescriptionRuleConfig;
5960
}

src/rules/jsdoc/no-types.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export type NoTypesOptions = [NoTypesOption?];
2020
*
2121
* The rule is intended to prevent the indication of types on tags where the type information would be redundant with TypeScript.
2222
*
23-
* @see [no-types](https://github.com/gajus/eslint-plugin-jsdoc#no-types)
23+
* @see [no-types](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-types)
2424
*/
2525
export type NoTypesRuleConfig = RuleConfig<NoTypesOptions>;
2626

@@ -29,15 +29,15 @@ export type NoTypesRuleConfig = RuleConfig<NoTypesOptions>;
2929
*
3030
* The rule is intended to prevent the indication of types on tags where the type information would be redundant with TypeScript.
3131
*
32-
* @see [no-types](https://github.com/gajus/eslint-plugin-jsdoc#no-types)
32+
* @see [no-types](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-types)
3333
*/
3434
export interface NoTypesRule {
3535
/**
3636
* This rule reports types being used on `@param` or `@returns`.
3737
*
3838
* The rule is intended to prevent the indication of types on tags where the type information would be redundant with TypeScript.
3939
*
40-
* @see [no-types](https://github.com/gajus/eslint-plugin-jsdoc#no-types)
40+
* @see [no-types](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-types)
4141
*/
4242
'jsdoc/no-types': NoTypesRuleConfig;
4343
}

src/rules/jsdoc/require-asterisk-prefix.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import type { RuleConfig } from '../rule-config';
22

3+
/**
4+
* Config.
5+
*/
6+
export type RequireAsteriskPrefixConfig = {
7+
tags?: Record<string, any>;
8+
};
9+
310
/**
411
* Option.
512
*/
@@ -8,7 +15,7 @@ export type RequireAsteriskPrefixOption = 'always' | 'never' | 'any';
815
/**
916
* Options.
1017
*/
11-
export type RequireAsteriskPrefixOptions = [RequireAsteriskPrefixOption?];
18+
export type RequireAsteriskPrefixOptions = [RequireAsteriskPrefixOption?, RequireAsteriskPrefixConfig?];
1219

1320
/**
1421
*

src/rules/jsdoc/require-hyphen-before-param-description.d.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import type { RuleConfig } from '../rule-config';
22

3+
/**
4+
* Config.
5+
*/
6+
export type RequireHyphenBeforeParamDescriptionConfig = {
7+
tags?: any;
8+
};
9+
310
/**
411
* Option.
512
*/
@@ -8,7 +15,10 @@ export type RequireHyphenBeforeParamDescriptionOption = 'always' | 'never';
815
/**
916
* Options.
1017
*/
11-
export type RequireHyphenBeforeParamDescriptionOptions = [RequireHyphenBeforeParamDescriptionOption?];
18+
export type RequireHyphenBeforeParamDescriptionOptions = [
19+
RequireHyphenBeforeParamDescriptionOption?,
20+
RequireHyphenBeforeParamDescriptionConfig?
21+
];
1222

1323
/**
1424
* Requires a hyphen before the `@param` description.

src/rules/jsdoc/require-jsdoc.d.ts

Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,36 @@ import type { RuleConfig } from '../rule-config';
44
* Option.
55
*/
66
export type RequireJsdocOption = {
7+
/**
8+
* A value indicating whether `constructors` should be checked.
9+
*
10+
* When `true`, `exemptEmptyConstructors` may still avoid reporting when no parameters or return values are found.
11+
*
12+
* @default true
13+
*
14+
* @see [checkConstructors](https://github.com/gajus/eslint-plugin-jsdoc#checkconstructors)
15+
*/
16+
checkConstructors?: boolean;
17+
/**
18+
* A value indicating whether getters should be checked.
19+
*
20+
* Besides setting as a boolean, this option can be set to the string `"no-setter"` to indicate that getters should be checked but only when there is no setter. This may be useful if one only wishes documentation on one of the two accessors.
21+
*
22+
* @default false
23+
*
24+
* @see [checkGetters](https://github.com/gajus/eslint-plugin-jsdoc#checkgetters)
25+
*/
26+
checkGetters?: boolean;
27+
/**
28+
* A value indicating whether setters should be checked.
29+
*
30+
* Besides setting as a boolean, this option can be set to the string `"no-getter"` to indicate that setters should be checked but only when there is no getter. This may be useful if one only wishes documentation on one of the two accessors.
31+
*
32+
* @default false
33+
*
34+
* @see [checkSetters](https://github.com/gajus/eslint-plugin-jsdoc#checksetters)
35+
*/
36+
checkSetters?: boolean;
737
/**
838
* Set this to an array of strings or objects representing the additional AST contexts where you wish the rule to be applied (e.g., `Property` for properties).
939
*
@@ -24,6 +54,31 @@ export type RequireJsdocOption = {
2454
inlineCommentBlock?: boolean;
2555
}
2656
>;
57+
/**
58+
* A boolean on whether to enable the fixer (which adds an empty jsdoc block).
59+
*
60+
* @default true
61+
*
62+
* @see [enableFixer](https://github.com/gajus/eslint-plugin-jsdoc#enablefixer)
63+
*/
64+
enableFixer?: boolean;
65+
/**
66+
* When `true`, the rule will not report missing jsdoc blocks above constructors with no parameters or return values (this is enabled by default as the class name or description should be seen as sufficient to convey intent).
67+
*
68+
* @default true
69+
*
70+
* @see [exemptEmptyConstructors](https://github.com/gajus/eslint-plugin-jsdoc#exemptemptyconstructors)
71+
*/
72+
exemptEmptyConstructors?: boolean;
73+
/**
74+
* When `true`, the rule will not report missing jsdoc blocks above functions/methods with no parameters or return values (intended where function/method names are sufficient for themselves as documentation).
75+
*
76+
* @default false
77+
*
78+
* @see [exemptEmptyFunctions](https://github.com/gajus/eslint-plugin-jsdoc#exemptemptyfunctions)
79+
*/
80+
exemptEmptyFunctions?: boolean;
81+
fixerMessage?: string;
2782
/**
2883
* @see [publicOnly](https://github.com/gajus/eslint-plugin-jsdoc#publiconly)
2984
*/
@@ -84,60 +139,6 @@ export type RequireJsdocOption = {
84139
*/
85140
MethodDefinition?: boolean;
86141
};
87-
/**
88-
* When `true`, the rule will not report missing jsdoc blocks above constructors with no parameters or return values (this is enabled by default as the class name or description should be seen as sufficient to convey intent).
89-
*
90-
* @default true
91-
*
92-
* @see [exemptEmptyConstructors](https://github.com/gajus/eslint-plugin-jsdoc#exemptemptyconstructors)
93-
*/
94-
exemptEmptyConstructors?: boolean;
95-
/**
96-
* When `true`, the rule will not report missing jsdoc blocks above functions/methods with no parameters or return values (intended where function/method names are sufficient for themselves as documentation).
97-
*
98-
* @default false
99-
*
100-
* @see [exemptEmptyFunctions](https://github.com/gajus/eslint-plugin-jsdoc#exemptemptyfunctions)
101-
*/
102-
exemptEmptyFunctions?: boolean;
103-
/**
104-
* A value indicating whether `constructors` should be checked.
105-
*
106-
* When `true`, `exemptEmptyConstructors` may still avoid reporting when no parameters or return values are found.
107-
*
108-
* @default true
109-
*
110-
* @see [checkConstructors](https://github.com/gajus/eslint-plugin-jsdoc#checkconstructors)
111-
*/
112-
checkConstructors?: boolean;
113-
/**
114-
* A value indicating whether getters should be checked.
115-
*
116-
* Besides setting as a boolean, this option can be set to the string `"no-setter"` to indicate that getters should be checked but only when there is no setter. This may be useful if one only wishes documentation on one of the two accessors.
117-
*
118-
* @default false
119-
*
120-
* @see [checkGetters](https://github.com/gajus/eslint-plugin-jsdoc#checkgetters)
121-
*/
122-
checkGetters?: boolean;
123-
/**
124-
* A value indicating whether setters should be checked.
125-
*
126-
* Besides setting as a boolean, this option can be set to the string `"no-getter"` to indicate that setters should be checked but only when there is no getter. This may be useful if one only wishes documentation on one of the two accessors.
127-
*
128-
* @default false
129-
*
130-
* @see [checkSetters](https://github.com/gajus/eslint-plugin-jsdoc#checksetters)
131-
*/
132-
checkSetters?: boolean;
133-
/**
134-
* A boolean on whether to enable the fixer (which adds an empty jsdoc block).
135-
*
136-
* @default true
137-
*
138-
* @see [enableFixer](https://github.com/gajus/eslint-plugin-jsdoc#enablefixer)
139-
*/
140-
enableFixer?: boolean;
141142
};
142143

143144
/**
@@ -148,20 +149,20 @@ export type RequireJsdocOptions = [RequireJsdocOption?];
148149
/**
149150
* Checks for presence of jsdoc comments, on class declarations as well as functions.
150151
*
151-
* @see [require-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc#require-jsdoc)
152+
* @see [require-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-jsdoc)
152153
*/
153154
export type RequireJsdocRuleConfig = RuleConfig<RequireJsdocOptions>;
154155

155156
/**
156157
* Checks for presence of jsdoc comments, on class declarations as well as functions.
157158
*
158-
* @see [require-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc#require-jsdoc)
159+
* @see [require-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-jsdoc)
159160
*/
160161
export interface RequireJsdocRule {
161162
/**
162163
* Checks for presence of jsdoc comments, on class declarations as well as functions.
163164
*
164-
* @see [require-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc#require-jsdoc)
165+
* @see [require-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-jsdoc)
165166
*/
166167
'jsdoc/require-jsdoc': RequireJsdocRuleConfig;
167168
}

src/rules/jsdoc/require-param-type.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ export type RequireParamTypeOptions = [RequireParamTypeOption?];
2424
/**
2525
* Requires that each `@param` tag has a `type` value.
2626
*
27-
* @see [require-param-type](https://github.com/gajus/eslint-plugin-jsdoc#require-param-type)
27+
* @see [require-param-type](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-type)
2828
*/
2929
export type RequireParamTypeRuleConfig = RuleConfig<RequireParamTypeOptions>;
3030

3131
/**
3232
* Requires that each `@param` tag has a `type` value.
3333
*
34-
* @see [require-param-type](https://github.com/gajus/eslint-plugin-jsdoc#require-param-type)
34+
* @see [require-param-type](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-type)
3535
*/
3636
export interface RequireParamTypeRule {
3737
/**
3838
* Requires that each `@param` tag has a `type` value.
3939
*
40-
* @see [require-param-type](https://github.com/gajus/eslint-plugin-jsdoc#require-param-type)
40+
* @see [require-param-type](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-type)
4141
*/
4242
'jsdoc/require-param-type': RequireParamTypeRuleConfig;
4343
}

src/rules/jsdoc/require-returns-type.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ export type RequireReturnsTypeOptions = [RequireReturnsTypeOption?];
2424
/**
2525
* Requires that `@returns` tag has `type` value.
2626
*
27-
* @see [require-returns-type](https://github.com/gajus/eslint-plugin-jsdoc#require-returns-type)
27+
* @see [require-returns-type](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-type)
2828
*/
2929
export type RequireReturnsTypeRuleConfig = RuleConfig<RequireReturnsTypeOptions>;
3030

3131
/**
3232
* Requires that `@returns` tag has `type` value.
3333
*
34-
* @see [require-returns-type](https://github.com/gajus/eslint-plugin-jsdoc#require-returns-type)
34+
* @see [require-returns-type](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-type)
3535
*/
3636
export interface RequireReturnsTypeRule {
3737
/**
3838
* Requires that `@returns` tag has `type` value.
3939
*
40-
* @see [require-returns-type](https://github.com/gajus/eslint-plugin-jsdoc#require-returns-type)
40+
* @see [require-returns-type](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-type)
4141
*/
4242
'jsdoc/require-returns-type': RequireReturnsTypeRuleConfig;
4343
}

0 commit comments

Comments
 (0)