From 6001b7dd29d17ffc2513b00e5d400c0a2ba77314 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Fri, 27 Dec 2024 01:36:55 +0800 Subject: [PATCH] fix: fix remaining bugs & update examples --- README.md | 72 +++++++------- examples/allow-js/eslint.config.js | 28 +++--- examples/minimal/eslint.config.js | 8 +- examples/type-checked/eslint.config.js | 12 +-- examples/usage-before-14.3/.editorconfig | 6 ++ examples/usage-before-14.3/.gitignore | 30 ++++++ examples/usage-before-14.3/.prettierrc.json | 7 ++ .../usage-before-14.3/.vscode/extensions.json | 8 ++ examples/usage-before-14.3/README.md | 61 ++++++++++++ examples/usage-before-14.3/cypress.config.ts | 8 ++ .../cypress/e2e/example.cy.ts | 8 ++ .../cypress/fixtures/example.json | 5 + .../cypress/support/commands.ts | 39 ++++++++ .../usage-before-14.3/cypress/support/e2e.ts | 20 ++++ .../usage-before-14.3/cypress/tsconfig.json | 8 ++ examples/usage-before-14.3/env.d.ts | 1 + examples/usage-before-14.3/eslint.config.js | 34 +++++++ examples/usage-before-14.3/index.html | 13 +++ examples/usage-before-14.3/package.json | 48 ++++++++++ examples/usage-before-14.3/public/favicon.ico | Bin 0 -> 4286 bytes examples/usage-before-14.3/src/App.vue | 85 +++++++++++++++++ .../usage-before-14.3/src/assets/base.css | 86 +++++++++++++++++ .../usage-before-14.3/src/assets/logo.svg | 1 + .../usage-before-14.3/src/assets/main.css | 35 +++++++ .../src/components/HelloWorld.vue | 41 ++++++++ .../src/components/TheWelcome.vue | 88 ++++++++++++++++++ .../src/components/WelcomeItem.vue | 87 +++++++++++++++++ .../components/__tests__/HelloWorld.spec.ts | 11 +++ .../src/components/icons/IconCommunity.vue | 7 ++ .../components/icons/IconDocumentation.vue | 7 ++ .../src/components/icons/IconEcosystem.vue | 7 ++ .../src/components/icons/IconSupport.vue | 7 ++ .../src/components/icons/IconTooling.vue | 19 ++++ examples/usage-before-14.3/src/main.ts | 14 +++ .../usage-before-14.3/src/router/index.ts | 24 +++++ .../usage-before-14.3/src/stores/counter.ts | 12 +++ .../usage-before-14.3/src/views/AboutView.vue | 15 +++ .../usage-before-14.3/src/views/HomeView.vue | 9 ++ examples/usage-before-14.3/tsconfig.app.json | 14 +++ examples/usage-before-14.3/tsconfig.json | 17 ++++ examples/usage-before-14.3/tsconfig.node.json | 19 ++++ .../usage-before-14.3/tsconfig.vitest.json | 11 +++ examples/usage-before-14.3/vite.config.ts | 20 ++++ examples/usage-before-14.3/vitest.config.ts | 14 +++ examples/with-cypress/eslint.config.js | 14 +-- examples/with-jsx-in-vue/eslint.config.js | 38 +++++--- examples/with-jsx/eslint.config.js | 10 +- examples/with-nightwatch/eslint.config.js | 10 +- examples/with-playwright/eslint.config.js | 10 +- examples/with-prettier/eslint.config.js | 10 +- examples/with-tsx-in-vue/eslint.config.js | 24 +++-- examples/with-tsx/eslint.config.js | 10 +- examples/with-tsx/src/App.vue | 1 + examples/with-vitest/eslint.config.js | 10 +- src/configs.ts | 45 +++++---- src/utilities.ts | 14 +-- test/index.spec.ts | 3 + 57 files changed, 1128 insertions(+), 137 deletions(-) create mode 100644 examples/usage-before-14.3/.editorconfig create mode 100644 examples/usage-before-14.3/.gitignore create mode 100644 examples/usage-before-14.3/.prettierrc.json create mode 100644 examples/usage-before-14.3/.vscode/extensions.json create mode 100644 examples/usage-before-14.3/README.md create mode 100644 examples/usage-before-14.3/cypress.config.ts create mode 100644 examples/usage-before-14.3/cypress/e2e/example.cy.ts create mode 100644 examples/usage-before-14.3/cypress/fixtures/example.json create mode 100644 examples/usage-before-14.3/cypress/support/commands.ts create mode 100644 examples/usage-before-14.3/cypress/support/e2e.ts create mode 100644 examples/usage-before-14.3/cypress/tsconfig.json create mode 100644 examples/usage-before-14.3/env.d.ts create mode 100644 examples/usage-before-14.3/eslint.config.js create mode 100644 examples/usage-before-14.3/index.html create mode 100644 examples/usage-before-14.3/package.json create mode 100644 examples/usage-before-14.3/public/favicon.ico create mode 100644 examples/usage-before-14.3/src/App.vue create mode 100644 examples/usage-before-14.3/src/assets/base.css create mode 100644 examples/usage-before-14.3/src/assets/logo.svg create mode 100644 examples/usage-before-14.3/src/assets/main.css create mode 100644 examples/usage-before-14.3/src/components/HelloWorld.vue create mode 100644 examples/usage-before-14.3/src/components/TheWelcome.vue create mode 100644 examples/usage-before-14.3/src/components/WelcomeItem.vue create mode 100644 examples/usage-before-14.3/src/components/__tests__/HelloWorld.spec.ts create mode 100644 examples/usage-before-14.3/src/components/icons/IconCommunity.vue create mode 100644 examples/usage-before-14.3/src/components/icons/IconDocumentation.vue create mode 100644 examples/usage-before-14.3/src/components/icons/IconEcosystem.vue create mode 100644 examples/usage-before-14.3/src/components/icons/IconSupport.vue create mode 100644 examples/usage-before-14.3/src/components/icons/IconTooling.vue create mode 100644 examples/usage-before-14.3/src/main.ts create mode 100644 examples/usage-before-14.3/src/router/index.ts create mode 100644 examples/usage-before-14.3/src/stores/counter.ts create mode 100644 examples/usage-before-14.3/src/views/AboutView.vue create mode 100644 examples/usage-before-14.3/src/views/HomeView.vue create mode 100644 examples/usage-before-14.3/tsconfig.app.json create mode 100644 examples/usage-before-14.3/tsconfig.json create mode 100644 examples/usage-before-14.3/tsconfig.node.json create mode 100644 examples/usage-before-14.3/tsconfig.vitest.json create mode 100644 examples/usage-before-14.3/vite.config.ts create mode 100644 examples/usage-before-14.3/vitest.config.ts diff --git a/README.md b/README.md index d7adb741..7b0c2cfb 100644 --- a/README.md +++ b/README.md @@ -60,50 +60,50 @@ All the ` + + diff --git a/examples/usage-before-14.3/package.json b/examples/usage-before-14.3/package.json new file mode 100644 index 00000000..edd5e94b --- /dev/null +++ b/examples/usage-before-14.3/package.json @@ -0,0 +1,48 @@ +{ + "name": "usage-before-14.3", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "build": "run-p type-check \"build-only {@}\" --", + "preview": "vite preview", + "test:unit": "vitest", + "test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'", + "test:e2e:dev": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress open --e2e'", + "build-only": "vite build", + "type-check": "vue-tsc --build --force", + "lint": "eslint . --fix", + "format": "prettier --write src/" + }, + "dependencies": { + "pinia": "^2.3.0", + "vue": "^3.5.13", + "vue-router": "^4.5.0" + }, + "devDependencies": { + "@tsconfig/node20": "^20.1.4", + "@types/jsdom": "^21.1.7", + "@types/node": "^20.17.10", + "@vitejs/plugin-vue": "^5.2.1", + "@vitejs/plugin-vue-jsx": "^4.1.1", + "@vitest/eslint-plugin": "^1.1.20", + "@vue/eslint-config-prettier": "^10.1.0", + "@vue/eslint-config-typescript": "workspace:*", + "@vue/test-utils": "^2.4.6", + "@vue/tsconfig": "^0.7.0", + "cypress": "^13.17.0", + "eslint": "^9.17.0", + "eslint-plugin-cypress": "^4.1.0", + "eslint-plugin-vue": "^9.32.0", + "jsdom": "^25.0.1", + "npm-run-all2": "^7.0.2", + "prettier": "^3.4.2", + "start-server-and-test": "^2.0.9", + "typescript": "~5.6.3", + "vite": "^6.0.5", + "vite-plugin-vue-devtools": "^7.6.8", + "vitest": "^2.1.8", + "vue-tsc": "^2.1.10" + } +} diff --git a/examples/usage-before-14.3/public/favicon.ico b/examples/usage-before-14.3/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..df36fcfb72584e00488330b560ebcf34a41c64c2 GIT binary patch literal 4286 zcmds*O-Phc6o&64GDVCEQHxsW(p4>LW*W<827=Unuo8sGpRux(DN@jWP-e29Wl%wj zY84_aq9}^Am9-cWTD5GGEo#+5Fi2wX_P*bo+xO!)p*7B;iKlbFd(U~_d(U?#hLj56 zPhFkj-|A6~Qk#@g^#D^U0XT1cu=c-vu1+SElX9NR;kzAUV(q0|dl0|%h|dI$%VICy zJnu2^L*Te9JrJMGh%-P79CL0}dq92RGU6gI{v2~|)p}sG5x0U*z<8U;Ij*hB9z?ei z@g6Xq-pDoPl=MANPiR7%172VA%r)kevtV-_5H*QJKFmd;8yA$98zCxBZYXTNZ#QFk2(TX0;Y2dt&WitL#$96|gJY=3xX zpCoi|YNzgO3R`f@IiEeSmKrPSf#h#Qd<$%Ej^RIeeYfsxhPMOG`S`Pz8q``=511zm zAm)MX5AV^5xIWPyEu7u>qYs?pn$I4nL9J!=K=SGlKLXpE<5x+2cDTXq?brj?n6sp= zphe9;_JHf40^9~}9i08r{XM$7HB!`{Ys~TK0kx<}ZQng`UPvH*11|q7&l9?@FQz;8 zx!=3<4seY*%=OlbCbcae?5^V_}*K>Uo6ZWV8mTyE^B=DKy7-sdLYkR5Z?paTgK-zyIkKjIcpyO z{+uIt&YSa_$QnN_@t~L014dyK(fOOo+W*MIxbA6Ndgr=Y!f#Tokqv}n<7-9qfHkc3 z=>a|HWqcX8fzQCT=dqVbogRq!-S>H%yA{1w#2Pn;=e>JiEj7Hl;zdt-2f+j2%DeVD zsW0Ab)ZK@0cIW%W7z}H{&~yGhn~D;aiP4=;m-HCo`BEI+Kd6 z={Xwx{TKxD#iCLfl2vQGDitKtN>z|-AdCN|$jTFDg0m3O`WLD4_s#$S literal 0 HcmV?d00001 diff --git a/examples/usage-before-14.3/src/App.vue b/examples/usage-before-14.3/src/App.vue new file mode 100644 index 00000000..7905b051 --- /dev/null +++ b/examples/usage-before-14.3/src/App.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/examples/usage-before-14.3/src/assets/base.css b/examples/usage-before-14.3/src/assets/base.css new file mode 100644 index 00000000..8816868a --- /dev/null +++ b/examples/usage-before-14.3/src/assets/base.css @@ -0,0 +1,86 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +@media (prefers-color-scheme: dark) { + :root { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); + } +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: + color 0.5s, + background-color 0.5s; + line-height: 1.6; + font-family: + Inter, + -apple-system, + BlinkMacSystemFont, + 'Segoe UI', + Roboto, + Oxygen, + Ubuntu, + Cantarell, + 'Fira Sans', + 'Droid Sans', + 'Helvetica Neue', + sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/examples/usage-before-14.3/src/assets/logo.svg b/examples/usage-before-14.3/src/assets/logo.svg new file mode 100644 index 00000000..75656603 --- /dev/null +++ b/examples/usage-before-14.3/src/assets/logo.svg @@ -0,0 +1 @@ + diff --git a/examples/usage-before-14.3/src/assets/main.css b/examples/usage-before-14.3/src/assets/main.css new file mode 100644 index 00000000..36fb845b --- /dev/null +++ b/examples/usage-before-14.3/src/assets/main.css @@ -0,0 +1,35 @@ +@import './base.css'; + +#app { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + font-weight: normal; +} + +a, +.green { + text-decoration: none; + color: hsla(160, 100%, 37%, 1); + transition: 0.4s; + padding: 3px; +} + +@media (hover: hover) { + a:hover { + background-color: hsla(160, 100%, 37%, 0.2); + } +} + +@media (min-width: 1024px) { + body { + display: flex; + place-items: center; + } + + #app { + display: grid; + grid-template-columns: 1fr 1fr; + padding: 0 2rem; + } +} diff --git a/examples/usage-before-14.3/src/components/HelloWorld.vue b/examples/usage-before-14.3/src/components/HelloWorld.vue new file mode 100644 index 00000000..d174cf8e --- /dev/null +++ b/examples/usage-before-14.3/src/components/HelloWorld.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/examples/usage-before-14.3/src/components/TheWelcome.vue b/examples/usage-before-14.3/src/components/TheWelcome.vue new file mode 100644 index 00000000..e65a66b4 --- /dev/null +++ b/examples/usage-before-14.3/src/components/TheWelcome.vue @@ -0,0 +1,88 @@ + + + diff --git a/examples/usage-before-14.3/src/components/WelcomeItem.vue b/examples/usage-before-14.3/src/components/WelcomeItem.vue new file mode 100644 index 00000000..6d7086ae --- /dev/null +++ b/examples/usage-before-14.3/src/components/WelcomeItem.vue @@ -0,0 +1,87 @@ + + + diff --git a/examples/usage-before-14.3/src/components/__tests__/HelloWorld.spec.ts b/examples/usage-before-14.3/src/components/__tests__/HelloWorld.spec.ts new file mode 100644 index 00000000..25332020 --- /dev/null +++ b/examples/usage-before-14.3/src/components/__tests__/HelloWorld.spec.ts @@ -0,0 +1,11 @@ +import { describe, it, expect } from 'vitest' + +import { mount } from '@vue/test-utils' +import HelloWorld from '../HelloWorld.vue' + +describe('HelloWorld', () => { + it('renders properly', () => { + const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } }) + expect(wrapper.text()).toContain('Hello Vitest') + }) +}) diff --git a/examples/usage-before-14.3/src/components/icons/IconCommunity.vue b/examples/usage-before-14.3/src/components/icons/IconCommunity.vue new file mode 100644 index 00000000..2dc8b055 --- /dev/null +++ b/examples/usage-before-14.3/src/components/icons/IconCommunity.vue @@ -0,0 +1,7 @@ + diff --git a/examples/usage-before-14.3/src/components/icons/IconDocumentation.vue b/examples/usage-before-14.3/src/components/icons/IconDocumentation.vue new file mode 100644 index 00000000..6d4791cf --- /dev/null +++ b/examples/usage-before-14.3/src/components/icons/IconDocumentation.vue @@ -0,0 +1,7 @@ + diff --git a/examples/usage-before-14.3/src/components/icons/IconEcosystem.vue b/examples/usage-before-14.3/src/components/icons/IconEcosystem.vue new file mode 100644 index 00000000..c3a4f078 --- /dev/null +++ b/examples/usage-before-14.3/src/components/icons/IconEcosystem.vue @@ -0,0 +1,7 @@ + diff --git a/examples/usage-before-14.3/src/components/icons/IconSupport.vue b/examples/usage-before-14.3/src/components/icons/IconSupport.vue new file mode 100644 index 00000000..7452834d --- /dev/null +++ b/examples/usage-before-14.3/src/components/icons/IconSupport.vue @@ -0,0 +1,7 @@ + diff --git a/examples/usage-before-14.3/src/components/icons/IconTooling.vue b/examples/usage-before-14.3/src/components/icons/IconTooling.vue new file mode 100644 index 00000000..660598d7 --- /dev/null +++ b/examples/usage-before-14.3/src/components/icons/IconTooling.vue @@ -0,0 +1,19 @@ + + diff --git a/examples/usage-before-14.3/src/main.ts b/examples/usage-before-14.3/src/main.ts new file mode 100644 index 00000000..5dcad83c --- /dev/null +++ b/examples/usage-before-14.3/src/main.ts @@ -0,0 +1,14 @@ +import './assets/main.css' + +import { createApp } from 'vue' +import { createPinia } from 'pinia' + +import App from './App.vue' +import router from './router' + +const app = createApp(App) + +app.use(createPinia()) +app.use(router) + +app.mount('#app') diff --git a/examples/usage-before-14.3/src/router/index.ts b/examples/usage-before-14.3/src/router/index.ts new file mode 100644 index 00000000..ce51fcff --- /dev/null +++ b/examples/usage-before-14.3/src/router/index.ts @@ -0,0 +1,24 @@ +import { createRouter, createWebHistory } from 'vue-router' +import HomeView from '../views/HomeView.vue' +import type { Component } from 'vue' + +const router = createRouter({ + history: createWebHistory(import.meta.env.BASE_URL), + routes: [ + { + path: '/', + name: 'home', + component: HomeView + }, + { + path: '/about', + name: 'about', + // route level code-splitting + // this generates a separate chunk (About.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: async (): Promise<{ default: Component }> => import('../views/AboutView.vue') + } + ] +}) + +export default router diff --git a/examples/usage-before-14.3/src/stores/counter.ts b/examples/usage-before-14.3/src/stores/counter.ts new file mode 100644 index 00000000..b6757ba5 --- /dev/null +++ b/examples/usage-before-14.3/src/stores/counter.ts @@ -0,0 +1,12 @@ +import { ref, computed } from 'vue' +import { defineStore } from 'pinia' + +export const useCounterStore = defineStore('counter', () => { + const count = ref(0) + const doubleCount = computed(() => count.value * 2) + function increment() { + count.value++ + } + + return { count, doubleCount, increment } +}) diff --git a/examples/usage-before-14.3/src/views/AboutView.vue b/examples/usage-before-14.3/src/views/AboutView.vue new file mode 100644 index 00000000..756ad2a1 --- /dev/null +++ b/examples/usage-before-14.3/src/views/AboutView.vue @@ -0,0 +1,15 @@ + + + diff --git a/examples/usage-before-14.3/src/views/HomeView.vue b/examples/usage-before-14.3/src/views/HomeView.vue new file mode 100644 index 00000000..d5c0217e --- /dev/null +++ b/examples/usage-before-14.3/src/views/HomeView.vue @@ -0,0 +1,9 @@ + + + diff --git a/examples/usage-before-14.3/tsconfig.app.json b/examples/usage-before-14.3/tsconfig.app.json new file mode 100644 index 00000000..e14c754d --- /dev/null +++ b/examples/usage-before-14.3/tsconfig.app.json @@ -0,0 +1,14 @@ +{ + "extends": "@vue/tsconfig/tsconfig.dom.json", + "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], + "exclude": ["src/**/__tests__/*"], + "compilerOptions": { + "composite": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"] + } + } +} diff --git a/examples/usage-before-14.3/tsconfig.json b/examples/usage-before-14.3/tsconfig.json new file mode 100644 index 00000000..5304731b --- /dev/null +++ b/examples/usage-before-14.3/tsconfig.json @@ -0,0 +1,17 @@ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.node.json" + }, + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.vitest.json" + } + ], + "compilerOptions": { + "module": "NodeNext" + } +} diff --git a/examples/usage-before-14.3/tsconfig.node.json b/examples/usage-before-14.3/tsconfig.node.json new file mode 100644 index 00000000..f0940630 --- /dev/null +++ b/examples/usage-before-14.3/tsconfig.node.json @@ -0,0 +1,19 @@ +{ + "extends": "@tsconfig/node20/tsconfig.json", + "include": [ + "vite.config.*", + "vitest.config.*", + "cypress.config.*", + "nightwatch.conf.*", + "playwright.config.*" + ], + "compilerOptions": { + "composite": true, + "noEmit": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + + "module": "ESNext", + "moduleResolution": "Bundler", + "types": ["node"] + } +} diff --git a/examples/usage-before-14.3/tsconfig.vitest.json b/examples/usage-before-14.3/tsconfig.vitest.json new file mode 100644 index 00000000..571995d1 --- /dev/null +++ b/examples/usage-before-14.3/tsconfig.vitest.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.app.json", + "exclude": [], + "compilerOptions": { + "composite": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo", + + "lib": [], + "types": ["node", "jsdom"] + } +} diff --git a/examples/usage-before-14.3/vite.config.ts b/examples/usage-before-14.3/vite.config.ts new file mode 100644 index 00000000..c036b6f6 --- /dev/null +++ b/examples/usage-before-14.3/vite.config.ts @@ -0,0 +1,20 @@ +import { fileURLToPath, URL } from 'node:url' + +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' +import vueDevTools from 'vite-plugin-vue-devtools' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [ + vue(), + vueJsx(), + vueDevTools(), + ], + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)) + } + } +}) diff --git a/examples/usage-before-14.3/vitest.config.ts b/examples/usage-before-14.3/vitest.config.ts new file mode 100644 index 00000000..4b1c8979 --- /dev/null +++ b/examples/usage-before-14.3/vitest.config.ts @@ -0,0 +1,14 @@ +import { fileURLToPath } from 'node:url' +import { mergeConfig, defineConfig, configDefaults } from 'vitest/config' +import viteConfig from './vite.config' + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + environment: 'jsdom', + exclude: [...configDefaults.exclude, 'e2e/**'], + root: fileURLToPath(new URL('./', import.meta.url)) + } + }) +) diff --git a/examples/with-cypress/eslint.config.js b/examples/with-cypress/eslint.config.js index a96818ce..cdd486a3 100644 --- a/examples/with-cypress/eslint.config.js +++ b/examples/with-cypress/eslint.config.js @@ -1,8 +1,8 @@ import pluginVue from 'eslint-plugin-vue' import pluginCypress from 'eslint-plugin-cypress/flat' -import vueTsEslintConfig from '@vue/eslint-config-typescript' +import { defineConfig, configs } from '@vue/eslint-config-typescript' -export default [ +export default defineConfig( { name: 'app/files-to-lint', files: ['**/*.ts', '**/*.mts', '**/*.vue'], @@ -13,15 +13,15 @@ export default [ ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'], }, - ...pluginVue.configs['flat/essential'], - ...vueTsEslintConfig(), + pluginVue.configs['flat/essential'], + configs.recommended, { ...pluginCypress.configs.recommended, files: [ '**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}', 'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}', - 'cypress/support/**/*.{js,ts,jsx,tsx}' + 'cypress/support/**/*.{js,ts,jsx,tsx}', ], - } -] + }, +) diff --git a/examples/with-jsx-in-vue/eslint.config.js b/examples/with-jsx-in-vue/eslint.config.js index 639d855b..8ff58102 100644 --- a/examples/with-jsx-in-vue/eslint.config.js +++ b/examples/with-jsx-in-vue/eslint.config.js @@ -1,10 +1,31 @@ import pluginVue from 'eslint-plugin-vue' -import vueTsEslintConfig from '@vue/eslint-config-typescript' +import { + defineConfig, + configureVueProject, + configs, +} from '@vue/eslint-config-typescript' -export default [ +configureVueProject({ + supportedScriptLangs: { + js: true, + jsx: true, + ts: true, + tsx: true, + }, +}) + +export default defineConfig( { name: 'app/files-to-lint', - files: ['**/*.js', '**/*.mjs', '**/*.jsx', '**/*.ts', '**/*.mts', '**/*.tsx', '**/*.vue'], + files: [ + '**/*.js', + '**/*.mjs', + '**/*.jsx', + '**/*.ts', + '**/*.mts', + '**/*.tsx', + '**/*.vue', + ], }, { @@ -13,12 +34,5 @@ export default [ }, ...pluginVue.configs['flat/essential'], - ...vueTsEslintConfig({ - supportedScriptLangs: { - ts: true, - tsx: true, - js: true, - jsx: true - } - }), -] + configs.recommended, +) diff --git a/examples/with-jsx/eslint.config.js b/examples/with-jsx/eslint.config.js index 94678153..1dd8a095 100644 --- a/examples/with-jsx/eslint.config.js +++ b/examples/with-jsx/eslint.config.js @@ -1,7 +1,7 @@ import pluginVue from 'eslint-plugin-vue' -import vueTsEslintConfig from '@vue/eslint-config-typescript' +import { defineConfig, configs } from '@vue/eslint-config-typescript' -export default [ +export default defineConfig( { name: 'app/files-to-lint', files: ['**/*.js', '**/*.mjs', '**/*.jsx', '**/*.ts', '**/*.mts', '**/*.tsx', '**/*.vue'], @@ -12,6 +12,6 @@ export default [ ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'], }, - ...pluginVue.configs['flat/essential'], - ...vueTsEslintConfig(), -] + pluginVue.configs['flat/essential'], + configs.recommended, +) diff --git a/examples/with-nightwatch/eslint.config.js b/examples/with-nightwatch/eslint.config.js index 3dd45b59..e1ee3206 100644 --- a/examples/with-nightwatch/eslint.config.js +++ b/examples/with-nightwatch/eslint.config.js @@ -1,7 +1,7 @@ import pluginVue from 'eslint-plugin-vue' -import vueTsEslintConfig from '@vue/eslint-config-typescript' +import { defineConfig, configs } from '@vue/eslint-config-typescript' -export default [ +export default defineConfig( { name: 'app/files-to-lint', files: ['**/*.ts', '**/*.mts', '**/*.vue'], @@ -12,8 +12,8 @@ export default [ ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'], }, - ...pluginVue.configs['flat/essential'], - ...vueTsEslintConfig(), + pluginVue.configs['flat/essential'], + configs.recommended, { // nightwatch specs @@ -24,4 +24,4 @@ export default [ // You can use https://github.com/ihordiachenko/eslint-plugin-chai-friendly for more accurate linting }, }, -] +) diff --git a/examples/with-playwright/eslint.config.js b/examples/with-playwright/eslint.config.js index 87746fdf..8e27f514 100644 --- a/examples/with-playwright/eslint.config.js +++ b/examples/with-playwright/eslint.config.js @@ -1,8 +1,8 @@ import pluginVue from 'eslint-plugin-vue' import pluginPlaywright from 'eslint-plugin-playwright' -import vueTsEslintConfig from '@vue/eslint-config-typescript' +import { defineConfig, configs } from '@vue/eslint-config-typescript' -export default [ +export default defineConfig( { name: 'app/files-to-lint', files: ['**/*.ts', '**/*.mts', '**/*.vue'], @@ -13,11 +13,11 @@ export default [ ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'], }, - ...pluginVue.configs['flat/essential'], - ...vueTsEslintConfig(), + pluginVue.configs['flat/essential'], + configs.recommended, { ...pluginPlaywright.configs['flat/recommended'], files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'], }, -] +) diff --git a/examples/with-prettier/eslint.config.js b/examples/with-prettier/eslint.config.js index e9cee7f8..a0d79b81 100644 --- a/examples/with-prettier/eslint.config.js +++ b/examples/with-prettier/eslint.config.js @@ -1,8 +1,8 @@ import pluginVue from 'eslint-plugin-vue' -import vueTsEslintConfig from '@vue/eslint-config-typescript' +import { defineConfig, configs } from '@vue/eslint-config-typescript' import skipFormatting from '@vue/eslint-config-prettier/skip-formatting' -export default [ +export default defineConfig( { name: 'app/files-to-lint', files: ['**/*.ts', '**/*.mts', '**/*.vue'], @@ -13,8 +13,8 @@ export default [ ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'], }, - ...pluginVue.configs['flat/essential'], - ...vueTsEslintConfig(), + pluginVue.configs['flat/essential'], + configs.recommended, skipFormatting -] +) diff --git a/examples/with-tsx-in-vue/eslint.config.js b/examples/with-tsx-in-vue/eslint.config.js index d2b67b9a..3c63ef89 100644 --- a/examples/with-tsx-in-vue/eslint.config.js +++ b/examples/with-tsx-in-vue/eslint.config.js @@ -1,7 +1,18 @@ import pluginVue from 'eslint-plugin-vue' -import vueTsEslintConfig from '@vue/eslint-config-typescript' +import { + defineConfig, + configureVueProject, + configs, +} from '@vue/eslint-config-typescript' -export default [ +configureVueProject({ + supportedScriptLangs: { + ts: true, + tsx: true, + } +}) + +export default defineConfig( { name: 'app/files-to-lint', files: ['**/*.ts', '**/*.mts', '**/*.tsx', '**/*.vue'], @@ -13,10 +24,5 @@ export default [ }, ...pluginVue.configs['flat/essential'], - ...vueTsEslintConfig({ - supportedScriptLangs: { - ts: true, - tsx: true - } - }), -] + configs.recommended, +) diff --git a/examples/with-tsx/eslint.config.js b/examples/with-tsx/eslint.config.js index 2d989385..8ecebd64 100644 --- a/examples/with-tsx/eslint.config.js +++ b/examples/with-tsx/eslint.config.js @@ -1,7 +1,7 @@ import pluginVue from 'eslint-plugin-vue' -import vueTsEslintConfig from '@vue/eslint-config-typescript' +import { defineConfig, configs } from '@vue/eslint-config-typescript' -export default [ +export default defineConfig( { name: 'app/files-to-lint', files: ['**/*.ts', '**/*.mts', '**/*.tsx', '**/*.vue'], @@ -12,6 +12,6 @@ export default [ ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'], }, - ...pluginVue.configs['flat/essential'], - ...vueTsEslintConfig(), -] + pluginVue.configs['flat/essential'], + configs.recommended, +) diff --git a/examples/with-tsx/src/App.vue b/examples/with-tsx/src/App.vue index b7bd148c..c4fcbd9f 100644 --- a/examples/with-tsx/src/App.vue +++ b/examples/with-tsx/src/App.vue @@ -2,6 +2,7 @@ import HelloWorld from './components/HelloWorld.vue' import TheWelcome from './components/TheWelcome.vue' import FooComp from './FooComp' +// @ts-ignore