From 9ce588867c4955a90c88b0a6e7ecd36a194eaebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=95=88=E8=BE=89?= Date: Tue, 10 Oct 2023 14:26:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A7=A3=E5=86=B3ts=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E9=94=99=E8=AF=AF=EF=BC=8C=E6=8A=8A=E8=A7=84=E5=88=99=E6=94=BE?= =?UTF-8?q?=E5=88=B0=E5=8D=95=E7=8B=AC=E6=96=87=E4=BB=B6=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 5 +- pnpm-lock.yaml | 170 +++++++++++++++++++++++++------------------ src/configs/all.ts | 47 ++++++++++++ src/configs/index.ts | 2 + src/configs/react.ts | 1 + src/configs/vue.ts | 20 +++++ src/factory.ts | 76 +++---------------- src/globs.ts | 2 + src/utils.ts | 2 +- 9 files changed, 186 insertions(+), 139 deletions(-) create mode 100644 src/configs/all.ts create mode 100644 src/configs/vue.ts diff --git a/package.json b/package.json index 20d5b5f..f4deaaf 100644 --- a/package.json +++ b/package.json @@ -35,13 +35,14 @@ }, "dependencies": { "@antfu/eslint-config": "1.0.0-beta.24", - "@typescript-eslint/parser": "^6.7.4", + "@typescript-eslint/parser": "^6.7.5", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0" }, "devDependencies": { "@dxhuii/eslint-config": "workspace:*", - "@types/node": "^20.8.3", + "@types/eslint": "^8.44.3", + "@types/node": "^20.8.4", "bumpp": "^9.2.0", "eslint": "^8.51.0", "lint-staged": "^14.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6971c55..d1ce4b6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: 1.0.0-beta.24 version: 1.0.0-beta.24(eslint@8.51.0)(typescript@5.2.2)(vitest@0.34.6) '@typescript-eslint/parser': - specifier: ^6.7.4 - version: 6.7.4(eslint@8.51.0)(typescript@5.2.2) + specifier: ^6.7.5 + version: 6.7.5(eslint@8.51.0)(typescript@5.2.2) eslint-plugin-react: specifier: ^7.33.2 version: 7.33.2(eslint@8.51.0) @@ -24,9 +24,12 @@ importers: '@dxhuii/eslint-config': specifier: workspace:* version: 'link:' + '@types/eslint': + specifier: ^8.44.3 + version: 8.44.3 '@types/node': - specifier: ^20.8.3 - version: 20.8.3 + specifier: ^20.8.4 + version: 20.8.4 bumpp: specifier: ^9.2.0 version: 9.2.0 @@ -59,21 +62,21 @@ packages: dependencies: '@antfu/eslint-define-config': 1.23.0-1 '@stylistic/eslint-plugin': 0.0.8(eslint@8.51.0)(typescript@5.2.2) - '@typescript-eslint/eslint-plugin': 6.7.4(@typescript-eslint/parser@6.7.4)(eslint@8.51.0)(typescript@5.2.2) - '@typescript-eslint/parser': 6.7.4(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/eslint-plugin': 6.7.5(@typescript-eslint/parser@6.7.5)(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/parser': 6.7.5(eslint@8.51.0)(typescript@5.2.2) eslint: 8.51.0 eslint-config-flat-gitignore: 0.1.0 eslint-plugin-antfu: 1.0.0-beta.12(eslint@8.51.0)(typescript@5.2.2) eslint-plugin-eslint-comments: 3.2.0(eslint@8.51.0) - eslint-plugin-i: 2.28.1(@typescript-eslint/parser@6.7.4)(eslint@8.51.0) + eslint-plugin-i: 2.28.1(@typescript-eslint/parser@6.7.5)(eslint@8.51.0) eslint-plugin-jsdoc: 46.8.2(eslint@8.51.0) eslint-plugin-jsonc: 2.10.0(eslint@8.51.0) eslint-plugin-markdown: 3.0.1(eslint@8.51.0) eslint-plugin-n: 16.1.0(eslint@8.51.0) eslint-plugin-no-only-tests: 3.1.0 eslint-plugin-unicorn: 48.0.1(eslint@8.51.0) - eslint-plugin-unused-imports: 3.0.0(@typescript-eslint/eslint-plugin@6.7.4)(eslint@8.51.0) - eslint-plugin-vitest: 0.3.2(@typescript-eslint/eslint-plugin@6.7.4)(eslint@8.51.0)(typescript@5.2.2)(vitest@0.34.6) + eslint-plugin-unused-imports: 3.0.0(@typescript-eslint/eslint-plugin@6.7.5)(eslint@8.51.0) + eslint-plugin-vitest: 0.3.2(@typescript-eslint/eslint-plugin@6.7.5)(eslint@8.51.0)(typescript@5.2.2)(vitest@0.34.6) eslint-plugin-vue: 9.17.0(eslint@8.51.0) eslint-plugin-yml: 1.10.0(eslint@8.51.0) globals: 13.23.0 @@ -110,6 +113,7 @@ packages: /@babel/highlight@7.22.20: resolution: {integrity: sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==} engines: {node: '>=6.9.0'} + requiresBuild: true dependencies: '@babel/helper-validator-identifier': 7.22.20 chalk: 2.4.2 @@ -449,9 +453,9 @@ packages: eslint: '*' dependencies: '@stylistic/eslint-plugin-js': 0.0.8(eslint@8.51.0) - '@typescript-eslint/scope-manager': 6.7.4 - '@typescript-eslint/type-utils': 6.7.4(eslint@8.51.0)(typescript@5.2.2) - '@typescript-eslint/utils': 6.7.4(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/scope-manager': 6.7.5 + '@typescript-eslint/type-utils': 6.7.5(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/utils': 6.7.5(eslint@8.51.0)(typescript@5.2.2) eslint: 8.51.0 graphemer: 1.4.0 transitivePeerDependencies: @@ -476,16 +480,26 @@ packages: /@types/chai-subset@1.3.3: resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==} dependencies: - '@types/chai': 4.3.6 + '@types/chai': 4.3.7 dev: false - /@types/chai@4.3.6: - resolution: {integrity: sha512-VOVRLM1mBxIRxydiViqPcKn6MIxZytrbMpd6RJLIWKxUNr3zux8no0Oc7kJx0WAPIitgZ0gkrDS+btlqQpubpw==} + /@types/chai@4.3.7: + resolution: {integrity: sha512-/k+vesl92vMvMygmQrFe9Aimxi6oQXFUX9mA5HanTrKUSAMoLauSi6PNFOdRw0oeqilaW600GNx2vSaT2f8aIQ==} dev: false + /@types/eslint@8.44.3: + resolution: {integrity: sha512-iM/WfkwAhwmPff3wZuPLYiHX18HI24jU8k1ZSH7P8FHwxTjZ2P6CoX2wnF43oprR+YXJM6UUxATkNvyv/JHd+g==} + dependencies: + '@types/estree': 1.0.2 + '@types/json-schema': 7.0.13 + dev: true + + /@types/estree@1.0.2: + resolution: {integrity: sha512-VeiPZ9MMwXjO32/Xu7+OwflfmeoRwkE/qzndw42gGtgJwZopBnzy2gD//NN1+go1mADzkDcqf/KnFRSjTJ8xJA==} + dev: true + /@types/json-schema@7.0.13: resolution: {integrity: sha512-RbSSoHliUbnXj3ny0CNFOoxrIDV6SUGyStHsvDqosw6CkdPV8TtWGlfecuK4ToyMEAql6pzNxgCFKanovUzlgQ==} - dev: false /@types/mdast@3.0.13: resolution: {integrity: sha512-HjiGiWedR0DVFkeNljpa6Lv4/IZU1+30VY5d747K7lBudFc3R0Ibr6yJ9lN3BE28VnZyDfLF/VB1Ql1ZIbKrmg==} @@ -493,8 +507,10 @@ packages: '@types/unist': 2.0.8 dev: false - /@types/node@20.8.3: - resolution: {integrity: sha512-jxiZQFpb+NlH5kjW49vXxvxTjeeqlbsnTAdBTKpzEdPs9itay7MscYXz3Fo9VYFEsfQ6LJFitHad3faerLAjCw==} + /@types/node@20.8.4: + resolution: {integrity: sha512-ZVPnqU58giiCjSxjVUESDtdPk4QR5WQhhINbc9UBrKLU68MX5BF6kbQzTrkwbolyr0X8ChBpXfavr5mZFKZQ5A==} + dependencies: + undici-types: 5.25.3 /@types/normalize-package-data@2.4.2: resolution: {integrity: sha512-lqa4UEhhv/2sjjIQgjX8B+RBjj47eo0mzGasklVJ78UKGQY1r0VpB9XHDaZZO9qzEFDdy4MrXLuEaSmPrPSe/A==} @@ -508,8 +524,8 @@ packages: resolution: {integrity: sha512-d0XxK3YTObnWVp6rZuev3c49+j4Lo8g4L1ZRm9z5L0xpoZycUPshHgczK5gsUMaZOstjVYYi09p5gYvUtfChYw==} dev: false - /@typescript-eslint/eslint-plugin@6.7.4(@typescript-eslint/parser@6.7.4)(eslint@8.51.0)(typescript@5.2.2): - resolution: {integrity: sha512-DAbgDXwtX+pDkAHwiGhqP3zWUGpW49B7eqmgpPtg+BKJXwdct79ut9+ifqOFPJGClGKSHXn2PTBatCnldJRUoA==} + /@typescript-eslint/eslint-plugin@6.7.5(@typescript-eslint/parser@6.7.5)(eslint@8.51.0)(typescript@5.2.2): + resolution: {integrity: sha512-JhtAwTRhOUcP96D0Y6KYnwig/MRQbOoLGXTON2+LlyB/N35SP9j1boai2zzwXb7ypKELXMx3DVk9UTaEq1vHEw==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: '@typescript-eslint/parser': ^6.0.0 || ^6.0.0-alpha @@ -520,11 +536,11 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.9.1 - '@typescript-eslint/parser': 6.7.4(eslint@8.51.0)(typescript@5.2.2) - '@typescript-eslint/scope-manager': 6.7.4 - '@typescript-eslint/type-utils': 6.7.4(eslint@8.51.0)(typescript@5.2.2) - '@typescript-eslint/utils': 6.7.4(eslint@8.51.0)(typescript@5.2.2) - '@typescript-eslint/visitor-keys': 6.7.4 + '@typescript-eslint/parser': 6.7.5(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/scope-manager': 6.7.5 + '@typescript-eslint/type-utils': 6.7.5(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/utils': 6.7.5(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/visitor-keys': 6.7.5 debug: 4.3.4 eslint: 8.51.0 graphemer: 1.4.0 @@ -537,8 +553,8 @@ packages: - supports-color dev: false - /@typescript-eslint/parser@6.7.4(eslint@8.51.0)(typescript@5.2.2): - resolution: {integrity: sha512-I5zVZFY+cw4IMZUeNCU7Sh2PO5O57F7Lr0uyhgCJmhN/BuTlnc55KxPonR4+EM3GBdfiCyGZye6DgMjtubQkmA==} + /@typescript-eslint/parser@6.7.5(eslint@8.51.0)(typescript@5.2.2): + resolution: {integrity: sha512-bIZVSGx2UME/lmhLcjdVc7ePBwn7CLqKarUBL4me1C5feOd663liTGjMBGVcGr+BhnSLeP4SgwdvNnnkbIdkCw==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^7.0.0 || ^8.0.0 @@ -547,10 +563,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 6.7.4 - '@typescript-eslint/types': 6.7.4 - '@typescript-eslint/typescript-estree': 6.7.4(typescript@5.2.2) - '@typescript-eslint/visitor-keys': 6.7.4 + '@typescript-eslint/scope-manager': 6.7.5 + '@typescript-eslint/types': 6.7.5 + '@typescript-eslint/typescript-estree': 6.7.5(typescript@5.2.2) + '@typescript-eslint/visitor-keys': 6.7.5 debug: 4.3.4 eslint: 8.51.0 typescript: 5.2.2 @@ -558,16 +574,16 @@ packages: - supports-color dev: false - /@typescript-eslint/scope-manager@6.7.4: - resolution: {integrity: sha512-SdGqSLUPTXAXi7c3Ob7peAGVnmMoGzZ361VswK2Mqf8UOYcODiYvs8rs5ILqEdfvX1lE7wEZbLyELCW+Yrql1A==} + /@typescript-eslint/scope-manager@6.7.5: + resolution: {integrity: sha512-GAlk3eQIwWOJeb9F7MKQ6Jbah/vx1zETSDw8likab/eFcqkjSD7BI75SDAeC5N2L0MmConMoPvTsmkrg71+B1A==} engines: {node: ^16.0.0 || >=18.0.0} dependencies: - '@typescript-eslint/types': 6.7.4 - '@typescript-eslint/visitor-keys': 6.7.4 + '@typescript-eslint/types': 6.7.5 + '@typescript-eslint/visitor-keys': 6.7.5 dev: false - /@typescript-eslint/type-utils@6.7.4(eslint@8.51.0)(typescript@5.2.2): - resolution: {integrity: sha512-n+g3zi1QzpcAdHFP9KQF+rEFxMb2KxtnJGID3teA/nxKHOVi3ylKovaqEzGBbVY2pBttU6z85gp0D00ufLzViQ==} + /@typescript-eslint/type-utils@6.7.5(eslint@8.51.0)(typescript@5.2.2): + resolution: {integrity: sha512-Gs0qos5wqxnQrvpYv+pf3XfcRXW6jiAn9zE/K+DlmYf6FcpxeNYN0AIETaPR7rHO4K2UY+D0CIbDP9Ut0U4m1g==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^7.0.0 || ^8.0.0 @@ -576,8 +592,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 6.7.4(typescript@5.2.2) - '@typescript-eslint/utils': 6.7.4(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/typescript-estree': 6.7.5(typescript@5.2.2) + '@typescript-eslint/utils': 6.7.5(eslint@8.51.0)(typescript@5.2.2) debug: 4.3.4 eslint: 8.51.0 ts-api-utils: 1.0.3(typescript@5.2.2) @@ -586,13 +602,13 @@ packages: - supports-color dev: false - /@typescript-eslint/types@6.7.4: - resolution: {integrity: sha512-o9XWK2FLW6eSS/0r/tgjAGsYasLAnOWg7hvZ/dGYSSNjCh+49k5ocPN8OmG5aZcSJ8pclSOyVKP2x03Sj+RrCA==} + /@typescript-eslint/types@6.7.5: + resolution: {integrity: sha512-WboQBlOXtdj1tDFPyIthpKrUb+kZf2VroLZhxKa/VlwLlLyqv/PwUNgL30BlTVZV1Wu4Asu2mMYPqarSO4L5ZQ==} engines: {node: ^16.0.0 || >=18.0.0} dev: false - /@typescript-eslint/typescript-estree@6.7.4(typescript@5.2.2): - resolution: {integrity: sha512-ty8b5qHKatlNYd9vmpHooQz3Vki3gG+3PchmtsA4TgrZBKWHNjWfkQid7K7xQogBqqc7/BhGazxMD5vr6Ha+iQ==} + /@typescript-eslint/typescript-estree@6.7.5(typescript@5.2.2): + resolution: {integrity: sha512-NhJiJ4KdtwBIxrKl0BqG1Ur+uw7FiOnOThcYx9DpOGJ/Abc9z2xNzLeirCG02Ig3vkvrc2qFLmYSSsaITbKjlg==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: typescript: '*' @@ -600,8 +616,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 6.7.4 - '@typescript-eslint/visitor-keys': 6.7.4 + '@typescript-eslint/types': 6.7.5 + '@typescript-eslint/visitor-keys': 6.7.5 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 @@ -612,8 +628,8 @@ packages: - supports-color dev: false - /@typescript-eslint/utils@6.7.4(eslint@8.51.0)(typescript@5.2.2): - resolution: {integrity: sha512-PRQAs+HUn85Qdk+khAxsVV+oULy3VkbH3hQ8hxLRJXWBEd7iI+GbQxH5SEUSH7kbEoTp6oT1bOwyga24ELALTA==} + /@typescript-eslint/utils@6.7.5(eslint@8.51.0)(typescript@5.2.2): + resolution: {integrity: sha512-pfRRrH20thJbzPPlPc4j0UNGvH1PjPlhlCMq4Yx7EGjV7lvEeGX0U6MJYe8+SyFutWgSHsdbJ3BXzZccYggezA==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^7.0.0 || ^8.0.0 @@ -621,9 +637,9 @@ packages: '@eslint-community/eslint-utils': 4.4.0(eslint@8.51.0) '@types/json-schema': 7.0.13 '@types/semver': 7.5.3 - '@typescript-eslint/scope-manager': 6.7.4 - '@typescript-eslint/types': 6.7.4 - '@typescript-eslint/typescript-estree': 6.7.4(typescript@5.2.2) + '@typescript-eslint/scope-manager': 6.7.5 + '@typescript-eslint/types': 6.7.5 + '@typescript-eslint/typescript-estree': 6.7.5(typescript@5.2.2) eslint: 8.51.0 semver: 7.5.4 transitivePeerDependencies: @@ -631,11 +647,11 @@ packages: - typescript dev: false - /@typescript-eslint/visitor-keys@6.7.4: - resolution: {integrity: sha512-pOW37DUhlTZbvph50x5zZCkFn3xzwkGtNoJHzIM3svpiSkJzwOYr/kVBaXmf+RAQiUDs1AHEZVNPg6UJCJpwRA==} + /@typescript-eslint/visitor-keys@6.7.5: + resolution: {integrity: sha512-3MaWdDZtLlsexZzDSdQWsFQ9l9nL8B80Z4fImSpyllFC/KLqWQRdEcB+gGGO+N3Q2uL40EsG66wZLsohPxNXvg==} engines: {node: ^16.0.0 || >=18.0.0} dependencies: - '@typescript-eslint/types': 6.7.4 + '@typescript-eslint/types': 6.7.5 eslint-visitor-keys: 3.4.3 dev: false @@ -730,6 +746,7 @@ packages: /ansi-styles@3.2.1: resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} engines: {node: '>=4'} + requiresBuild: true dependencies: color-convert: 1.9.3 dev: false @@ -963,6 +980,7 @@ packages: /chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} + requiresBuild: true dependencies: ansi-styles: 3.2.1 escape-string-regexp: 1.0.5 @@ -1048,6 +1066,7 @@ packages: /color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} + requiresBuild: true dependencies: color-name: 1.1.3 dev: false @@ -1060,6 +1079,7 @@ packages: /color-name@1.1.3: resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} + requiresBuild: true dev: false /color-name@1.1.4: @@ -1085,7 +1105,7 @@ packages: dev: false /concat-map@0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} /cross-spawn@7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} @@ -1353,7 +1373,7 @@ packages: - supports-color dev: false - /eslint-module-utils@2.8.0(@typescript-eslint/parser@6.7.4)(eslint-import-resolver-node@0.3.9)(eslint@8.51.0): + /eslint-module-utils@2.8.0(@typescript-eslint/parser@6.7.5)(eslint-import-resolver-node@0.3.9)(eslint@8.51.0): resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==} engines: {node: '>=4'} peerDependencies: @@ -1374,7 +1394,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 6.7.4(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/parser': 6.7.5(eslint@8.51.0)(typescript@5.2.2) debug: 3.2.7 eslint: 8.51.0 eslint-import-resolver-node: 0.3.9 @@ -1387,7 +1407,7 @@ packages: peerDependencies: eslint: '*' dependencies: - '@typescript-eslint/utils': 6.7.4(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/utils': 6.7.5(eslint@8.51.0)(typescript@5.2.2) eslint: 8.51.0 transitivePeerDependencies: - supports-color @@ -1416,7 +1436,7 @@ packages: ignore: 5.2.4 dev: false - /eslint-plugin-i@2.28.1(@typescript-eslint/parser@6.7.4)(eslint@8.51.0): + /eslint-plugin-i@2.28.1(@typescript-eslint/parser@6.7.5)(eslint@8.51.0): resolution: {integrity: sha512-a4oVt0j3ixNhGhvV4XF6NS7OWRFK2rrJ0Q5C4S2dSRb8FxZi31J0uUd5WJLL58wnVJ/OiQ1BxiXnFA4dWQO1Cg==} engines: {node: '>=12'} peerDependencies: @@ -1426,7 +1446,7 @@ packages: doctrine: 2.1.0 eslint: 8.51.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.7.4)(eslint-import-resolver-node@0.3.9)(eslint@8.51.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.7.5)(eslint-import-resolver-node@0.3.9)(eslint@8.51.0) get-tsconfig: 4.7.2 is-glob: 4.0.3 minimatch: 3.1.2 @@ -1565,7 +1585,7 @@ packages: strip-indent: 3.0.0 dev: false - /eslint-plugin-unused-imports@3.0.0(@typescript-eslint/eslint-plugin@6.7.4)(eslint@8.51.0): + /eslint-plugin-unused-imports@3.0.0(@typescript-eslint/eslint-plugin@6.7.5)(eslint@8.51.0): resolution: {integrity: sha512-sduiswLJfZHeeBJ+MQaG+xYzSWdRXoSw61DpU13mzWumCkR0ufD0HmO4kdNokjrkluMHpj/7PJeN35pgbhW3kw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1575,12 +1595,12 @@ packages: '@typescript-eslint/eslint-plugin': optional: true dependencies: - '@typescript-eslint/eslint-plugin': 6.7.4(@typescript-eslint/parser@6.7.4)(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/eslint-plugin': 6.7.5(@typescript-eslint/parser@6.7.5)(eslint@8.51.0)(typescript@5.2.2) eslint: 8.51.0 eslint-rule-composer: 0.3.0 dev: false - /eslint-plugin-vitest@0.3.2(@typescript-eslint/eslint-plugin@6.7.4)(eslint@8.51.0)(typescript@5.2.2)(vitest@0.34.6): + /eslint-plugin-vitest@0.3.2(@typescript-eslint/eslint-plugin@6.7.5)(eslint@8.51.0)(typescript@5.2.2)(vitest@0.34.6): resolution: {integrity: sha512-A1P0qJVkqHyfDolwm09h8/gu7SbGFOKbacJSeyZ9IRb8uyddgqLcqv4VrqgQfLA7QmGI9lwj1iV90NyZ1cHp8Q==} engines: {node: 14.x || >= 16} peerDependencies: @@ -1591,8 +1611,8 @@ packages: '@typescript-eslint/eslint-plugin': optional: true dependencies: - '@typescript-eslint/eslint-plugin': 6.7.4(@typescript-eslint/parser@6.7.4)(eslint@8.51.0)(typescript@5.2.2) - '@typescript-eslint/utils': 6.7.4(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/eslint-plugin': 6.7.5(@typescript-eslint/parser@6.7.5)(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/utils': 6.7.5(eslint@8.51.0)(typescript@5.2.2) eslint: 8.51.0 vitest: 0.34.6 transitivePeerDependencies: @@ -1985,6 +2005,7 @@ packages: /has-flag@3.0.0: resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} engines: {node: '>=4'} + requiresBuild: true dev: false /has-flag@4.0.0: @@ -2312,6 +2333,7 @@ packages: /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + requiresBuild: true dev: false /js-yaml@4.1.0: @@ -3355,6 +3377,7 @@ packages: /supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} engines: {node: '>=4'} + requiresBuild: true dependencies: has-flag: 3.0.0 dev: false @@ -3562,6 +3585,9 @@ packages: which-boxed-primitive: 1.0.2 dev: false + /undici-types@5.25.3: + resolution: {integrity: sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==} + /unist-util-stringify-position@2.0.3: resolution: {integrity: sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==} dependencies: @@ -3584,7 +3610,7 @@ packages: spdx-expression-parse: 3.0.1 dev: false - /vite-node@0.34.6(@types/node@20.8.3): + /vite-node@0.34.6(@types/node@20.8.4): resolution: {integrity: sha512-nlBMJ9x6n7/Amaz6F3zJ97EBwR2FkzhBRxF5e+jE6LA3yi6Wtc2lyTij1OnDMIr34v5g/tVQtsVAzhT0jc5ygA==} engines: {node: '>=v14.18.0'} hasBin: true @@ -3594,7 +3620,7 @@ packages: mlly: 1.4.2 pathe: 1.1.1 picocolors: 1.0.0 - vite: 4.4.11(@types/node@20.8.3) + vite: 4.4.11(@types/node@20.8.4) transitivePeerDependencies: - '@types/node' - less @@ -3606,7 +3632,7 @@ packages: - terser dev: false - /vite@4.4.11(@types/node@20.8.3): + /vite@4.4.11(@types/node@20.8.4): resolution: {integrity: sha512-ksNZJlkcU9b0lBwAGZGGaZHCMqHsc8OpgtoYhsQ4/I2v5cnpmmmqe5pM4nv/4Hn6G/2GhTdj0DhZh2e+Er1q5A==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -3634,7 +3660,7 @@ packages: terser: optional: true dependencies: - '@types/node': 20.8.3 + '@types/node': 20.8.4 esbuild: 0.18.20 postcss: 8.4.31 rollup: 3.29.4 @@ -3673,9 +3699,9 @@ packages: webdriverio: optional: true dependencies: - '@types/chai': 4.3.6 + '@types/chai': 4.3.7 '@types/chai-subset': 1.3.3 - '@types/node': 20.8.3 + '@types/node': 20.8.4 '@vitest/expect': 0.34.6 '@vitest/runner': 0.34.6 '@vitest/snapshot': 0.34.6 @@ -3694,8 +3720,8 @@ packages: strip-literal: 1.3.0 tinybench: 2.5.1 tinypool: 0.7.0 - vite: 4.4.11(@types/node@20.8.3) - vite-node: 0.34.6(@types/node@20.8.3) + vite: 4.4.11(@types/node@20.8.4) + vite-node: 0.34.6(@types/node@20.8.4) why-is-node-running: 2.2.2 transitivePeerDependencies: - less diff --git a/src/configs/all.ts b/src/configs/all.ts new file mode 100644 index 0000000..001019e --- /dev/null +++ b/src/configs/all.ts @@ -0,0 +1,47 @@ +import type { ConfigItem } from '@antfu/eslint-config' + +export const all: ConfigItem[] = [ + { + name: 'dxhuii:all', + rules: { + 'antfu/no-cjs-exports': 'off', // 允许使用 commonjs 的 exports + 'antfu/consistent-list-newline': 'off', // 允许在数组元素之间换行 + 'arrow-parens': ['error', 'as-needed'], // 箭头函数参数只有一个时不需要括号 + + 'import/prefer-default-export': 'off', // 允许使用 export + 'import/extensions': 'off', // 允许不写文件后缀 + + 'no-multi-str': 'off', // 允许多行字符串 + 'no-restricted-globals': 'off', // 允许使用全局变量 + 'no-console': 'off', // 允许使用 console + + 'node/prefer-global/process': 'off', // 允许使用 process + + // 删除未尾逗号 + 'jsonc/comma-dangle': ['error', 'never'], + 'style/comma-dangle': ['error', 'never'], + 'style/jsx-quotes': ['error', 'prefer-single'], // jsx 使用单引号 + 'style/jsx-closing-bracket-location': ['error', 'after-props'], + 'style/jsx-wrap-multilines': ['error', { + declaration: 'parens-new-line', + assignment: 'parens-new-line', + return: 'parens-new-line', + arrow: 'parens-new-line', + condition: 'parens-new-line', + logical: 'parens-new-line', + prop: 'parens-new-line' + }], + // 删除未使用的依赖 + 'unused-imports/no-unused-imports': 'error', + 'unused-imports/no-unused-vars': [ + 'warn', + { + vars: 'all', + varsIgnorePattern: '^_', + args: 'after-used', + argsIgnorePattern: '^_' + } + ] + } + } +] diff --git a/src/configs/index.ts b/src/configs/index.ts index 9fe5b93..0cb1049 100644 --- a/src/configs/index.ts +++ b/src/configs/index.ts @@ -1 +1,3 @@ export * from './react' +export * from './vue' +export * from './all' diff --git a/src/configs/react.ts b/src/configs/react.ts index b73432b..5264943 100644 --- a/src/configs/react.ts +++ b/src/configs/react.ts @@ -15,6 +15,7 @@ export const react: ConfigItem[] = [ } } }, + name: 'dxhuii:react', plugins: { 'react': pluginReact, 'react-hooks': pluginReactHooks diff --git a/src/configs/vue.ts b/src/configs/vue.ts new file mode 100644 index 0000000..c3665d2 --- /dev/null +++ b/src/configs/vue.ts @@ -0,0 +1,20 @@ +import type { ConfigItem } from '@antfu/eslint-config' +import { GLOB_VUE } from '../globs' + +export const vue: ConfigItem[] = [ + { + files: [GLOB_VUE], + name: 'dxhuii:vue', + rules: { + 'vue/v-on-event-hyphenation': ['error', 'never'], // 事件名不允许使用连字符 + 'vue/valid-attribute-name': 'off', // 属性名不允许使用连字符 + // 关闭组件命名规则 + 'vue/multi-word-component-names': 'off', // 组件名不允许使用连字符 + 'vue/custom-event-name-casing': ['error', 'camelCase', { // 事件名不允许使用连字符 + ignores: [ + '/^(click):[a-z]+[a-zA-Z]+$/' + ] + }] + } + } +] diff --git a/src/factory.ts b/src/factory.ts index 90da5f5..2a61be4 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -1,79 +1,27 @@ import type { ConfigItem, OptionsConfig } from '@antfu/eslint-config' -import { react } from './configs' +import { all, react, vue } from './configs' import { combine } from './utils' +interface CustomConfig { react?: boolean; all?: boolean } + /** - * Construct an array of ESLint flat config items. + * 构建一个 ESLint 平面配置项数组。 */ -export function dxhuii(options: OptionsConfig & { react?: boolean } & ConfigItem = {}, ...userConfigs: (ConfigItem | ConfigItem[])[]) { +export function dxhuii(options: OptionsConfig & CustomConfig & ConfigItem = {}, ...userConfigs: (ConfigItem | ConfigItem[])[]) { const configs: ConfigItem[][] = [] if (options.react ?? true) configs.push(react) - const merged = combine( - ...configs, - ...userConfigs, - { - // Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files - files: ['**/*.vue'], - rules: { - 'vue/v-on-event-hyphenation': ['error', 'never'], // 事件名不允许使用连字符 - 'vue/valid-attribute-name': 'off', // 属性名不允许使用连字符 - // 关闭组件命名规则 - 'vue/multi-word-component-names': 'off', // 组件名不允许使用连字符 - 'vue/custom-event-name-casing': ['error', 'camelCase', { // 事件名不允许使用连字符 - ignores: [ - '/^(click):[a-z]+[a-zA-Z]+$/' - ] - }] - } - }, - { - // 所有文件 - rules: { - 'no-multi-str': 'off', // 允许多行字符串 - 'no-restricted-globals': 'off', // 允许使用全局变量 - 'antfu/no-cjs-exports': 'off', // 允许使用 commonjs 的 exports - 'node/prefer-global/process': 'off', // 允许使用 process - - 'antfu/consistent-list-newline': 'off', // 允许在数组元素之间换行 - - 'arrow-parens': ['error', 'as-needed'], // 箭头函数参数只有一个时不需要括号 + if (options.vue ?? true) + configs.push(vue) - 'import/prefer-default-export': 'off', // 允许使用 export - 'import/extensions': 'off', // 允许不写文件后缀 + if (options.all ?? true) + configs.push(all) - 'no-console': 'off', // 允许使用 console - - // 删除未尾逗号 - 'style/comma-dangle': ['error', 'never'], - 'jsonc/comma-dangle': ['error', 'never'], - - 'style/jsx-quotes': ['error', 'prefer-single'], // jsx 使用单引号 - 'style/jsx-closing-bracket-location': ['error', 'after-props'], - 'style/jsx-wrap-multilines': ['error', { - declaration: 'parens-new-line', - assignment: 'parens-new-line', - return: 'parens-new-line', - arrow: 'parens-new-line', - condition: 'parens-new-line', - logical: 'parens-new-line', - prop: 'parens-new-line' - }], - // 删除未使用的依赖 - 'unused-imports/no-unused-imports': 'error', - 'unused-imports/no-unused-vars': [ - 'warn', - { - vars: 'all', - varsIgnorePattern: '^_', - args: 'after-used', - argsIgnorePattern: '^_' - } - ] - } as any - } + const merged = combine( + ...configs, + ...userConfigs ) return merged diff --git a/src/globs.ts b/src/globs.ts index c968679..26d0e9f 100644 --- a/src/globs.ts +++ b/src/globs.ts @@ -1,2 +1,4 @@ export const GLOB_JSX = '**/*.?([cm])jsx' export const GLOB_TSX = '**/*.?([cm])tsx' + +export const GLOB_VUE = '**/*.vue' diff --git a/src/utils.ts b/src/utils.ts index 7112c08..ac0e90d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,7 +1,7 @@ import type { ConfigItem } from '@antfu/eslint-config' /** - * Combine array and non-array configs into a single array. + * 将阵列和非阵列配置合并为一个阵列。 */ export function combine(...configs: (ConfigItem | ConfigItem[])[]): ConfigItem[] { return configs.flatMap(config => Array.isArray(config) ? config : [config])