Skip to content

Commit a40428e

Browse files
committed
feat: compatibility with changelogen
Also adds a wip type for WIP commits that don't hit the changelog.
1 parent 05b29bd commit a40428e

File tree

4 files changed

+388
-28
lines changed

4 files changed

+388
-28
lines changed

package.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
{
2-
"name": "@jcamp/starter-typescript",
2+
"name": "commitlint-config-unjs",
33
"type": "module",
44
"version": "0.1.0",
55
"private": true,
6-
"description": "Starter repo for Typescript projects and NPM packages",
6+
"description": "A commitlint config for unjs's changelogen tool",
77
"author": "John Campion",
88
"license": "MIT",
9-
"homepage": "https://github.com/jcamp-code/starter-typescript",
9+
"homepage": "https://github.com/jcamp-code/commitlint-config-unjs",
1010
"repository": {
1111
"type": "git",
12-
"url": "git+https://github.com/jcamp-code/starter-typescript.git"
12+
"url": "git+https://github.com/jcamp-code/commitlint-config-unjs.git"
1313
},
1414
"bugs": {
15-
"url": "https://github.com/jcamp-code/starter-typescript/issues"
15+
"url": "https://github.com/jcamp-code/commitlint-config-unjs/issues"
1616
},
1717
"keywords": [
18-
"npm",
19-
"package",
20-
"starter",
21-
"vitest"
18+
"commitlint",
19+
"changelogen",
20+
"unjs"
2221
],
2322
"exports": {
2423
".": {
24+
"types": "./dist/index.d.ts",
2525
"require": "./dist/index.cjs",
2626
"import": "./dist/index.mjs"
2727
}
2828
},
2929
"main": "./dist/index.cjs",
30+
"module": "./dist/index.mjs",
3031
"types": "./dist/index.d.ts",
3132
"files": [
3233
"dist"
@@ -46,6 +47,10 @@
4647
"release:major": "changelogen --release --major --push && pnpm publish",
4748
"release:patch": "changelogen --release --patch --push && pnpm publish"
4849
},
50+
"dependencies": {
51+
"@commitlint/types": "^17.4.4",
52+
"conventional-changelog-conventionalcommits": "^5.0.0"
53+
},
4954
"devDependencies": {
5055
"@commitlint/cli": "^17.5.1",
5156
"@commitlint/config-conventional": "^17.4.4",

pnpm-lock.yaml

Lines changed: 8 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 157 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,158 @@
1-
export function testAdd(digit: number, second: number): number {
2-
return digit + second
1+
import type { UserConfig } from '@commitlint/types'
2+
import { RuleConfigSeverity } from '@commitlint/types'
3+
4+
export const Configuration: UserConfig = {
5+
parserPreset: 'conventional-changelog-conventionalcommits',
6+
rules: {
7+
'body-leading-blank': [RuleConfigSeverity.Warning, 'always'],
8+
'body-max-line-length': [RuleConfigSeverity.Error, 'always', 100],
9+
'footer-leading-blank': [RuleConfigSeverity.Warning, 'always'],
10+
'footer-max-line-length': [RuleConfigSeverity.Error, 'always', 100],
11+
'header-max-length': [RuleConfigSeverity.Error, 'always', 100],
12+
'subject-case': [
13+
RuleConfigSeverity.Error,
14+
'never',
15+
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
16+
],
17+
'subject-empty': [RuleConfigSeverity.Error, 'never'],
18+
'subject-full-stop': [RuleConfigSeverity.Error, 'never', '.'],
19+
'type-case': [RuleConfigSeverity.Error, 'always', 'lower-case'],
20+
'type-empty': [RuleConfigSeverity.Error, 'never'],
21+
'type-enum': [
22+
RuleConfigSeverity.Error,
23+
'always',
24+
[
25+
'build',
26+
'chore',
27+
'ci',
28+
'docs',
29+
'examples',
30+
'feat',
31+
'fix',
32+
'perf',
33+
'refactor',
34+
'revert',
35+
'style',
36+
'test',
37+
'types',
38+
'wip',
39+
],
40+
],
41+
},
42+
prompt: {
43+
questions: {
44+
type: {
45+
description: "Select the type of change that you're committing",
46+
enum: {
47+
feat: {
48+
description: 'A new feature or enhancement',
49+
title: 'Enhancements',
50+
emoji: '🚀',
51+
},
52+
fix: {
53+
description: 'A bug fix',
54+
title: 'Fixes',
55+
emoji: '🩹',
56+
},
57+
docs: {
58+
description: 'Documentation only changes',
59+
title: 'Documentation',
60+
emoji: '📖',
61+
},
62+
style: {
63+
description:
64+
'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)',
65+
title: 'Styles',
66+
emoji: '🎨',
67+
},
68+
refactor: {
69+
description:
70+
'A code change that neither fixes a bug nor adds a feature',
71+
title: 'Code Refactoring',
72+
emoji: '💅',
73+
},
74+
perf: {
75+
description: 'A code change that improves performance',
76+
title: 'Performance Improvements',
77+
emoji: '🔥',
78+
},
79+
test: {
80+
description: 'Adding missing tests or correcting existing tests',
81+
title: 'Tests',
82+
emoji: '✅',
83+
},
84+
build: {
85+
description:
86+
'Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)',
87+
title: 'Builds',
88+
emoji: '📦',
89+
},
90+
ci: {
91+
description:
92+
'Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)',
93+
title: 'Continuous Integrations',
94+
emoji: '🤖',
95+
},
96+
chore: {
97+
description: "Other changes that don't modify src or test files",
98+
title: 'Chores',
99+
emoji: '🏡',
100+
},
101+
revert: {
102+
description: 'Reverts a previous commit',
103+
title: 'Reverts',
104+
emoji: '🗑',
105+
},
106+
types: {
107+
description: 'Changes to typescript types',
108+
title: 'Types',
109+
emoji: '🌊',
110+
},
111+
examples: {
112+
description: 'Work on examples or demos',
113+
title: 'Examples',
114+
emoji: '🏀',
115+
},
116+
wip: {
117+
description: 'WIP commits that should not be in the changelog',
118+
title: 'WIP Commits',
119+
emoji: '⛔️',
120+
},
121+
},
122+
},
123+
scope: {
124+
description:
125+
'What is the scope of this change (e.g. component or file name)',
126+
},
127+
subject: {
128+
description:
129+
'Write a short, imperative tense description of the change',
130+
},
131+
body: {
132+
description: 'Provide a longer description of the change',
133+
},
134+
isBreaking: {
135+
description: 'Are there any breaking changes?',
136+
},
137+
breakingBody: {
138+
description:
139+
'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself',
140+
},
141+
breaking: {
142+
description: 'Describe the breaking changes',
143+
},
144+
isIssueAffected: {
145+
description: 'Does this change affect any open issues?',
146+
},
147+
issuesBody: {
148+
description:
149+
'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself',
150+
},
151+
issues: {
152+
description: 'Add issue references (e.g. "fix #123", "re #123".)',
153+
},
154+
},
155+
},
3156
}
157+
158+
module.exports = Configuration

0 commit comments

Comments
 (0)