-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add @jsxiaosi/commitlint-config
- Loading branch information
Showing
4 changed files
with
63 additions
and
307 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,37 @@ | ||
/** | ||
* feature | ||
* fixbug 修复 | ||
* refactor:重构代码(既没有新增功能,也没有修复 bug) | ||
* docs:文档更新 | ||
* style:不影响程序逻辑的代码修改(修改空白字符,格式缩进,补全缺失的分号等,没有改变代码逻辑) | ||
* perf:性能, 体验优化 | ||
* chore:不属于以上类型的其他类型,比如构建流程, 依赖管理 | ||
* revert:回滚某个更早之前的提交 | ||
*/ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
// CommonJS | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { execSync } = require('child_process'); | ||
|
||
const scopes = fs.readdirSync(path.resolve(__dirname, 'src')); | ||
|
||
const gitStatus = execSync('git status --porcelain || true').toString().trim().split('\n'); | ||
|
||
const scopeComplete = gitStatus | ||
.find((r) => ~r.indexOf('M src')) | ||
?.replace(/(\/)/g, '%%') | ||
?.match(/src%%((\w|-)*)/)?.[1]; | ||
|
||
const subjectComplete = gitStatus | ||
.find((r) => ~r.indexOf('M src')) | ||
?.replace(/\//g, '%%') | ||
?.match(/src%%((\w|-)*)/)?.[1]; | ||
|
||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
rules: { | ||
'type-enum': [ | ||
2, | ||
'always', | ||
['feature', 'fixbug', 'refactor', 'docs', 'style', 'perf', 'chore', 'revert'], | ||
], | ||
'subject-full-stop': [0, 'never'], | ||
'subject-case': [0, 'never'], | ||
extends: ['@jsxiaosi/commitlint-config'], | ||
prompt: { | ||
// 范围设置 | ||
scopes: [...scopes, 'mock'], | ||
// 范围是否可以多选 | ||
enableMultipleScopes: true, | ||
// 多选范围后用标识符隔开 | ||
scopeEnumSeparator: ',', | ||
// 设置 选择范围 中 为空选项(empty) 和 自定义选项(custom) 的 位置 | ||
customScopesAlign: !scopeComplete ? 'top' : 'bottom', | ||
// 如果 defaultScope 与在选择范围列表项中的 value 相匹配就会进行星标置顶操作。 | ||
defaultScope: scopeComplete, | ||
// 描述预设值 | ||
defaultSubject: subjectComplete && `[${subjectComplete}] `, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.