From 248826886a509293328a3d0a81f5ad7fd17c8e7b Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Wed, 25 Dec 2024 17:39:41 +0800 Subject: [PATCH] style: lint fix --- scripts/tsup-args.ts | 14 +++++++------- theme/src/client/composables/dark-mode.ts | 18 +++++++++--------- theme/src/client/composables/encrypt.ts | 2 +- theme/src/client/composables/latest-updated.ts | 12 ++++++------ theme/src/client/composables/sidebar.ts | 4 ++-- theme/src/node/autoFrontmatter/generator.ts | 8 ++++---- theme/src/node/prepare/prepareEncrypt.ts | 6 +++--- theme/src/node/prepare/prepareThemeData.ts | 12 ++++++------ 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/scripts/tsup-args.ts b/scripts/tsup-args.ts index 89100fad..5b4386a7 100644 --- a/scripts/tsup-args.ts +++ b/scripts/tsup-args.ts @@ -11,13 +11,13 @@ const tsupArgv = rawArgv.includes('--') ? rawArgv.slice(rawArgv.indexOf('--') + const parsed = tsupArgv.length ? minimist(tsupArgv, { - boolean: ['client', 'node', 'all'], - alias: { - client: 'c', - node: 'n', - all: 'a', - }, - }) + boolean: ['client', 'node', 'all'], + alias: { + client: 'c', + node: 'n', + all: 'a', + }, + }) : { client: true, node: true, diff --git a/theme/src/client/composables/dark-mode.ts b/theme/src/client/composables/dark-mode.ts index 909cbd48..10f5ea75 100644 --- a/theme/src/client/composables/dark-mode.ts +++ b/theme/src/client/composables/dark-mode.ts @@ -30,15 +30,15 @@ export function setupDarkMode(app: App): void { ? ref(true) : appearance ? useDark({ - storageKey: 'vuepress-theme-appearance', - attribute: 'data-theme', - valueLight: 'light', - valueDark: 'dark', - disableTransition, - initialValue: () => - typeof appearance === 'string' ? appearance : 'auto', - ...(typeof appearance === 'object' ? appearance : {}), - }) + storageKey: 'vuepress-theme-appearance', + attribute: 'data-theme', + valueLight: 'light', + valueDark: 'dark', + disableTransition, + initialValue: () => + typeof appearance === 'string' ? appearance : 'auto', + ...(typeof appearance === 'object' ? appearance : {}), + }) : ref(false) app.provide(darkModeSymbol, isDark) diff --git a/theme/src/client/composables/encrypt.ts b/theme/src/client/composables/encrypt.ts index d29cafdf..f4c6fd0b 100644 --- a/theme/src/client/composables/encrypt.ts +++ b/theme/src/client/composables/encrypt.ts @@ -102,7 +102,7 @@ export function setupEncrypt() { const filePathRelative = page.value.filePathRelative return encrypt.value.ruleList.length ? encrypt.value.ruleList - .filter(item => toMatch(item.match, pagePath, filePathRelative)) + .filter(item => toMatch(item.match, pagePath, filePathRelative)) : [] }) diff --git a/theme/src/client/composables/latest-updated.ts b/theme/src/client/composables/latest-updated.ts index 863330e8..18848f3c 100644 --- a/theme/src/client/composables/latest-updated.ts +++ b/theme/src/client/composables/latest-updated.ts @@ -26,12 +26,12 @@ export function useLastUpdated() { datetime.value = date.value ? new Intl.DateTimeFormat( - themeData.value.lastUpdated?.formatOptions?.forceLocale ? lang.value : undefined, - themeData.value.lastUpdated?.formatOptions ?? { - dateStyle: 'short', - timeStyle: 'short', - }, - ).format(date.value) + themeData.value.lastUpdated?.formatOptions?.forceLocale ? lang.value : undefined, + themeData.value.lastUpdated?.formatOptions ?? { + dateStyle: 'short', + timeStyle: 'short', + }, + ).format(date.value) : '' }) }) diff --git a/theme/src/client/composables/sidebar.ts b/theme/src/client/composables/sidebar.ts index e490cd8f..ce8fa9f0 100644 --- a/theme/src/client/composables/sidebar.ts +++ b/theme/src/client/composables/sidebar.ts @@ -69,8 +69,8 @@ export function setupSidebar() { const sidebarData = computed(() => { return hasSidebar.value ? getSidebar(typeof frontmatter.value.sidebar === 'string' - ? frontmatter.value.sidebar - : page.value.path, routeLocale.value) + ? frontmatter.value.sidebar + : page.value.path, routeLocale.value) : [] }) diff --git a/theme/src/node/autoFrontmatter/generator.ts b/theme/src/node/autoFrontmatter/generator.ts index 517233eb..10521d4a 100644 --- a/theme/src/node/autoFrontmatter/generator.ts +++ b/theme/src/node/autoFrontmatter/generator.ts @@ -167,10 +167,10 @@ async function generator(file: AutoFrontmatterMarkdownFile): Promise { const yaml = isEmptyObject(data) ? '' : jsonToYaml - .stringify(data) - .replace(/\n\s{2}/g, '\n') - .replace(/"/g, '') - .replace(/\s+\n/g, '\n') + .stringify(data) + .replace(/\n\s{2}/g, '\n') + .replace(/"/g, '') + .replace(/\s+\n/g, '\n') const newContent = yaml ? `${yaml}---\n${content}` : content await fs.promises.writeFile(filepath, newContent, 'utf-8') diff --git a/theme/src/node/prepare/prepareEncrypt.ts b/theme/src/node/prepare/prepareEncrypt.ts index cb286389..3ae0e17e 100644 --- a/theme/src/node/prepare/prepareEncrypt.ts +++ b/theme/src/node/prepare/prepareEncrypt.ts @@ -48,9 +48,9 @@ const salt = () => genSaltSync(random(8, 16)) function resolveEncrypt(encrypt?: EncryptOptions): EncryptConfig { const admin = encrypt?.admin ? toArray(encrypt.admin) - .filter(isStringLike) - .map(item => hashSync(String(item), salt())) - .join(separator) + .filter(isStringLike) + .map(item => hashSync(String(item), salt())) + .join(separator) : '' const rules: Record = {} diff --git a/theme/src/node/prepare/prepareThemeData.ts b/theme/src/node/prepare/prepareThemeData.ts index 24bab9c6..6bcbc7dc 100644 --- a/theme/src/node/prepare/prepareThemeData.ts +++ b/theme/src/node/prepare/prepareThemeData.ts @@ -56,9 +56,9 @@ async function resolveBulletin(app: App, themeData: PlumeThemeData) { const type = themeData.bulletin.contentType ?? 'text' themeData.bulletin.content = type === 'markdown' ? app.markdown.render(themeData.bulletin.content, { - filepath: app.dir.source(`/_bulletin.md`), - filePathRelative: `_bulletin.md`, - }) + filepath: app.dir.source(`/_bulletin.md`), + filePathRelative: `_bulletin.md`, + }) : themeData.bulletin.content } } @@ -83,9 +83,9 @@ async function resolveBulletin(app: App, themeData: PlumeThemeData) { const type = themeData.locales[locale].bulletin.contentType ?? 'text' themeData.locales[locale].bulletin.content = type === 'markdown' ? app.markdown.render(themeData.locales[locale].bulletin.content, { - filepath: app.dir.source(`${locale}_bulletin.md`), - filePathRelative: `${locale.slice(1)}_bulletin.md`, - }) + filepath: app.dir.source(`${locale}_bulletin.md`), + filePathRelative: `${locale.slice(1)}_bulletin.md`, + }) : themeData.locales[locale].bulletin.content } }