From ae93da12af4853bcb42e746d0d89f7fddc7be792 Mon Sep 17 00:00:00 2001 From: haoziqaq <357229046@qq.com> Date: Sun, 18 Jul 2021 19:29:17 +0800 Subject: [PATCH] fix(cli): fix eslint pattern affects: @varlet/cli --- lerna.json | 4 +--- packages/varlet-cli/src/commands/lint.ts | 21 ++++++++++++++------- packages/varlet-cli/src/shared/constant.ts | 2 +- scripts/bootstrap.mjs | 3 +-- scripts/publish.mjs | 3 +-- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lerna.json b/lerna.json index 5cc25db1dc7..56c58a4ffc6 100644 --- a/lerna.json +++ b/lerna.json @@ -18,8 +18,6 @@ "publishConfig": { "access": "public" }, - "ignoreChanges": [ - "**/*.md" - ], + "ignoreChanges": ["**/*.md"], "version": "1.9.4" } diff --git a/packages/varlet-cli/src/commands/lint.ts b/packages/varlet-cli/src/commands/lint.ts index a9ed4eb2b58..487edf59b71 100644 --- a/packages/varlet-cli/src/commands/lint.ts +++ b/packages/varlet-cli/src/commands/lint.ts @@ -1,6 +1,8 @@ import execa from 'execa' import ora, { Ora } from 'ora' -import { ESLINT_EXTENSIONS } from '../shared/constant' +import { CWD, ESLINT_EXTENSIONS } from '../shared/constant' +import { isDir } from '../shared/fsUtils' +import { resolve } from 'path' export async function lint() { let spinner: Ora @@ -14,13 +16,18 @@ export async function lint() { spinner.succeed('stylelint success') spinner = ora('eslint starting...').start() - await execa('eslint', [ + + const patterns: string[] = [ './src', - 'packages/varlet-cli/src', - 'packages/varlet-ui/src', - 'packages/varlet-icons/lib', - 'packages/varlet-markdown-loader', - 'packages/varlet-vscode-extension/src', + './packages/varlet-cli/src', + './packages/varlet-ui/src', + './packages/varlet-icons/lib', + './packages/varlet-markdown-loader', + './packages/varlet-vscode-extension/src', + ] + + await execa('eslint', [ + ...patterns.filter((pattern) => isDir(resolve(CWD, pattern))), '--fix', '--ext', ESLINT_EXTENSIONS.join(','), diff --git a/packages/varlet-cli/src/shared/constant.ts b/packages/varlet-cli/src/shared/constant.ts index 192a7fc4d49..01e992f3dc5 100644 --- a/packages/varlet-cli/src/shared/constant.ts +++ b/packages/varlet-cli/src/shared/constant.ts @@ -9,7 +9,7 @@ export const ES_DIR = resolve(CWD, 'es') export const UMD_DIR = resolve(CWD, 'umd') export const TYPES_DIR = resolve(CWD, 'types') export const ROOT_DOCS_DIR = resolve(CWD, 'docs') -export const ESLINT_EXTENSIONS = ['.vue', '.ts', '.js'] +export const ESLINT_EXTENSIONS = ['.vue', '.ts', '.js', '.mjs'] export const EXTENSIONS = ['.vue', '.ts', '.js', '.less', '.css'] export const STYLE_DIR_NAME = 'style' export const EXAMPLE_DIR_NAME = 'example' diff --git a/scripts/bootstrap.mjs b/scripts/bootstrap.mjs index a1eaadab3ec..8144092ce68 100644 --- a/scripts/bootstrap.mjs +++ b/scripts/bootstrap.mjs @@ -1,7 +1,6 @@ import ora from 'ora' import { buildCli, buildIcons, buildUI } from './build.mjs' - -(async () => { +;(async () => { let spinner = ora('Start build @varlet/cli & @varlet/icons').start() await Promise.all([buildCli(), buildIcons()]) spinner.succeed('@varlet/cli & @varlet/icons build success') diff --git a/scripts/publish.mjs b/scripts/publish.mjs index 68755d920cd..76eed32de76 100644 --- a/scripts/publish.mjs +++ b/scripts/publish.mjs @@ -1,7 +1,6 @@ import ora from 'ora' import { buildCli, buildIcons, buildUI } from './build.mjs' - -(async () => { +;(async () => { let spinner = ora('Start build @varlet/cli & @varlet/icons').start() await Promise.all([buildCli(), buildIcons()]) spinner.succeed('@varlet/cli & @varlet/icons build success')