mirror of
https://github.com/vitejs/vite.git
synced 2024-11-22 07:09:05 +00:00
chore: enable import/no-duplicates
eslint rule (#8199)
This commit is contained in:
parent
8d478df78d
commit
11243de9eb
@ -89,6 +89,7 @@ module.exports = defineConfig({
|
||||
{ prefer: 'type-imports' }
|
||||
],
|
||||
|
||||
'import/no-duplicates': 'error',
|
||||
'import/order': 'error',
|
||||
'sort-imports': [
|
||||
'error',
|
||||
|
@ -1,5 +1,4 @@
|
||||
import type * as babelCore from '@babel/core'
|
||||
import type { Visitor, types as t } from '@babel/core'
|
||||
|
||||
/**
|
||||
* Replace this:
|
||||
@ -11,13 +10,13 @@ import type { Visitor, types as t } from '@babel/core'
|
||||
* var _jsx = require("react/jsx-runtime").jsx
|
||||
*/
|
||||
export function babelImportToRequire({ types: t }: typeof babelCore): {
|
||||
visitor: Visitor
|
||||
visitor: babelCore.Visitor
|
||||
} {
|
||||
return {
|
||||
visitor: {
|
||||
ImportDeclaration(path) {
|
||||
const decl = path.node
|
||||
const spec = decl.specifiers[0] as t.ImportSpecifier
|
||||
const spec = decl.specifiers[0] as babelCore.types.ImportSpecifier
|
||||
|
||||
path.replaceWith(
|
||||
t.variableDeclaration('var', [
|
||||
|
@ -1,9 +1,11 @@
|
||||
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]
|
||||
type RestoredJSX = [
|
||||
result: babelCore.types.File | null | undefined,
|
||||
isCommonJS: boolean
|
||||
]
|
||||
|
||||
let babelRestoreJSX: Promise<PluginItem> | undefined
|
||||
let babelRestoreJSX: Promise<babelCore.PluginItem> | undefined
|
||||
|
||||
const jsxNotFound: RestoredJSX = [null, false]
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import fs from 'fs'
|
||||
import type { Plugin, ViteDevServer } from 'vite'
|
||||
import { createFilter } from '@rollup/pluginutils'
|
||||
/* eslint-disable import/no-duplicates */
|
||||
import type {
|
||||
SFCBlock,
|
||||
SFCScriptCompileOptions,
|
||||
@ -8,6 +9,7 @@ import type {
|
||||
SFCTemplateCompileOptions
|
||||
} from 'vue/compiler-sfc'
|
||||
import type * as _compiler from 'vue/compiler-sfc'
|
||||
/* eslint-enable import/no-duplicates */
|
||||
import { resolveCompiler } from './compiler'
|
||||
import { parseVueRequest } from './utils/query'
|
||||
import { getDescriptor, getSrcDescriptor } from './utils/descriptorCache'
|
||||
|
@ -6,9 +6,8 @@ import type { OutputOptions, PluginContext } from 'rollup'
|
||||
import MagicString from 'magic-string'
|
||||
import type { Plugin } from '../plugin'
|
||||
import type { ResolvedConfig } from '../config'
|
||||
import { cleanUrl } from '../utils'
|
||||
import { cleanUrl, getHash, normalizePath } from '../utils'
|
||||
import { FS_PREFIX } from '../constants'
|
||||
import { getHash, normalizePath } from '../utils'
|
||||
|
||||
export const assetUrlRE = /__VITE_ASSET__([a-z\d]{8})__(?:\$_(.*?)__)?/g
|
||||
|
||||
|
@ -32,6 +32,7 @@ import {
|
||||
asyncReplace,
|
||||
cleanUrl,
|
||||
combineSourcemaps,
|
||||
emptyCssComments,
|
||||
generateCodeFrame,
|
||||
getHash,
|
||||
isDataUrl,
|
||||
@ -41,7 +42,6 @@ import {
|
||||
parseRequest,
|
||||
processSrcSet
|
||||
} from '../utils'
|
||||
import { emptyCssComments } from '../utils'
|
||||
import type { Logger } from '../logger'
|
||||
import { addToHTMLProxyTransformResult } from './html'
|
||||
import {
|
||||
|
@ -12,15 +12,15 @@ import type { SourceMap } from 'rollup'
|
||||
import { createFilter } from '@rollup/pluginutils'
|
||||
import type { TSConfckParseOptions, TSConfckParseResult } from 'tsconfck'
|
||||
import { TSConfckParseError, findAll, parse } from 'tsconfck'
|
||||
import { combineSourcemaps } from '../utils'
|
||||
import type { ResolvedConfig, ViteDevServer } from '..'
|
||||
import {
|
||||
cleanUrl,
|
||||
combineSourcemaps,
|
||||
createDebugger,
|
||||
ensureWatchedFile,
|
||||
generateCodeFrame,
|
||||
toUpperCaseDriveLetter
|
||||
} from '../utils'
|
||||
import type { ResolvedConfig, ViteDevServer } from '..'
|
||||
import type { Plugin } from '../plugin'
|
||||
import { searchForWorkspaceRoot } from '..'
|
||||
|
||||
|
@ -5,8 +5,7 @@ import type { RollupError } from 'rollup'
|
||||
import { stripLiteral } from 'strip-literal'
|
||||
import type { ResolvedConfig } from '../config'
|
||||
import type { Plugin } from '../plugin'
|
||||
import { cleanUrl, injectQuery } from '../utils'
|
||||
import { parseRequest } from '../utils'
|
||||
import { cleanUrl, injectQuery, parseRequest } from '../utils'
|
||||
import { ENV_ENTRY, ENV_PUBLIC_PATH } from '../constants'
|
||||
import type { ViteDevServer } from '..'
|
||||
import { workerFileToUrl } from './worker'
|
||||
|
@ -1,5 +1,4 @@
|
||||
import path from 'path'
|
||||
import type { Server } from 'http'
|
||||
import type * as http from 'http'
|
||||
import sirv from 'sirv'
|
||||
import connect from 'connect'
|
||||
@ -47,7 +46,7 @@ export interface PreviewServer {
|
||||
/**
|
||||
* native Node http server instance
|
||||
*/
|
||||
httpServer: Server
|
||||
httpServer: http.Server
|
||||
/**
|
||||
* Print server urls
|
||||
*/
|
||||
|
@ -2,7 +2,6 @@ import fs from 'fs'
|
||||
import path from 'path'
|
||||
import type * as net from 'net'
|
||||
import type * as http from 'http'
|
||||
import type { AddressInfo } from 'net'
|
||||
import { performance } from 'perf_hooks'
|
||||
import connect from 'connect'
|
||||
import corsMiddleware from 'cors'
|
||||
@ -16,7 +15,7 @@ import type { CommonServerOptions } from '../http'
|
||||
import { httpServerStart, resolveHttpServer, resolveHttpsConfig } from '../http'
|
||||
import type { InlineConfig, ResolvedConfig } from '../config'
|
||||
import { mergeConfig, resolveConfig } from '../config'
|
||||
import { isParentDirectory, normalizePath } from '../utils'
|
||||
import { isParentDirectory, normalizePath, resolveHostname } from '../utils'
|
||||
import { ssrLoadModule } from '../ssr/ssrModuleLoader'
|
||||
import { resolveSSRExternal } from '../ssr/ssrExternal'
|
||||
import {
|
||||
@ -26,7 +25,6 @@ import {
|
||||
import { ssrTransform } from '../ssr/ssrTransform'
|
||||
import { createOptimizedDeps } from '../optimizer/registerMissing'
|
||||
import type { OptimizedDeps } from '../optimizer'
|
||||
import { resolveHostname } from '../utils'
|
||||
import { CLIENT_DIR } from '../constants'
|
||||
import type { Logger } from '../logger'
|
||||
import { printCommonServerUrls } from '../logger'
|
||||
@ -452,7 +450,7 @@ export async function createServer(
|
||||
if (!middlewareMode && httpServer) {
|
||||
httpServer.once('listening', () => {
|
||||
// update actual port since this may be different from initial value
|
||||
serverConfig.port = (httpServer.address() as AddressInfo).port
|
||||
serverConfig.port = (httpServer.address() as net.AddressInfo).port
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,9 @@ import type { FSWatcher } from 'chokidar'
|
||||
import colors from 'picocolors'
|
||||
import type * as postcss from 'postcss'
|
||||
import type { Plugin } from '../plugin'
|
||||
import { cleanUrl, combineSourcemaps } from '../utils'
|
||||
import {
|
||||
cleanUrl,
|
||||
combineSourcemaps,
|
||||
createDebugger,
|
||||
ensureWatchedFile,
|
||||
generateCodeFrame,
|
||||
|
@ -1,6 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import { dirname } from 'path'
|
||||
import { join } from 'path'
|
||||
import { dirname, join } from 'path'
|
||||
import { isFileReadable } from '../utils'
|
||||
|
||||
// https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
|
||||
|
@ -3,10 +3,9 @@ import os from 'os'
|
||||
import path from 'path'
|
||||
import { createHash } from 'crypto'
|
||||
import { promisify } from 'util'
|
||||
import { URL, pathToFileURL } from 'url'
|
||||
import { URL, URLSearchParams, pathToFileURL } from 'url'
|
||||
import { builtinModules } from 'module'
|
||||
import { performance } from 'perf_hooks'
|
||||
import { URLSearchParams } from 'url'
|
||||
import resolve from 'resolve'
|
||||
import type { FSWatcher } from 'chokidar'
|
||||
import remapping from '@ampproject/remapping'
|
||||
|
Loading…
Reference in New Issue
Block a user