forked from element-plus/element-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: check message when commit (element-plus#8166)
- Loading branch information
Showing
6 changed files
with
119 additions
and
114 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
pnpm exec commitlint --config commitlint.config.js --edit "${1}" |
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,110 +1,3 @@ | ||
'use strict' | ||
const { execSync } = require('child_process') | ||
const fg = require('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] | ||
|
||
module.exports = { | ||
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, | ||
}, | ||
} | ||
// commitlint uses `ts-node` to load typescript config, it's too slow. So we replace it with `esbuild`. | ||
require('@esbuild-kit/cjs-loader') | ||
module.exports = require('./commitlint.config.ts').default |
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 |
---|---|---|
@@ -0,0 +1,109 @@ | ||
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, | ||
}, | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.