-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
849 additions
and
0 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,52 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
function ask () { | ||
|
||
# This is a general-purpose function to ask Yes/No questions in Bash, either | ||
# with or without a default answer. It keeps repeating the question until it | ||
# gets a valid answer. | ||
|
||
# http://djm.me/ask | ||
|
||
if [ "${2:-}" = "Y" ]; then | ||
prompt="Y/n" | ||
default=Y | ||
elif [ "${2:-}" = "N" ]; then | ||
prompt="y/N" | ||
default=N | ||
else | ||
prompt="y/n" | ||
default= | ||
fi | ||
|
||
while true; do | ||
|
||
# Ask the question (not using "read -p" as it uses stderr not stdout) | ||
echo -n "$1 [$prompt] " | ||
|
||
# Read the answer (use /dev/tty in case stdin is redirected from somewhere else) | ||
read REPLY </dev/tty | ||
|
||
# Default? | ||
if [ -z "$REPLY" ]; then | ||
REPLY=$default | ||
fi | ||
|
||
# Check if the reply is valid | ||
case "$REPLY" in | ||
Y*|y*) return 0 ;; | ||
N*|n*) return 1 ;; | ||
esac | ||
|
||
done | ||
|
||
} | ||
|
||
while ! npm run commit-msg -- "$1" ; do | ||
if [ -t 1 ] && ask 'There was an error. Do you wish to amend your commit message?' Y ; then | ||
${GIT_EDITOR:-$EDITOR} "$1" < /dev/tty | ||
else | ||
exit 1 | ||
fi | ||
done |
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,76 @@ | ||
/** | ||
* Commit Lint | ||
* | ||
* Rules are made up by a name and a configuration array. | ||
* The configuration array contains: | ||
* 1. Level: | [0..2] | 0 = disables | 1 = considered a warning | 2 an error for the rule. | ||
* 2. Applicable: | always/never | never inverts the rule. | ||
* 3. Value: | value to use for this rule. | ||
* | ||
* @link https://github.com/conventional-changelog/commitlint/blob/master/docs/reference/rules-configuration.md | ||
*/ | ||
|
||
export default { | ||
parserPreset: { | ||
parserOpts: { | ||
headerPattern: /^:[a-z\d_]+: (\w+)(?:\((.+)\))?!?: (.+)$/, | ||
breakingHeaderPattern: /^:boom: (\w+)(?:\((.+)\))?!: (.+)$/, | ||
headerCorrespondence: ['type', 'scope', 'subject'], | ||
noteKeywords: ['BREAKING CHANGE'], | ||
revertPattern: | ||
/^:wastebasket: revert:\s"?([\s\S]+?)"?\s*this reverts commit (\w+)\./i, | ||
revertCorrespondence: ['header', 'hash'], | ||
issuePrefixes: ['#'], | ||
}, | ||
}, | ||
rules: { | ||
'header-max-length': [2, 'always', 79], | ||
'body-max-line-length': [2, 'always', 79], | ||
'footer-max-line-length': [2, 'always', 79], | ||
'type-empty': [2, 'never'], | ||
'type-case': [2, 'always', 'lower-case'], | ||
'type-enum': [ | ||
2, | ||
'always', | ||
[ | ||
'a11y', | ||
'bug', | ||
'chore', | ||
'cleaning', | ||
'config', | ||
'deprecate', | ||
'deps', | ||
'docs', | ||
'dx', | ||
'experiment', | ||
'feat', | ||
'fix', | ||
'i18n', | ||
'idea', | ||
'initial', | ||
'license', | ||
'merge', | ||
'perf', | ||
'progress', | ||
'refactor', | ||
'release', | ||
'revert', | ||
'security', | ||
'style', | ||
'test', | ||
'trash', | ||
'typo', | ||
'ui', | ||
'ux', | ||
], | ||
], | ||
'scope-case': [0, 'always', 'lower-case'], | ||
'subject-empty': [2, 'never'], | ||
'subject-case': [2, 'always', 'sentence-case'], | ||
'subject-full-stop': [2, 'always', '.'], | ||
'body-leading-blank': [2, 'always'], | ||
'body-empty': [0, 'never'], | ||
'body-full-stop': [2, 'always', '.'], | ||
'footer-leading-blank': [2, 'always'], | ||
}, | ||
}; |
Oops, something went wrong.