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

Commit d7a4469

Browse files
committed
Improve jsdoc generation
1 parent 756f3ba commit d7a4469

File tree

195 files changed

+603
-589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+603
-589
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"np": "~7.5.0",
5555
"prettier": "2.4.1",
5656
"prettier-plugin-organize-imports": "~2.3.4",
57-
"typescript": "~4.4.3"
57+
"typescript": "~4.4.3",
58+
"upper-case-first": "~2.0.2"
5859
}
5960
}

scripts/generate-files.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import type { Rule } from 'eslint';
33
// @ts-expect-error
44
import eslintPluginJSDoc from 'eslint-plugin-jsdoc';
55
// @ts-expect-error
6+
import eslintPluginSpellcheck from 'eslint-plugin-spellcheck';
7+
// @ts-expect-error
68
import eslintPluginVue from 'eslint-plugin-vue';
79
import * as fs from 'fs';
810
import type { JSONSchema4 } from 'json-schema';
911
import * as path from 'path';
1012
import type { Options } from 'prettier';
1113
import { format } from 'prettier';
14+
import { upperCaseFirst } from 'upper-case-first';
1215

1316
interface Plugin {
1417
name: string;
@@ -32,6 +35,10 @@ const generationMap: Record<string, Plugin> = {
3235
name: 'JSDoc',
3336
rules: (eslintPluginJSDoc as Plugin).rules
3437
},
38+
spellcheck: {
39+
name: 'Spellcheck',
40+
rules: (eslintPluginSpellcheck as Plugin).rules
41+
},
3542
vue: {
3643
name: 'Vue',
3744
rules: (eslintPluginVue as Plugin).rules
@@ -52,6 +59,11 @@ for (const pluginName in generationMap) {
5259
const rulePath: string = path.resolve(ruleProviderDir, `${ruleName}.d.ts`);
5360
let ruleContent: string = "import type { RuleConfig } from '../rule-config';";
5461

62+
const ruleNamePascalCase: string = pascalCase(ruleName);
63+
64+
const description: string = upperCaseFirst(meta?.docs?.description ?? '');
65+
const seeDocLink: string = meta?.docs?.url ? `@see [${ruleName}](${meta.docs.url})` : '';
66+
5567
const schema: JSONSchema4 | JSONSchema4[] | undefined = meta?.schema;
5668
const mainSchema: JSONSchema4 | undefined = Array.isArray(schema) ? schema[0] : schema;
5769
const hasOptionProperties: boolean = !!mainSchema?.properties;
@@ -61,12 +73,12 @@ for (const pluginName in generationMap) {
6173
/**
6274
* Option.
6375
*/
64-
export type ${pascalCase(ruleName)}Option = {`;
76+
export type ${ruleNamePascalCase}Option = {`;
6577

6678
Object.entries(mainSchema.properties).forEach(([propertyName, propertyDefinition]) => {
6779
ruleContent += `
6880
/**
69-
* @see [${ruleName}](${meta?.docs?.url})
81+
* ${seeDocLink}
7082
*/
7183
'${propertyName}'?: any;\n`;
7284
});
@@ -76,32 +88,32 @@ export type ${pascalCase(ruleName)}Option = {`;
7688
/**
7789
* Options.
7890
*/
79-
export type ${pascalCase(ruleName)}Options = [${pascalCase(ruleName)}Option?];`;
91+
export type ${ruleNamePascalCase}Options = [${ruleNamePascalCase}Option?];`;
8092
}
8193

8294
ruleContent += `
8395
8496
/**
85-
* ${meta?.docs?.description}
97+
* ${description}
8698
*
87-
* @see [${ruleName}](${meta?.docs?.url})
99+
* ${seeDocLink}
88100
*/
89-
export type ${pascalCase(ruleName)}RuleConfig = RuleConfig<${
90-
hasOptionProperties ? `${pascalCase(ruleName)}Options` : '[]'
101+
export type ${ruleNamePascalCase}RuleConfig = RuleConfig<${
102+
hasOptionProperties ? `${ruleNamePascalCase}Options` : '[]'
91103
}>;
92104
93105
/**
94-
* ${meta?.docs?.description}
106+
* ${description}
95107
*
96-
* @see [${ruleName}](${meta?.docs?.url})
108+
* ${seeDocLink}
97109
*/
98-
export interface ${pascalCase(ruleName)}Rule {
110+
export interface ${ruleNamePascalCase}Rule {
99111
/**
100-
* ${meta?.docs?.description}
112+
* ${description}
101113
*
102-
* @see [${ruleName}](${meta?.docs?.url})
114+
* ${seeDocLink}
103115
*/
104-
'${camelCase(pluginName)}/${ruleName}': ${pascalCase(ruleName)}RuleConfig;
116+
'${camelCase(pluginName)}/${ruleName}': ${ruleNamePascalCase}RuleConfig;
105117
}
106118
`;
107119
ruleContent = format(ruleContent, PRETTIER_OPTIONS);

src/rules/spellcheck/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { SpellCheckerRule } from './spell-checker';
22

33
/**
4-
* All spellcheck rules.
4+
* All Spellcheck rules.
55
*/
66
export type SpellcheckRules = SpellCheckerRule;

src/rules/vue/array-bracket-newline.d.ts

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

33
/**
4-
* enforce linebreaks after opening and before closing array brackets
4+
* Enforce linebreaks after opening and before closing array brackets
55
*
66
* @see [array-bracket-newline](https://eslint.vuejs.org/rules/array-bracket-newline.html)
77
*/
88
export type ArrayBracketNewlineRuleConfig = RuleConfig<[]>;
99

1010
/**
11-
* enforce linebreaks after opening and before closing array brackets
11+
* Enforce linebreaks after opening and before closing array brackets
1212
*
1313
* @see [array-bracket-newline](https://eslint.vuejs.org/rules/array-bracket-newline.html)
1414
*/
1515
export interface ArrayBracketNewlineRule {
1616
/**
17-
* enforce linebreaks after opening and before closing array brackets
17+
* Enforce linebreaks after opening and before closing array brackets
1818
*
1919
* @see [array-bracket-newline](https://eslint.vuejs.org/rules/array-bracket-newline.html)
2020
*/

src/rules/vue/array-bracket-spacing.d.ts

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

33
/**
4-
* enforce consistent spacing inside array brackets
4+
* Enforce consistent spacing inside array brackets
55
*
66
* @see [array-bracket-spacing](https://eslint.vuejs.org/rules/array-bracket-spacing.html)
77
*/
88
export type ArrayBracketSpacingRuleConfig = RuleConfig<[]>;
99

1010
/**
11-
* enforce consistent spacing inside array brackets
11+
* Enforce consistent spacing inside array brackets
1212
*
1313
* @see [array-bracket-spacing](https://eslint.vuejs.org/rules/array-bracket-spacing.html)
1414
*/
1515
export interface ArrayBracketSpacingRule {
1616
/**
17-
* enforce consistent spacing inside array brackets
17+
* Enforce consistent spacing inside array brackets
1818
*
1919
* @see [array-bracket-spacing](https://eslint.vuejs.org/rules/array-bracket-spacing.html)
2020
*/

src/rules/vue/arrow-spacing.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ export type ArrowSpacingOption = {
2121
export type ArrowSpacingOptions = [ArrowSpacingOption?];
2222

2323
/**
24-
* enforce consistent spacing before and after the arrow in arrow functions
24+
* Enforce consistent spacing before and after the arrow in arrow functions
2525
*
2626
* @see [arrow-spacing](https://eslint.vuejs.org/rules/arrow-spacing.html)
2727
*/
2828
export type ArrowSpacingRuleConfig = RuleConfig<ArrowSpacingOptions>;
2929

3030
/**
31-
* enforce consistent spacing before and after the arrow in arrow functions
31+
* Enforce consistent spacing before and after the arrow in arrow functions
3232
*
3333
* @see [arrow-spacing](https://eslint.vuejs.org/rules/arrow-spacing.html)
3434
*/
3535
export interface ArrowSpacingRule {
3636
/**
37-
* enforce consistent spacing before and after the arrow in arrow functions
37+
* Enforce consistent spacing before and after the arrow in arrow functions
3838
*
3939
* @see [arrow-spacing](https://eslint.vuejs.org/rules/arrow-spacing.html)
4040
*/

src/rules/vue/attribute-hyphenation.d.ts

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

33
/**
4-
* enforce attribute naming style on custom components in template
4+
* Enforce attribute naming style on custom components in template
55
*
66
* @see [attribute-hyphenation](https://eslint.vuejs.org/rules/attribute-hyphenation.html)
77
*/
88
export type AttributeHyphenationRuleConfig = RuleConfig<[]>;
99

1010
/**
11-
* enforce attribute naming style on custom components in template
11+
* Enforce attribute naming style on custom components in template
1212
*
1313
* @see [attribute-hyphenation](https://eslint.vuejs.org/rules/attribute-hyphenation.html)
1414
*/
1515
export interface AttributeHyphenationRule {
1616
/**
17-
* enforce attribute naming style on custom components in template
17+
* Enforce attribute naming style on custom components in template
1818
*
1919
* @see [attribute-hyphenation](https://eslint.vuejs.org/rules/attribute-hyphenation.html)
2020
*/

src/rules/vue/attributes-order.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ export type AttributesOrderOption = {
2121
export type AttributesOrderOptions = [AttributesOrderOption?];
2222

2323
/**
24-
* enforce order of attributes
24+
* Enforce order of attributes
2525
*
2626
* @see [attributes-order](https://eslint.vuejs.org/rules/attributes-order.html)
2727
*/
2828
export type AttributesOrderRuleConfig = RuleConfig<AttributesOrderOptions>;
2929

3030
/**
31-
* enforce order of attributes
31+
* Enforce order of attributes
3232
*
3333
* @see [attributes-order](https://eslint.vuejs.org/rules/attributes-order.html)
3434
*/
3535
export interface AttributesOrderRule {
3636
/**
37-
* enforce order of attributes
37+
* Enforce order of attributes
3838
*
3939
* @see [attributes-order](https://eslint.vuejs.org/rules/attributes-order.html)
4040
*/

src/rules/vue/block-lang.d.ts

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

33
/**
4-
* disallow use other than available `lang`
4+
* Disallow use other than available `lang`
55
*
66
* @see [block-lang](https://eslint.vuejs.org/rules/block-lang.html)
77
*/
88
export type BlockLangRuleConfig = RuleConfig<[]>;
99

1010
/**
11-
* disallow use other than available `lang`
11+
* Disallow use other than available `lang`
1212
*
1313
* @see [block-lang](https://eslint.vuejs.org/rules/block-lang.html)
1414
*/
1515
export interface BlockLangRule {
1616
/**
17-
* disallow use other than available `lang`
17+
* Disallow use other than available `lang`
1818
*
1919
* @see [block-lang](https://eslint.vuejs.org/rules/block-lang.html)
2020
*/

src/rules/vue/block-spacing.d.ts

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

33
/**
4-
* disallow or enforce spaces inside of blocks after opening block and before closing block
4+
* Disallow or enforce spaces inside of blocks after opening block and before closing block
55
*
66
* @see [block-spacing](https://eslint.vuejs.org/rules/block-spacing.html)
77
*/
88
export type BlockSpacingRuleConfig = RuleConfig<[]>;
99

1010
/**
11-
* disallow or enforce spaces inside of blocks after opening block and before closing block
11+
* Disallow or enforce spaces inside of blocks after opening block and before closing block
1212
*
1313
* @see [block-spacing](https://eslint.vuejs.org/rules/block-spacing.html)
1414
*/
1515
export interface BlockSpacingRule {
1616
/**
17-
* disallow or enforce spaces inside of blocks after opening block and before closing block
17+
* Disallow or enforce spaces inside of blocks after opening block and before closing block
1818
*
1919
* @see [block-spacing](https://eslint.vuejs.org/rules/block-spacing.html)
2020
*/

0 commit comments

Comments
 (0)