Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct label for failing empty subjects #481

Merged
merged 3 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions @commitlint/cli/src/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ test('should pick up parser preset and fail accordingly', async t => {
'type(scope): subject'
);
t.is(actual.code, 1);
t.true(actual.stdout.includes('message may not be empty [subject-empty]'));
t.true(actual.stdout.includes('may not be empty'));
});

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

test('should work with absolute formatter path', async t => {
const formatterPath = path.resolve(__dirname, '../fixtures/custom-formatter/formatters/custom.js');
const formatterPath = path.resolve(
__dirname,
'../fixtures/custom-formatter/formatters/custom.js'
);
const cwd = await git.bootstrap('fixtures/custom-formatter');
const actual = await cli(['--format', formatterPath], {cwd})('test: this should work');
const actual = await cli(['--format', formatterPath], {cwd})(
'test: this should work'
);

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

test('should work with relative formatter path', async t => {
const cwd = path.resolve(await git.bootstrap('fixtures/custom-formatter'), './formatters');
const actual = await cli(['--format', './custom.js'], {cwd})('test: this should work');
const cwd = path.resolve(
await git.bootstrap('fixtures/custom-formatter'),
'./formatters'
);
const actual = await cli(['--format', './custom.js'], {cwd})(
'test: this should work'
);

t.true(actual.stdout.includes('custom-formatter-ok'));
t.is(actual.code, 0);
Expand Down
6 changes: 0 additions & 6 deletions @commitlint/rules/src/body-tense.js

This file was deleted.

13 changes: 0 additions & 13 deletions @commitlint/rules/src/body-tense.test.js

This file was deleted.

8 changes: 0 additions & 8 deletions @commitlint/rules/src/footer-tense.js

This file was deleted.

13 changes: 0 additions & 13 deletions @commitlint/rules/src/footer-tense.test.js

This file was deleted.

4 changes: 0 additions & 4 deletions @commitlint/rules/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ export default {
'body-max-length': require('./body-max-length'),
'body-max-line-length': require('./body-max-line-length'),
'body-min-length': require('./body-min-length'),
'body-tense': require('./body-tense'),
'footer-empty': require('./footer-empty'),
'footer-leading-blank': require('./footer-leading-blank'),
'footer-max-length': require('./footer-max-length'),
'footer-max-line-length': require('./footer-max-line-length'),
'footer-min-length': require('./footer-min-length'),
'footer-tense': require('./footer-tense'),
'header-max-length': require('./header-max-length'),
'header-min-length': require('./header-min-length'),
lang: require('./lang'),
'references-empty': require('./references-empty'),
'scope-case': require('./scope-case'),
'scope-empty': require('./scope-empty'),
Expand All @@ -27,7 +24,6 @@ export default {
'subject-full-stop': require('./subject-full-stop'),
'subject-max-length': require('./subject-max-length'),
'subject-min-length': require('./subject-min-length'),
'subject-tense': require('./subject-tense'),
'type-case': require('./type-case'),
'type-empty': require('./type-empty'),
'type-enum': require('./type-enum'),
Expand Down
3 changes: 0 additions & 3 deletions @commitlint/rules/src/lang.js

This file was deleted.

15 changes: 0 additions & 15 deletions @commitlint/rules/src/lang.test.js

This file was deleted.

2 changes: 1 addition & 1 deletion @commitlint/rules/src/subject-empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export default (parsed, when) => {

return [
negated ? notEmpty : !notEmpty,
message(['message', negated ? 'may not' : 'must', 'be empty'])
message(['subject', negated ? 'may not' : 'must', 'be empty'])
];
};
2 changes: 1 addition & 1 deletion @commitlint/rules/src/subject-full-stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default (parsed, when, value) => {

return [
negated ? !hasStop : hasStop,
message(['message', negated ? 'may not' : 'must', 'end with full stop'])
message(['subject', negated ? 'may not' : 'must', 'end with full stop'])
];
};
2 changes: 1 addition & 1 deletion @commitlint/rules/src/subject-max-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export default (parsed, when, value) => {

return [
maxLength(input, value),
`footer must not be longer than ${value} characters`
`subject must not be longer than ${value} characters`
];
};
8 changes: 0 additions & 8 deletions @commitlint/rules/src/subject-tense.js

This file was deleted.

13 changes: 0 additions & 13 deletions @commitlint/rules/src/subject-tense.test.js

This file was deleted.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
"build": "lerna run build --stream --parallel --include-filtered-dependencies",
"clean": "npx lerna clean --yes && npx lerna run clean --stream --parallel --include-filtered-dependencies",
"commit": "node @commitlint/prompt-cli/cli.js",
"commitmsg": "node @commitlint/cli/lib/cli.js -E GIT_PARAMS",
"deps": "lerna run deps",
"pkg": "lerna run pkg",
"docs": "docsify serve docs",
"lint": "lerna run lint",
"precommit": "lint-staged",
"publish": "lerna publish --conventional-commits",
"reinstall": "yarn clean && yarn install",
"start": "lerna run start --stream --parallel --include-filtered-dependencies",
Expand Down Expand Up @@ -101,5 +99,11 @@
"npx": "9.7.1",
"prettier": "1.10.2",
"xo": "0.20.3"
},
"husky": {
"hooks": {
"commit-msg": "node @commitlint/cli/lib/cli.js -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
}
}