mirror of
https://github.com/youzan/vant.git
synced 2025-10-16 08:00:34 +00:00
chore: bump prettier v3 and format all code (#12111)
* chore: bump prettier v3 and format all code * chore: mjs config * chore: revert * chore: revert * chore: update lock
This commit is contained in:
@@ -35,7 +35,7 @@ const transformSFC = (code, path) => {
|
||||
if (descriptor.script) {
|
||||
const content = descriptor.script.content.replace(
|
||||
'export default',
|
||||
'const script ='
|
||||
'const script =',
|
||||
);
|
||||
output.push(content);
|
||||
} else if (descriptor.scriptSetup) {
|
||||
@@ -88,7 +88,7 @@ module.exports = {
|
||||
code = transformJsx(code, path);
|
||||
}
|
||||
return {
|
||||
code: transformScript(code)
|
||||
code: transformScript(code),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
@@ -14,14 +14,12 @@ function getPostcssPlugins(rootConfig) {
|
||||
const plugins = rootConfig.plugins || [];
|
||||
|
||||
if (Array.isArray(plugins)) {
|
||||
const hasAutoprefixerPlugin = plugins.find(
|
||||
(plugin) => {
|
||||
if (typeof plugin === 'object') {
|
||||
return plugin.postcssPlugin === 'autoprefixer';
|
||||
}
|
||||
return plugin === 'autoprefixer';
|
||||
const hasAutoprefixerPlugin = plugins.find((plugin) => {
|
||||
if (typeof plugin === 'object') {
|
||||
return plugin.postcssPlugin === 'autoprefixer';
|
||||
}
|
||||
);
|
||||
return plugin === 'autoprefixer';
|
||||
});
|
||||
if (hasAutoprefixerPlugin) {
|
||||
return plugins;
|
||||
}
|
||||
|
@@ -81,7 +81,7 @@
|
||||
"picocolors": "^1.0.0",
|
||||
"postcss": "^8.4.23",
|
||||
"postcss-load-config": "^4.0.1",
|
||||
"prettier": "^2.7.1",
|
||||
"prettier": "^3.0.0",
|
||||
"release-it": "^15.4.1",
|
||||
"terser": "^5.16.1",
|
||||
"transliteration": "^2.3.5",
|
||||
|
@@ -40,7 +40,7 @@ export function syncPathToParent() {
|
||||
type: 'replacePath',
|
||||
value: getCurrentDir(),
|
||||
},
|
||||
'*'
|
||||
'*',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export function syncPathToChild() {
|
||||
type: 'replacePath',
|
||||
value: getCurrentDir(),
|
||||
},
|
||||
'*'
|
||||
'*',
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export function syncThemeToChild(theme) {
|
||||
type: 'updateTheme',
|
||||
value: theme,
|
||||
},
|
||||
'*'
|
||||
'*',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@@ -6,9 +6,20 @@ body {
|
||||
overflow-x: auto;
|
||||
color: var(--van-doc-text-color-2);
|
||||
font-size: 16px;
|
||||
font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue',
|
||||
Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui',
|
||||
'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
|
||||
font-family:
|
||||
'Open Sans',
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
'Helvetica Neue',
|
||||
Helvetica,
|
||||
Segoe UI,
|
||||
Arial,
|
||||
Roboto,
|
||||
'PingFang SC',
|
||||
'miui',
|
||||
'Hiragino Sans GB',
|
||||
'Microsoft Yahei',
|
||||
sans-serif;
|
||||
background-color: var(--van-doc-background);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
@@ -107,11 +107,11 @@ export default {
|
||||
|
||||
const navItems = this.config.nav.reduce(
|
||||
(result, nav) => [...result, ...nav.items],
|
||||
[]
|
||||
[],
|
||||
);
|
||||
|
||||
const current = navItems.find(
|
||||
(item) => item.path === this.$route.meta.name
|
||||
(item) => item.path === this.$route.meta.name,
|
||||
);
|
||||
|
||||
if (current && current.title) {
|
||||
|
@@ -108,7 +108,9 @@ export default {
|
||||
cursor: pointer;
|
||||
opacity: 0.6;
|
||||
outline: none;
|
||||
transition: opacity 0.2s, background 0.2s;
|
||||
transition:
|
||||
opacity 0.2s,
|
||||
background 0.2s;
|
||||
|
||||
// expand click area
|
||||
&::after {
|
||||
|
@@ -142,7 +142,7 @@ export default {
|
||||
const action = val ? 'add' : 'remove';
|
||||
document.body[`${action}EventListener`](
|
||||
'click',
|
||||
this.checkHideVersionPop
|
||||
this.checkHideVersionPop,
|
||||
);
|
||||
|
||||
this.showVersionPop = val;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
@@ -15,10 +15,7 @@
|
||||
<meta http-equiv="Cache-Control" content="no-cache" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<% if (headHtml) { %>
|
||||
<%= headHtml %>
|
||||
<% } %>
|
||||
<% if (baiduAnalytics) { %>
|
||||
<% if (headHtml) { %> <%= headHtml %> <% } %> <% if (baiduAnalytics) { %>
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
(function () {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
@@ -15,16 +15,12 @@
|
||||
<meta http-equiv="Cache-Control" content="no-cache" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<% if (headHtml) { %>
|
||||
<%= headHtml %>
|
||||
<% } %>
|
||||
<% if (enableVConsole) { %>
|
||||
<% if (headHtml) { %> <%= headHtml %> <% } %> <% if (enableVConsole) { %>
|
||||
<script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
|
||||
<script>
|
||||
var vConsole = new window.VConsole();
|
||||
</script>
|
||||
<% } %>
|
||||
<% if (baiduAnalytics) { %>
|
||||
<% } %> <% if (baiduAnalytics) { %>
|
||||
<script>
|
||||
// avoid to load analytics in iframe
|
||||
if (window.top === window) {
|
||||
|
@@ -31,17 +31,17 @@ export default {
|
||||
if (darkModeClass) {
|
||||
document.documentElement.classList.toggle(
|
||||
darkModeClass,
|
||||
newVal === 'dark'
|
||||
newVal === 'dark',
|
||||
);
|
||||
}
|
||||
if (lightModeClass) {
|
||||
document.documentElement.classList.toggle(
|
||||
lightModeClass,
|
||||
newVal === 'light'
|
||||
newVal === 'light',
|
||||
);
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
{ immediate: true },
|
||||
);
|
||||
},
|
||||
};
|
||||
|
@@ -27,27 +27,27 @@ program
|
||||
.description('Run unit tests through jest')
|
||||
.option(
|
||||
'--watch',
|
||||
'Watch files for changes and rerun tests related to changed files'
|
||||
'Watch files for changes and rerun tests related to changed files',
|
||||
)
|
||||
.option(
|
||||
'--clearCache',
|
||||
'Clears the configured Jest cache directory and then exits'
|
||||
'Clears the configured Jest cache directory and then exits',
|
||||
)
|
||||
.option(
|
||||
'--changedSince <changedSince>',
|
||||
'Runs tests related to the changes since the provided branch or commit hash'
|
||||
'Runs tests related to the changes since the provided branch or commit hash',
|
||||
)
|
||||
.option(
|
||||
'--logHeapUsage',
|
||||
'Logs the heap usage after every test. Useful to debug memory leaks'
|
||||
'Logs the heap usage after every test. Useful to debug memory leaks',
|
||||
)
|
||||
.option(
|
||||
'--runInBand',
|
||||
'Run all tests serially in the current process, rather than creating a worker pool of child processes that run tests'
|
||||
'Run all tests serially in the current process, rather than creating a worker pool of child processes that run tests',
|
||||
)
|
||||
.option(
|
||||
'--updateSnapshot',
|
||||
'Re-record every snapshot that fails during this test run'
|
||||
'Re-record every snapshot that fails during this test run',
|
||||
)
|
||||
.option('--debug', 'Print debugging info about your Jest config')
|
||||
.action(async (options) => {
|
||||
|
@@ -66,7 +66,7 @@ async function preCompileDir(dir: string) {
|
||||
return compileSfc(filePath);
|
||||
}
|
||||
return Promise.resolve();
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ async function compileDir(dir: string, format: Format) {
|
||||
return isDir(filePath)
|
||||
? compileDir(filePath, format)
|
||||
: compileFile(filePath, format);
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -64,7 +64,7 @@ export async function changelog(): Promise<void> {
|
||||
headerPartial,
|
||||
commitPartial,
|
||||
transform,
|
||||
}
|
||||
},
|
||||
)
|
||||
.pipe(createWriteStream(DIST_FILE))
|
||||
.on('close', () => {
|
||||
|
@@ -11,7 +11,7 @@ type RunCommandMessages = {
|
||||
function runCommand(
|
||||
cmd: string,
|
||||
options: string[],
|
||||
messages: RunCommandMessages
|
||||
messages: RunCommandMessages,
|
||||
) {
|
||||
const spinner = createSpinner(messages.start).start();
|
||||
|
||||
@@ -40,7 +40,7 @@ function eslint() {
|
||||
start: 'Running eslint...',
|
||||
succeed: 'ESLint Passed.',
|
||||
failed: 'ESLint failed!',
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -39,6 +39,6 @@ const IMPORT_STYLE_RE = /import\s+?(?:(?:".*?")|(?:'.*?'))[\s]*?(?:;|$|)/g;
|
||||
// "import 'a.less';" => "import 'a.css';"
|
||||
export function replaceCSSImportExt(code: string) {
|
||||
return code.replace(IMPORT_STYLE_RE, (str) =>
|
||||
str.replace(`.${CSS_LANG}`, '.css')
|
||||
str.replace(`.${CSS_LANG}`, '.css'),
|
||||
);
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ export function getComponents() {
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export function camelize(str: string): string {
|
||||
export function pascalize(str: string): string {
|
||||
return camelize(str).replace(
|
||||
pascalizeRE,
|
||||
(_, c1, c2) => c1.toUpperCase() + c2
|
||||
(_, c1, c2) => c1.toUpperCase() + c2,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ export function smartOutputFile(filePath: string, content: string) {
|
||||
|
||||
export async function mergeCustomViteConfig(
|
||||
config: InlineConfig,
|
||||
mode: 'production' | 'development'
|
||||
mode: 'production' | 'development',
|
||||
): Promise<InlineConfig> {
|
||||
const vantConfig = getVantConfig();
|
||||
const configureVite = vantConfig.build?.configureVite;
|
||||
@@ -127,7 +127,7 @@ export async function mergeCustomViteConfig(
|
||||
command: mode === 'development' ? 'serve' : 'build',
|
||||
},
|
||||
undefined,
|
||||
process.cwd()
|
||||
process.cwd(),
|
||||
);
|
||||
|
||||
if (configureVite) {
|
||||
|
@@ -38,9 +38,9 @@ export async function compileBundles() {
|
||||
build(
|
||||
await mergeCustomViteConfig(
|
||||
getViteConfigForPackage(config),
|
||||
'production'
|
||||
)
|
||||
)
|
||||
)
|
||||
'production',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ const { readFileSync, removeSync, outputFileSync } = fse;
|
||||
|
||||
export async function compileScript(
|
||||
filePath: string,
|
||||
format: Format
|
||||
format: Format,
|
||||
): Promise<void> {
|
||||
if (filePath.includes('.d.ts')) {
|
||||
return;
|
||||
|
@@ -127,7 +127,7 @@ export async function compileSfc(filePath: string): Promise<any> {
|
||||
}
|
||||
|
||||
outputFile(scriptFilePath, script).then(resolve);
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ export async function compileSfc(filePath: string): Promise<any> {
|
||||
// }
|
||||
|
||||
return outputFile(cssFilePath, styleSource);
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
return Promise.all(tasks);
|
||||
|
@@ -31,13 +31,13 @@ export async function compileSite(production = false) {
|
||||
if (production) {
|
||||
const config = await mergeCustomViteConfig(
|
||||
getViteConfigForSiteProd(),
|
||||
'production'
|
||||
'production',
|
||||
);
|
||||
await build(config);
|
||||
} else {
|
||||
const config = await mergeCustomViteConfig(
|
||||
getViteConfigForSiteDev(),
|
||||
'development'
|
||||
'development',
|
||||
);
|
||||
const server = await createServer(config);
|
||||
await server.listen(config.server?.port);
|
||||
|
@@ -81,7 +81,7 @@ function genEntry(params: {
|
||||
}
|
||||
|
||||
export function genComponentStyle(
|
||||
options: { cache: boolean } = { cache: true }
|
||||
options: { cache: boolean } = { cache: true },
|
||||
) {
|
||||
if (!options.cache) {
|
||||
const require = createRequire(import.meta.url);
|
||||
|
@@ -20,7 +20,7 @@ function getPathByName(name: string, pathResolver?: PathResolver) {
|
||||
function genImports(
|
||||
names: string[],
|
||||
pathResolver?: PathResolver,
|
||||
namedExport?: boolean
|
||||
namedExport?: boolean,
|
||||
): string {
|
||||
return names
|
||||
.map((name) => {
|
||||
@@ -36,7 +36,7 @@ function genImports(
|
||||
function genExports(
|
||||
names: string[],
|
||||
pathResolver?: PathResolver,
|
||||
namedExport?: boolean
|
||||
namedExport?: boolean,
|
||||
): string {
|
||||
if (namedExport) {
|
||||
const exports = names
|
||||
|
@@ -38,7 +38,7 @@ function genConfig(demos: DemoItem[]) {
|
||||
function demoFilter(nav: any[]) {
|
||||
return nav.filter((group) => {
|
||||
group.items = group.items.filter((item: any) =>
|
||||
demoNames.includes(item.path)
|
||||
demoNames.includes(item.path),
|
||||
);
|
||||
return group.items.length;
|
||||
});
|
||||
|
@@ -106,13 +106,13 @@ export async function genStyleDepsMap() {
|
||||
|
||||
Object.keys(map).forEach((key) => {
|
||||
map[key] = map[key].sort(
|
||||
(a, b) => sequence.indexOf(a) - sequence.indexOf(b)
|
||||
(a, b) => sequence.indexOf(a) - sequence.indexOf(b),
|
||||
);
|
||||
});
|
||||
|
||||
smartOutputFile(
|
||||
STYLE_DEPS_JSON_FILE,
|
||||
JSON.stringify({ map, sequence }, null, 2)
|
||||
JSON.stringify({ map, sequence }, null, 2),
|
||||
);
|
||||
|
||||
resolve();
|
||||
|
@@ -105,7 +105,7 @@ export function getDeps(filePath: string) {
|
||||
export function replaceScriptImportExt(
|
||||
code: string,
|
||||
filePath: string,
|
||||
ext: string
|
||||
ext: string,
|
||||
) {
|
||||
const imports = [...matchImports(code), ...matchExportFroms(code)];
|
||||
|
||||
@@ -132,7 +132,6 @@ export function replaceScriptImportExt(
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const pathInfo = getPathByImport(line, filePath);
|
||||
|
||||
if (pathInfo) {
|
||||
@@ -141,7 +140,7 @@ export function replaceScriptImportExt(
|
||||
if (pathInfo.isIndex) {
|
||||
const newLine = line.replace(
|
||||
relativePath,
|
||||
`${relativePath}/index${ext}`
|
||||
`${relativePath}/index${ext}`,
|
||||
);
|
||||
|
||||
updateImport(index, newLine);
|
||||
|
@@ -77,7 +77,7 @@ function findTag(vueTags: VueTag[], name: string) {
|
||||
export function formatter(
|
||||
vueTags: VueTag[],
|
||||
articles: Articles,
|
||||
tagPrefix = ''
|
||||
tagPrefix = '',
|
||||
) {
|
||||
if (!articles.length) {
|
||||
return;
|
||||
|
@@ -36,7 +36,7 @@ export async function parseAndWrite(options: Options) {
|
||||
const webTypes = genWebTypes(vueTags, options);
|
||||
fse.outputFileSync(
|
||||
join(options.outputDir, 'web-types.json'),
|
||||
JSON.stringify(webTypes)
|
||||
JSON.stringify(webTypes),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
export function toKebabCase(input: string): string {
|
||||
return input.replace(
|
||||
/[A-Z]/g,
|
||||
(val, index) => (index === 0 ? '' : '-') + val.toLowerCase()
|
||||
(val, index) => (index === 0 ? '' : '-') + val.toLowerCase(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -32,4 +32,3 @@
|
||||
{{~/if}}
|
||||
/{{~@root.commit}}/{{hash}})
|
||||
{{~/if}}
|
||||
|
||||
|
Reference in New Issue
Block a user