Skip to content

Commit 2c80390

Browse files
authored
chore: enable typecheck for tests and scripts (#8114)
1 parent 5f2f4b8 commit 2c80390

File tree

12 files changed

+25
-13
lines changed

12 files changed

+25
-13
lines changed

.eslintrc.cjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ module.exports = defineConfig({
119119
rules: {
120120
'node/no-extraneous-import': 'off',
121121
'node/no-extraneous-require': 'off',
122-
'node/no-missing-import': 'off'
122+
'node/no-missing-import': 'off',
123+
'node/no-missing-require': 'off'
123124
}
124125
},
125126
{

.github/workflows/ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,13 @@ jobs:
102102
run: |
103103
pnpm run ci-build-vite
104104
pnpm run build-plugin-vue
105+
pnpm run build-plugin-react
105106
106107
- name: Lint
107108
run: pnpm run lint
108109

109110
- name: Check formatting
110111
run: pnpm prettier --check .
112+
113+
- name: Typecheck
114+
run: pnpm run typecheck

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"serve-docs": "vitepress serve docs",
2828
"release": "ts-node scripts/release.ts",
2929
"ci-publish": "ts-node scripts/publishCI.ts",
30+
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit",
3031
"build": "run-s build-vite build-plugin-vue build-plugin-react",
3132
"build-vite": "cd packages/vite && npm run build",
3233
"build-plugin-vue": "cd packages/plugin-vue && npm run build",

playground/ssr-vue/__tests__/serve.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// this is automatically detected by scripts/vitestSetup.ts and will replace
1+
// this is automatically detected by playground/vitestSetup.ts and will replace
22
// the default e2e test serve behavior
33

44
import path from 'path'

playground/ssr-vue/server.js

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ async function createServer(
6363
render = (await vite.ssrLoadModule('/src/entry-server.js')).render
6464
} else {
6565
template = indexProd
66+
// @ts-ignore
6667
render = require('./dist/server/entry-server.js').render
6768
}
6869

playground/test-utils.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/triple-slash-reference */
12
// test utils used in e2e tests for playgrounds.
23
// `import { getColor } from '~utils'`
34

@@ -12,9 +13,9 @@ import type { Manifest } from 'vite'
1213
import { normalizePath } from 'vite'
1314
import { fromComment } from 'convert-source-map'
1415
import { expect } from 'vitest'
15-
import { page } from '../scripts/vitestSetup'
16+
import { page } from './vitestSetup'
1617

17-
export * from '../scripts/vitestSetup'
18+
export * from './vitestSetup'
1819

1920
export const workspaceRoot = path.resolve(__dirname, '../')
2021

playground/tsconfig.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
"exclude": ["**/dist/**"],
44
"compilerOptions": {
55
"target": "es2019",
6+
"module": "esnext",
67
"outDir": "dist",
8+
"baseUrl": ".",
79
"allowJs": true,
810
"esModuleInterop": true,
9-
"moduleResolution": "node",
1011
"resolveJsonModule": true,
11-
"baseUrl": ".",
12+
"moduleResolution": "node",
13+
"skipLibCheck": true,
14+
"noUnusedLocals": true,
1215
"jsx": "preserve",
1316
"types": ["vite/client", "vitest/globals", "node"],
1417
"paths": {
File renamed without changes.

scripts/vitestSetup.ts renamed to playground/vitestSetup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
ViteDevServer
1414
} from 'vite'
1515
import { build, createServer, mergeConfig } from 'vite'
16-
import type { Browser, ConsoleMessage, Page } from 'playwright-chromium'
16+
import type { Browser, Page } from 'playwright-chromium'
1717
import type { RollupError, RollupWatcher, RollupWatcherEvent } from 'rollup'
1818
import type { File } from 'vitest'
1919
import { beforeAll } from 'vitest'

playground/vue-lib/__tests__/serve.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// this is automatically detected by scripts/vitestSetup.ts and will replace
1+
// this is automatically detected by playground/vitestSetup.ts and will replace
22
// the default e2e test serve behavior
33

44
export async function serve() {

scripts/tsconfig.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"$schema": "https://json.schemastore.org/tsconfig",
3+
"include": ["."],
34
"compilerOptions": {
45
"module": "commonjs",
5-
"moduleResolution": "node",
66
"target": "es2019",
7+
"moduleResolution": "node",
78
"strict": true,
89
"esModuleInterop": true,
910
"skipLibCheck": true,
10-
"forceConsistentCasingInFileNames": true,
11-
"types": ["node", "vitest/globals"]
11+
"noUnusedLocals": true,
12+
"forceConsistentCasingInFileNames": true
1213
}
1314
}

vitest.config.e2e.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export default defineConfig({
99
},
1010
test: {
1111
include: ['./playground/**/*.spec.[tj]s'],
12-
setupFiles: ['./scripts/vitestSetup.ts'],
13-
globalSetup: ['./scripts/vitestGlobalSetup.ts'],
12+
setupFiles: ['./playground/vitestSetup.ts'],
13+
globalSetup: ['./playground/vitestGlobalSetup.ts'],
1414
testTimeout: process.env.CI ? 50000 : 20000,
1515
globals: true,
1616
reporters: 'dot',

0 commit comments

Comments
 (0)