@diplodoc/lint 1.9.2 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/commit-msg +49 -0
- package/.release-please-manifest.json +1 -1
- package/AGENTS.md +8 -2
- package/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/scaffolding/.husky/commit-msg +49 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
COMMIT_MSG_FILE="$1"
|
|
2
|
+
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
|
|
3
|
+
|
|
4
|
+
# Check if commit message contains Cyrillic characters
|
|
5
|
+
# All commit messages must be in English per .agents/style-and-testing.md
|
|
6
|
+
if echo "$COMMIT_MSG" | grep -q '[А-Яа-яЁё]'; then
|
|
7
|
+
echo "❌ Error: Commit message contains Cyrillic characters."
|
|
8
|
+
echo ""
|
|
9
|
+
echo "All commit messages must be in English per .agents/style-and-testing.md"
|
|
10
|
+
echo "Please rewrite your commit message in English."
|
|
11
|
+
echo ""
|
|
12
|
+
echo "Current commit message:"
|
|
13
|
+
echo "$COMMIT_MSG"
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# Extract the first line (subject) of commit message
|
|
18
|
+
SUBJECT=$(echo "$COMMIT_MSG" | head -n1)
|
|
19
|
+
|
|
20
|
+
# Allow fixup! and squash! prefixes (for git commit --fixup and --squash)
|
|
21
|
+
if echo "$SUBJECT" | grep -qE '^(fixup!|squash!)'; then
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
# Check Conventional Commits format: <type>(<scope>): <subject>
|
|
26
|
+
# Types: feat, fix, perf, refactor, docs, chore, revert
|
|
27
|
+
# Scope is optional
|
|
28
|
+
if ! echo "$SUBJECT" | grep -qE '^(feat|fix|perf|refactor|docs|chore|revert)(\([^)]+\))?: .+'; then
|
|
29
|
+
echo "❌ Error: Commit message does not follow Conventional Commits format."
|
|
30
|
+
echo ""
|
|
31
|
+
echo "Expected format: <type>(<scope>): <subject>"
|
|
32
|
+
echo ""
|
|
33
|
+
echo "Types: feat, fix, perf, refactor, docs, chore, revert"
|
|
34
|
+
echo "Scope is optional"
|
|
35
|
+
echo ""
|
|
36
|
+
echo "Examples:"
|
|
37
|
+
echo " feat(cli): add new command"
|
|
38
|
+
echo " fix(transform): handle edge case"
|
|
39
|
+
echo " docs(readme): update installation"
|
|
40
|
+
echo ""
|
|
41
|
+
echo "For fixing previous commits, use:"
|
|
42
|
+
echo " fixup! <original commit message>"
|
|
43
|
+
echo ""
|
|
44
|
+
echo "Current commit message:"
|
|
45
|
+
echo "$SUBJECT"
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
exit 0
|
package/AGENTS.md
CHANGED
|
@@ -42,6 +42,7 @@ This file contains instructions for AI agents working with the `@diplodoc/lint`
|
|
|
42
42
|
- `.stylelintrc.js` — Stylelint configuration template
|
|
43
43
|
- `.lintstagedrc.js` — lint-staged configuration template
|
|
44
44
|
- `.husky/pre-commit` — Husky pre-commit hook template
|
|
45
|
+
- `.husky/commit-msg` — Husky commit-msg hook template (validates commit messages are in English)
|
|
45
46
|
- `scripts/` — helper scripts for package.json and .ignore file modification
|
|
46
47
|
- `modify-package.js` — adds lint scripts to package.json
|
|
47
48
|
- `modify-ignore.js` — updates .ignore files with standard patterns
|
|
@@ -413,6 +414,13 @@ Files in `scaffolding/` are copied to packages during `init`/`update`:
|
|
|
413
414
|
|
|
414
415
|
- Runs `npm run pre-commit` before each commit
|
|
415
416
|
- Pre-commit script runs `lint update && lint-staged`
|
|
417
|
+
|
|
418
|
+
**`.husky/commit-msg`**:
|
|
419
|
+
|
|
420
|
+
- Validates that commit messages follow Conventional Commits format (per `.agents/style-and-testing.md`)
|
|
421
|
+
- Validates that commit messages are in English (rejects Cyrillic characters)
|
|
422
|
+
- Allows `fixup!` and `squash!` prefixes for git commit --fixup/--squash
|
|
423
|
+
- Provides helpful error messages with examples and reference to style guide
|
|
416
424
|
- lint-staged automatically runs unit tests when relevant files are changed
|
|
417
425
|
|
|
418
426
|
**Ignore Files** (updated via `modify-ignore.js`):
|
|
@@ -487,13 +495,11 @@ npm run test:old
|
|
|
487
495
|
## Code Conventions
|
|
488
496
|
|
|
489
497
|
1. **File naming**:
|
|
490
|
-
|
|
491
498
|
- Config files: `*-config.js` (e.g., `eslint-common-config.js`)
|
|
492
499
|
- Scripts: `modify-*.js` in `scripts/` directory
|
|
493
500
|
- Binaries: executable scripts in `bin/` directory
|
|
494
501
|
|
|
495
502
|
2. **Comments and documentation**:
|
|
496
|
-
|
|
497
503
|
- **All code comments must be in English**
|
|
498
504
|
- **All documentation files (ADR, AGENTS.md, README, etc.) must be in English**
|
|
499
505
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.10.0](https://github.com/diplodoc-platform/lint/compare/v1.9.2...v1.10.0) (2026-01-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **lint:** add commit-msg hook for validation ([06aa520](https://github.com/diplodoc-platform/lint/commit/06aa520e80c189116d891d7dc3b48535cf479d3d))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **lint:** remove deprecated husky lines from commit-msg hook ([6aca178](https://github.com/diplodoc-platform/lint/commit/6aca178046d0d55eceee0f3341c6b46eb1c570e4))
|
|
14
|
+
|
|
3
15
|
## [1.9.2](https://github.com/diplodoc-platform/lint/compare/v1.9.1...v1.9.2) (2025-12-29)
|
|
4
16
|
|
|
5
17
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
COMMIT_MSG_FILE="$1"
|
|
2
|
+
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
|
|
3
|
+
|
|
4
|
+
# Check if commit message contains Cyrillic characters
|
|
5
|
+
# All commit messages must be in English per .agents/style-and-testing.md
|
|
6
|
+
if echo "$COMMIT_MSG" | grep -q '[А-Яа-яЁё]'; then
|
|
7
|
+
echo "❌ Error: Commit message contains Cyrillic characters."
|
|
8
|
+
echo ""
|
|
9
|
+
echo "All commit messages must be in English per .agents/style-and-testing.md"
|
|
10
|
+
echo "Please rewrite your commit message in English."
|
|
11
|
+
echo ""
|
|
12
|
+
echo "Current commit message:"
|
|
13
|
+
echo "$COMMIT_MSG"
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# Extract the first line (subject) of commit message
|
|
18
|
+
SUBJECT=$(echo "$COMMIT_MSG" | head -n1)
|
|
19
|
+
|
|
20
|
+
# Allow fixup! and squash! prefixes (for git commit --fixup and --squash)
|
|
21
|
+
if echo "$SUBJECT" | grep -qE '^(fixup!|squash!)'; then
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
# Check Conventional Commits format: <type>(<scope>): <subject>
|
|
26
|
+
# Types: feat, fix, perf, refactor, docs, chore, revert
|
|
27
|
+
# Scope is optional
|
|
28
|
+
if ! echo "$SUBJECT" | grep -qE '^(feat|fix|perf|refactor|docs|chore|revert)(\([^)]+\))?: .+'; then
|
|
29
|
+
echo "❌ Error: Commit message does not follow Conventional Commits format."
|
|
30
|
+
echo ""
|
|
31
|
+
echo "Expected format: <type>(<scope>): <subject>"
|
|
32
|
+
echo ""
|
|
33
|
+
echo "Types: feat, fix, perf, refactor, docs, chore, revert"
|
|
34
|
+
echo "Scope is optional"
|
|
35
|
+
echo ""
|
|
36
|
+
echo "Examples:"
|
|
37
|
+
echo " feat(cli): add new command"
|
|
38
|
+
echo " fix(transform): handle edge case"
|
|
39
|
+
echo " docs(readme): update installation"
|
|
40
|
+
echo ""
|
|
41
|
+
echo "For fixing previous commits, use:"
|
|
42
|
+
echo " fixup! <original commit message>"
|
|
43
|
+
echo ""
|
|
44
|
+
echo "Current commit message:"
|
|
45
|
+
echo "$SUBJECT"
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
exit 0
|