diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index 578e00417db95b..48a0bd7773b0d7 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -89,7 +89,11 @@ module.exports = defineConfig({
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off', // maybe we should turn this on in a new PR
'@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR
- '@typescript-eslint/no-var-requires': 'off'
+ '@typescript-eslint/no-var-requires': 'off',
+ '@typescript-eslint/consistent-type-imports': [
+ 'error',
+ { prefer: 'type-imports' }
+ ]
},
overrides: [
{
diff --git a/packages/create-vite/__tests__/cli.spec.ts b/packages/create-vite/__tests__/cli.spec.ts
index 307ce36a5a2b35..c52998172149e6 100644
--- a/packages/create-vite/__tests__/cli.spec.ts
+++ b/packages/create-vite/__tests__/cli.spec.ts
@@ -1,5 +1,6 @@
/* eslint-disable node/no-extraneous-import */
-import { commandSync, ExecaSyncReturnValue, SyncOptions } from 'execa'
+import type { ExecaSyncReturnValue, SyncOptions } from 'execa'
+import { commandSync } from 'execa'
import { mkdirpSync, readdirSync, remove, writeFileSync } from 'fs-extra'
import { join } from 'path'
diff --git a/packages/create-vite/template-vue-ts/src/env.d.ts b/packages/create-vite/template-vue-ts/src/env.d.ts
index d27eb5a311f66a..aafef9509dd5c4 100644
--- a/packages/create-vite/template-vue-ts/src/env.d.ts
+++ b/packages/create-vite/template-vue-ts/src/env.d.ts
@@ -1,7 +1,7 @@
///
declare module '*.vue' {
- import { DefineComponent } from 'vue'
+ import type { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>
export default component
diff --git a/packages/playground/react-emotion/vite.config.ts b/packages/playground/react-emotion/vite.config.ts
index 5b60bc7e26d145..9364c8f616c2f5 100644
--- a/packages/playground/react-emotion/vite.config.ts
+++ b/packages/playground/react-emotion/vite.config.ts
@@ -1,6 +1,7 @@
import react from '@vitejs/plugin-react'
+import type { UserConfig } from 'vite'
-const config: import('vite').UserConfig = {
+const config: UserConfig = {
plugins: [
react({
jsxImportSource: '@emotion/react',
diff --git a/packages/playground/react/vite.config.ts b/packages/playground/react/vite.config.ts
index e8780031511dac..c6955a131d375f 100644
--- a/packages/playground/react/vite.config.ts
+++ b/packages/playground/react/vite.config.ts
@@ -1,6 +1,7 @@
import react from '@vitejs/plugin-react'
+import type { UserConfig } from 'vite'
-const config: import('vite').UserConfig = {
+const config: UserConfig = {
plugins: [react()],
build: {
// to make tests faster
diff --git a/packages/playground/shims.d.ts b/packages/playground/shims.d.ts
index 99ed8eb232b14f..ced8fb1ad585ae 100644
--- a/packages/playground/shims.d.ts
+++ b/packages/playground/shims.d.ts
@@ -4,7 +4,7 @@ declare module 'css-color-names' {
}
declare module '*.vue' {
- import { ComponentOptions } from 'vue'
+ import type { ComponentOptions } from 'vue'
const component: ComponentOptions
export default component
}
diff --git a/packages/playground/testUtils.ts b/packages/playground/testUtils.ts
index 2be13b1aee8cc4..3c6cba769b3ffe 100644
--- a/packages/playground/testUtils.ts
+++ b/packages/playground/testUtils.ts
@@ -5,7 +5,7 @@
import fs from 'fs'
import path from 'path'
import colors from 'css-color-names'
-import { ElementHandle } from 'playwright-chromium'
+import type { ElementHandle } from 'playwright-chromium'
import type { Manifest } from 'vite'
export function slash(p: string): string {
diff --git a/packages/playground/tsconfig-json/nested-with-extends/main.ts b/packages/playground/tsconfig-json/nested-with-extends/main.ts
index 557f496c4fe1dc..497708b4f4d226 100644
--- a/packages/playground/tsconfig-json/nested-with-extends/main.ts
+++ b/packages/playground/tsconfig-json/nested-with-extends/main.ts
@@ -1,4 +1,5 @@
// @ts-nocheck
+// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import { NestedWithExtendsTypeOnlyClass } from './not-used-type'
class NestedWithExtendsBase {
diff --git a/packages/playground/tsconfig-json/nested/main.ts b/packages/playground/tsconfig-json/nested/main.ts
index c3c23c44ef59f8..306efd0b1a87d9 100644
--- a/packages/playground/tsconfig-json/nested/main.ts
+++ b/packages/playground/tsconfig-json/nested/main.ts
@@ -1,4 +1,5 @@
// @ts-nocheck
+// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import { NestedTypeOnlyClass } from './not-used-type'
class NestedBase {
diff --git a/packages/playground/tsconfig-json/src/main.ts b/packages/playground/tsconfig-json/src/main.ts
index 05f1d1a02796ae..6ae1fe03b7d023 100644
--- a/packages/playground/tsconfig-json/src/main.ts
+++ b/packages/playground/tsconfig-json/src/main.ts
@@ -2,6 +2,7 @@
import '../nested/main'
import '../nested-with-extends/main'
+// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import { MainTypeOnlyClass } from './not-used-type'
class MainBase {
diff --git a/packages/playground/vue/CustomBlockPlugin.ts b/packages/playground/vue/CustomBlockPlugin.ts
index b434bbc24cf324..4f5def023902bc 100644
--- a/packages/playground/vue/CustomBlockPlugin.ts
+++ b/packages/playground/vue/CustomBlockPlugin.ts
@@ -1,4 +1,4 @@
-import { Plugin } from 'vite'
+import type { Plugin } from 'vite'
export const vueI18nPlugin: Plugin = {
name: 'vue-i18n',
diff --git a/packages/playground/worker/__tests__/worker.spec.ts b/packages/playground/worker/__tests__/worker.spec.ts
index 46b136edd66d2a..b84ea39fef5d0a 100644
--- a/packages/playground/worker/__tests__/worker.spec.ts
+++ b/packages/playground/worker/__tests__/worker.spec.ts
@@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'
import { untilUpdated, isBuild, testDir } from '../../testUtils'
-import { Page } from 'playwright-chromium'
+import type { Page } from 'playwright-chromium'
test('normal', async () => {
await page.click('.ping')
diff --git a/packages/plugin-legacy/index.d.ts b/packages/plugin-legacy/index.d.ts
index 612e6cacda9702..8f340f11cba074 100644
--- a/packages/plugin-legacy/index.d.ts
+++ b/packages/plugin-legacy/index.d.ts
@@ -1,4 +1,4 @@
-import { Plugin } from 'vite'
+import type { Plugin } from 'vite'
export interface Options {
/**
diff --git a/packages/plugin-react/src/jsx-runtime/babel-import-to-require.ts b/packages/plugin-react/src/jsx-runtime/babel-import-to-require.ts
index 936d88b0c8472b..dc7129862fd976 100644
--- a/packages/plugin-react/src/jsx-runtime/babel-import-to-require.ts
+++ b/packages/plugin-react/src/jsx-runtime/babel-import-to-require.ts
@@ -1,3 +1,4 @@
+import type * as babelCore from '@babel/core'
import type { types as t, Visitor } from '@babel/core'
/**
@@ -9,9 +10,7 @@ import type { types as t, Visitor } from '@babel/core'
*
* var _jsx = require("react/jsx-runtime").jsx
*/
-export function babelImportToRequire({
- types: t
-}: typeof import('@babel/core')): {
+export function babelImportToRequire({ types: t }: typeof babelCore): {
visitor: Visitor
} {
return {
diff --git a/packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts b/packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts
index da08f5327a4eae..669a0aeeced207 100644
--- a/packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts
+++ b/packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts
@@ -2,7 +2,7 @@
* https://github.com/flying-sheep/babel-plugin-transform-react-createelement-to-jsx
* @license GNU General Public License v3.0
*/
-import * as babel from '@babel/core'
+import type * as babel from '@babel/core'
/**
* Visitor factory for babel, converting React.createElement(...) to ...
diff --git a/packages/plugin-react/src/jsx-runtime/restore-jsx.ts b/packages/plugin-react/src/jsx-runtime/restore-jsx.ts
index 095f7c586e43a1..5cc7042a32c55e 100644
--- a/packages/plugin-react/src/jsx-runtime/restore-jsx.ts
+++ b/packages/plugin-react/src/jsx-runtime/restore-jsx.ts
@@ -1,3 +1,4 @@
+import type * as babelCore from '@babel/core'
import type { PluginItem, types as t } from '@babel/core'
type RestoredJSX = [result: t.File | null | undefined, isCommonJS: boolean]
@@ -8,7 +9,7 @@ const jsxNotFound: RestoredJSX = [null, false]
/** Restore JSX from `React.createElement` calls */
export async function restoreJSX(
- babel: typeof import('@babel/core'),
+ babel: typeof babelCore,
code: string,
filename: string
): Promise {
diff --git a/packages/plugin-vue-jsx/index.d.ts b/packages/plugin-vue-jsx/index.d.ts
index 2cac80ba56632e..a702c09baa8417 100644
--- a/packages/plugin-vue-jsx/index.d.ts
+++ b/packages/plugin-vue-jsx/index.d.ts
@@ -1,6 +1,6 @@
-import { Plugin } from 'vite'
-import { VueJSXPluginOptions } from '@vue/babel-plugin-jsx'
-import { FilterPattern } from '@rollup/pluginutils'
+import type { Plugin } from 'vite'
+import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx'
+import type { FilterPattern } from '@rollup/pluginutils'
declare interface FilterOptions {
include?: FilterPattern
diff --git a/packages/plugin-vue/src/compiler.ts b/packages/plugin-vue/src/compiler.ts
index 59350659b9a31e..0fb4eef7d2677a 100644
--- a/packages/plugin-vue/src/compiler.ts
+++ b/packages/plugin-vue/src/compiler.ts
@@ -5,7 +5,7 @@ declare module 'vue/compiler-sfc' {
}
}
-import * as _compiler from 'vue/compiler-sfc'
+import type * as _compiler from 'vue/compiler-sfc'
export function resolveCompiler(root: string): typeof _compiler {
// resolve from project root first, then fallback to peer dep (if any)
diff --git a/packages/plugin-vue/src/handleHotUpdate.ts b/packages/plugin-vue/src/handleHotUpdate.ts
index d93e647a1498bf..2bce3950563367 100644
--- a/packages/plugin-vue/src/handleHotUpdate.ts
+++ b/packages/plugin-vue/src/handleHotUpdate.ts
@@ -1,13 +1,13 @@
import _debug from 'debug'
-import { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc'
+import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc'
import {
createDescriptor,
getDescriptor,
setPrevDescriptor
} from './utils/descriptorCache'
import { getResolvedScript, setResolvedScript } from './script'
-import { ModuleNode, HmrContext } from 'vite'
-import { ResolvedOptions } from '.'
+import type { ModuleNode, HmrContext } from 'vite'
+import type { ResolvedOptions } from '.'
const debug = _debug('vite:hmr')
diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts
index 51ac057232aef0..f12dbd5b4cc0ef 100644
--- a/packages/plugin-vue/src/index.ts
+++ b/packages/plugin-vue/src/index.ts
@@ -1,13 +1,13 @@
import fs from 'fs'
-import { Plugin, ViteDevServer } from 'vite'
+import type { Plugin, ViteDevServer } from 'vite'
import { createFilter } from '@rollup/pluginutils'
-import {
+import type {
SFCBlock,
SFCScriptCompileOptions,
SFCStyleCompileOptions,
SFCTemplateCompileOptions
} from 'vue/compiler-sfc'
-import * as _compiler from 'vue/compiler-sfc'
+import type * as _compiler from 'vue/compiler-sfc'
import { resolveCompiler } from './compiler'
import { parseVueRequest } from './utils/query'
import { getDescriptor, getSrcDescriptor } from './utils/descriptorCache'
diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts
index 11dad79cc61733..29c5cffa4cfa81 100644
--- a/packages/plugin-vue/src/main.ts
+++ b/packages/plugin-vue/src/main.ts
@@ -1,18 +1,19 @@
import qs from 'querystring'
import path from 'path'
-import { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc'
-import { ResolvedOptions } from '.'
+import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc'
+import type { ResolvedOptions } from '.'
import {
createDescriptor,
getPrevDescriptor,
setSrcDescriptor
} from './utils/descriptorCache'
-import { PluginContext, SourceMap, TransformPluginContext } from 'rollup'
+import type { PluginContext, SourceMap, TransformPluginContext } from 'rollup'
import { normalizePath } from '@rollup/pluginutils'
import { resolveScript, isUseInlineTemplate } from './script'
import { transformTemplateInMain } from './template'
import { isOnlyTemplateChanged, isEqualBlock } from './handleHotUpdate'
-import { RawSourceMap, SourceMapConsumer, SourceMapGenerator } from 'source-map'
+import type { RawSourceMap } from 'source-map'
+import { SourceMapConsumer, SourceMapGenerator } from 'source-map'
import { createRollupError } from './utils/error'
import { transformWithEsbuild } from 'vite'
import { EXPORT_HELPER_ID } from './helper'
diff --git a/packages/plugin-vue/src/script.ts b/packages/plugin-vue/src/script.ts
index 241eca21eefea1..93610dcf7f6a36 100644
--- a/packages/plugin-vue/src/script.ts
+++ b/packages/plugin-vue/src/script.ts
@@ -1,5 +1,5 @@
-import { SFCDescriptor, SFCScriptBlock } from 'vue/compiler-sfc'
-import { ResolvedOptions } from '.'
+import type { SFCDescriptor, SFCScriptBlock } from 'vue/compiler-sfc'
+import type { ResolvedOptions } from '.'
import { resolveTemplateCompilerOptions } from './template'
// ssr and non ssr builds would output different script content
diff --git a/packages/plugin-vue/src/style.ts b/packages/plugin-vue/src/style.ts
index c27e16591f1de9..ad9d981412f52d 100644
--- a/packages/plugin-vue/src/style.ts
+++ b/packages/plugin-vue/src/style.ts
@@ -1,6 +1,6 @@
-import { SFCDescriptor } from 'vue/compiler-sfc'
-import { TransformPluginContext } from 'rollup'
-import { ResolvedOptions } from '.'
+import type { SFCDescriptor } from 'vue/compiler-sfc'
+import type { TransformPluginContext } from 'rollup'
+import type { ResolvedOptions } from '.'
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export async function transformStyle(
diff --git a/packages/plugin-vue/src/template.ts b/packages/plugin-vue/src/template.ts
index 9ee386b1c90d69..72e9588967556e 100644
--- a/packages/plugin-vue/src/template.ts
+++ b/packages/plugin-vue/src/template.ts
@@ -1,13 +1,13 @@
import path from 'path'
import slash from 'slash'
-import {
+import type {
SFCDescriptor,
SFCTemplateCompileOptions,
SFCTemplateCompileResults,
CompilerOptions
} from 'vue/compiler-sfc'
-import { PluginContext, TransformPluginContext } from 'rollup'
-import { ResolvedOptions } from '.'
+import type { PluginContext, TransformPluginContext } from 'rollup'
+import type { ResolvedOptions } from '.'
import { getResolvedScript } from './script'
import { createRollupError } from './utils/error'
diff --git a/packages/plugin-vue/src/utils/descriptorCache.ts b/packages/plugin-vue/src/utils/descriptorCache.ts
index 990f679d0ac08b..c0b77e72d3e613 100644
--- a/packages/plugin-vue/src/utils/descriptorCache.ts
+++ b/packages/plugin-vue/src/utils/descriptorCache.ts
@@ -2,8 +2,8 @@ import fs from 'fs'
import path from 'path'
import slash from 'slash'
import hash from 'hash-sum'
-import { CompilerError, SFCDescriptor } from 'vue/compiler-sfc'
-import { ResolvedOptions, VueQuery } from '..'
+import type { CompilerError, SFCDescriptor } from 'vue/compiler-sfc'
+import type { ResolvedOptions, VueQuery } from '..'
// compiler-sfc should be exported so it can be re-used
export interface SFCParseResult {
diff --git a/packages/plugin-vue/src/utils/error.ts b/packages/plugin-vue/src/utils/error.ts
index 1f3e48d7c7ed44..50999910fabb7b 100644
--- a/packages/plugin-vue/src/utils/error.ts
+++ b/packages/plugin-vue/src/utils/error.ts
@@ -1,5 +1,5 @@
-import { CompilerError } from 'vue/compiler-sfc'
-import { RollupError } from 'rollup'
+import type { CompilerError } from 'vue/compiler-sfc'
+import type { RollupError } from 'rollup'
export function createRollupError(
id: string,
diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts
index 188d6f1a5eb01b..c801b716d0318c 100644
--- a/packages/vite/src/client/client.ts
+++ b/packages/vite/src/client/client.ts
@@ -1,4 +1,4 @@
-import {
+import type {
ErrorPayload,
FullReloadPayload,
HMRPayload,
@@ -6,7 +6,7 @@ import {
Update,
UpdatePayload
} from 'types/hmrPayload'
-import { CustomEventName } from 'types/customEvent'
+import type { CustomEventName } from 'types/customEvent'
import { ErrorOverlay, overlayId } from './overlay'
// eslint-disable-next-line node/no-missing-import
import '@vite/env'
diff --git a/packages/vite/src/client/overlay.ts b/packages/vite/src/client/overlay.ts
index 536b9df167a83f..150c570fbc8aaf 100644
--- a/packages/vite/src/client/overlay.ts
+++ b/packages/vite/src/client/overlay.ts
@@ -1,4 +1,4 @@
-import { ErrorPayload } from 'types/hmrPayload'
+import type { ErrorPayload } from 'types/hmrPayload'
const template = /*html*/ `