Skip to content

Commit

Permalink
chore: enable typecheck for tests and scripts (#8114)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored May 11, 2022
1 parent 5f2f4b8 commit 2c80390
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ module.exports = defineConfig({
rules: {
'node/no-extraneous-import': 'off',
'node/no-extraneous-require': 'off',
'node/no-missing-import': 'off'
'node/no-missing-import': 'off',
'node/no-missing-require': 'off'
}
},
{
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,13 @@ jobs:
run: |
pnpm run ci-build-vite
pnpm run build-plugin-vue
pnpm run build-plugin-react
- name: Lint
run: pnpm run lint

- name: Check formatting
run: pnpm prettier --check .

- name: Typecheck
run: pnpm run typecheck
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"serve-docs": "vitepress serve docs",
"release": "ts-node scripts/release.ts",
"ci-publish": "ts-node scripts/publishCI.ts",
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit",
"build": "run-s build-vite build-plugin-vue build-plugin-react",
"build-vite": "cd packages/vite && npm run build",
"build-plugin-vue": "cd packages/plugin-vue && npm run build",
Expand Down
2 changes: 1 addition & 1 deletion playground/ssr-vue/__tests__/serve.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// this is automatically detected by scripts/vitestSetup.ts and will replace
// this is automatically detected by playground/vitestSetup.ts and will replace
// the default e2e test serve behavior

import path from 'path'
Expand Down
1 change: 1 addition & 0 deletions playground/ssr-vue/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ async function createServer(
render = (await vite.ssrLoadModule('/src/entry-server.js')).render
} else {
template = indexProd
// @ts-ignore
render = require('./dist/server/entry-server.js').render
}

Expand Down
5 changes: 3 additions & 2 deletions playground/test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/triple-slash-reference */
// test utils used in e2e tests for playgrounds.
// `import { getColor } from '~utils'`

Expand All @@ -12,9 +13,9 @@ import type { Manifest } from 'vite'
import { normalizePath } from 'vite'
import { fromComment } from 'convert-source-map'
import { expect } from 'vitest'
import { page } from '../scripts/vitestSetup'
import { page } from './vitestSetup'

export * from '../scripts/vitestSetup'
export * from './vitestSetup'

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

Expand Down
7 changes: 5 additions & 2 deletions playground/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
"exclude": ["**/dist/**"],
"compilerOptions": {
"target": "es2019",
"module": "esnext",
"outDir": "dist",
"baseUrl": ".",
"allowJs": true,
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"baseUrl": ".",
"moduleResolution": "node",
"skipLibCheck": true,
"noUnusedLocals": true,
"jsx": "preserve",
"types": ["vite/client", "vitest/globals", "node"],
"paths": {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/vitestSetup.ts → playground/vitestSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
ViteDevServer
} from 'vite'
import { build, createServer, mergeConfig } from 'vite'
import type { Browser, ConsoleMessage, Page } from 'playwright-chromium'
import type { Browser, Page } from 'playwright-chromium'
import type { RollupError, RollupWatcher, RollupWatcherEvent } from 'rollup'
import type { File } from 'vitest'
import { beforeAll } from 'vitest'
Expand Down
2 changes: 1 addition & 1 deletion playground/vue-lib/__tests__/serve.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// this is automatically detected by scripts/vitestSetup.ts and will replace
// this is automatically detected by playground/vitestSetup.ts and will replace
// the default e2e test serve behavior

export async function serve() {
Expand Down
7 changes: 4 additions & 3 deletions scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"include": ["."],
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es2019",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"types": ["node", "vitest/globals"]
"noUnusedLocals": true,
"forceConsistentCasingInFileNames": true
}
}
4 changes: 2 additions & 2 deletions vitest.config.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default defineConfig({
},
test: {
include: ['./playground/**/*.spec.[tj]s'],
setupFiles: ['./scripts/vitestSetup.ts'],
globalSetup: ['./scripts/vitestGlobalSetup.ts'],
setupFiles: ['./playground/vitestSetup.ts'],
globalSetup: ['./playground/vitestGlobalSetup.ts'],
testTimeout: process.env.CI ? 50000 : 20000,
globals: true,
reporters: 'dot',
Expand Down

0 comments on commit 2c80390

Please sign in to comment.