From 3e260c0b7e3cd1340b6d0c100b8173caf2588ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Mon, 27 Jan 2025 19:42:41 +0800 Subject: [PATCH] feat: detect `@unocss/eslint-plugin` for unocss option --- src/env.ts | 9 +++++---- src/presets.ts | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/env.ts b/src/env.ts index 51835d9..bffcace 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,16 +1,17 @@ import process from 'node:process' import { isPackageExists } from 'local-pkg' -export const hasTypeScript: boolean = isPackageExists('typescript') -export const hasVue: boolean = +export const hasTypeScript = (): boolean => isPackageExists('typescript') +export const hasVue = (): boolean => isPackageExists('vue') || isPackageExists('nuxt') || isPackageExists('vitepress') || isPackageExists('@slidev/cli') -export const hasUnocss: boolean = +export const hasUnocss = (): boolean => isPackageExists('unocss') || isPackageExists('@unocss/webpack') || - isPackageExists('@unocss/nuxt') + isPackageExists('@unocss/nuxt') || + isPackageExists('@unocss/eslint-plugin') export function isInEditorEnv(): boolean { if (process.env.CI) return false diff --git a/src/presets.ts b/src/presets.ts index a2d39fa..63b0060 100644 --- a/src/presets.ts +++ b/src/presets.ts @@ -75,8 +75,8 @@ export async function sxzz( command: enableCommand = true, markdown: enableMarkdown = true, prettier: enablePrettier = true, - unocss: enableUnocss = hasUnocss, - vue: enableVue = hasVue, + unocss: enableUnocss = hasUnocss(), + vue: enableVue = hasVue(), }: Partial<{ /** Vue support. Auto-enable if detected. */ vue: boolean