Skip to content

Commit

Permalink
chore: prefer type imports (#5835)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Dec 19, 2021
1 parent 2f4c8e5 commit f2d9ae8
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 32 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-vue-jsx/index.d.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-vue/src/handleHotUpdate.ts
Original file line number Diff line number Diff line change
@@ -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')

Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-vue/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
9 changes: 5 additions & 4 deletions packages/plugin-vue/src/main.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue/src/script.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-vue/src/style.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-vue/src/template.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue/src/utils/descriptorCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue/src/utils/error.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
9 changes: 4 additions & 5 deletions scripts/jestPerTestSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import fs from 'fs-extra'
import * as http from 'http'
import { resolve, dirname } from 'path'
import sirv from 'sirv'
import {
createServer,
build,
import type {
ViteDevServer,
UserConfig,
PluginOption,
ResolvedConfig,
Logger
} from 'vite'
import { Page } from 'playwright-chromium'
import { createServer, build } from 'vite'
import type { Page } from 'playwright-chromium'
// eslint-disable-next-line node/no-extraneous-import
import { RollupError, RollupWatcher, RollupWatcherEvent } from 'rollup'
import type { RollupError, RollupWatcher, RollupWatcherEvent } from 'rollup'

const isBuildTest = !!process.env.VITE_TEST_BUILD

Expand Down

0 comments on commit f2d9ae8

Please sign in to comment.