18 |
19 | [TypeScript] Found 1 error. Watching for file changes.",
20 | ]
21 | `;
22 |
--------------------------------------------------------------------------------
/playground/backend-integration/__test__/serve.js:
--------------------------------------------------------------------------------
1 | // this is automatically detected by playground/vitestSetup.ts and will replace
2 | // the default e2e test serve behavior
3 |
4 | import path from 'node:path'
5 | // import kill from 'kill-port'
6 | // import { hmrPorts, ports } from '~utils'
7 | import { fileURLToPath } from 'url'
8 |
9 | const isTest = process.env.VITEST
10 | const __dirname = path.dirname(fileURLToPath(import.meta.url))
11 |
12 | export async function serve() {
13 | // await kill(port)
14 | const rootDir = path.resolve(__dirname, '../')
15 |
16 | const { createServer, port } = await import(path.resolve(rootDir, 'server.js'))
17 | const { app, viteDevServer } = await createServer(rootDir, port)
18 |
19 | return new Promise((resolve, reject) => {
20 | try {
21 | const server = app.listen(port, () => {
22 | resolve({
23 | // for test teardown
24 | async close() {
25 | await new Promise((resolve) => {
26 | server.close(resolve)
27 | })
28 | if (viteDevServer) {
29 | await viteDevServer.close()
30 | }
31 | },
32 | viteDevServer,
33 | port,
34 | })
35 | })
36 | } catch (e) {
37 | reject(e)
38 | }
39 | })
40 | }
41 |
42 | // serve()
43 |
--------------------------------------------------------------------------------
/playground/backend-integration/__test__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import { describe, expect, it } from 'vitest'
3 |
4 | import {
5 | diagnostics,
6 | expectStderrContains,
7 | isBuild,
8 | isServe,
9 | log,
10 | sleepForServerReady,
11 | stripedLog,
12 | } from '../../testUtils'
13 |
14 | describe('backend-integration', () => {
15 | describe.runIf(isServe)('serve', () => {
16 | it('get initial error', async () => {
17 | await sleepForServerReady()
18 |
19 | expect(stringify(diagnostics)).toMatchSnapshot()
20 | expect(stripedLog).toMatchSnapshot()
21 | })
22 | })
23 |
24 | describe.runIf(isBuild)('build', () => {
25 | it('should fail', async () => {
26 | const expectedMsg = `TS2345: Argument of type 'number' is not assignable to parameter of type 'string | (() => string)'`
27 | expectStderrContains(log, expectedMsg)
28 | })
29 | })
30 | })
31 |
--------------------------------------------------------------------------------
/playground/backend-integration/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Vite + React + TS
7 |
8 |
9 |
Title on static server
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/backend-integration/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/backend-integration",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "node server.js",
9 | "preview": "vite preview"
10 | },
11 | "dependencies": {
12 | "react": "^19.1.0",
13 | "react-dom": "^19.1.0"
14 | },
15 | "devDependencies": {
16 | "@types/express": "^5.0.2",
17 | "@types/react": "^19.1.3",
18 | "@types/react-dom": "^19.1.3",
19 | "@vitejs/plugin-react": "^4.4.1",
20 | "express": "^5.1.0",
21 | "http-proxy-middleware": "^3.0.5",
22 | "typescript": "^5.8.3",
23 | "vite": "^6.3.4",
24 | "vite-plugin-checker": "workspace:*"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/playground/backend-integration/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/playground/backend-integration/server.js:
--------------------------------------------------------------------------------
1 | import fs from 'node:fs'
2 | import path from 'node:path'
3 | import { fileURLToPath } from 'node:url'
4 | import express from 'express'
5 | import { createProxyMiddleware } from 'http-proxy-middleware'
6 | import { createServer as createViteServer } from 'vite'
7 | const __dirname = path.dirname(fileURLToPath(import.meta.url))
8 |
9 | const rootDir = path.resolve(__dirname)
10 | export const port = 3008
11 |
12 | export async function createServer() {
13 | const app = express()
14 | const viteDevServer = await createViteServer({ root: rootDir })
15 |
16 | let html = await fs.promises.readFile(path.resolve(__dirname, 'index.html'), 'utf-8')
17 |
18 | app.get('/', async (req, res) => {
19 | html = html.replace(
20 | '',
21 | `
22 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | `
36 | )
37 | res.status(200).set({ 'Content-Type': 'text/html' }).send(html)
38 | })
39 |
40 | app.use('/', createProxyMiddleware({ target: 'http://127.0.0.1:5173', changeOrigin: true }))
41 |
42 | return { app, viteDevServer }
43 | }
44 |
45 | const isTest = process.env.VITEST
46 |
47 | if (!isTest) {
48 | createServer().then(({ app, viteDevServer }) => {
49 | viteDevServer.listen()
50 | app.listen(port, () => {
51 | console.log('http://localhost:5173')
52 | })
53 | })
54 | }
55 |
--------------------------------------------------------------------------------
/playground/backend-integration/src/App.css:
--------------------------------------------------------------------------------
1 | #root {
2 | max-width: 1280px;
3 | margin: 0 auto;
4 | padding: 2rem;
5 | text-align: center;
6 | }
7 |
8 | .logo {
9 | height: 6em;
10 | padding: 1.5em;
11 | will-change: filter;
12 | }
13 | .logo:hover {
14 | filter: drop-shadow(0 0 2em #646cffaa);
15 | }
16 | .logo.react:hover {
17 | filter: drop-shadow(0 0 2em #61dafbaa);
18 | }
19 |
20 | @keyframes logo-spin {
21 | from {
22 | transform: rotate(0deg);
23 | }
24 | to {
25 | transform: rotate(360deg);
26 | }
27 | }
28 |
29 | @media (prefers-reduced-motion: no-preference) {
30 | a:nth-of-type(2) .logo {
31 | animation: logo-spin infinite 20s linear;
32 | }
33 | }
34 |
35 | .card {
36 | padding: 2em;
37 | }
38 |
39 | .read-the-docs {
40 | color: #888;
41 | }
42 |
--------------------------------------------------------------------------------
/playground/backend-integration/src/App.tsx:
--------------------------------------------------------------------------------
1 | import { useState } from 'react'
2 | import reactLogo from './assets/react.svg'
3 | import './App.css'
4 |
5 | function App() {
6 | const [count, setCount] = useState
(0)
7 |
8 | return (
9 |
10 |
18 |
Vite + React
19 |
20 |
21 |
22 | Edit src/App.tsx
and save to test HMR
23 |
24 |
25 |
Click on the Vite and React logos to learn more
26 |
27 | )
28 | }
29 |
30 | export default App
31 |
--------------------------------------------------------------------------------
/playground/backend-integration/src/index.css:
--------------------------------------------------------------------------------
1 | :root {
2 | font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
3 | font-size: 16px;
4 | line-height: 24px;
5 | font-weight: 400;
6 |
7 | color-scheme: light dark;
8 | color: rgba(255, 255, 255, 0.87);
9 | background-color: #242424;
10 |
11 | font-synthesis: none;
12 | text-rendering: optimizeLegibility;
13 | -webkit-font-smoothing: antialiased;
14 | -moz-osx-font-smoothing: grayscale;
15 | -webkit-text-size-adjust: 100%;
16 | }
17 |
18 | a {
19 | font-weight: 500;
20 | color: #646cff;
21 | text-decoration: inherit;
22 | }
23 | a:hover {
24 | color: #535bf2;
25 | }
26 |
27 | body {
28 | margin: 0;
29 | place-items: center;
30 | min-width: 320px;
31 | min-height: 100vh;
32 | }
33 |
34 | h1 {
35 | font-size: 3.2em;
36 | line-height: 1.1;
37 | }
38 |
39 | button {
40 | border-radius: 8px;
41 | border: 1px solid transparent;
42 | padding: 0.6em 1.2em;
43 | font-size: 1em;
44 | font-weight: 500;
45 | font-family: inherit;
46 | background-color: #1a1a1a;
47 | cursor: pointer;
48 | transition: border-color 0.25s;
49 | }
50 | button:hover {
51 | border-color: #646cff;
52 | }
53 | button:focus,
54 | button:focus-visible {
55 | outline: 4px auto -webkit-focus-ring-color;
56 | }
57 |
58 | @media (prefers-color-scheme: light) {
59 | :root {
60 | color: #213547;
61 | background-color: #ffffff;
62 | }
63 | a:hover {
64 | color: #747bff;
65 | }
66 | button {
67 | background-color: #f9f9f9;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/playground/backend-integration/src/main.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { createRoot } from 'react-dom/client'
3 |
4 | import App from './App'
5 | import './index.css'
6 |
7 | const container = document.getElementById('root') as HTMLElement
8 | const root = createRoot(container)
9 | root.render(
10 |
11 |
12 |
13 | )
14 |
--------------------------------------------------------------------------------
/playground/backend-integration/src/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/playground/backend-integration/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "useDefineForClassFields": true,
5 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
6 | "allowJs": false,
7 | "skipLibCheck": true,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true,
17 | "jsx": "react-jsx"
18 | },
19 | "include": ["src"],
20 | "references": [{ "path": "./tsconfig.node.json" }]
21 | }
22 |
--------------------------------------------------------------------------------
/playground/backend-integration/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "module": "ESNext",
5 | "moduleResolution": "Node",
6 | "allowSyntheticDefaultImports": true
7 | },
8 | "include": ["vite.config.ts"]
9 | }
10 |
--------------------------------------------------------------------------------
/playground/backend-integration/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import react from '@vitejs/plugin-react'
3 | import checker from 'vite-plugin-checker'
4 |
5 | // https://vitejs.dev/config/
6 | export default defineConfig({
7 | build: {
8 | // generate manifest.json in outDir
9 | manifest: true,
10 | rollupOptions: {
11 | input: './src/main.tsx',
12 | },
13 | },
14 | plugins: [react(), checker({ typescript: true })],
15 | })
16 |
--------------------------------------------------------------------------------
/playground/biome-default/__tests__/__snapshots__/test.spec.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`biome > serve > get initial error and subsequent error 1`] = `"[{"checkerId":"Biome","frame":" 1 | const a = 'hello'/n > 2 | var b = 'world'/n | ^^^^^^^^^^^^^^^/n 3 | const c = '!'/n 4 | var d = a + b + c/n 5 |","id":"/playground-temp/biome-default/src/index.js","level":1,"loc":{"column":1,"file":"/playground-temp/biome-default/src/index.js","line":2},"message":"[lint/style/noVar] Use let or const instead of var.","stack":""},{"checkerId":"Biome","frame":" 2 | var b = 'world'/n 3 | const c = '!'/n > 4 | var d = a + b + c/n | ^^^^^^^^^^^^^^^^^/n 5 |","id":"/playground-temp/biome-default/src/index.js","level":1,"loc":{"column":1,"file":"/playground-temp/biome-default/src/index.js","line":4},"message":"[lint/style/noVar] Use let or const instead of var.","stack":""}]"`;
4 |
5 | exports[`biome > serve > get initial error and subsequent error 2`] = `
6 | [
7 | " ERROR(Biome) [lint/style/noVar] Use let or const instead of var.
8 | FILE /playground-temp/biome-default/src/index.js:2:1
9 |
10 | 1 | const a = 'hello'
11 | > 2 | var b = 'world'
12 | | ^^^^^^^^^^^^^^^
13 | 3 | const c = '!'
14 | 4 | var d = a + b + c
15 | 5 |
16 | ",
17 | " ERROR(Biome) [lint/style/noVar] Use let or const instead of var.
18 | FILE /playground-temp/biome-default/src/index.js:4:1
19 |
20 | 2 | var b = 'world'
21 | 3 | const c = '!'
22 | > 4 | var d = a + b + c
23 | | ^^^^^^^^^^^^^^^^^
24 | 5 |
25 | ",
26 | "[Biome] Found 2 errors and 0 warning",
27 | ]
28 | `;
29 |
30 | exports[`biome > serve > get initial error and subsequent error 3`] = `"[{"checkerId":"Biome","frame":" 2 | const b = 'world'/n 3 | const c = '!'/n > 4 | var d = a + b + c/n | ^^^^^^^^^^^^^^^^^/n 5 |","id":"/playground-temp/biome-default/src/index.js","level":1,"loc":{"column":1,"file":"/playground-temp/biome-default/src/index.js","line":4},"message":"[lint/style/noVar] Use let or const instead of var.","stack":""}]"`;
31 |
32 | exports[`biome > serve > get initial error and subsequent error 4`] = `
33 | [
34 | " ERROR(Biome) [lint/style/noVar] Use let or const instead of var.
35 | FILE /playground-temp/biome-default/src/index.js:4:1
36 |
37 | 2 | const b = 'world'
38 | 3 | const c = '!'
39 | > 4 | var d = a + b + c
40 | | ^^^^^^^^^^^^^^^^^
41 | 5 |
42 | ",
43 | "[Biome] Found 1 error and 0 warning",
44 | ]
45 | `;
46 |
--------------------------------------------------------------------------------
/playground/biome-default/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import fs from 'node:fs'
3 | import { describe, expect, it } from 'vitest'
4 | import {
5 | diagnostics,
6 | editFile,
7 | expectStderrContains,
8 | isBuild,
9 | isServe,
10 | stripedLog,
11 | resetDiagnostics,
12 | resetReceivedLog,
13 | sleepForEdit,
14 | sleepForServerReady,
15 | } from '../../testUtils'
16 | import path from 'node:path'
17 |
18 | describe('biome', () => {
19 | describe.runIf(isServe)('serve', () => {
20 | it('get initial error and subsequent error', async () => {
21 | await sleepForServerReady()
22 | expect(stringify(diagnostics)).toMatchSnapshot()
23 | expect(stripedLog).toMatchSnapshot()
24 |
25 | console.log('-- edit error file --')
26 | resetReceivedLog()
27 | resetDiagnostics()
28 | editFile('src/index.js', (code) => code.replace(`var b = 'world'`, `const b = 'world'`))
29 | await sleepForEdit()
30 | expect(stringify(diagnostics)).toMatchSnapshot()
31 | expect(stripedLog).toMatchSnapshot()
32 | })
33 | })
34 |
35 | describe.runIf(isBuild)('build', () => {
36 | it('should fail', async () => {
37 | const expectedMsg = ['Use let or const instead of var', 'Found 2 errors']
38 | expectStderrContains(stripedLog, expectedMsg)
39 | })
40 | })
41 | })
42 |
--------------------------------------------------------------------------------
/playground/biome-default/biome.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
3 | "files": {
4 | "include": ["./src/*.js"]
5 | },
6 | "linter": {
7 | "rules": {
8 | "recommended": true
9 | }
10 | },
11 | "formatter": {
12 | "enabled": false
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/playground/biome-default/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/biome-default/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/biome-default",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "biome lint",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@biomejs/biome": "^1.9.4",
14 | "vite": "^6.3.4",
15 | "vite-plugin-checker": "workspace:*"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/playground/biome-default/src/index.js:
--------------------------------------------------------------------------------
1 | const a = 'hello'
2 | var b = 'world'
3 | const c = '!'
4 | var d = a + b + c
5 |
--------------------------------------------------------------------------------
/playground/biome-default/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/biome-default/vite.config.js:
--------------------------------------------------------------------------------
1 | // @ts-check
2 | import { defineConfig } from 'vite'
3 | import checker from 'vite-plugin-checker'
4 |
5 | export default defineConfig({
6 | plugins: [
7 | checker({
8 | biome: true,
9 | }),
10 | ],
11 | })
12 |
--------------------------------------------------------------------------------
/playground/config-default/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
4 | "parser": "@typescript-eslint/parser",
5 | "plugins": ["@typescript-eslint"]
6 | }
7 |
--------------------------------------------------------------------------------
/playground/config-default/__tests__/__snapshots__/test.spec.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`config-default > serve > get initial error 1`] = `"[{"checkerId":"ESLint","frame":" 1 | import { text } from './text'/n 2 |/n > 3 | var hello = 'Hello'/n | ^^^^^^^^^^^^^^^^^^^/n 4 |/n 5 | const rootDom = document.querySelector('#root')! as HTMLElement/n 6 | rootDom.innerHTML = hello + text","id":"/playground-temp/config-default/src/main.ts","level":1,"loc":{"column":1,"file":"/playground-temp/config-default/src/main.ts","line":3},"message":"Unexpected var, use let or const instead. (no-var)","stack":""},{"checkerId":"ESLint","frame":" 3 | var hello = 'Hello'/n 4 |/n > 5 | const rootDom = document.querySelector('#root')! as HTMLElement/n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^/n 6 | rootDom.innerHTML = hello + text/n 7 |/n 8 | export {}","id":"/playground-temp/config-default/src/main.ts","level":0,"loc":{"column":17,"file":"/playground-temp/config-default/src/main.ts","line":5},"message":"Forbidden non-null assertion. (@typescript-eslint/no-non-null-assertion)","stack":""}]"`;
4 |
5 | exports[`config-default > serve > get initial error 2`] = `
6 | [
7 | " ERROR(ESLint) Unexpected var, use let or const instead. (no-var)
8 | FILE /playground-temp/config-default/src/main.ts:3:1
9 |
10 | 1 | import { text } from './text'
11 | 2 |
12 | > 3 | var hello = 'Hello'
13 | | ^^^^^^^^^^^^^^^^^^^
14 | 4 |
15 | 5 | const rootDom = document.querySelector('#root')! as HTMLElement
16 | 6 | rootDom.innerHTML = hello + text
17 | ",
18 | " WARNING(ESLint) Forbidden non-null assertion. (@typescript-eslint/no-non-null-assertion)
19 | FILE /playground-temp/config-default/src/main.ts:5:17
20 |
21 | 3 | var hello = 'Hello'
22 | 4 |
23 | > 5 | const rootDom = document.querySelector('#root')! as HTMLElement
24 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
25 | 6 | rootDom.innerHTML = hello + text
26 | 7 |
27 | 8 | export {}
28 | ",
29 | "[ESLint] Found 1 error and 1 warning",
30 | ]
31 | `;
32 |
--------------------------------------------------------------------------------
/playground/config-default/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import { describe, expect, it } from 'vitest'
3 |
4 | import {
5 | diagnostics,
6 | expectStderrContains,
7 | isBuild,
8 | isServe,
9 | log,
10 | sleepForServerReady,
11 | stripedLog,
12 | } from '../../testUtils'
13 |
14 | describe('config-default', () => {
15 | describe.runIf(isServe)('serve', () => {
16 | it('get initial error', async () => {
17 | await sleepForServerReady()
18 |
19 | expect(stringify(diagnostics)).toMatchSnapshot()
20 | expect(stripedLog).toMatchSnapshot()
21 | })
22 | })
23 |
24 | describe.runIf(isBuild)('build', () => {
25 | it('should fail', async () => {
26 | const expectedMsg = 'Unexpected var, use let or const instead no-var'
27 | expectStderrContains(log, expectedMsg)
28 | })
29 | })
30 | })
31 |
--------------------------------------------------------------------------------
/playground/config-default/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/config-default/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/config-default",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/config-default/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | var hello = 'Hello'
4 |
5 | const rootDom = document.querySelector('#root')! as HTMLElement
6 | rootDom.innerHTML = hello + text
7 |
8 | export {}
9 |
--------------------------------------------------------------------------------
/playground/config-default/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/config-default/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/config-default/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | base: '/my-app/',
7 | // config-edit-slot
8 | plugins: [
9 | checker({
10 | eslint: {
11 | lintCommand: 'eslint ./src --ext .ts',
12 | },
13 | // checker-edit-slot
14 | }),
15 | ],
16 | })
17 |
--------------------------------------------------------------------------------
/playground/config-enableBuild-false/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/config-enableBuild-false/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest'
2 |
3 | import { buildSucceed, isBuild } from '../../testUtils'
4 |
5 | describe('config-enableBuild-false', () => {
6 | describe.runIf(isBuild)('build', () => {
7 | it('should pass', async () => {
8 | expect(buildSucceed).toBe(true)
9 | })
10 | })
11 | })
12 |
--------------------------------------------------------------------------------
/playground/config-enableBuild-false/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/config-enableBuild-false/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/config-enable-build-false",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/config-enableBuild-false/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | var hello = 'Hello'
4 |
5 | const rootDom = document.querySelector('#root')! as HTMLElement
6 | rootDom.innerHTML = hello + text
7 |
8 | export {}
9 |
--------------------------------------------------------------------------------
/playground/config-enableBuild-false/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/config-enableBuild-false/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/config-enableBuild-false/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | // config-edit-slot
7 | plugins: [
8 | checker({
9 | enableBuild: false,
10 | eslint: {
11 | lintCommand: 'eslint ./src --ext .ts',
12 | },
13 | // checker-edit-slot
14 | }),
15 | ],
16 | })
17 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error-warnings/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error-warnings/__tests__/__snapshots__/test.spec.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`config-initialIsOpen-error-warnings > serve > should not show overlay when only warning exists 1`] = `
4 | " 1 | import { text } from './text'
5 | 2 |
6 | > 3 | var rootDom = document.querySelector('#root')! as HTMLElement
7 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8 | 4 | rootDom.innerHTML = text
9 | 5 |
10 | 6 | export {}"
11 | `;
12 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error-warnings/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest'
2 |
3 | import {
4 | editFile,
5 | getHmrOverlay,
6 | getHmrOverlayText,
7 | isServe,
8 | pollingUntil,
9 | sleepForEdit,
10 | sleepForServerReady,
11 | } from '../../testUtils'
12 |
13 | describe('config-initialIsOpen-error-warnings', () => {
14 | describe.runIf(isServe)('serve', () => {
15 | it('should not show overlay when only warning exists', async () => {
16 | await sleepForServerReady()
17 | try {
18 | await getHmrOverlayText()
19 | } catch (e) {
20 | expect((e as any).toString()).toContain(
21 | 'Invariant failed: shadow dom is expected to be found, but got null'
22 | )
23 | }
24 |
25 | console.log('-- overlay appears after introduce an error --')
26 | editFile('src/main.ts', (code) => code.replace('const rootDom', 'var rootDom'))
27 | await sleepForEdit()
28 | await getHmrOverlayText()
29 | await pollingUntil(getHmrOverlay, (dom) => !!dom)
30 | const [, , frame] = await getHmrOverlayText()
31 | expect(frame).toMatchSnapshot()
32 | })
33 | })
34 | })
35 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error-warnings/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error-warnings/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/config-initial-is-open-error-warnings",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error-warnings/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | const rootDom = document.querySelector('#root')! as HTMLElement
4 | rootDom.innerHTML = text
5 |
6 | export {}
7 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error-warnings/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error-warnings/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error-warnings/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | export default defineConfig({
5 | plugins: [
6 | checker({
7 | overlay: {
8 | initialIsOpen: 'error',
9 | },
10 | eslint: {
11 | lintCommand: 'eslint ./src --ext .ts',
12 | },
13 | }),
14 | ],
15 | })
16 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error/__tests__/__snapshots__/test.spec.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`config-initialIsOpen-error > serve > -- should find overlay with error -- 1`] = `"Unexpected var, use let or const instead. (no-var)"`;
4 |
5 | exports[`config-initialIsOpen-error > serve > -- should find overlay with error -- 2`] = `"/playground-temp/config-initialIsOpen-error/src/main.ts:3:1"`;
6 |
7 | exports[`config-initialIsOpen-error > serve > -- should find overlay with error -- 3`] = `
8 | " 1 | import { text } from './text'
9 | 2 |
10 | > 3 | var hello = 'Hello'
11 | | ^^^^^^^^^^^^^^^^^^^
12 | 4 |
13 | 5 | const rootDom = document.querySelector('#root')! as HTMLElement
14 | 6 | rootDom.innerHTML = hello + text"
15 | `;
16 |
17 | exports[`config-initialIsOpen-error > serve > -- should find overlay with error -- 4`] = `""`;
18 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest'
2 |
3 | import {
4 | editFile,
5 | getHmrOverlay,
6 | getHmrOverlayText,
7 | isServe,
8 | pollingUntil,
9 | sleep,
10 | sleepForEdit,
11 | sleepForServerReady,
12 | } from '../../testUtils'
13 |
14 | describe('config-initialIsOpen-error', () => {
15 | describe.runIf(isServe)('serve', () => {
16 | it('-- should find overlay with error --', async () => {
17 | await sleepForServerReady()
18 | const [message1, file1, frame1] = await getHmrOverlayText()
19 | expect(message1).toMatchSnapshot()
20 | expect(file1).toMatchSnapshot()
21 | expect(frame1).toMatchSnapshot()
22 |
23 | console.log('-- overlay remains after fix error --')
24 | editFile('src/main.ts', (code) => code.replace('var hello', `const hello`))
25 | await sleepForEdit()
26 | await pollingUntil(getHmrOverlay, (dom) => !!dom)
27 | const [, , frame2] = await getHmrOverlayText()
28 | expect(frame2).toMatchSnapshot()
29 |
30 | console.log('-- overlay dismiss after fix warning --')
31 | editFile('src/main.ts', (code) => code.replace('! as', ` as`))
32 | await sleep(6000)
33 | await expect(getHmrOverlayText()).rejects.toThrow(
34 | 'Invariant failed: .message-body is expected in shadow root'
35 | )
36 | })
37 | })
38 | })
39 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/config-initial-is-open-error",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | var hello = 'Hello'
4 |
5 | const rootDom = document.querySelector('#root')! as HTMLElement
6 | rootDom.innerHTML = hello + text
7 |
8 | export {}
9 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-error/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | export default defineConfig({
5 | plugins: [
6 | checker({
7 | overlay: {
8 | initialIsOpen: 'error',
9 | },
10 | eslint: {
11 | lintCommand: 'eslint ./src --ext .ts',
12 | },
13 | }),
14 | ],
15 | })
16 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-false/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-false/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest'
2 |
3 | import { getHmrOverlayText, isServe, sleepForServerReady } from '../../testUtils'
4 |
5 | describe('config-initialIsOpen-false', () => {
6 | describe.runIf(isServe)('serve', () => {
7 | it('should not find overlay', async () => {
8 | if (isServe) {
9 | await sleepForServerReady()
10 | try {
11 | await getHmrOverlayText()
12 | } catch (e) {
13 | expect((e as any).toString()).toContain(
14 | 'Invariant failed: shadow dom is expected to be found, but got null'
15 | )
16 | }
17 | }
18 | })
19 | })
20 | })
21 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-false/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-false/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/config-initial-is-open-false",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-false/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | var hello = 'Hello'
4 |
5 | const rootDom = document.querySelector('#root')! as HTMLElement
6 | rootDom.innerHTML = hello + text
7 |
8 | export {}
9 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-false/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-false/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/config-initialIsOpen-false/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | export default defineConfig({
5 | plugins: [
6 | checker({
7 | overlay: {
8 | initialIsOpen: false,
9 | },
10 | eslint: {
11 | lintCommand: 'eslint ./src --ext .ts',
12 | },
13 | }),
14 | ],
15 | })
16 |
--------------------------------------------------------------------------------
/playground/config-no-runtime-in-build/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/config-no-runtime-in-build/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import fs from 'fs'
2 | import { globSync } from 'tinyglobby'
3 | import path from 'path'
4 | import { describe, expect, it } from 'vitest'
5 |
6 | import { isBuild, sleepForServerReady, testDir } from '../../testUtils'
7 |
8 | describe('config-no-runtime-code-in-build', () => {
9 | describe.runIf(isBuild)('build', () => {
10 | it('should not contain plugin code in build artifacts', async () => {
11 | await sleepForServerReady()
12 | const files = globSync('**', { cwd: path.resolve(testDir, 'dist'), absolute: true, onlyFiles: true })
13 | expect(files.length).toBeGreaterThan(1)
14 | for await (const file of files) {
15 | const content = await fs.promises.readFile(file, 'utf-8')
16 | expect(content).not.toContain('vite-plugin-checker')
17 | }
18 | })
19 | })
20 | })
21 |
--------------------------------------------------------------------------------
/playground/config-no-runtime-in-build/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/config-no-runtime-in-build/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/config-no-runtime-in-build",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/config-no-runtime-in-build/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | console.log(text)
4 |
--------------------------------------------------------------------------------
/playground/config-no-runtime-in-build/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/config-no-runtime-in-build/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/config-no-runtime-in-build/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | export default defineConfig({
5 | plugins: [
6 | checker({
7 | eslint: {
8 | lintCommand: 'eslint ./src --ext .ts',
9 | },
10 | }),
11 | ],
12 | })
13 |
--------------------------------------------------------------------------------
/playground/config-overlay-changes/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/config-overlay-changes/__tests__/__snapshots__/test.spec.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`config-overlay-changes > serve > get initial error from overlay and overlay error content changes on modifying 1`] = `"Unexpected var, use let or const instead. (no-var)"`;
4 |
5 | exports[`config-overlay-changes > serve > get initial error from overlay and overlay error content changes on modifying 2`] = `"/playground-temp/config-overlay-changes/src/main.ts:3:1"`;
6 |
7 | exports[`config-overlay-changes > serve > get initial error from overlay and overlay error content changes on modifying 3`] = `
8 | " 1 | import { text } from './text'
9 | 2 |
10 | > 3 | var hello = 'Hello'
11 | | ^^^^^^^^^^^^^^^^^^^
12 | 4 |
13 | 5 | const rootDom = document.querySelector('#root')! as HTMLElement
14 | 6 | rootDom.innerHTML = hello + text"
15 | `;
16 |
17 | exports[`config-overlay-changes > serve > get initial error from overlay and overlay error content changes on modifying 4`] = `
18 | " 1 | import { text } from './text'
19 | 2 |
20 | > 3 | var hello = 'Hello1'
21 | | ^^^^^^^^^^^^^^^^^^^^
22 | 4 |
23 | 5 | const rootDom = document.querySelector('#root')! as HTMLElement
24 | 6 | rootDom.innerHTML = hello + text"
25 | `;
26 |
--------------------------------------------------------------------------------
/playground/config-overlay-changes/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest'
2 |
3 | import {
4 | editFile,
5 | getHmrOverlay,
6 | getHmrOverlayText,
7 | isServe,
8 | pollingUntil,
9 | sleep,
10 | sleepForEdit,
11 | sleepForServerReady,
12 | } from '../../testUtils'
13 |
14 | describe('config-overlay-changes', () => {
15 | describe.runIf(isServe)('serve', () => {
16 | it('get initial error from overlay and overlay error content changes on modifying', async () => {
17 | await sleepForServerReady()
18 | const [message1, file1, frame1] = await getHmrOverlayText()
19 | expect(message1).toMatchSnapshot()
20 | expect(file1).toMatchSnapshot()
21 | expect(frame1).toMatchSnapshot()
22 |
23 | console.log('-- overlay update after edit --')
24 | editFile('src/main.ts', (code) => code.replace('Hello', 'Hello1'))
25 | await sleepForEdit()
26 | await pollingUntil(getHmrOverlay, (dom) => !!dom)
27 | const [, , frame2] = await getHmrOverlayText()
28 | expect(frame2).toMatchSnapshot()
29 |
30 | console.log('-- overlay dismiss after fix error --')
31 | editFile('src/main.ts', (code) => code.replace('var hello', `const hello`))
32 | editFile('src/main.ts', (code) => code.replace('! as', ` as`))
33 | await sleep(6000)
34 | await expect(getHmrOverlayText()).rejects.toThrow(
35 | 'Invariant failed: .message-body is expected in shadow root'
36 | )
37 | })
38 | })
39 | })
40 |
--------------------------------------------------------------------------------
/playground/config-overlay-changes/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/config-overlay-changes/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/config-overlay-changes",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/config-overlay-changes/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | var hello = 'Hello'
4 |
5 | const rootDom = document.querySelector('#root')! as HTMLElement
6 | rootDom.innerHTML = hello + text
7 |
8 | export {}
9 |
--------------------------------------------------------------------------------
/playground/config-overlay-changes/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/config-overlay-changes/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/config-overlay-changes/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | // config-edit-slot
7 | plugins: [
8 | checker({
9 | eslint: {
10 | lintCommand: 'eslint ./src --ext .ts',
11 | },
12 | // checker-edit-slot
13 | }),
14 | ],
15 | })
16 |
--------------------------------------------------------------------------------
/playground/config-overlay-false/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/config-overlay-false/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest'
2 |
3 | import { getHmrOverlayText, isServe, sleepForServerReady } from '../../testUtils'
4 |
5 | describe('config-overlay-false', () => {
6 | describe.runIf(isServe)('serve', async () => {
7 | it('should not find overlay', async () => {
8 | await sleepForServerReady()
9 | try {
10 | await getHmrOverlayText()
11 | } catch (e) {
12 | await expect((e as any).toString()).toContain(
13 | 'Error: Invariant failed: .message-body is expected in shadow root'
14 | )
15 | }
16 | })
17 | })
18 | })
19 |
--------------------------------------------------------------------------------
/playground/config-overlay-false/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/config-overlay-false/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/config-overlay-false",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/config-overlay-false/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | var hello = 'Hello'
4 |
5 | const rootDom = document.querySelector('#root')! as HTMLElement
6 | rootDom.innerHTML = hello + text
7 |
8 | export {}
9 |
--------------------------------------------------------------------------------
/playground/config-overlay-false/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/config-overlay-false/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/config-overlay-false/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 |
5 | export default defineConfig({
6 | plugins: [
7 | checker({
8 | overlay: false,
9 | eslint: {
10 | lintCommand: 'eslint ./src --ext .ts',
11 | },
12 | }),
13 | ],
14 | })
15 |
--------------------------------------------------------------------------------
/playground/config-overlay-position-style/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/config-overlay-position-style/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import { sleepForServerReady, getHmrOverlay, isServe } from '../../testUtils'
2 | import { describe, expect, it } from 'vitest'
3 |
4 | describe('config-overlay-position-style', () => {
5 | describe.runIf(isServe)('serve', () => {
6 | it('find badge in right top corner and customized by badgeStyle', async () => {
7 | await sleepForServerReady()
8 | const shadowRoot = await getHmrOverlay()
9 | const badge = await shadowRoot!.$('.badge-base')
10 |
11 | const { bgColor, top, right } = await badge!.evaluate((el) => {
12 | const bgColor = window.getComputedStyle(el).getPropertyValue('background-color')
13 | const top = window.getComputedStyle(el).getPropertyValue('top')
14 | const right = window.getComputedStyle(el).getPropertyValue('right')
15 | return { bgColor, top, right }
16 | })
17 |
18 | expect(bgColor).toBe('rgb(231, 153, 176)')
19 | expect(top).toBe('0px')
20 | expect(right).toBe('0px')
21 | })
22 |
23 | it('panel be customized by panelStyle', async () => {
24 | await sleepForServerReady()
25 | const shadowRoot = await getHmrOverlay()
26 | const panel = await shadowRoot!.$('.window')
27 |
28 | const { bgColor } = await panel!.evaluate((el) => {
29 | const bgColor = window.getComputedStyle(el).getPropertyValue('background-color')
30 | return { bgColor }
31 | })
32 |
33 | expect(bgColor).toBe('rgb(164, 193, 255)')
34 | })
35 | })
36 | })
37 |
--------------------------------------------------------------------------------
/playground/config-overlay-position-style/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/config-overlay-position-style/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/config-overlay-position-style",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/config-overlay-position-style/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | var hello = 'Hello'
4 |
5 | const rootDom = document.querySelector('#root')! as HTMLElement
6 | rootDom.innerHTML = hello + text
7 |
8 | export {}
9 |
--------------------------------------------------------------------------------
/playground/config-overlay-position-style/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/config-overlay-position-style/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/config-overlay-position-style/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | export default defineConfig({
5 | plugins: [
6 | checker({
7 | overlay: {
8 | position: 'tr',
9 | badgeStyle: 'background-color: #E799B0',
10 | panelStyle: 'background-color: #A4C1FF;',
11 | },
12 | eslint: {
13 | lintCommand: 'eslint ./src --ext .ts',
14 | },
15 | }),
16 | ],
17 | })
18 |
--------------------------------------------------------------------------------
/playground/config-terminal-false/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/config-terminal-false/__tests__/__snapshots__/test.spec.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`config-terminal-false > serve > should not log into terminal 1`] = `"[{"checkerId":"ESLint","frame":" 1 | import { text } from './text'/n 2 |/n > 3 | var hello = 'Hello'/n | ^^^^^^^^^^^^^^^^^^^/n 4 |/n 5 | const rootDom = document.querySelector('#root')! as HTMLElement/n 6 | rootDom.innerHTML = hello + text","id":"/playground-temp/config-terminal-false/src/main.ts","level":1,"loc":{"column":1,"file":"/playground-temp/config-terminal-false/src/main.ts","line":3},"message":"Unexpected var, use let or const instead. (no-var)","stack":""},{"checkerId":"ESLint","frame":" 3 | var hello = 'Hello'/n 4 |/n > 5 | const rootDom = document.querySelector('#root')! as HTMLElement/n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^/n 6 | rootDom.innerHTML = hello + text/n 7 |/n 8 | export {}","id":"/playground-temp/config-terminal-false/src/main.ts","level":0,"loc":{"column":17,"file":"/playground-temp/config-terminal-false/src/main.ts","line":5},"message":"Forbidden non-null assertion. (@typescript-eslint/no-non-null-assertion)","stack":""}]"`;
4 |
5 | exports[`config-terminal-false > serve > should not log into terminal 2`] = `[]`;
6 |
--------------------------------------------------------------------------------
/playground/config-terminal-false/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import { describe, expect, it } from 'vitest'
3 |
4 | import { diagnostics, isServe, sleepForServerReady, stripedLog } from '../../testUtils'
5 |
6 | describe('config-terminal-false', () => {
7 | describe.runIf(isServe)('serve', () => {
8 | it('should not log into terminal', async () => {
9 | await sleepForServerReady()
10 | expect(stringify(diagnostics)).toMatchSnapshot()
11 | expect(stripedLog).toMatchSnapshot()
12 | })
13 | })
14 | })
15 |
--------------------------------------------------------------------------------
/playground/config-terminal-false/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/config-terminal-false/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/config-terminal-false",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/config-terminal-false/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | var hello = 'Hello'
4 |
5 | const rootDom = document.querySelector('#root')! as HTMLElement
6 | rootDom.innerHTML = hello + text
7 |
8 | export {}
9 |
--------------------------------------------------------------------------------
/playground/config-terminal-false/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/config-terminal-false/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/config-terminal-false/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | // config-edit-slot
7 | plugins: [
8 | checker({
9 | terminal: false,
10 | eslint: {
11 | lintCommand: 'eslint ./src --ext .ts',
12 | },
13 | // checker-edit-slot
14 | }),
15 | ],
16 | })
17 |
--------------------------------------------------------------------------------
/playground/eslint-config-log-level/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/eslint-config-log-level/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import { describe, expect, it } from 'vitest'
3 |
4 | import {
5 | diagnostics,
6 | editFile,
7 | isServe,
8 | resetReceivedLog,
9 | sleepForEdit,
10 | sleepForServerReady,
11 | stripedLog,
12 | } from '../../testUtils'
13 |
14 | describe('eslint-config-log-level', () => {
15 | describe.runIf(isServe)('serve', () => {
16 | it('should only emit warning logs', async () => {
17 | await sleepForServerReady()
18 | expect(stringify(diagnostics)).toMatchSnapshot()
19 | expect(stripedLog).toMatchSnapshot()
20 |
21 | console.log('-- edit error file --')
22 | resetReceivedLog()
23 | editFile('src/main.ts', (code) => code.replace(`'Hello'`, `'Hello~'`))
24 | await sleepForEdit()
25 | expect(stringify(diagnostics)).toMatchSnapshot()
26 | expect(stripedLog).toMatchSnapshot()
27 | })
28 | })
29 | })
30 |
--------------------------------------------------------------------------------
/playground/eslint-config-log-level/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/eslint-config-log-level/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/eslint-config-log-level",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/eslint-config-log-level/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | var hello = 'Hello'
4 |
5 | const rootDom = document.querySelector('#root')!
6 | rootDom.innerHTML = hello + text
7 |
8 | export {}
9 |
--------------------------------------------------------------------------------
/playground/eslint-config-log-level/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/eslint-config-log-level/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/eslint-config-log-level/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | export default defineConfig({
5 | plugins: [
6 | checker({
7 | eslint: {
8 | lintCommand: 'eslint ./src --ext .ts',
9 | dev: { logLevel: ['warning'] },
10 | },
11 | }),
12 | ],
13 | })
14 |
--------------------------------------------------------------------------------
/playground/eslint-default/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/eslint-default/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import { describe, expect, it } from 'vitest'
3 | import {
4 | diagnostics,
5 | editFile,
6 | expectStderrContains,
7 | isBuild,
8 | isServe,
9 | log,
10 | resetReceivedLog,
11 | sleepForEdit,
12 | sleepForServerReady,
13 | stripedLog,
14 | } from '../../testUtils'
15 |
16 | describe('eslint-default', () => {
17 | describe.runIf(isServe)('serve', () => {
18 | it('get initial error and subsequent error', async () => {
19 | await sleepForServerReady()
20 | expect(stringify(diagnostics)).toMatchSnapshot()
21 | expect(stripedLog).toMatchSnapshot()
22 |
23 | console.log('-- edit error file --')
24 | resetReceivedLog()
25 | editFile('src/main.ts', (code) => code.replace(`'Hello'`, `'Hello~'`))
26 | await sleepForEdit()
27 | expect(stringify(diagnostics)).toMatchSnapshot()
28 | expect(stripedLog).toMatchSnapshot()
29 |
30 | console.log('-- edit non error file --')
31 | resetReceivedLog()
32 | editFile('src/text.ts', (code) => code.replace(`Vanilla`, `vanilla`))
33 | await sleepForEdit()
34 | expect(stringify(diagnostics)).toMatchSnapshot()
35 | expect(stripedLog).toMatchSnapshot()
36 | })
37 | })
38 |
39 | describe.runIf(isBuild)('build', () => {
40 | const expectedMsg = 'Unexpected var, use let or const instead'
41 |
42 | it('should fail', async () => {
43 | expectStderrContains(log, expectedMsg)
44 | })
45 | })
46 | })
47 |
--------------------------------------------------------------------------------
/playground/eslint-default/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/eslint-default/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/eslint-default",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/eslint-default/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | let count: string = 0
4 | var hello = 'Hello'
5 |
6 | const rootDom = document.querySelector('#root')!
7 | rootDom.innerHTML = hello + text
8 |
9 | export {}
10 |
--------------------------------------------------------------------------------
/playground/eslint-default/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Vanilla JS/TS'
2 |
--------------------------------------------------------------------------------
/playground/eslint-default/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/eslint-default/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | export default defineConfig({
5 | plugins: [
6 | checker({
7 | eslint: {
8 | lintCommand: 'eslint ./src --ext .ts',
9 | },
10 | }),
11 | ],
12 | })
13 |
--------------------------------------------------------------------------------
/playground/eslint-flat/__tests__/__snapshots__/test.spec.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`eslint > serve > get initial error and subsequent error 1`] = `"[{"checkerId":"ESLint","frame":" > 1 | const a = /"hello/"/n | ^/n > 2 |/n | ^","id":"/playground-temp/eslint-flat/src/index.js","level":1,"loc":{"column":18,"file":"/playground-temp/eslint-flat/src/index.js","line":1},"message":"Missing semicolon. (semi)","stack":""}]"`;
4 |
5 | exports[`eslint > serve > get initial error and subsequent error 2`] = `
6 | [
7 | " ERROR(ESLint) Missing semicolon. (semi)
8 | FILE /playground-temp/eslint-flat/src/index.js:1:18
9 |
10 | > 1 | const a = "hello"
11 | | ^
12 | > 2 |
13 | | ^
14 | ",
15 | "[ESLint] Found 1 error and 0 warning",
16 | ]
17 | `;
18 |
19 | exports[`eslint > serve > get initial error and subsequent error 3`] = `"[{"checkerId":"ESLint","frame":" > 1 | const a = /"hello/"/n | ^/n > 2 |/n | ^","id":"/playground-temp/eslint-flat/src/index.js","level":1,"loc":{"column":18,"file":"/playground-temp/eslint-flat/src/index.js","line":1},"message":"Missing semicolon. (semi)","stack":""},{"checkerId":"ESLint","frame":" > 1 | const a = /"hello/"/n | ^/n > 2 |/n | ^","id":"/playground-temp/eslint-flat/src/index.js","level":1,"loc":{"column":18,"file":"/playground-temp/eslint-flat/src/index.js","line":1},"message":"Missing semicolon. (semi)","stack":""}]"`;
20 |
21 | exports[`eslint > serve > get initial error and subsequent error 4`] = `
22 | [
23 | " ERROR(ESLint) Missing semicolon. (semi)
24 | FILE /playground-temp/eslint-flat/src/index.js:1:18
25 |
26 | > 1 | const a = "hello"
27 | | ^
28 | > 2 |
29 | | ^
30 | ",
31 | "[ESLint] Found 1 error and 0 warning",
32 | ]
33 | `;
34 |
--------------------------------------------------------------------------------
/playground/eslint-flat/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import { describe, expect, it } from 'vitest'
3 | import {
4 | diagnostics,
5 | editFile,
6 | expectStderrContains,
7 | isBuild,
8 | isServe,
9 | log,
10 | resetReceivedLog,
11 | sleepForEdit,
12 | sleepForServerReady,
13 | stripedLog,
14 | } from '../../testUtils'
15 |
16 | describe('eslint', () => {
17 | describe.runIf(isServe)('serve', () => {
18 | it('get initial error and subsequent error', async () => {
19 | await sleepForServerReady()
20 | expect(stringify(diagnostics)).toMatchSnapshot()
21 | expect(stripedLog).toMatchSnapshot()
22 |
23 | console.log('-- edit error file --')
24 | resetReceivedLog()
25 | editFile('src/index.js', (code) => code.replace(`Hello`, `Hello~`))
26 | await sleepForEdit()
27 | expect(stringify(diagnostics)).toMatchSnapshot()
28 | expect(stripedLog).toMatchSnapshot()
29 | })
30 | })
31 |
32 | describe.runIf(isBuild)('build', () => {
33 | const expectedMsg = 'Missing semicolon'
34 |
35 | it('should fail', async () => {
36 | expectStderrContains(log, expectedMsg)
37 | })
38 | })
39 | })
40 |
--------------------------------------------------------------------------------
/playground/eslint-flat/eslint.config.js:
--------------------------------------------------------------------------------
1 | export default [
2 | {
3 | files: ["src/**/*"],
4 | rules: {
5 | semi: 'error',
6 | },
7 | },
8 | ]
9 |
--------------------------------------------------------------------------------
/playground/eslint-flat/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/eslint-flat/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/eslint-flat",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint .",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "eslint": "^9.26.0",
14 | "vite": "^6.3.4",
15 | "vite-plugin-checker": "workspace:*"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/playground/eslint-flat/src/index.js:
--------------------------------------------------------------------------------
1 | const a = "hello"
2 |
--------------------------------------------------------------------------------
/playground/eslint-flat/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/eslint-flat/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | export default defineConfig({
5 | plugins: [
6 | checker({
7 | eslint: {
8 | lintCommand: 'eslint "./src/**/*.js"',
9 | useFlatConfig: true,
10 | },
11 | }),
12 | ],
13 | })
14 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import stable from 'sort-deep-object-arrays'
3 | import { describe, expect, it } from 'vitest'
4 |
5 | import {
6 | diagnostics,
7 | editFile,
8 | expectStderrContains,
9 | isBuild,
10 | isServe,
11 | resetDiagnostics,
12 | resetReceivedLog,
13 | log,
14 | sleepForEdit,
15 | sleepForServerReady,
16 | stripedLog,
17 | } from '../../testUtils'
18 |
19 | describe('multiple-hmr', () => {
20 | describe.runIf(isServe)('serve', () => {
21 | it('get initial error and subsequent error', async () => {
22 | await sleepForServerReady()
23 | expect(stringify(stable(diagnostics))).toMatchSnapshot()
24 | expect(stable(stripedLog)).toMatchSnapshot()
25 |
26 | console.log('-- edit with error --')
27 | resetDiagnostics()
28 | resetReceivedLog()
29 | editFile('src/value.ts', (code) =>
30 | code.replace('export var value: string = 1', 'export var value: string = 2')
31 | )
32 | await sleepForEdit()
33 | expect(stringify(stable(diagnostics))).toMatchSnapshot()
34 | // don't know why striped log in disorder on Linux, while correct on mac and Windows
35 | // comment out for now to pass test cases stably and striped log is duplicated with diagnostics somehow.
36 | // Need help to figure out what went wrong. 😅
37 | // expect(stripedLog).toMatchSnapshot()
38 |
39 | console.log('-- fix typescript error --')
40 | resetDiagnostics()
41 | resetReceivedLog()
42 | editFile('src/value.ts', (code) =>
43 | code.replace('export var value: string = 2', `export var value = 2`)
44 | )
45 | await sleepForEdit()
46 | expect(stringify(stable(diagnostics))).toMatchSnapshot()
47 |
48 | console.log('-- fix eslint error --')
49 | resetDiagnostics()
50 | resetReceivedLog()
51 | editFile('src/value.ts', (code) => code.replace('var', 'const'))
52 | await sleepForEdit()
53 | expect(stringify(stable(diagnostics))).toMatchSnapshot()
54 | })
55 | })
56 |
57 | describe.runIf(isBuild)('build', () => {
58 | const expectedMsg = [
59 | 'Unexpected var, use let or const instead',
60 | `error TS2322: Type 'number' is not assignable to type 'string'`,
61 | ]
62 |
63 | it('should fail', async () => {
64 | expectStderrContains(log, expectedMsg)
65 | })
66 | })
67 | })
68 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/multiple-hmr",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "serve": "vite preview"
10 | },
11 | "dependencies": {
12 | "react": "^19.1.0",
13 | "react-dom": "^19.1.0"
14 | },
15 | "devDependencies": {
16 | "@types/react": "^19.1.3",
17 | "@types/react-dom": "^19.1.3",
18 | "@vitejs/plugin-react": "^4.4.1",
19 | "typescript": "^5.8.3",
20 | "vite": "^6.3.4",
21 | "vite-plugin-checker": "workspace:*"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
40 | button {
41 | font-size: calc(10px + 2vmin);
42 | }
43 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/src/App.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react'
2 | import logo from './logo.svg'
3 | import { value } from './value'
4 | import './App.css'
5 |
6 | function App() {
7 | const [count, setCount] = useState(0)
8 | return (
9 |
10 |
11 |
12 | Hello Vite + React! ({value})
13 |
14 |
15 |
16 |
17 | Edit App.tsx
and save to test HMR updates.
18 |
19 |
20 |
26 | Learn React
27 |
28 | {' | '}
29 |
35 | Vite Docs
36 |
37 |
38 |
39 |
40 | )
41 | }
42 |
43 | export default App
44 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/src/favicon.svg:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/src/logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/src/main.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { createRoot } from 'react-dom/client'
3 |
4 | import App from './App'
5 | import './index.css'
6 |
7 | const container = document.getElementById('root') as HTMLElement
8 | const root = createRoot(container)
9 | root.render(
10 |
11 |
12 |
13 | )
14 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/src/value.ts:
--------------------------------------------------------------------------------
1 | export var value: string = 1
2 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true,
17 | "jsx": "react"
18 | },
19 | "include": ["./src"]
20 | }
21 |
--------------------------------------------------------------------------------
/playground/multiple-hmr/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import react from '@vitejs/plugin-react'
3 | import checker from 'vite-plugin-checker'
4 |
5 | // https://vitejs.dev/config/
6 | export default defineConfig({
7 | plugins: [
8 |
9 | react(),
10 | checker({
11 | typescript: true,
12 | eslint: {
13 | lintCommand: 'eslint ./src --ext .ts',
14 | },
15 | }),
16 | ],
17 | })
18 |
--------------------------------------------------------------------------------
/playground/multiple-reload/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/multiple-reload/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import stable from 'sort-deep-object-arrays'
3 | import { describe, expect, it } from 'vitest'
4 |
5 | import {
6 | diagnostics,
7 | editFile,
8 | expectStderrContains,
9 | isBuild,
10 | isServe,
11 | resetDiagnostics,
12 | resetReceivedLog,
13 | log,
14 | sleepForEdit,
15 | sleepForServerReady,
16 | stripedLog,
17 | } from '../../testUtils'
18 |
19 | describe('multiple-reload', () => {
20 | describe.runIf(isServe)('serve', () => {
21 | it('get initial error and subsequent error', async () => {
22 | await sleepForServerReady()
23 | expect(stringify(stable(diagnostics))).toMatchSnapshot()
24 | expect(stable(stripedLog)).toMatchSnapshot()
25 |
26 | console.log('-- edit with error --')
27 | resetDiagnostics()
28 | resetReceivedLog()
29 | editFile('src/main.ts', (code) =>
30 | code.replace(`var count: number = 0`, `var count: number = 1`)
31 | )
32 | await sleepForEdit()
33 | expect(stringify(stable(diagnostics))).toMatchSnapshot()
34 | // don't know why striped log in disorder on Linux, while correct on mac and Windows
35 | // comment out for now to pass test cases stably and striped log is duplicated with diagnostics somehow.
36 | // Need help to figure out what went wrong. 😅
37 | // expect(stable(stripedLog)).toMatchSnapshot()
38 |
39 | console.log('-- fix typescript error --')
40 | resetDiagnostics()
41 | resetReceivedLog()
42 | editFile('src/main.ts', (code) =>
43 | code.replace('var count: number = 1', `var count: string = 1`)
44 | )
45 | await sleepForEdit()
46 | expect(stringify(stable(diagnostics))).toMatchSnapshot()
47 |
48 | console.log('-- fix eslint error --')
49 | resetDiagnostics()
50 | resetReceivedLog()
51 | editFile('src/main.ts', (code) => code.replace('var count: string = 1', 'const count = 0'))
52 | await sleepForEdit()
53 | expect(stringify(stable(diagnostics))).toMatchSnapshot()
54 | })
55 | })
56 |
57 | describe.runIf(isBuild)('build', () => {
58 | const expectedMsg = [
59 | 'Unexpected var, use let or const instead',
60 | `error TS2322: Type 'number' is not assignable to type 'string'`,
61 | ]
62 |
63 | it('should fail', async () => {
64 | expectStderrContains(log, expectedMsg)
65 | })
66 | })
67 | })
68 |
--------------------------------------------------------------------------------
/playground/multiple-reload/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/multiple-reload/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/multiple-reload",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "eslint --ext .js,.ts ./src/**",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "@typescript-eslint/eslint-plugin": "^5.62.0",
14 | "@typescript-eslint/parser": "^5.62.0",
15 | "eslint": "^8.57.1",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/multiple-reload/src/main.ts:
--------------------------------------------------------------------------------
1 | import { text } from './text'
2 |
3 | var count: string = 0
4 | const hello = 'Hello'
5 |
6 | const rootDom = document.querySelector('#root')!
7 | rootDom.innerHTML = hello + text + count
8 |
9 | export {}
10 |
--------------------------------------------------------------------------------
/playground/multiple-reload/src/text.ts:
--------------------------------------------------------------------------------
1 | export const text = 'Multiple Checkers'
2 |
--------------------------------------------------------------------------------
/playground/multiple-reload/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/multiple-reload/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | export default defineConfig({
5 | plugins: [
6 | checker({
7 | typescript: true,
8 | eslint: {
9 | lintCommand: 'eslint ./src --ext .ts',
10 | },
11 | }),
12 | ],
13 | })
14 |
--------------------------------------------------------------------------------
/playground/serializers.ts:
--------------------------------------------------------------------------------
1 | import type { SnapshotSerializer } from 'vitest'
2 |
3 | function normalizePaths(val: string) {
4 | return val
5 | .replace(/\\/gim, '/') // replace slashes
6 | .replace(/\/\//gim, '/') // replace slashes
7 | .replace(/[a-zA-Z]:\//gim, '/') // Remove win32 drive letters, C:\ -> \
8 | }
9 |
10 | function createResult(val: string) {
11 | const cwd = normalizePaths(process.cwd())
12 |
13 | return normalizePaths(val)
14 | .replaceAll(cwd, '')
15 | .replace(/\/r\/n/gim, '/n')
16 | }
17 |
18 | export const normalizeLogSerializer: SnapshotSerializer = {
19 | print(val: string, print) {
20 | return print(createResult(val))
21 | },
22 | test(val) {
23 | return typeof val === 'string' && val && createResult(val) !== val
24 | },
25 | }
26 |
--------------------------------------------------------------------------------
/playground/stylelint-default/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
4 | }
5 |
--------------------------------------------------------------------------------
/playground/stylelint-default/.stylelintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "stylelint-config-standard"
3 | }
4 |
--------------------------------------------------------------------------------
/playground/stylelint-default/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import { describe, expect, it } from 'vitest'
3 | import {
4 | diagnostics,
5 | editFile,
6 | expectStderrContains,
7 | isBuild,
8 | isServe,
9 | log,
10 | resetReceivedLog,
11 | sleepForEdit,
12 | sleepForServerReady,
13 | stripedLog,
14 | } from '../../testUtils'
15 |
16 | describe('stylelint', () => {
17 | describe.runIf(isServe)('serve', () => {
18 | it('get initial error and subsequent error', async () => {
19 | await sleepForServerReady()
20 | expect(stringify(diagnostics)).toMatchSnapshot()
21 | expect(stripedLog).toMatchSnapshot()
22 |
23 | console.log('-- edit error file --')
24 | resetReceivedLog()
25 | editFile('src/style.css', (code) => code.replace(`color: rgb(0, 0, 0);`, `color: #fff;`))
26 | await sleepForEdit()
27 | expect(stringify(diagnostics)).toMatchSnapshot()
28 | expect(stripedLog).toMatchSnapshot()
29 | })
30 | })
31 |
32 | describe.runIf(isBuild)('build', () => {
33 | const expectedMsg = ['Unexpected empty block', 'Expected modern color-function notation']
34 |
35 | it('should fail', async () => {
36 | expectStderrContains(log, expectedMsg)
37 | })
38 | })
39 | })
40 |
--------------------------------------------------------------------------------
/playground/stylelint-default/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/stylelint-default/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/stylelint-default",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "lint": "stylelint \"./**/*.css\"",
10 | "serve": "vite preview"
11 | },
12 | "devDependencies": {
13 | "meow": "^13.2.0",
14 | "stylelint": "^16.19.1",
15 | "stylelint-config-standard": "^38.0.0",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/stylelint-default/src/main.ts:
--------------------------------------------------------------------------------
1 | import './style.css'
2 |
3 | const rootDom = document.querySelector('#root')!
4 | rootDom.innerHTML = 'Hello world.'
5 |
6 | export {}
7 |
--------------------------------------------------------------------------------
/playground/stylelint-default/src/style.css:
--------------------------------------------------------------------------------
1 | #root {
2 | }
3 |
4 | body {
5 | color: rgb(0, 0, 0);
6 | }
7 |
--------------------------------------------------------------------------------
/playground/stylelint-default/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true
17 | },
18 | "include": ["./src"]
19 | }
20 |
--------------------------------------------------------------------------------
/playground/stylelint-default/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import checker from 'vite-plugin-checker'
3 |
4 | export default defineConfig({
5 | plugins: [
6 | checker({
7 | stylelint: {
8 | lintCommand: 'stylelint "./**/*.css"',
9 | },
10 | }),
11 | ],
12 | })
13 |
--------------------------------------------------------------------------------
/playground/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["./"],
3 | "exclude": ["**/dist/**"],
4 | "compilerOptions": {
5 | "lib": ["ESNext"],
6 | "target": "ES2020",
7 | "module": "ESNext",
8 | "outDir": "dist",
9 | "baseUrl": ".",
10 | "allowJs": true,
11 | "esModuleInterop": true,
12 | "resolveJsonModule": true,
13 | "moduleResolution": "Node",
14 | "skipLibCheck": true,
15 | "noUnusedLocals": true,
16 | "jsx": "preserve"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/playground/typescript-react/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import { describe, expect, it } from 'vitest'
3 |
4 | import {
5 | diagnostics,
6 | editFile,
7 | expectStderrContains,
8 | isBuild,
9 | isServe,
10 | log,
11 | resetReceivedLog,
12 | sleepForEdit,
13 | sleepForServerReady,
14 | stripedLog,
15 | } from '../../testUtils'
16 |
17 | describe('typescript-react', () => {
18 | describe.runIf(isServe)('serve', () => {
19 | it('get initial error and subsequent error', async () => {
20 | await sleepForServerReady()
21 | expect(stringify(diagnostics)).toMatchSnapshot()
22 | expect(stripedLog).toMatchSnapshot()
23 |
24 | console.log('-- edit file --')
25 | resetReceivedLog()
26 | editFile('src/App.tsx', (code) => code.replace('useState(1)', 'useState(2)'))
27 | await sleepForEdit()
28 | expect(stringify(diagnostics)).toMatchSnapshot()
29 | expect(stripedLog).toMatchSnapshot()
30 | })
31 | })
32 |
33 | describe.runIf(isBuild)('build', () => {
34 | it('should fail', async () => {
35 | expectStderrContains(log, 'error TS2345')
36 | })
37 | })
38 | })
39 |
--------------------------------------------------------------------------------
/playground/typescript-react/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/typescript-react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/typescript-react",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "serve": "vite preview"
10 | },
11 | "dependencies": {
12 | "react": "^19.1.0",
13 | "react-dom": "^19.1.0"
14 | },
15 | "devDependencies": {
16 | "@types/react": "^19.1.3",
17 | "@types/react-dom": "^19.1.3",
18 | "@vitejs/plugin-react": "^4.4.1",
19 | "typescript": "^5.8.3",
20 | "vite": "^6.3.4",
21 | "vite-plugin-checker": "workspace:*"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/playground/typescript-react/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
40 | button {
41 | font-size: calc(10px + 2vmin);
42 | }
43 |
--------------------------------------------------------------------------------
/playground/typescript-react/src/App.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react'
2 | import logo from './logo.svg'
3 | import './App.css'
4 |
5 | function App() {
6 | const [count, setCount] = useState(1)
7 | return (
8 |
9 |
10 |
11 | Hello Vite + React!
12 |
13 |
14 |
15 |
16 | Edit App.tsx
and save to test HMR updates.
17 |
18 |
19 |
25 | Learn React
26 |
27 | {' | '}
28 |
34 | Vite Docs
35 |
36 |
37 |
38 |
39 | )
40 | }
41 |
42 | export default App
43 |
--------------------------------------------------------------------------------
/playground/typescript-react/src/favicon.svg:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------
/playground/typescript-react/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/playground/typescript-react/src/main.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { createRoot } from 'react-dom/client'
3 |
4 | import App from './App'
5 | import './index.css'
6 |
7 | const container = document.getElementById('root') as HTMLElement
8 | const root = createRoot(container)
9 | root.render(
10 |
11 |
12 |
13 | )
14 |
--------------------------------------------------------------------------------
/playground/typescript-react/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
5 | "types": ["vite/client"],
6 | "allowJs": false,
7 | "skipLibCheck": false,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true,
17 | "jsx": "react"
18 | },
19 | "include": ["./src"]
20 | }
21 |
--------------------------------------------------------------------------------
/playground/typescript-react/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import react from '@vitejs/plugin-react'
3 | import checker from 'vite-plugin-checker'
4 |
5 | // https://vitejs.dev/config/
6 | export default defineConfig({
7 | plugins: [
8 | react(),
9 | checker({
10 | typescript: true,
11 | }),
12 | ],
13 | })
14 |
--------------------------------------------------------------------------------
/playground/vitestGlobalSetup.ts:
--------------------------------------------------------------------------------
1 | import { rmSync } from 'node:fs'
2 | import fs from 'node:fs/promises'
3 | import os from 'node:os'
4 | import path from 'node:path'
5 | import { chromium } from 'playwright-chromium'
6 |
7 | import type { BrowserServer } from 'playwright-chromium'
8 | const DIR = path.join(os.tmpdir(), 'vitest_playwright_global_setup')
9 |
10 | let browserServer: BrowserServer | undefined
11 |
12 | export async function setup(): Promise {
13 | browserServer = await chromium.launchServer({
14 | headless: !process.env.VITE_DEBUG_SERVE,
15 | args: process.env.CI ? ['--no-sandbox', '--disable-setuid-sandbox'] : undefined,
16 | })
17 |
18 | await fs.mkdir(DIR, { recursive: true })
19 | await fs.writeFile(path.join(DIR, 'wsEndpoint'), browserServer.wsEndpoint())
20 |
21 | const tempDir = path.resolve(__dirname, '../playground-temp')
22 | await fs.rm(tempDir, { force: true, recursive: true })
23 | await fs.mkdir(tempDir, { recursive: true })
24 | await fs
25 | .cp(path.resolve(__dirname, '../playground'), tempDir, {
26 | dereference: false,
27 | recursive: true,
28 | filter(file) {
29 | const _file = file.replace(/\\/g, '/')
30 | return !_file.includes('__tests__') && !file.match(/dist(\/|$)/)
31 | },
32 | })
33 | .catch(async (error) => {
34 | if (error.code === 'EPERM' && error.syscall === 'symlink') {
35 | throw new Error(
36 | 'Could not create symlinks. On Windows, consider activating Developer Mode to allow non-admin users to create symlinks by following the instructions at https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development.'
37 | )
38 | } else {
39 | throw error
40 | }
41 | })
42 | }
43 |
44 | export async function teardown(): Promise {
45 | browserServer?.close()
46 | if (!process.env.VITE_PRESERVE_BUILD_ARTIFACTS) {
47 | rmSync(path.resolve(__dirname, '../playground-temp'), { force: true, recursive: true })
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/playground/vls-vue2/.browserslistrc:
--------------------------------------------------------------------------------
1 | > 1%
2 | last 2 versions
3 | not dead
4 |
--------------------------------------------------------------------------------
/playground/vls-vue2/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: {
4 | node: true,
5 | },
6 | extends: [
7 | 'plugin:vue/essential',
8 | 'eslint:recommended',
9 | '@vue/typescript/recommended',
10 | '@vue/prettier',
11 | ],
12 | parserOptions: {
13 | ecmaVersion: 2020,
14 | parser: '@typescript-eslint/parser',
15 | },
16 | rules: {
17 | 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
18 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
19 | },
20 | }
21 |
--------------------------------------------------------------------------------
/playground/vls-vue2/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 | pnpm-debug.log*
15 |
16 | # Editor directories and files
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw?
24 |
25 | pnpm-lock.yaml
--------------------------------------------------------------------------------
/playground/vls-vue2/.npmrc:
--------------------------------------------------------------------------------
1 | shamefully-hoist=true
2 |
--------------------------------------------------------------------------------
/playground/vls-vue2/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Martinus Suherman
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/playground/vls-vue2/README.md:
--------------------------------------------------------------------------------
1 | # Vue2 + Typescript + Vite Starter Template
2 |
3 | [](https://www.codefactor.io/repository/github/martinussuherman/vue-template) [](https://github.com/martinussuherman/vue-template/actions/workflows/codeql-analysis.yml) [](https://github.com/martinussuherman/vue-template/actions/workflows/gh-pages.yml)
4 | ---
5 |
6 | Starter template example for Vue2 + Typescript + Vite.
7 |
8 | Note: Using pnpm for package manager.
9 |
10 | ## Project setup
11 | ```
12 | pnpm install
13 | ```
14 |
15 | ### Compiles and hot-reloads for development
16 | ```
17 | pnpm run serve
18 | ```
19 |
20 | ### Compiles and minifies for production
21 | ```
22 | pnpm run build
23 | ```
24 |
25 | ### Lints and fixes files
26 | ```
27 | pnpm run lint
28 | ```
29 |
30 | ### Customize configuration
31 | See [Configuration Reference](https://cli.vuejs.org/config/).
32 |
--------------------------------------------------------------------------------
/playground/vls-vue2/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import { describe, expect, it } from 'vitest'
3 |
4 | import {
5 | diagnostics,
6 | editFile,
7 | expectStderrContains,
8 | isBuild,
9 | isServe,
10 | log,
11 | resetReceivedLog,
12 | sleepForEdit,
13 | sleepForServerReady,
14 | stripedLog,
15 | } from '../../testUtils'
16 |
17 | describe('vue2-vls', () => {
18 | describe.runIf(isServe)('serve', () => {
19 | it('get initial error and subsequent error', async () => {
20 | await sleepForServerReady()
21 | expect(stringify(diagnostics)).toMatchSnapshot()
22 | expect(stripedLog).toMatchSnapshot()
23 |
24 | console.log('-- edit file --')
25 | resetReceivedLog()
26 | editFile('src/components/HelloWorld.vue', (code) => code.replace('msg1', 'msg2'))
27 | await sleepForEdit()
28 |
29 | expect(stringify(diagnostics)).toMatchSnapshot()
30 | expect(stripedLog).toMatchSnapshot()
31 | })
32 | })
33 |
34 | // As per https://github.com/vuejs/vetur/issues/3686
35 | // We may remove VLS in the future to push the community to Vue 3 & Vue Language Tools.
36 | // describe.runIf(isBuild)('build', () => {
37 | // it('should fail', async () => {
38 | // expectStderrContains(log, `Property 'msg1' does not exist on type`)
39 | // })
40 | // })
41 | })
42 |
--------------------------------------------------------------------------------
/playground/vls-vue2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Vue2 + Vite
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/playground/vls-vue2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/vls-vue2",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "serve": "vite preview"
10 | },
11 | "dependencies": {
12 | "vue": "^2.7.16",
13 | "vue-class-component": "7.2.6",
14 | "vue-property-decorator": "9.1.2",
15 | "vue-router": "3.6.5",
16 | "vuex": "3.6.2"
17 | },
18 | "devDependencies": {
19 | "@types/node": "^18.19.87",
20 | "@typescript-eslint/eslint-plugin": "^4.33.0",
21 | "@typescript-eslint/parser": "^4.33.0",
22 | "@vue/eslint-config-prettier": "6.0.0",
23 | "@vue/eslint-config-typescript": "^7.0.0",
24 | "eslint": "^7.32.0",
25 | "eslint-plugin-prettier": "^3.4.1",
26 | "eslint-plugin-vue": "^7.20.0",
27 | "prettier": "3.5.3",
28 | "sass": "^1.87.0",
29 | "typescript": "~4.9.5",
30 | "vite": "^6.3.4",
31 | "vite-plugin-checker": "workspace:*",
32 | "vite-plugin-components": "^0.13.3",
33 | "vite-plugin-vue2": "^2.0.3",
34 | "vls": "^0.8.5",
35 | "vti": "^0.1.11",
36 | "vue-template-compiler": "^2.7.16"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/playground/vls-vue2/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fi3ework/vite-plugin-checker/78a8a7e1d748d333e77bddd3797734a13c8f0039/playground/vls-vue2/public/favicon.ico
--------------------------------------------------------------------------------
/playground/vls-vue2/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Home |
5 | About
6 |
7 |
8 |
9 |
10 |
11 |
33 |
--------------------------------------------------------------------------------
/playground/vls-vue2/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fi3ework/vite-plugin-checker/78a8a7e1d748d333e77bddd3797734a13c8f0039/playground/vls-vue2/src/assets/logo.png
--------------------------------------------------------------------------------
/playground/vls-vue2/src/main.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from '@/App.vue'
3 | import router from '@/router'
4 | import store from '@/store'
5 |
6 | Vue.config.productionTip = false
7 |
8 | new Vue({
9 | router,
10 | store,
11 | render: (h) => h(App),
12 | }).$mount('#app')
13 |
14 | export const str: string = 1
15 |
--------------------------------------------------------------------------------
/playground/vls-vue2/src/router/index.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueRouter, { RouteConfig } from 'vue-router'
3 | import Home from '@/views/Home.vue'
4 |
5 | Vue.use(VueRouter)
6 |
7 | const routes: Array = [
8 | {
9 | path: '/',
10 | name: 'Home',
11 | component: Home,
12 | },
13 | {
14 | path: '/about',
15 | name: 'About',
16 | // route level code-splitting
17 | // this generates a separate chunk (about.[hash].js) for this route
18 | // which is lazy-loaded when the route is visited.
19 | component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'),
20 | },
21 | ]
22 |
23 | const router = new VueRouter({
24 | mode: 'history',
25 | base: import.meta.env.BASE_URL,
26 | routes,
27 | })
28 |
29 | export default router
30 |
--------------------------------------------------------------------------------
/playground/vls-vue2/src/shims-tsx.d.ts:
--------------------------------------------------------------------------------
1 | import Vue, { VNode } from 'vue'
2 |
3 | declare global {
4 | namespace JSX {
5 | // tslint:disable no-empty-interface
6 | interface Element extends VNode {}
7 | // tslint:disable no-empty-interface
8 | interface ElementClass extends Vue {}
9 | interface IntrinsicElements {
10 | [elem: string]: any
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/playground/vls-vue2/src/shims-vue.d.ts:
--------------------------------------------------------------------------------
1 | declare module '*.vue' {
2 | import Vue from 'vue'
3 | export default Vue
4 | }
5 |
--------------------------------------------------------------------------------
/playground/vls-vue2/src/store/index.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Vuex from 'vuex'
3 |
4 | Vue.use(Vuex)
5 |
6 | export default new Vuex.Store({
7 | state: {},
8 | mutations: {},
9 | actions: {},
10 | modules: {},
11 | })
12 |
--------------------------------------------------------------------------------
/playground/vls-vue2/src/views/About.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
This is an about page
4 |
5 |
6 |
--------------------------------------------------------------------------------
/playground/vls-vue2/src/views/Home.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |

4 |
5 |
6 |
7 |
8 |
11 |
--------------------------------------------------------------------------------
/playground/vls-vue2/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "module": "esnext",
5 | "strict": true,
6 | "jsx": "preserve",
7 | "importHelpers": true,
8 | "moduleResolution": "node",
9 | "experimentalDecorators": true,
10 | "skipLibCheck": true,
11 | "esModuleInterop": true,
12 | "allowSyntheticDefaultImports": true,
13 | "sourceMap": true,
14 | "baseUrl": ".",
15 | "types": ["vite/client"],
16 | "paths": {
17 | "@/*": ["src/*"]
18 | },
19 | "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
20 | },
21 | "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx"],
22 | "exclude": ["node_modules"]
23 | }
24 |
--------------------------------------------------------------------------------
/playground/vls-vue2/vetur.config.cjs:
--------------------------------------------------------------------------------
1 | // vetur.config.js
2 | /** @type {import('vls').VeturConfig} */
3 |
4 | module.exports = {
5 | // **optional** default: `{}`
6 | // override vscode settings
7 | // Notice: It only affects the settings used by Vetur.
8 | settings: {
9 | 'vetur.useWorkspaceDependencies': true,
10 | 'vetur.experimental.templateInterpolationService': true,
11 | },
12 | // **optional** default: `[{ root: './' }]`
13 | // support monorepos
14 | projects: ['./'],
15 | }
16 |
--------------------------------------------------------------------------------
/playground/vls-vue2/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import { createVuePlugin } from 'vite-plugin-vue2'
3 | import ViteComponents from 'vite-plugin-components'
4 | import checker from 'vite-plugin-checker'
5 | import { resolve } from 'path'
6 |
7 | const config = defineConfig({
8 | resolve: {
9 | alias: {
10 | '@': `${resolve(__dirname, 'src')}`,
11 | },
12 | },
13 | base: '/vue-template/',
14 | build: {
15 | minify: true,
16 | },
17 | plugins: [
18 | createVuePlugin({}),
19 | (ViteComponents.default || ViteComponents)({ transformer: 'vue2' }),
20 | checker({ vls: true }),
21 | ],
22 | })
23 |
24 | export default config
25 |
--------------------------------------------------------------------------------
/playground/vue-tsc-vue3/__tests__/test.spec.ts:
--------------------------------------------------------------------------------
1 | import stringify from 'fast-json-stable-stringify'
2 | import { describe, expect, it } from 'vitest'
3 |
4 | import {
5 | diagnostics,
6 | editFile,
7 | expectStderrContains,
8 | isBuild,
9 | isServe,
10 | log,
11 | resetReceivedLog,
12 | sleepForEdit,
13 | sleepForServerReady,
14 | stripedLog,
15 | } from '../../testUtils'
16 |
17 | describe('vue-tsc-vue3', () => {
18 | describe.runIf(isServe)('serve', () => {
19 | it('get initial error and subsequent error', async () => {
20 | await sleepForServerReady(2)
21 | expect(stringify(diagnostics)).toMatchSnapshot()
22 | expect(stripedLog).toMatchSnapshot()
23 |
24 | console.log('-- edit file --')
25 | resetReceivedLog()
26 | editFile('src/App.vue', (code) =>
27 | code.replace('', '')
28 | )
29 | await sleepForEdit(2)
30 | expect(stringify(diagnostics)).toMatchSnapshot()
31 | expect(stripedLog).toMatchSnapshot()
32 | })
33 | })
34 |
35 | describe.runIf(isBuild)('build', () => {
36 | it('should fail', async () => {
37 | const expectedMsg = `error TS2345`
38 | expectStderrContains(log, expectedMsg)
39 | })
40 | })
41 | })
42 |
--------------------------------------------------------------------------------
/playground/vue-tsc-vue3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/vue-tsc-vue3/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@playground/vue-tsc-vue3",
3 | "version": "0.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "build": "vite build",
8 | "dev": "vite",
9 | "serve": "vite preview"
10 | },
11 | "dependencies": {
12 | "vue": "^3.5.13"
13 | },
14 | "devDependencies": {
15 | "@vitejs/plugin-vue": "^5.2.4",
16 | "typescript": "^5.8.3",
17 | "vite": "^6.3.4",
18 | "vite-plugin-checker": "workspace:*",
19 | "vue-tsc": "~2.2.10"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/playground/vue-tsc-vue3/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fi3ework/vite-plugin-checker/78a8a7e1d748d333e77bddd3797734a13c8f0039/playground/vue-tsc-vue3/public/favicon.ico
--------------------------------------------------------------------------------
/playground/vue-tsc-vue3/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
28 |
--------------------------------------------------------------------------------
/playground/vue-tsc-vue3/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fi3ework/vite-plugin-checker/78a8a7e1d748d333e77bddd3797734a13c8f0039/playground/vue-tsc-vue3/src/assets/logo.png
--------------------------------------------------------------------------------
/playground/vue-tsc-vue3/src/components/HelloWorld.vue:
--------------------------------------------------------------------------------
1 |
2 | {{ msg }}
3 |
4 |
5 | Recommended IDE setup:
6 | VSCode
7 | +
8 | Vetur
12 | or
13 | Volar
14 | (if using
15 | <script setup>
)
16 |
17 |
18 | See README.md
for more information.
19 |
20 |
21 | Vite Docs |
22 | Vue 3 Docs
23 |
24 |
25 |
26 |
27 | Edit
28 | components/HelloWorld.vue
to test hot module replacement.
29 |
30 |
31 |
32 |
48 |
49 |
66 |
--------------------------------------------------------------------------------
/playground/vue-tsc-vue3/src/main.ts:
--------------------------------------------------------------------------------
1 | import { createApp } from 'vue'
2 | import App from './App.vue'
3 |
4 | createApp(App).mount('#app')
5 |
--------------------------------------------------------------------------------
/playground/vue-tsc-vue3/src/shims-vue.d.ts:
--------------------------------------------------------------------------------
1 | declare module '*.vue' {
2 | import { DefineComponent } from 'vue'
3 | const component: DefineComponent<{}, {}, any>
4 | export default component
5 | }
6 |
--------------------------------------------------------------------------------
/playground/vue-tsc-vue3/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "module": "esnext",
5 | "moduleResolution": "node",
6 | "strict": true,
7 | "jsx": "preserve",
8 | "sourceMap": true,
9 | "resolveJsonModule": true,
10 | "esModuleInterop": true,
11 | "skipLibCheck": true,
12 | "lib": ["esnext", "dom"],
13 | "types": ["vite/client"]
14 | },
15 | "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
16 | }
17 |
--------------------------------------------------------------------------------
/playground/vue-tsc-vue3/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import vue from '@vitejs/plugin-vue'
3 | import checker from 'vite-plugin-checker'
4 |
5 | // https://vitejs.dev/config/
6 | export default defineConfig({
7 | plugins: [vue(), checker({ vueTsc: true })],
8 | })
9 |
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - 'playground/**'
3 | - 'packages/*'
4 | - 'docs'
5 |
--------------------------------------------------------------------------------
/scripts/docs-check.sh:
--------------------------------------------------------------------------------
1 | echo "prev commit: $CACHED_COMMIT_REF"
2 | echo "current commit: $COMMIT_REF"
3 | git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF docs package.json pnpm-lock.yaml netlify.toml scripts/docs-check.sh
4 | has_diff=$?
5 | git describe --exact-match --tags $(git log -n1 --pretty='%h')
6 | has_tag=$?
7 |
8 | echo "diff exit code: $has_diff"
9 | echo "tag exit code: $has_tag"
10 |
11 | exit $(($has_diff || $has_tag))
--------------------------------------------------------------------------------
/scripts/vitestGlobalSetup.ts:
--------------------------------------------------------------------------------
1 | import { rmSync } from 'node:fs'
2 | import fs from 'node:fs/promises'
3 | import path from 'node:path'
4 |
5 | const tempRuntimePath = path.resolve(
6 | __dirname,
7 | '../packages/vite-plugin-checker/src/@runtime',
8 | )
9 |
10 | export async function setup(): Promise {
11 | await fs.rm(tempRuntimePath, { force: true, recursive: true })
12 | await fs.mkdir(tempRuntimePath, { recursive: true })
13 | await fs.cp(
14 | path.resolve(__dirname, '../packages/vite-plugin-checker/dist/@runtime'),
15 | tempRuntimePath,
16 | {
17 | recursive: true,
18 | dereference: false,
19 | },
20 | )
21 | }
22 |
23 | export async function teardown(): Promise {
24 | rmSync(tempRuntimePath, { force: true, recursive: true })
25 | }
26 |
--------------------------------------------------------------------------------
/vitest.config.e2e.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'node:path'
2 | import { defineConfig } from 'vitest/config'
3 |
4 | const timeout = process.env.CI ? 80000 : 40000
5 |
6 | export default defineConfig({
7 | test: {
8 | cache: false,
9 | pool: 'forks',
10 | poolOptions: {
11 | forks: {
12 | // singleFork: true,
13 | },
14 | },
15 | include: ['./playground/**/*.spec.[tj]s'],
16 | setupFiles: ['./playground/vitestSetup.ts'],
17 | globalSetup: ['./playground/vitestGlobalSetup.ts'],
18 | testTimeout: timeout,
19 | hookTimeout: timeout,
20 | globals: true,
21 | reporters: 'dot',
22 | onConsoleLog(log) {
23 | if (log.match(/experimental|jit engine|emitted file|tailwind/i))
24 | return false
25 | },
26 | },
27 | esbuild: {
28 | target: 'node14',
29 | },
30 | })
31 |
--------------------------------------------------------------------------------
/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | exclude: [
6 | '**/node_modules/**',
7 | '**/dist/**',
8 | './playground/**/*.*',
9 | './playground-temp/**/*.*',
10 | ],
11 | testTimeout: 20000,
12 | globalSetup: ['./scripts/vitestGlobalSetup.ts'],
13 | },
14 | esbuild: {
15 | target: 'node14',
16 | },
17 | })
18 |
--------------------------------------------------------------------------------