Skip to content

Commit

Permalink
feat: improve commitlint config
Browse files Browse the repository at this point in the history
Add tests to prove that our config is working as expected
  • Loading branch information
Fetz committed Jul 27, 2018
1 parent fe18f09 commit bb27c34
Show file tree
Hide file tree
Showing 6 changed files with 1,906 additions and 176 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "mailonline",
"extends": [
"mailonline",
"mailonline/jest"
],
"rules": {
"import/unambiguous": "off",
"import/no-commonjs": "off",
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ notifications:
email: false
script:
- yarn lint
- yarn test
deploy:
- provider: script
skip-cleanup: true
Expand Down
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
/*
* - footer-leading-blank removed warning since it causes warning when using
* breaking change and/or issues
*
* - subject-case sentence case was removed since it breaks when using emoji
*/

module.exports = {
rules: {
'body-leading-blank': [1, 'always'],
'footer-leading-blank': [1, 'always'],
'footer-leading-blank': [0, 'always'],
'header-max-length': [2, 'always', 50],
'scope-empty': [2, 'always'],
'subject-case': [
2,
'never',
['start-case', 'pascal-case', 'upper-case']
],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
Expand Down
63 changes: 63 additions & 0 deletions index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const lint = require('@commitlint/lint');
const {rules} = require('./');

test('should support subjects starting with emoji', async () => {
const {valid, warnings} = await lint('test: 🤖 improve testing', rules);

expect(valid).toBe(true);
expect(warnings).toEqual([]);
});

test('should support a mol full complete message', async () => {
const message = `fix: remove setConfig method
Remove setConfig method that was clashing with global configuration
handler and preventing other components configuration reading
affects: @mol/videojs-vast-vpaid
BREAKING CHANGE: The setConfig method has been removed.
Issues: MOL-4321`;

const {valid, warnings} = await lint(message, rules);

expect(valid).toBe(true);
expect(warnings).toEqual([]);
});

test('should allow github multiple authors commit message', async () => {
const message = `fix: allow multiple authors
Message body, here will be the body of the message
Co-authored-by: name <[email protected]>
Co-authored-by: another-name <[email protected]>`;

const {valid, warnings} = await lint(message, rules);

expect(valid).toBe(true);
expect(warnings).toEqual([]);
});

test('should allow a mol full complete message with github multiple authors commit message', async () => {
const message = `fix: allow multiple authors
Remove setConfig method that was clashing with global configuration
handler and preventing other components configuration reading
affects: @mol/videojs-vast-vpaid
BREAKING CHANGE: The setConfig method has been removed.
Issues: MOL-4321
Co-authored-by: name <[email protected]>
Co-authored-by: another-name <[email protected]>`;

const {valid, warnings} = await lint(message, rules);

expect(valid).toBe(true);
expect(warnings).toEqual([]);
});
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"index.js"
],
"scripts": {
"test": "echo \"No test specified\" && exit 0",
"test": "jest",
"lint": "eslint ./",
"semantic-release": "semantic-release"
},
Expand All @@ -26,9 +26,15 @@
},
"homepage": "https://github.com/MailOnline/mol-commitlint-config#readme",
"devDependencies": {
"@commitlint/lint": "^7.0.0",
"eslint": "^5.1.0",
"eslint-config-mailonline": "^9.0.0",
"husky": "^0.14.3",
"jest": "^23.4.1",
"semantic-release": "^15.8.0"
},
"jest": {
"verbose": true,
"testURL": "http://localhost/"
}
}
Loading

0 comments on commit bb27c34

Please sign in to comment.