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

Commit 83adcbc

Browse files
committed
Write index.d.ts rules file
1 parent 78c77c6 commit 83adcbc

File tree

197 files changed

+3678
-142
lines changed

Some content is hidden

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

197 files changed

+3678
-142
lines changed

.eslintrc.js

Lines changed: 2 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ module.exports = defineConfig({
1111
'eslint:recommended',
1212
'plugin:@typescript-eslint/recommended',
1313
'plugin:@typescript-eslint/recommended-requiring-type-checking',
14-
'plugin:jsdoc/recommended',
1514
'plugin:prettier/recommended'
1615
],
1716
parser: '@typescript-eslint/parser',
1817
parserOptions: {
1918
project: ['./tsconfig.json'],
2019
warnOnUnsupportedTypeScriptVersion: false
2120
},
22-
plugins: ['@typescript-eslint', 'prettier', 'jsdoc', 'spellcheck', 'inclusive-language'],
21+
plugins: ['@typescript-eslint', 'prettier'],
2322
rules: {
2423
curly: ['error'],
2524
'linebreak-style': ['error', 'unix'],
@@ -40,123 +39,6 @@ module.exports = defineConfig({
4039
'@typescript-eslint/prefer-optional-chain': 'warn',
4140
'@typescript-eslint/prefer-readonly': ['warn'],
4241
'@typescript-eslint/restrict-template-expressions': 'off',
43-
'@typescript-eslint/typedef': ['warn', { memberVariableDeclaration: true, variableDeclaration: true }],
44-
45-
'jsdoc/match-description': [
46-
'warn',
47-
{
48-
mainDescription: '/^[A-Z`].+?(\\.|:)(\\n\\n.*((\\n{1,2}- .+)|(_.+_)|`.+`|\\n\\n---))?$/us',
49-
matchDescription: '^[A-Z`].+(\\.|`.+`)$',
50-
contexts: ['any'],
51-
tags: {
52-
param: true,
53-
returns: true
54-
}
55-
}
56-
],
57-
'jsdoc/no-types': 'error',
58-
'jsdoc/require-jsdoc': [
59-
'warn',
60-
{
61-
contexts: [
62-
'ClassDeclaration',
63-
"ClassProperty:not([accessibility='private'])",
64-
'ExportNamedDeclaration:has(VariableDeclaration)',
65-
'FunctionExpression',
66-
"MethodDefinition:not([accessibility='private']) > FunctionExpression",
67-
'TSEnumDeclaration',
68-
'TSInterfaceDeclaration',
69-
'TSMethodSignature',
70-
// 'TSPropertySignature',
71-
'TSTypeAliasDeclaration'
72-
]
73-
}
74-
],
75-
'jsdoc/require-param-type': 'off',
76-
'jsdoc/require-returns-type': 'off',
77-
'jsdoc/tag-lines': 'off',
78-
79-
'spellcheck/spell-checker': [
80-
'warn',
81-
{
82-
minLength: 3,
83-
skipWords: [
84-
'accessor',
85-
'accessors',
86-
'amd',
87-
'applescript',
88-
'argv',
89-
'asyncgenerator',
90-
'asynciterable',
91-
'atomtest',
92-
'backtick',
93-
'backticks',
94-
'browserify',
95-
'cjs',
96-
'commonjs',
97-
'declarator',
98-
'denylist',
99-
'dom',
100-
'ecma',
101-
'embertest',
102-
'esm',
103-
'esnext',
104-
'getters',
105-
'globals',
106-
'greasemonkey',
107-
'inferrable',
108-
'jsdoc',
109-
'jsx',
110-
'lang',
111-
'len',
112-
'linebreak',
113-
'loc',
114-
'multiline',
115-
'nashorn',
116-
'nocheck',
117-
'nullish',
118-
'phantomjs',
119-
'pragma',
120-
'prototypejs',
121-
'readonly',
122-
'scripthost',
123-
'sharedmemory',
124-
'singleline',
125-
'tsconfig',
126-
'typedarrays',
127-
'unix',
128-
'urls',
129-
'vue',
130-
'webextensions',
131-
'webworker',
132-
'wellknown',
133-
'whitespace',
134-
'writeable'
135-
]
136-
}
137-
],
138-
139-
'inclusive-language/use-inclusive-words': [
140-
'warn',
141-
{
142-
allowedTerms: [
143-
{
144-
term: '/master',
145-
allowPartialMatches: true
146-
}
147-
],
148-
words: [
149-
{
150-
word: 'guys',
151-
suggestions: ['folks']
152-
}
153-
]
154-
}
155-
]
156-
},
157-
settings: {
158-
jsdoc: {
159-
mode: 'typescript'
160-
}
42+
'@typescript-eslint/typedef': ['warn', { memberVariableDeclaration: true, variableDeclaration: true }]
16143
}
16244
});

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
"devDependencies": {
4141
"@types/eslint": "~7.28.0",
4242
"@types/node": "~16.9.6",
43+
"@types/prettier": "~2.4.1",
4344
"@typescript-eslint/eslint-plugin": "~4.31.2",
4445
"@typescript-eslint/parser": "~4.31.2",
46+
"change-case": "~4.1.2",
4547
"eslint": "~7.32.0",
4648
"eslint-config-prettier": "~8.3.0",
4749
"eslint-plugin-inclusive-language": "~2.1.1",

scripts/generate-files.ts

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,74 @@
1-
/* eslint-disable */
2-
1+
import { pascalCase } from 'change-case';
32
import type { Rule } from 'eslint';
43
// @ts-expect-error
54
import eslintPluginVue from 'eslint-plugin-vue';
65
import * as fs from 'fs';
76
import * as path from 'path';
7+
import type { Options } from 'prettier';
8+
import { format } from 'prettier';
89

910
interface Plugin {
1011
rules: Record<string, Rule.RuleModule>;
1112
}
1213

13-
function pascalCase(value: string): string {
14-
return value.replace(/(\w)(\w*)/g, (_, g1, g2) => g1.toUpperCase() + g2.toLowerCase()).replace(/-/g, '');
15-
}
14+
const PRETTIER_OPTIONS: Options = {
15+
parser: 'typescript',
16+
arrowParens: 'always',
17+
bracketSpacing: true,
18+
printWidth: 120,
19+
semi: true,
20+
singleQuote: true,
21+
tabWidth: 2,
22+
trailingComma: 'none',
23+
useTabs: false
24+
};
1625

17-
const rulesDir = path.resolve(__dirname, '../src/rules');
26+
// Generating rule files
27+
const rulesDir: string = path.resolve(__dirname, '../src/rules');
1828

19-
const ruleProviderDir = path.resolve(rulesDir, 'vue');
29+
const ruleProviderDir: string = path.resolve(rulesDir, 'vue');
2030

2131
fs.mkdirSync(ruleProviderDir, { mode: 0o755, recursive: true });
2232

2333
Object.entries((eslintPluginVue as Plugin).rules).forEach(([name, { meta }]) => {
24-
const rulePath = path.resolve(ruleProviderDir, `${name}.d.ts`);
25-
fs.writeFileSync(
26-
rulePath,
27-
`import type { RuleConfig } from '../rule-config';
34+
const rulePath: string = path.resolve(ruleProviderDir, `${name}.d.ts`);
35+
let ruleContent: string = `import type { RuleConfig } from '../rule-config';
2836
29-
/**
30-
*
31-
*/
32-
export type ${pascalCase(name)}RuleConfig = RuleConfig<[]>;
37+
/**
38+
*
39+
*/
40+
export type ${pascalCase(name)}RuleConfig = RuleConfig<[]>;
41+
42+
/**
43+
*
44+
*/
45+
export interface ${pascalCase(name)}Rule {
46+
/**
47+
*
48+
*/
49+
'vue/${name}': ${pascalCase(name)}RuleConfig;
50+
}
51+
`;
52+
ruleContent = format(ruleContent, PRETTIER_OPTIONS);
53+
fs.writeFileSync(rulePath, ruleContent);
54+
});
55+
56+
// Generating index.d.ts for rules
57+
const indexPath: string = path.resolve(ruleProviderDir, 'index.d.ts');
58+
let indexContent: string = Object.keys((eslintPluginVue as Plugin).rules)
59+
.map((name) => `import type { ${pascalCase(name)}Rule } from './${name}';`)
60+
.join('\n');
61+
62+
indexContent += `
3363
3464
/**
35-
*
65+
* All @typescript-eslint rules.
3666
*/
37-
export interface ${pascalCase(name)}Rule {
38-
'vue/${name}': any;
39-
}
40-
`
41-
);
42-
});
67+
export type VueRules = ${Object.keys((eslintPluginVue as Plugin).rules)
68+
.map((name) => `${pascalCase(name)}Rule`)
69+
.join(' & ')}
70+
`;
71+
72+
indexContent = format(indexContent, PRETTIER_OPTIONS);
73+
74+
fs.writeFileSync(indexPath, indexContent);

src/rules/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { NodeRules } from './node';
55
import type { RuleConfig } from './rule-config';
66
import type { SpellcheckRules } from './spellcheck';
77
import type { TypeScriptEslintRules } from './typescript-eslint';
8+
import type { VueRules } from './vue';
89

910
/**
1011
* Rules.
@@ -18,5 +19,6 @@ export type Rules = Partial<
1819
ImportRules &
1920
JSDocRules &
2021
SpellcheckRules &
22+
VueRules &
2123
Record<string, RuleConfig>
2224
>;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
*
5+
*/
6+
export type ArrayBracketNewlineRuleConfig = RuleConfig<[]>;
7+
8+
/**
9+
*
10+
*/
11+
export interface ArrayBracketNewlineRule {
12+
/**
13+
*
14+
*/
15+
'vue/array-bracket-newline': ArrayBracketNewlineRuleConfig;
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
*
5+
*/
6+
export type ArrayBracketSpacingRuleConfig = RuleConfig<[]>;
7+
8+
/**
9+
*
10+
*/
11+
export interface ArrayBracketSpacingRule {
12+
/**
13+
*
14+
*/
15+
'vue/array-bracket-spacing': ArrayBracketSpacingRuleConfig;
16+
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
*
5+
*/
6+
export type ArrowSpacingRuleConfig = RuleConfig<[]>;
7+
8+
/**
9+
*
10+
*/
11+
export interface ArrowSpacingRule {
12+
/**
13+
*
14+
*/
15+
'vue/arrow-spacing': ArrowSpacingRuleConfig;
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
*
5+
*/
6+
export type AttributeHyphenationRuleConfig = RuleConfig<[]>;
7+
8+
/**
9+
*
10+
*/
11+
export interface AttributeHyphenationRule {
12+
/**
13+
*
14+
*/
15+
'vue/attribute-hyphenation': AttributeHyphenationRuleConfig;
16+
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
*
5+
*/
6+
export type AttributesOrderRuleConfig = RuleConfig<[]>;
7+
8+
/**
9+
*
10+
*/
11+
export interface AttributesOrderRule {
12+
/**
13+
*
14+
*/
15+
'vue/attributes-order': AttributesOrderRuleConfig;
16+
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
*
5+
*/
6+
export type BlockLangRuleConfig = RuleConfig<[]>;
7+
8+
/**
9+
*
10+
*/
11+
export interface BlockLangRule {
12+
/**
13+
*
14+
*/
15+
'vue/block-lang': BlockLangRuleConfig;
16+
}

0 commit comments

Comments
 (0)