Skip to content

Commit 2e7e34d

Browse files
authored
fix: use correct label for failing empty subjects (#481)
* fix: use correct label for failing empty subjects, see #476 * chore: budge to husky api change * test: adapt to corrected subject message
1 parent e1ea490 commit 2e7e34d

14 files changed

+24
-93
lines changed

@commitlint/cli/src/cli.test.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ test('should pick up parser preset and fail accordingly', async t => {
157157
'type(scope): subject'
158158
);
159159
t.is(actual.code, 1);
160-
t.true(actual.stdout.includes('message may not be empty [subject-empty]'));
160+
t.true(actual.stdout.includes('may not be empty'));
161161
});
162162

163163
test('should pick up parser preset and succeed accordingly', async t => {
@@ -264,17 +264,27 @@ test('should fail for invalid formatters from flags', async t => {
264264
});
265265

266266
test('should work with absolute formatter path', async t => {
267-
const formatterPath = path.resolve(__dirname, '../fixtures/custom-formatter/formatters/custom.js');
267+
const formatterPath = path.resolve(
268+
__dirname,
269+
'../fixtures/custom-formatter/formatters/custom.js'
270+
);
268271
const cwd = await git.bootstrap('fixtures/custom-formatter');
269-
const actual = await cli(['--format', formatterPath], {cwd})('test: this should work');
272+
const actual = await cli(['--format', formatterPath], {cwd})(
273+
'test: this should work'
274+
);
270275

271276
t.true(actual.stdout.includes('custom-formatter-ok'));
272277
t.is(actual.code, 0);
273278
});
274279

275280
test('should work with relative formatter path', async t => {
276-
const cwd = path.resolve(await git.bootstrap('fixtures/custom-formatter'), './formatters');
277-
const actual = await cli(['--format', './custom.js'], {cwd})('test: this should work');
281+
const cwd = path.resolve(
282+
await git.bootstrap('fixtures/custom-formatter'),
283+
'./formatters'
284+
);
285+
const actual = await cli(['--format', './custom.js'], {cwd})(
286+
'test: this should work'
287+
);
278288

279289
t.true(actual.stdout.includes('custom-formatter-ok'));
280290
t.is(actual.code, 0);

@commitlint/rules/src/body-tense.js

-6
This file was deleted.

@commitlint/rules/src/body-tense.test.js

-13
This file was deleted.

@commitlint/rules/src/footer-tense.js

-8
This file was deleted.

@commitlint/rules/src/footer-tense.test.js

-13
This file was deleted.

@commitlint/rules/src/index.js

-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ export default {
55
'body-max-length': require('./body-max-length'),
66
'body-max-line-length': require('./body-max-line-length'),
77
'body-min-length': require('./body-min-length'),
8-
'body-tense': require('./body-tense'),
98
'footer-empty': require('./footer-empty'),
109
'footer-leading-blank': require('./footer-leading-blank'),
1110
'footer-max-length': require('./footer-max-length'),
1211
'footer-max-line-length': require('./footer-max-line-length'),
1312
'footer-min-length': require('./footer-min-length'),
14-
'footer-tense': require('./footer-tense'),
1513
'header-max-length': require('./header-max-length'),
1614
'header-min-length': require('./header-min-length'),
17-
lang: require('./lang'),
1815
'references-empty': require('./references-empty'),
1916
'scope-case': require('./scope-case'),
2017
'scope-empty': require('./scope-empty'),
@@ -27,7 +24,6 @@ export default {
2724
'subject-full-stop': require('./subject-full-stop'),
2825
'subject-max-length': require('./subject-max-length'),
2926
'subject-min-length': require('./subject-min-length'),
30-
'subject-tense': require('./subject-tense'),
3127
'type-case': require('./type-case'),
3228
'type-empty': require('./type-empty'),
3329
'type-enum': require('./type-enum'),

@commitlint/rules/src/lang.js

-3
This file was deleted.

@commitlint/rules/src/lang.test.js

-15
This file was deleted.

@commitlint/rules/src/subject-empty.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export default (parsed, when) => {
77

88
return [
99
negated ? notEmpty : !notEmpty,
10-
message(['message', negated ? 'may not' : 'must', 'be empty'])
10+
message(['subject', negated ? 'may not' : 'must', 'be empty'])
1111
];
1212
};

@commitlint/rules/src/subject-full-stop.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ export default (parsed, when, value) => {
1212

1313
return [
1414
negated ? !hasStop : hasStop,
15-
message(['message', negated ? 'may not' : 'must', 'end with full stop'])
15+
message(['subject', negated ? 'may not' : 'must', 'end with full stop'])
1616
];
1717
};

@commitlint/rules/src/subject-max-length.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export default (parsed, when, value) => {
99

1010
return [
1111
maxLength(input, value),
12-
`footer must not be longer than ${value} characters`
12+
`subject must not be longer than ${value} characters`
1313
];
1414
};

@commitlint/rules/src/subject-tense.js

-8
This file was deleted.

@commitlint/rules/src/subject-tense.test.js

-13
This file was deleted.

package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
"build": "lerna run build --stream --parallel --include-filtered-dependencies",
99
"clean": "npx lerna clean --yes && npx lerna run clean --stream --parallel --include-filtered-dependencies",
1010
"commit": "node @commitlint/prompt-cli/cli.js",
11-
"commitmsg": "node @commitlint/cli/lib/cli.js -E GIT_PARAMS",
1211
"deps": "lerna run deps",
1312
"pkg": "lerna run pkg",
1413
"docs": "docsify serve docs",
1514
"lint": "lerna run lint",
16-
"precommit": "lint-staged",
1715
"publish": "lerna publish --conventional-commits",
1816
"reinstall": "yarn clean && yarn install",
1917
"start": "lerna run start --stream --parallel --include-filtered-dependencies",
@@ -101,5 +99,11 @@
10199
"npx": "9.7.1",
102100
"prettier": "1.10.2",
103101
"xo": "0.20.3"
102+
},
103+
"husky": {
104+
"hooks": {
105+
"commit-msg": "node @commitlint/cli/lib/cli.js -E HUSKY_GIT_PARAMS",
106+
"pre-commit": "lint-staged"
107+
}
104108
}
105109
}

0 commit comments

Comments
 (0)