Skip to content

Commit

Permalink
fix: 修正config类型
Browse files Browse the repository at this point in the history
  • Loading branch information
xuasir committed Mar 5, 2021
1 parent 853e295 commit bd1723d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/cli/src/exports/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import type { IPluginAPI } from './pluginAPI'

export interface IConfig extends IProjectConfig {
libBuild: ILibBuildConfig
lint: ILintConfig
changelog: IChangelogConfig
release: IReleaseConfig
lint: Partial<ILintConfig>
changelog: Partial<IChangelogConfig>
release: Partial<IReleaseConfig>
}

export type IPlugin = IPluginBase<(api: IPluginAPI) => void>
Expand Down
12 changes: 10 additions & 2 deletions packages/preset-built-in/src/plugin/command/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ export default createPlugin({
if (lintConfig.eslint) {
const eslint = lintConfig.eslint
if (typeof eslint != 'boolean') {
const ext =
eslint.ext.length > 0
? eslint.ext
: ['.js', '.jsx', '.ts', '.tsx', '.vue']
const args = [
eslint.include,
'--fix',
'--ext',
eslint.ext.join(',')
ext.join(',')
].filter(Boolean)
api.logger.debug(`run eslint with `)
api.logger.debug(args)
Expand All @@ -36,7 +40,11 @@ export default createPlugin({
if (lintConfig.stylelint) {
const stylelint = lintConfig.stylelint
if (typeof stylelint != 'boolean') {
const args = stylelint.include.concat(['--fix'])
const include =
stylelint.include.length > 0
? stylelint.include
: ['./**/*.css', './**/*.vue', './**/*.less', './**/*.sass']
const args = include.concat(['--fix'])
api.logger.debug(`run stylelint with `)
api.logger.debug(args)
stylelintRes = await runCmd('stylelint', args, {
Expand Down
10 changes: 5 additions & 5 deletions packages/preset-built-in/src/plugin/config/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ export type ILintConfig = {
eslint:
| boolean
| {
include: string
ext: string[]
include?: string
ext?: string[]
}
stylelint:
| boolean
| {
include: string[]
include?: string[]
}
}

Expand All @@ -36,10 +36,10 @@ export function defaultLitConfig(): ILintConfig {
return {
eslint: {
include: '**/src/**/*',
ext: ['.js', '.jsx', '.ts', '.tsx', '.vue']
ext: []
},
stylelint: {
include: ['./**/*.css', './**/*.vue', './**/*.less', './**/*.sass']
include: []
}
}
}

0 comments on commit bd1723d

Please sign in to comment.