From c344865851b1f140f51b2f8d03821419114ac3b9 Mon Sep 17 00:00:00 2001 From: Jeff Yang <32727188+ydcjeff@users.noreply.github.com> Date: Sun, 28 Nov 2021 20:11:47 +0630 Subject: [PATCH] chore: format & check with prettier (#5869) --- .github/workflows/ci.yml | 3 +++ docs/config/index.md | 7 ++++++- docs/guide/api-plugin.md | 1 - .../index.html" | 1 - packages/playground/resolve/config-dep.js | 2 +- packages/playground/resolve/vite.config.js | 2 +- packages/playground/ssr-vue/src/pages/Home.vue | 5 ++++- packages/plugin-vue/src/main.ts | 4 +--- packages/vite/src/node/plugins/asset.ts | 6 +----- packages/vite/src/node/plugins/css.ts | 14 +++++++++----- 10 files changed, 26 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af17a906be4fdb..0e946cf9b4fda1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,3 +91,6 @@ jobs: - name: Lint run: pnpm run lint + + - name: Check formatting + run: pnpm prettier --check . diff --git a/docs/config/index.md b/docs/config/index.md index 647266448c52c2..fc3ec5b8752d48 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -238,7 +238,12 @@ export default defineConfig(async ({ command, mode }) => { /** * default: null */ - localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | null + localsConvention?: + | 'camelCase' + | 'camelCaseOnly' + | 'dashes' + | 'dashesOnly' + | null } ``` diff --git a/docs/guide/api-plugin.md b/docs/guide/api-plugin.md index ddccdd36c6296b..058130cec38414 100644 --- a/docs/guide/api-plugin.md +++ b/docs/guide/api-plugin.md @@ -40,7 +40,6 @@ Vite convention for virtual modules is to prefix the user-facing path with `virt Note that modules directly derived from a real file, as in the case of a script module in a Single File Component (like a .vue or .svelte SFC) don't need to follow this convention. SFCs generally generate a set of submodules when processed but the code in these can be mapped back to the filesystem. Using `\0` for these submodules would prevent sourcemaps from working correctly. - ## Plugins config Users will add plugins to the project `devDependencies` and configure them using the `plugins` array option. diff --git "a/packages/playground/html/unicode-path/\344\270\255\346\226\207-\343\201\253\343\201\273\343\202\223\343\201\224-\355\225\234\352\270\200-\360\237\214\225\360\237\214\226\360\237\214\227/index.html" "b/packages/playground/html/unicode-path/\344\270\255\346\226\207-\343\201\253\343\201\273\343\202\223\343\201\224-\355\225\234\352\270\200-\360\237\214\225\360\237\214\226\360\237\214\227/index.html" index 083283dab90380..f3c55befe1f315 100644 --- "a/packages/playground/html/unicode-path/\344\270\255\346\226\207-\343\201\253\343\201\273\343\202\223\343\201\224-\355\225\234\352\270\200-\360\237\214\225\360\237\214\226\360\237\214\227/index.html" +++ "b/packages/playground/html/unicode-path/\344\270\255\346\226\207-\343\201\253\343\201\273\343\202\223\343\201\224-\355\225\234\352\270\200-\360\237\214\225\360\237\214\226\360\237\214\227/index.html" @@ -1,2 +1 @@

unicode-path

- diff --git a/packages/playground/resolve/config-dep.js b/packages/playground/resolve/config-dep.js index 84de4f6be3796d..8bc3563c743bcd 100644 --- a/packages/playground/resolve/config-dep.js +++ b/packages/playground/resolve/config-dep.js @@ -1,3 +1,3 @@ module.exports = { a: 1 -} \ No newline at end of file +} diff --git a/packages/playground/resolve/vite.config.js b/packages/playground/resolve/vite.config.js index e69de3fa778397..be1b75e431383a 100644 --- a/packages/playground/resolve/vite.config.js +++ b/packages/playground/resolve/vite.config.js @@ -2,7 +2,7 @@ const virtualFile = '@virtual-file' const virtualId = '\0' + virtualFile const customVirtualFile = '@custom-virtual-file' -const { a } = require('./config-dep'); +const { a } = require('./config-dep') module.exports = { resolve: { diff --git a/packages/playground/ssr-vue/src/pages/Home.vue b/packages/playground/ssr-vue/src/pages/Home.vue index 1ef187c0361ffb..eef2ee086f8967 100644 --- a/packages/playground/ssr-vue/src/pages/Home.vue +++ b/packages/playground/ssr-vue/src/pages/Home.vue @@ -9,7 +9,10 @@

this will be styled with a font-face

{{ state.url }}

{{ state.protocol }}

-
encrypted message:

{{ encryptedMsg }}

+
+ encrypted message: +

{{ encryptedMsg }}

+
diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index ca2835d41be799..bb3076763844bd 100644 --- a/packages/plugin-vue/src/main.ts +++ b/packages/plugin-vue/src/main.ts @@ -269,9 +269,7 @@ async function genScriptCode( scriptCode = compiler.rewriteDefault( script.content, '_sfc_main', - script.lang === 'ts' - ? ['typescript'] - : undefined + script.lang === 'ts' ? ['typescript'] : undefined ) map = script.map } else { diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index 75dc3dcaa3f71d..2cd423ae528c79 100644 --- a/packages/vite/src/node/plugins/asset.ts +++ b/packages/vite/src/node/plugins/asset.ts @@ -98,11 +98,7 @@ export function assetPlugin(config: ResolvedConfig): Plugin { const file = getAssetFilename(hash, config) || this.getFileName(hash) registerAssetToChunk(chunk, file) const outputFilepath = config.base + file + postfix - s.overwrite( - match.index, - match.index + full.length, - outputFilepath - ) + s.overwrite(match.index, match.index + full.length, outputFilepath) } if (s) { diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 19181acd66f430..2a66e7b5cb4b93 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -1002,12 +1002,16 @@ function loadPreprocessor(lang: PreprocessLang, root: string): any { return (loadedPreprocessors[lang] = require(resolved)) } catch (e) { if (e.code === 'MODULE_NOT_FOUND') { - throw new Error(`Preprocessor dependency "${lang}" not found. Did you install it?`); + throw new Error( + `Preprocessor dependency "${lang}" not found. Did you install it?` + ) } else { - const message = new Error(`Preprocessor dependency "${lang}" failed to load:\n${e.message}`); - message.stack = e.stack + '\n' + message.stack; - throw message; - } + const message = new Error( + `Preprocessor dependency "${lang}" failed to load:\n${e.message}` + ) + message.stack = e.stack + '\n' + message.stack + throw message + } } }