Skip to content

Commit 11de3c2

Browse files
authored
chore: prefer-const (#2733)
1 parent aee8b37 commit 11de3c2

File tree

9 files changed

+16
-9
lines changed

9 files changed

+16
-9
lines changed

.eslintrc.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ module.exports = {
5151
'node/no-unpublished-import': 'off',
5252
'node/no-unpublished-require': 'off',
5353
'node/no-unsupported-features/es-syntax': 'off',
54-
'no-process-exit': 'off'
54+
'no-process-exit': 'off',
55+
'prefer-const': [
56+
'warn',
57+
{
58+
destructuring: 'all'
59+
}
60+
]
5561
},
5662
overrides: [
5763
{

packages/plugin-vue/src/handleHotUpdate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export async function handleHotUpdate({
127127
}
128128
}
129129

130-
let updateType = []
130+
const updateType = []
131131
if (needRerender) {
132132
updateType.push(`template`)
133133
// template is inlined into main, add main module instead

packages/vite/src/client/client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export function updateStyle(id: string, content: string) {
236236
}
237237

238238
export function removeStyle(id: string) {
239-
let style = sheetsMap.get(id)
239+
const style = sheetsMap.get(id)
240240
if (style) {
241241
if (style instanceof CSSStyleSheet) {
242242
// @ts-ignore

packages/vite/src/node/importGlob.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function transformImportGlob(
4242
}
4343
let base
4444
let parentDepth = 0
45-
let isAbsolute = pattern.startsWith('/')
45+
const isAbsolute = pattern.startsWith('/')
4646
if (isAbsolute) {
4747
base = path.resolve(root)
4848
pattern = pattern.slice(1)

packages/vite/src/node/plugins/css.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ function rewriteCssUrls(
764764
replacer: CssUrlReplacer
765765
): Promise<string> {
766766
return asyncReplace(css, cssUrlRE, async (match) => {
767-
let [matched, rawUrl] = match
767+
const [matched, rawUrl] = match
768768
return await doUrlReplace(rawUrl, matched, replacer)
769769
})
770770
}
@@ -774,7 +774,7 @@ function rewriteCssImageSet(
774774
replacer: CssUrlReplacer
775775
): Promise<string> {
776776
return asyncReplace(css, cssImageSetRE, async (match) => {
777-
let [matched, rawUrl] = match
777+
const [matched, rawUrl] = match
778778
const url = await processSrcSet(rawUrl, ({ url }) =>
779779
doUrlReplace(url, matched, replacer)
780780
)

packages/vite/src/node/plugins/resolve.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function resolvePlugin(baseOptions: InternalResolveOptions): Plugin {
121121
// relative
122122
if (id.startsWith('.') || (preferRelative && /^\w/.test(id))) {
123123
const basedir = importer ? path.dirname(importer) : process.cwd()
124-
let fsPath = path.resolve(basedir, id)
124+
const fsPath = path.resolve(basedir, id)
125125
// handle browser field mapping for relative imports
126126

127127
if ((res = tryResolveBrowserMapping(fsPath, importer, options, true))) {

packages/vite/src/node/server/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ export async function createServer(
285285
const moduleGraph = new ModuleGraph(container)
286286
const closeHttpServer = createServerCloseFn(httpServer)
287287

288+
// eslint-disable-next-line prefer-const
288289
let exitProcess: () => void
289290

290291
const server: ViteDevServer = {

packages/vite/src/node/server/middlewares/static.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function serveStaticMiddleware(
4141
const serve = sirv(dir, sirvOptions)
4242

4343
return (req, res, next) => {
44-
let url = req.url!
44+
const url = req.url!
4545

4646
// only serve the file if it's not an html request
4747
// so that html requests can fallthrough to our html middleware for

packages/vite/src/node/server/openBrowser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function startBrowserProcess(browser: string | undefined, url: string) {
9191
// Fallback to open
9292
// (It will always open new tab)
9393
try {
94-
var options = { app: browser, url: true }
94+
const options = { app: browser, url: true }
9595
open(url, options).catch(() => {}) // Prevent `unhandledRejection` error.
9696
return true
9797
} catch (err) {

0 commit comments

Comments
 (0)