加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
commitlint.config.ts 2.31 KB
一键复制 编辑 原始数据 按行查看 历史
import { execSync } from 'child_process'
import fg from 'fast-glob'
const getPackages = (packagePath) =>
fg.sync('*', { cwd: packagePath, onlyDirectories: true })
const scopes = [
...getPackages('packages'),
...getPackages('internal'),
'docs',
'play',
'project',
'core',
'style',
'ci',
'dev',
'deploy',
'other',
'typography',
'color',
'border',
'var',
'ssr',
]
const gitStatus = execSync('git status --porcelain || true')
.toString()
.trim()
.split('\n')
const scopeComplete = gitStatus
.find((r) => ~r.indexOf('M packages'))
?.replace(/\//g, '%%')
?.match(/packages%%((\w|-)*)/)?.[1]
const subjectComplete = gitStatus
.find((r) => ~r.indexOf('M packages/components'))
?.replace(/\//g, '%%')
?.match(/packages%%components%%((\w|-)*)/)?.[1]
export default {
rules: {
/**
* type[scope]: [function] description
* ^^^^^
*/
'scope-enum': [2, 'always', scopes],
/**
* type[scope]: [function] description
*
* ^^^^^^^^^^^^^^ empty line.
* - Something here
*/
'body-leading-blank': [1, 'always'],
/**
* type[scope]: [function] description
*
* - something here
*
* ^^^^^^^^^^^^^^
*/
'footer-leading-blank': [1, 'always'],
/**
* type[scope]: [function] description [No more than 72 characters]
* ^^^^^
*/
'header-max-length': [2, 'always', 72],
'scope-case': [2, 'always', 'lower-case'],
'subject-case': [
1,
'never',
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
/**
* type[scope]: [function] description
* ^^^^
*/
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'release',
'style',
'test',
'improvement',
],
],
},
prompt: {
defaultScope: scopeComplete,
customScopesAlign: !scopeComplete ? 'top' : 'bottom',
defaultSubject: subjectComplete && `[${subjectComplete}] `,
allowCustomIssuePrefixs: false,
allowEmptyIssuePrefixs: false,
},
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化