Skip to content

File tree

6 files changed

+2211
-47
lines changed

6 files changed

+2211
-47
lines changed

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no -- commitlint --edit "$1"

.husky/pre-commit

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
# copied from: https://prettier.io/docs/en/precommit.html#option-5-shell-script
5+
6+
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
7+
[ -z "$FILES" ] && exit 0
8+
9+
# Prettify all selected files
10+
echo "$FILES" | xargs ./node_modules/.bin/prettier --ignore-unknown --write
11+
12+
# Add back the modified/prettified files to staging
13+
echo "$FILES" | xargs git add
14+
15+
exit 0
16+

commitlint.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const { RuleConfigSeverity } = require('@commitlint/types');
2+
const {
3+
utils: { getProjects },
4+
} = require('@commitlint/config-nx-scopes');
5+
6+
/** @type {import('@commitlint/types').UserConfig} */
7+
const configuration = {
8+
extends: ['@commitlint/config-conventional'],
9+
rules: {
10+
'scope-enum': async ctx => {
11+
const projects = await getProjects(
12+
ctx,
13+
({ name, projectType, tags }) =>
14+
projectType === 'library' || projectType === 'application',
15+
);
16+
const scopes = [...projects, 'tools', 'workflows', 'testing'].sort();
17+
return [RuleConfigSeverity.Error, 'always', scopes];
18+
},
19+
},
20+
};
21+
22+
module.exports = configuration;

0 commit comments

Comments
 (0)