From 6c675ed5b38a2e9244d785064d087ab3b1c90d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=80=81=E4=BD=A0=E5=8D=81=E4=B8=83=E6=9D=9F=E8=8A=B1?= <108746194+030liuxinghao@users.noreply.github.com> Date: Sun, 8 Oct 2023 14:18:56 +0800 Subject: [PATCH] :bug: Fixed invalidation issues with eslint --- .eslintrc.json | 2 +- README.md | 6 +- auto-imports.d.ts | 6 -- index.html | 8 +++ package.json | 17 +++--- pnpm-lock.yaml | 143 +++++++++++++++++++++++++++++++++++++++++++- src/pages/index.vue | 6 +- typed-router.d.ts | 143 -------------------------------------------- 8 files changed, 165 insertions(+), 166 deletions(-) delete mode 100644 typed-router.d.ts diff --git a/.eslintrc.json b/.eslintrc.json index abfb881..58529e3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,4 +6,4 @@ "plugins": [ "@unocss" ] -} +} diff --git a/README.md b/README.md index 2b467a4..287662e 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ 克隆项目到本地: ``` bash -git clone https://github.com/ileostar/vue3-star.git +npx degit ileostar/vue-star 你的项目名称 ``` 进入项目目录: ``` bash -cd vue3-vite-ts-alova +cd 你的项目名称 ``` 安装依赖: @@ -63,7 +63,7 @@ pnpm install ``` bash -pnpm run dev +pnpm dev ``` 打开浏览器,访问 http://localhost:5173 即可查看项目运行效果。 diff --git a/auto-imports.d.ts b/auto-imports.d.ts index cc8dc23..0a07468 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -7,7 +7,6 @@ export {} declare global { const EffectScope: typeof import('vue')['EffectScope'] const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate'] - const alova: typeof import('useFetcher')['alova'] const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] const computed: typeof import('vue')['computed'] @@ -32,8 +31,6 @@ declare global { const debouncedWatch: typeof import('@vueuse/core')['debouncedWatch'] const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] const defineComponent: typeof import('vue')['defineComponent'] - const defineLoader: typeof import('vue-router/auto')['defineLoader'] - const definePage: typeof import('unplugin-vue-router/runtime')['_definePage'] const defineStore: typeof import('pinia')['defineStore'] const eagerComputed: typeof import('@vueuse/core')['eagerComputed'] const effectScope: typeof import('vue')['effectScope'] @@ -100,7 +97,6 @@ declare global { const shallowReactive: typeof import('vue')['shallowReactive'] const shallowReadonly: typeof import('vue')['shallowReadonly'] const shallowRef: typeof import('vue')['shallowRef'] - const shimsD: typeof import('./shims.d')['default'] const storeToRefs: typeof import('pinia')['storeToRefs'] const syncRef: typeof import('@vueuse/core')['syncRef'] const syncRefs: typeof import('@vueuse/core')['syncRefs'] @@ -119,7 +115,6 @@ declare global { const tryOnMounted: typeof import('@vueuse/core')['tryOnMounted'] const tryOnScopeDispose: typeof import('@vueuse/core')['tryOnScopeDispose'] const tryOnUnmounted: typeof import('@vueuse/core')['tryOnUnmounted'] - const unoConfig: typeof import('./uno.config')['default'] const unref: typeof import('vue')['unref'] const unrefElement: typeof import('@vueuse/core')['unrefElement'] const until: typeof import('@vueuse/core')['until'] @@ -287,7 +282,6 @@ declare global { const useWindowFocus: typeof import('@vueuse/core')['useWindowFocus'] const useWindowScroll: typeof import('@vueuse/core')['useWindowScroll'] const useWindowSize: typeof import('@vueuse/core')['useWindowSize'] - const viteConfig: typeof import('./vite.config')['default'] const watch: typeof import('vue')['watch'] const watchArray: typeof import('@vueuse/core')['watchArray'] const watchAtMost: typeof import('@vueuse/core')['watchAtMost'] diff --git a/index.html b/index.html index 3508514..257a75d 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,14 @@
+ diff --git a/package.json b/package.json index 1e942b4..38db0b6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vue3-vite-alova-ts-vitest", "type": "module", - "version": "0.0.1", + "private": true, "packageManager": "pnpm@8.7.6", "scripts": { "dev": "vite --mode dev", @@ -24,6 +24,12 @@ "path": "./node_modules/cz-emoji" } }, + "lint-staged": { + "src/**/*.{js,vue,ts}": [ + "eslint --fix", + "git add ." + ] + }, "dependencies": { "@vueuse/core": "^10.4.1", "alova": "^2.13.1", @@ -32,6 +38,7 @@ }, "devDependencies": { "@alova/adapter-axios": "^1.1.1", + "@antfu/eslint-config": "1.0.0-beta.21", "@iconify-json/carbon": "^1.1.21", "@iconify-json/mdi": "^1.1.54", "@ileostar/eslint-config": "^0.3.0", @@ -47,7 +54,7 @@ "commitizen": "^4.3.0", "cz-emoji": "1.3.2-canary.2", "eslint": "^8.50.0", - "eslint-plugin-vue": "^9.17.0", + "eslint-define-config": "^1.23.0", "husky": "^8.0.3", "jsdom": "^22.1.0", "lint": "^0.8.19", @@ -68,11 +75,5 @@ "vite-plugin-pages": "^0.31.0", "vitest": "^0.34.6", "vue-tsc": "^1.8.15" - }, - "lint-staged": { - "src/**/*.{js,vue,ts}": [ - "eslint --fix", - "git add ." - ] } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e160096..03fbd95 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,6 +22,9 @@ devDependencies: '@alova/adapter-axios': specifier: ^1.1.1 version: 1.1.1 + '@antfu/eslint-config': + specifier: 1.0.0-beta.21 + version: 1.0.0-beta.21(eslint@8.50.0)(typescript@5.2.2)(vitest@0.34.6) '@iconify-json/carbon': specifier: ^1.1.21 version: 1.1.21 @@ -67,9 +70,9 @@ devDependencies: eslint: specifier: ^8.50.0 version: 8.50.0 - eslint-plugin-vue: - specifier: ^9.17.0 - version: 9.17.0(eslint@8.50.0) + eslint-define-config: + specifier: ^1.23.0 + version: 1.23.0 husky: specifier: ^8.0.3 version: 8.0.3 @@ -150,6 +153,43 @@ packages: '@jridgewell/trace-mapping': 0.3.19 dev: true + /@antfu/eslint-config@1.0.0-beta.21(eslint@8.50.0)(typescript@5.2.2)(vitest@0.34.6): + resolution: {integrity: sha512-bMTD0IZ6pPxLEANuxbBAQV8cQRCGcGKrsVjghcojtzhEqJjt6iirPrptKk+j/HKOqMDXH2ZaXuqSJfXrY4U+Ng==} + peerDependencies: + eslint: '>=8.0.0' + dependencies: + '@stylistic/eslint-plugin': 0.0.6(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/eslint-plugin': 6.7.4(@typescript-eslint/parser@6.7.4)(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/parser': 6.7.4(eslint@8.50.0)(typescript@5.2.2) + eslint: 8.50.0 + eslint-config-flat-gitignore: 0.1.0 + eslint-define-config: 1.23.0 + eslint-plugin-antfu: 1.0.0-beta.10(eslint@8.50.0)(typescript@5.2.2) + eslint-plugin-eslint-comments: 3.2.0(eslint@8.50.0) + eslint-plugin-i: 2.28.1(@typescript-eslint/parser@6.7.4)(eslint@8.50.0) + eslint-plugin-jsdoc: 46.8.2(eslint@8.50.0) + eslint-plugin-jsonc: 2.9.0(eslint@8.50.0) + eslint-plugin-markdown: 3.0.1(eslint@8.50.0) + eslint-plugin-n: 16.1.0(eslint@8.50.0) + eslint-plugin-no-only-tests: 3.1.0 + eslint-plugin-unicorn: 48.0.1(eslint@8.50.0) + eslint-plugin-unused-imports: 3.0.0(@typescript-eslint/eslint-plugin@6.7.4)(eslint@8.50.0) + eslint-plugin-vitest: 0.3.2(@typescript-eslint/eslint-plugin@6.7.4)(eslint@8.50.0)(typescript@5.2.2)(vitest@0.34.6) + eslint-plugin-vue: 9.17.0(eslint@8.50.0) + eslint-plugin-yml: 1.9.0(eslint@8.50.0) + globals: 13.22.0 + jsonc-eslint-parser: 2.3.0 + local-pkg: 0.5.0 + vue-eslint-parser: 9.3.1(eslint@8.50.0) + yaml-eslint-parser: 1.2.2 + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color + - typescript + - vitest + dev: true + /@antfu/install-pkg@0.1.1: resolution: {integrity: sha512-LyB/8+bSfa0DFGC06zpCEfs89/XoWZwws5ygEa5D+Xsm3OfI+aXQ86VgVG7Acyef+rSZ5HE7J8rrxzrQeM3PjQ==} dependencies: @@ -986,6 +1026,20 @@ packages: graphemer: 1.4.0 dev: true + /@stylistic/eslint-plugin-js@0.0.6(eslint@8.50.0): + resolution: {integrity: sha512-TAwD0mCMtXRUErqHrxsGKE/m5UtQWUZOg+HuNNeZXtHoGsp/A3KNfCJkhf5yRiPxwjOUuxQH1f4ANQqKd6rzmQ==} + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.50.0) + acorn: 8.10.0 + escape-string-regexp: 4.0.0 + eslint-visitor-keys: 3.4.3 + espree: 9.6.1 + esutils: 2.0.3 + graphemer: 1.4.0 + transitivePeerDependencies: + - eslint + dev: true + /@stylistic/eslint-plugin-ts@0.0.3(eslint@8.50.0)(typescript@5.2.2): resolution: {integrity: sha512-G/jZ+XHlZtkxABOXswJNTmN4h8qNmECTjPLkWPMykPlfQeD1RSpBMEQHiJHZ3GAxnEcqAgi7CNA1FTvGWz6qwQ==} peerDependencies: @@ -1004,6 +1058,35 @@ packages: - supports-color dev: true + /@stylistic/eslint-plugin-ts@0.0.6(eslint@8.50.0)(typescript@5.2.2): + resolution: {integrity: sha512-eI8K4I9G1AwzsEAykNFv85KHpuHEB0pB4dmbt3lHHfPAVHxvKn+vvRQSNW/wB7giGrzn5uCVBNA7DON6mWhqqg==} + peerDependencies: + eslint: '*' + dependencies: + '@stylistic/eslint-plugin-js': 0.0.6(eslint@8.50.0) + '@typescript-eslint/scope-manager': 6.7.4 + '@typescript-eslint/type-utils': 6.7.4(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/utils': 6.7.4(eslint@8.50.0)(typescript@5.2.2) + eslint: 8.50.0 + graphemer: 1.4.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + + /@stylistic/eslint-plugin@0.0.6(eslint@8.50.0)(typescript@5.2.2): + resolution: {integrity: sha512-biU1+SgcnebsnVAXju0+szDW24Aaom0KesyUlOiqS2tuja7kzDxrgz2CJ6pTdj1fsF7Fu+pn0hgSMOnNf46qyw==} + peerDependencies: + eslint: '*' + dependencies: + '@stylistic/eslint-plugin-js': 0.0.6(eslint@8.50.0) + '@stylistic/eslint-plugin-ts': 0.0.6(eslint@8.50.0)(typescript@5.2.2) + eslint: 8.50.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /@tootallnate/once@2.0.0: resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==} engines: {node: '>= 10'} @@ -3386,6 +3469,17 @@ packages: engines: {node: '>=12'} dev: true + /eslint-config-flat-gitignore@0.1.0: + resolution: {integrity: sha512-5nQMQFRkkhCb+ejFhKSATn/41I7ot9oRcnEDzfqwMlBE9036qM9ioYBDtKLpwmlICXr/J7naMFfb39pa4v4sGA==} + dependencies: + parse-gitignore: 2.0.0 + dev: true + + /eslint-define-config@1.23.0: + resolution: {integrity: sha512-4mMyu0JuBkQHsCtR+42irIQdFLmLIW+pMAVcyOV/gZRL4O1R8iuH0eMG3oL3Cbi1eo9fDAfT5CIHVHgdyxcf6w==} + engines: {node: ^16.13.0 || >=18.0.0, npm: '>=7.0.0', pnpm: '>= 8.6.0'} + dev: true + /eslint-import-resolver-node@0.3.9: resolution: {integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==} dependencies: @@ -3425,6 +3519,16 @@ packages: - supports-color dev: true + /eslint-plugin-antfu@1.0.0-beta.10(eslint@8.50.0)(typescript@5.2.2): + resolution: {integrity: sha512-7hgLK1wuHDKl3vHtlKPmcE9jZir1l7QN1RiQnsd2rKwRz5kx3BV4G/Lnn5YBFobJOmGjrSNM0DNY3/IBMJrQEQ==} + dependencies: + '@typescript-eslint/utils': 6.7.4(eslint@8.50.0)(typescript@5.2.2) + transitivePeerDependencies: + - eslint + - supports-color + - typescript + dev: true + /eslint-plugin-es-x@7.2.0(eslint@8.50.0): resolution: {integrity: sha512-9dvv5CcvNjSJPqnS5uZkqb3xmbeqRLnvXKK7iI5+oK/yTusyc46zbBZKENGsOfojm/mKfszyZb+wNqNPAPeGXA==} engines: {node: ^14.18.0 || >=16.0.0} @@ -3622,6 +3726,26 @@ packages: eslint-rule-composer: 0.3.0 dev: true + /eslint-plugin-vitest@0.3.2(@typescript-eslint/eslint-plugin@6.7.4)(eslint@8.50.0)(typescript@5.2.2)(vitest@0.34.6): + resolution: {integrity: sha512-A1P0qJVkqHyfDolwm09h8/gu7SbGFOKbacJSeyZ9IRb8uyddgqLcqv4VrqgQfLA7QmGI9lwj1iV90NyZ1cHp8Q==} + engines: {node: 14.x || >= 16} + peerDependencies: + '@typescript-eslint/eslint-plugin': '*' + eslint: '>=8.0.0' + vitest: '*' + peerDependenciesMeta: + '@typescript-eslint/eslint-plugin': + optional: true + dependencies: + '@typescript-eslint/eslint-plugin': 6.7.4(@typescript-eslint/parser@6.7.4)(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/utils': 6.7.4(eslint@8.50.0)(typescript@5.2.2) + eslint: 8.50.0 + vitest: 0.34.6(jsdom@22.1.0) + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /eslint-plugin-vue@9.17.0(eslint@8.50.0): resolution: {integrity: sha512-r7Bp79pxQk9I5XDP0k2dpUC7Ots3OSWgvGZNu3BxmKK6Zg7NgVtcOB6OCna5Kb9oQwJPl5hq183WD0SY5tZtIQ==} engines: {node: ^14.17.0 || >=16.0.0} @@ -5249,6 +5373,14 @@ packages: engines: {node: '>=14'} dev: true + /local-pkg@0.5.0: + resolution: {integrity: sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==} + engines: {node: '>=14'} + dependencies: + mlly: 1.4.2 + pkg-types: 1.0.3 + dev: true + /locate-path@3.0.0: resolution: {integrity: sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==} engines: {node: '>=6'} @@ -6129,6 +6261,11 @@ packages: is-hexadecimal: 1.0.4 dev: true + /parse-gitignore@2.0.0: + resolution: {integrity: sha512-RmVuCHWsfu0QPNW+mraxh/xjQVw/lhUCUru8Zni3Ctq3AoMhpDTq0OVdKS6iesd6Kqb7viCV3isAL43dciOSog==} + engines: {node: '>=14'} + dev: true + /parse-json@5.2.0: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} diff --git a/src/pages/index.vue b/src/pages/index.vue index 12c6be3..8a02b3f 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -24,9 +24,11 @@ const { count, msg } = storeToRefs(indexStore) -

{{ msg }}

+

+ {{ msg }} +

-

diff --git a/typed-router.d.ts b/typed-router.d.ts deleted file mode 100644 index 7152731..0000000 --- a/typed-router.d.ts +++ /dev/null @@ -1,143 +0,0 @@ -/* eslint-disable */ -/* prettier-ignore */ -// @ts-nocheck -// Generated by unplugin-vue-router. ‼️ DO NOT MODIFY THIS FILE ‼️ -// It's recommended to commit this file. -// Make sure to add this file to your tsconfig.json file as an "includes" or "files" entry. - -/// - -import type { - // type safe route locations - RouteLocationTypedList, - RouteLocationResolvedTypedList, - RouteLocationNormalizedTypedList, - RouteLocationNormalizedLoadedTypedList, - RouteLocationAsString, - RouteLocationAsRelativeTypedList, - RouteLocationAsPathTypedList, - - // helper types - // route definitions - RouteRecordInfo, - ParamValue, - ParamValueOneOrMore, - ParamValueZeroOrMore, - ParamValueZeroOrOne, - - // vue-router extensions - _RouterTyped, - RouterLinkTyped, - RouterLinkPropsTyped, - NavigationGuard, - UseLinkFnTyped, - - // data fetching - _DataLoader, - _DefineLoaderOptions, -} from 'unplugin-vue-router/types' - -declare module 'vue-router/auto/routes' { - export interface RouteNamedMap { - '/': RouteRecordInfo<'/', '/', Record, Record>, - '/[...all]': RouteRecordInfo<'/[...all]', '/:all(.*)', { all: ParamValue }, { all: ParamValue }>, - '/hi/[name]': RouteRecordInfo<'/hi/[name]', '/hi/:name', { name: ParamValue }, { name: ParamValue }>, - } -} - -declare module 'vue-router/auto' { - import type { RouteNamedMap } from 'vue-router/auto/routes' - - export type RouterTyped = _RouterTyped - - /** - * Type safe version of `RouteLocationNormalized` (the type of `to` and `from` in navigation guards). - * Allows passing the name of the route to be passed as a generic. - */ - export type RouteLocationNormalized = RouteLocationNormalizedTypedList[Name] - - /** - * Type safe version of `RouteLocationNormalizedLoaded` (the return type of `useRoute()`). - * Allows passing the name of the route to be passed as a generic. - */ - export type RouteLocationNormalizedLoaded = RouteLocationNormalizedLoadedTypedList[Name] - - /** - * Type safe version of `RouteLocationResolved` (the returned route of `router.resolve()`). - * Allows passing the name of the route to be passed as a generic. - */ - export type RouteLocationResolved = RouteLocationResolvedTypedList[Name] - - /** - * Type safe version of `RouteLocation` . Allows passing the name of the route to be passed as a generic. - */ - export type RouteLocation = RouteLocationTypedList[Name] - - /** - * Type safe version of `RouteLocationRaw` . Allows passing the name of the route to be passed as a generic. - */ - export type RouteLocationRaw = - | RouteLocationAsString - | RouteLocationAsRelativeTypedList[Name] - | RouteLocationAsPathTypedList[Name] - - /** - * Generate a type safe params for a route location. Requires the name of the route to be passed as a generic. - */ - export type RouteParams = RouteNamedMap[Name]['params'] - /** - * Generate a type safe raw params for a route location. Requires the name of the route to be passed as a generic. - */ - export type RouteParamsRaw = RouteNamedMap[Name]['paramsRaw'] - - export function useRouter(): RouterTyped - export function useRoute(name?: Name): RouteLocationNormalizedLoadedTypedList[Name] - - export const useLink: UseLinkFnTyped - - export function onBeforeRouteLeave(guard: NavigationGuard): void - export function onBeforeRouteUpdate(guard: NavigationGuard): void - - export const RouterLink: RouterLinkTyped - export const RouterLinkProps: RouterLinkPropsTyped - - // Experimental Data Fetching - - export function defineLoader< - P extends Promise, - Name extends keyof RouteNamedMap = keyof RouteNamedMap, - isLazy extends boolean = false, - >( - name: Name, - loader: (route: RouteLocationNormalizedLoaded) => P, - options?: _DefineLoaderOptions, - ): _DataLoader, isLazy> - export function defineLoader< - P extends Promise, - isLazy extends boolean = false, - >( - loader: (route: RouteLocationNormalizedLoaded) => P, - options?: _DefineLoaderOptions, - ): _DataLoader, isLazy> - - export { - _definePage as definePage, - _HasDataLoaderMeta as HasDataLoaderMeta, - _setupDataFetchingGuard as setupDataFetchingGuard, - _stopDataFetchingScope as stopDataFetchingScope, - } from 'unplugin-vue-router/runtime' -} - -declare module 'vue-router' { - import type { RouteNamedMap } from 'vue-router/auto/routes' - - export interface TypesConfig { - beforeRouteUpdate: NavigationGuard - beforeRouteLeave: NavigationGuard - - $route: RouteLocationNormalizedLoadedTypedList[keyof RouteNamedMap] - $router: _RouterTyped - - RouterLink: RouterLinkTyped - } -}