Skip to content

Commit

Permalink
chore: prefer-const (#2733)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Mar 31, 2021
1 parent aee8b37 commit 11de3c2
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 9 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ module.exports = {
'node/no-unpublished-import': 'off',
'node/no-unpublished-require': 'off',
'node/no-unsupported-features/es-syntax': 'off',
'no-process-exit': 'off'
'no-process-exit': 'off',
'prefer-const': [
'warn',
{
destructuring: 'all'
}
]
},
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/handleHotUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export async function handleHotUpdate({
}
}

let updateType = []
const updateType = []
if (needRerender) {
updateType.push(`template`)
// template is inlined into main, add main module instead
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export function updateStyle(id: string, content: string) {
}

export function removeStyle(id: string) {
let style = sheetsMap.get(id)
const style = sheetsMap.get(id)
if (style) {
if (style instanceof CSSStyleSheet) {
// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/importGlob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function transformImportGlob(
}
let base
let parentDepth = 0
let isAbsolute = pattern.startsWith('/')
const isAbsolute = pattern.startsWith('/')
if (isAbsolute) {
base = path.resolve(root)
pattern = pattern.slice(1)
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ function rewriteCssUrls(
replacer: CssUrlReplacer
): Promise<string> {
return asyncReplace(css, cssUrlRE, async (match) => {
let [matched, rawUrl] = match
const [matched, rawUrl] = match
return await doUrlReplace(rawUrl, matched, replacer)
})
}
Expand All @@ -774,7 +774,7 @@ function rewriteCssImageSet(
replacer: CssUrlReplacer
): Promise<string> {
return asyncReplace(css, cssImageSetRE, async (match) => {
let [matched, rawUrl] = match
const [matched, rawUrl] = match
const url = await processSrcSet(rawUrl, ({ url }) =>
doUrlReplace(url, matched, replacer)
)
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function resolvePlugin(baseOptions: InternalResolveOptions): Plugin {
// relative
if (id.startsWith('.') || (preferRelative && /^\w/.test(id))) {
const basedir = importer ? path.dirname(importer) : process.cwd()
let fsPath = path.resolve(basedir, id)
const fsPath = path.resolve(basedir, id)
// handle browser field mapping for relative imports

if ((res = tryResolveBrowserMapping(fsPath, importer, options, true))) {
Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export async function createServer(
const moduleGraph = new ModuleGraph(container)
const closeHttpServer = createServerCloseFn(httpServer)

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

const server: ViteDevServer = {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/middlewares/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function serveStaticMiddleware(
const serve = sirv(dir, sirvOptions)

return (req, res, next) => {
let url = req.url!
const url = req.url!

// only serve the file if it's not an html request
// so that html requests can fallthrough to our html middleware for
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/openBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function startBrowserProcess(browser: string | undefined, url: string) {
// Fallback to open
// (It will always open new tab)
try {
var options = { app: browser, url: true }
const options = { app: browser, url: true }
open(url, options).catch(() => {}) // Prevent `unhandledRejection` error.
return true
} catch (err) {
Expand Down

0 comments on commit 11de3c2

Please sign in to comment.