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

Commit 78c77c6

Browse files
committed
Start creating a script for automate generation
1 parent 4d309b0 commit 78c77c6

File tree

3 files changed

+108
-3
lines changed

3 files changed

+108
-3
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"tsconfig.json"
3939
],
4040
"devDependencies": {
41+
"@types/eslint": "~7.28.0",
4142
"@types/node": "~16.9.6",
4243
"@typescript-eslint/eslint-plugin": "~4.31.2",
4344
"@typescript-eslint/parser": "~4.31.2",
@@ -47,6 +48,7 @@
4748
"eslint-plugin-jsdoc": "~36.1.0",
4849
"eslint-plugin-prettier": "~4.0.0",
4950
"eslint-plugin-spellcheck": "~0.0.19",
51+
"eslint-plugin-vue": "~7.18.0",
5052
"np": "~7.5.0",
5153
"prettier": "2.4.1",
5254
"prettier-plugin-organize-imports": "~2.3.4",

scripts/generate-files.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* eslint-disable */
2+
3+
import type { Rule } from 'eslint';
4+
// @ts-expect-error
5+
import eslintPluginVue from 'eslint-plugin-vue';
6+
import * as fs from 'fs';
7+
import * as path from 'path';
8+
9+
interface Plugin {
10+
rules: Record<string, Rule.RuleModule>;
11+
}
12+
13+
function pascalCase(value: string): string {
14+
return value.replace(/(\w)(\w*)/g, (_, g1, g2) => g1.toUpperCase() + g2.toLowerCase()).replace(/-/g, '');
15+
}
16+
17+
const rulesDir = path.resolve(__dirname, '../src/rules');
18+
19+
const ruleProviderDir = path.resolve(rulesDir, 'vue');
20+
21+
fs.mkdirSync(ruleProviderDir, { mode: 0o755, recursive: true });
22+
23+
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';
28+
29+
/**
30+
*
31+
*/
32+
export type ${pascalCase(name)}RuleConfig = RuleConfig<[]>;
33+
34+
/**
35+
*
36+
*/
37+
export interface ${pascalCase(name)}Rule {
38+
'vue/${name}': any;
39+
}
40+
`
41+
);
42+
});

yarn.lock

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,31 @@ __metadata:
179179
languageName: node
180180
linkType: hard
181181

182+
"@types/eslint@npm:~7.28.0":
183+
version: 7.28.0
184+
resolution: "@types/eslint@npm:7.28.0"
185+
dependencies:
186+
"@types/estree": "*"
187+
"@types/json-schema": "*"
188+
checksum: 75ac2577d2a2e35bae66f56d2d1c871d5e836b2721cf14bd3df450c9d584eba48fa3b1013fba710245bf4795f16e1df0ed315e543e3199c4815ee4782537d0ae
189+
languageName: node
190+
linkType: hard
191+
192+
"@types/estree@npm:*":
193+
version: 0.0.50
194+
resolution: "@types/estree@npm:0.0.50"
195+
checksum: 9a2b6a4a8c117f34d08fbda5e8f69b1dfb109f7d149b60b00fd7a9fb6ac545c078bc590aa4ec2f0a256d680cf72c88b3b28b60c326ee38a7bc8ee1ee95624922
196+
languageName: node
197+
linkType: hard
198+
182199
"@types/http-cache-semantics@npm:*":
183200
version: 4.0.1
184201
resolution: "@types/http-cache-semantics@npm:4.0.1"
185202
checksum: 1048aacf627829f0d5f00184e16548205cd9f964bf0841c29b36bc504509230c40bc57c39778703a1c965a6f5b416ae2cbf4c1d4589c889d2838dd9dbfccf6e9
186203
languageName: node
187204
linkType: hard
188205

189-
"@types/json-schema@npm:^7.0.7":
206+
"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.7":
190207
version: 7.0.9
191208
resolution: "@types/json-schema@npm:7.0.9"
192209
checksum: 259d0e25f11a21ba5c708f7ea47196bd396e379fddb79c76f9f4f62c945879dc21657904914313ec2754e443c5018ea8372362f323f30e0792897fdb2098a705
@@ -338,7 +355,7 @@ __metadata:
338355
languageName: node
339356
linkType: hard
340357

341-
"acorn-jsx@npm:^5.3.1":
358+
"acorn-jsx@npm:^5.2.0, acorn-jsx@npm:^5.3.1":
342359
version: 5.3.2
343360
resolution: "acorn-jsx@npm:5.3.2"
344361
peerDependencies:
@@ -347,7 +364,7 @@ __metadata:
347364
languageName: node
348365
linkType: hard
349366

350-
"acorn@npm:^7.4.0":
367+
"acorn@npm:^7.1.1, acorn@npm:^7.4.0":
351368
version: 7.4.1
352369
resolution: "acorn@npm:7.4.1"
353370
bin:
@@ -1095,6 +1112,7 @@ __metadata:
10951112
version: 0.0.0-use.local
10961113
resolution: "eslint-define-config@workspace:."
10971114
dependencies:
1115+
"@types/eslint": ~7.28.0
10981116
"@types/node": ~16.9.6
10991117
"@typescript-eslint/eslint-plugin": ~4.31.2
11001118
"@typescript-eslint/parser": ~4.31.2
@@ -1104,6 +1122,7 @@ __metadata:
11041122
eslint-plugin-jsdoc: ~36.1.0
11051123
eslint-plugin-prettier: ~4.0.0
11061124
eslint-plugin-spellcheck: ~0.0.19
1125+
eslint-plugin-vue: ~7.18.0
11071126
np: ~7.5.0
11081127
prettier: 2.4.1
11091128
prettier-plugin-organize-imports: ~2.3.4
@@ -1167,6 +1186,20 @@ __metadata:
11671186
languageName: node
11681187
linkType: hard
11691188

1189+
"eslint-plugin-vue@npm:~7.18.0":
1190+
version: 7.18.0
1191+
resolution: "eslint-plugin-vue@npm:7.18.0"
1192+
dependencies:
1193+
eslint-utils: ^2.1.0
1194+
natural-compare: ^1.4.0
1195+
semver: ^6.3.0
1196+
vue-eslint-parser: ^7.10.0
1197+
peerDependencies:
1198+
eslint: ^6.2.0 || ^7.0.0 || ^8.0.0-0
1199+
checksum: 5df7e23478cb1094c5a0918c4239d50126c1770e34d4fb9ad30737b58a9ad33d31dda7d05aad2bc28dc97651a6c34c67f243bd82145ff76b6aea81f5c06345fd
1200+
languageName: node
1201+
linkType: hard
1202+
11701203
"eslint-scope@npm:^5.1.1":
11711204
version: 5.1.1
11721205
resolution: "eslint-scope@npm:5.1.1"
@@ -1261,6 +1294,17 @@ __metadata:
12611294
languageName: node
12621295
linkType: hard
12631296

1297+
"espree@npm:^6.2.1":
1298+
version: 6.2.1
1299+
resolution: "espree@npm:6.2.1"
1300+
dependencies:
1301+
acorn: ^7.1.1
1302+
acorn-jsx: ^5.2.0
1303+
eslint-visitor-keys: ^1.1.0
1304+
checksum: 99c508950b5b9f53d008d781d2abb7a4ef3496ea699306fb6eb737c7e513aa594644314364c50ec27abb220124c6851fff64a6b62c358479534369904849360b
1305+
languageName: node
1306+
linkType: hard
1307+
12641308
"espree@npm:^7.3.0, espree@npm:^7.3.1":
12651309
version: 7.3.1
12661310
resolution: "espree@npm:7.3.1"
@@ -3936,6 +3980,23 @@ typescript@~4.4.3:
39363980
languageName: node
39373981
linkType: hard
39383982

3983+
"vue-eslint-parser@npm:^7.10.0":
3984+
version: 7.11.0
3985+
resolution: "vue-eslint-parser@npm:7.11.0"
3986+
dependencies:
3987+
debug: ^4.1.1
3988+
eslint-scope: ^5.1.1
3989+
eslint-visitor-keys: ^1.1.0
3990+
espree: ^6.2.1
3991+
esquery: ^1.4.0
3992+
lodash: ^4.17.21
3993+
semver: ^6.3.0
3994+
peerDependencies:
3995+
eslint: ">=5.0.0"
3996+
checksum: 16d8bd31dacd9e5d3cd0fc82354c0cfdb42ee3d2e0c3aeda385b82aa48a59a440de3dc18521ea6535f4b00a54eb248d49a6ea2323fbae0d3c1afa0a00c63fe6c
3997+
languageName: node
3998+
linkType: hard
3999+
39394000
"which@npm:^2.0.1":
39404001
version: 2.0.2
39414002
resolution: "which@npm:2.0.2"

0 commit comments

Comments
 (0)