@commitlint/format 7.0.0 → 7.2.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ <a name="7.2.1"></a>
7
+ ## [7.2.1](https://github.com/marionebl/commitlint/compare/v7.2.0...v7.2.1) (2018-10-11)
8
+
9
+
10
+
11
+
12
+ **Note:** Version bump only for package @commitlint/format
13
+
14
+ <a name="7.2.0"></a>
15
+ # [7.2.0](https://github.com/marionebl/commitlint/compare/v7.1.2...v7.2.0) (2018-10-05)
16
+
17
+
18
+
19
+
20
+ **Note:** Version bump only for package @commitlint/format
21
+
22
+ <a name="7.1.2"></a>
23
+ ## [7.1.2](https://github.com/marionebl/commitlint/compare/v7.1.1...v7.1.2) (2018-09-04)
24
+
25
+
26
+
27
+
28
+ **Note:** Version bump only for package @commitlint/format
29
+
6
30
  <a name="6.1.1"></a>
7
31
  ## [6.1.1](https://github.com/marionebl/commitlint/compare/v6.1.0...v6.1.1) (2018-02-22)
8
32
 
package/README.md CHANGED
@@ -13,29 +13,44 @@ npm install --save @commitlint/format
13
13
  ```js
14
14
  const format = require('@commitlint/format');
15
15
 
16
- format({
17
- warnings: [
16
+ const output = format({
17
+ valid: false,
18
+ errorCount: 1,
19
+ warningCount: 1,
20
+ results: [
18
21
  {
19
- level: 0,
20
- name: 'some-hint',
21
- message: 'This will not show up as it has level 0'
22
- },
23
- {
24
- level: 1,
25
- name: 'some-warning',
26
- message: 'This will show up yellow as it has level 1'
27
- }
28
- ],
29
- errors: [
30
- {
31
- level: 2,
32
- name: 'some-error',
33
- message: 'This will show up red as it has level 2'
22
+ valid: false,
23
+ input: 'some: commit message',
24
+ errors: [
25
+ {
26
+ valid: false,
27
+ level: 2,
28
+ name: 'some-error',
29
+ message: 'This will show up red as it has level 2'
30
+ }
31
+ ],
32
+ warnings: [
33
+ {
34
+ valid: true,
35
+ level: 0,
36
+ name: 'some-hint',
37
+ message: 'This will not show up as it has level 0'
38
+ },
39
+ {
40
+ valid: false,
41
+ level: 1,
42
+ name: 'some-warning',
43
+ message: 'This will show up yellow as it has level 1'
44
+ }
45
+ ]
34
46
  }
35
- ]
47
+ ]
36
48
  }, {
37
49
  color: false
38
50
  });
51
+
52
+ process.stdout.write(output);
53
+
39
54
  /* => [
40
55
  '✖ This will show up red as it has level 2 [some-error]',
41
56
  ' This will not show up as it has level 0 [some-hint]',
@@ -45,3 +60,4 @@ format({
45
60
  ```
46
61
 
47
62
  Consult [docs/api](http://marionebl.github.io/commitlint/#/reference-api) for comprehensive documentation.
63
+
package/lib/index.js CHANGED
@@ -15,16 +15,51 @@ const DEFAULT_SIGNS = [' ', '⚠', '✖'];
15
15
  const DEFAULT_COLORS = ['white', 'yellow', 'red'];
16
16
 
17
17
  function format(report = {}, options = {}) {
18
+ var _report$results = report.results;
19
+ const results = _report$results === undefined ? [] : _report$results;
20
+
21
+
22
+ if (results.length > 0) {
23
+ return results.map(result => `${formatInput(result, options)}${formatResult(result, options).join('\n')}`).join('\n');
24
+ }
25
+
26
+ // Output a summary when nothing is found
27
+ return formatResult({}, options).join('\n');
28
+ }
29
+
30
+ function formatInput(result = {}, options = {}) {
31
+ var _options$color = options.color;
32
+ const enabled = _options$color === undefined ? true : _options$color;
33
+ var _result$errors = result.errors;
34
+ const errors = _result$errors === undefined ? [] : _result$errors;
35
+ var _result$input = result.input;
36
+ const input = _result$input === undefined ? '' : _result$input;
37
+
38
+
39
+ if (!input) {
40
+ return '';
41
+ }
42
+
43
+ const sign = '⧗';
44
+ const decoration = enabled ? _chalk2.default.gray(sign) : sign;
45
+ const commitText = errors.length > 0 ? `\n${input}\n` : input.split('\n')[0];
46
+
47
+ const decoratedInput = enabled ? _chalk2.default.bold(commitText) : commitText;
48
+
49
+ return `\n${decoration} input: ${decoratedInput}\n`;
50
+ }
51
+
52
+ function formatResult(result = {}, options = {}) {
18
53
  var _options$signs = options.signs;
19
54
  const signs = _options$signs === undefined ? DEFAULT_SIGNS : _options$signs;
20
55
  var _options$colors = options.colors;
21
56
  const colors = _options$colors === undefined ? DEFAULT_COLORS : _options$colors;
22
- var _options$color = options.color;
23
- const enabled = _options$color === undefined ? true : _options$color;
24
- var _report$errors = report.errors;
25
- const errors = _report$errors === undefined ? [] : _report$errors;
26
- var _report$warnings = report.warnings;
27
- const warnings = _report$warnings === undefined ? [] : _report$warnings;
57
+ var _options$color2 = options.color;
58
+ const enabled = _options$color2 === undefined ? true : _options$color2;
59
+ var _result$errors2 = result.errors;
60
+ const errors = _result$errors2 === undefined ? [] : _result$errors2;
61
+ var _result$warnings = result.warnings;
62
+ const warnings = _result$warnings === undefined ? [] : _result$warnings;
28
63
 
29
64
 
30
65
  const problems = [...errors, ...warnings].map(problem => {
@@ -43,18 +78,18 @@ function format(report = {}, options = {}) {
43
78
  return [...problems, enabled ? _chalk2.default.bold(summary) : summary];
44
79
  }
45
80
 
46
- function selectSign(report) {
47
- if (report.errors.length > 0) {
81
+ function selectSign(result) {
82
+ if (result.errors.length > 0) {
48
83
  return '✖';
49
84
  }
50
- return report.warnings.length ? '⚠' : '✔';
85
+ return result.warnings.length ? '⚠' : '✔';
51
86
  }
52
87
 
53
- function selectColor(report) {
54
- if (report.errors.length > 0) {
88
+ function selectColor(result) {
89
+ if (result.errors.length > 0) {
55
90
  return 'red';
56
91
  }
57
- return report.warnings.length ? 'yellow' : 'green';
92
+ return result.warnings.length ? 'yellow' : 'green';
58
93
  }
59
94
  module.exports = exports['default'];
60
95
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["format","DEFAULT_SIGNS","DEFAULT_COLORS","report","options","signs","colors","color","enabled","errors","warnings","problems","map","problem","sign","level","decoration","name","grey","message","selectSign","selectColor","summary","length","bold"],"mappings":";;;;;kBAK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EAAaO,IAAb,CAAV,GAA+BA,IAAlD;AACA,OAAMQ,UAAW,GAAEN,UAAW,YAAWP,OAAOc,MAAO,cACtDb,SAASa,MACT,WAFD;AAGA,QAAO,CAAC,GAAGZ,QAAJ,EAAcH,UAAU,gBAAMgB,IAAN,CAAWF,OAAX,CAAV,GAAgCA,OAA9C,CAAP;AACA;;AAED,SAASF,UAAT,CAAoBjB,MAApB,EAA4B;AAC3B,KAAIA,OAAOM,MAAP,CAAcc,MAAd,GAAuB,CAA3B,EAA8B;AAC7B,SAAO,GAAP;AACA;AACD,QAAOpB,OAAOO,QAAP,CAAgBa,MAAhB,GAAyB,GAAzB,GAA+B,GAAtC;AACA;;AAED,SAASF,WAAT,CAAqBlB,MAArB,EAA6B;AAC5B,KAAIA,OAAOM,MAAP,CAAcc,MAAd,GAAuB,CAA3B,EAA8B;AAC7B,SAAO,KAAP;AACA;AACD,QAAOpB,OAAOO,QAAP,CAAgBa,MAAhB,GAAyB,QAAzB,GAAoC,OAA3C;AACA","file":"index.js","sourcesContent":["import chalk from 'chalk';\n\nconst DEFAULT_SIGNS = [' ', '⚠', '✖'];\nconst DEFAULT_COLORS = ['white', 'yellow', 'red'];\n\nexport default function format(report = {}, options = {}) {\n\tconst {\n\t\tsigns = DEFAULT_SIGNS,\n\t\tcolors = DEFAULT_COLORS,\n\t\tcolor: enabled = true\n\t} = options;\n\tconst {errors = [], warnings = []} = report;\n\n\tconst problems = [...errors, ...warnings].map(problem => {\n\t\tconst sign = signs[problem.level] || '';\n\t\tconst color = colors[problem.level] || 'white';\n\t\tconst decoration = enabled ? chalk[color](sign) : sign;\n\t\tconst name = enabled\n\t\t\t? chalk.grey(`[${problem.name}]`)\n\t\t\t: `[${problem.name}]`;\n\t\treturn `${decoration} ${problem.message} ${name}`;\n\t});\n\n\tconst sign = selectSign({errors, warnings});\n\tconst color = selectColor({errors, warnings});\n\n\tconst decoration = enabled ? chalk[color](sign) : sign;\n\tconst summary = `${decoration} found ${errors.length} problems, ${\n\t\twarnings.length\n\t} warnings`;\n\treturn [...problems, enabled ? chalk.bold(summary) : summary];\n}\n\nfunction selectSign(report) {\n\tif (report.errors.length > 0) {\n\t\treturn '✖';\n\t}\n\treturn report.warnings.length ? '⚠' : '✔';\n}\n\nfunction selectColor(report) {\n\tif (report.errors.length > 0) {\n\t\treturn 'red';\n\t}\n\treturn report.warnings.length ? 'yellow' : 'green';\n}\n"]}
1
+ {"version":3,"sources":["../src/index.js"],"names":["format","DEFAULT_SIGNS","DEFAULT_COLORS","report","options","results","length","map","result","formatInput","formatResult","join","color","enabled","errors","input","sign","decoration","gray","commitText","split","decoratedInput","bold","signs","colors","warnings","problems","problem","level","name","grey","message","selectSign","selectColor","summary"],"mappings":";;;;;kBAKwBA,M;;AALxB;;;;;;AAEA,MAAMC,gBAAgB,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAAtB;AACA,MAAMC,iBAAiB,CAAC,OAAD,EAAU,QAAV,EAAoB,KAApB,CAAvB;;AAEe,SAASF,MAAT,CAAgBG,SAAS,EAAzB,EAA6BC,UAAU,EAAvC,EAA2C;AAAA,uBAClCD,MADkC,CAClDE,OADkD;AAAA,OAClDA,OADkD,mCACxC,EADwC;;;AAGzD,KAAIA,QAAQC,MAAR,GAAiB,CAArB,EAAwB;AACvB,SAAOD,QACLE,GADK,CAELC,UACE,GAAEC,YAAYD,MAAZ,EAAoBJ,OAApB,CAA6B,GAAEM,aAAaF,MAAb,EAAqBJ,OAArB,EAA8BO,IAA9B,CACjC,IADiC,CAEhC,EALE,EAOLA,IAPK,CAOA,IAPA,CAAP;AAQA;;AAED;AACA,QAAOD,aAAa,EAAb,EAAiBN,OAAjB,EAA0BO,IAA1B,CAA+B,IAA/B,CAAP;AACA;;AAED,SAASF,WAAT,CAAqBD,SAAS,EAA9B,EAAkCJ,UAAU,EAA5C,EAAgD;AAAA,sBACfA,OADe,CACxCQ,KADwC;AAAA,OACjCC,OADiC,kCACvB,IADuB;AAAA,sBAEbL,MAFa,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,KAAN,EAAaI,IAAb,CAAV,GAA+BA,IAAlD;AACA,QAAMa,OAAOhB,UACV,gBAAMiB,IAAN,CAAY,IAAGH,QAAQE,IAAK,GAA5B,CADU,GAET,IAAGF,QAAQE,IAAK,GAFpB;AAGA,SAAQ,GAAEZ,UAAW,MAAKU,QAAQI,OAAQ,IAAGF,IAAK,EAAlD;AACA,EARgB,CAAjB;;AAUA,OAAMb,OAAOgB,WAAW,EAAClB,MAAD,EAASW,QAAT,EAAX,CAAb;AACA,OAAMb,QAAQqB,YAAY,EAACnB,MAAD,EAASW,QAAT,EAAZ,CAAd;;AAEA,OAAMR,aAAaJ,UAAU,gBAAMD,KAAN,EAAaI,IAAb,CAAV,GAA+BA,IAAlD;AACA,OAAMkB,UAAW,GAAEjB,UAAW,YAAWH,OAAOR,MAAO,cACtDmB,SAASnB,MACT,WAFD;AAGA,QAAO,CAAC,GAAGoB,QAAJ,EAAcb,UAAU,gBAAMS,IAAN,CAAWY,OAAX,CAAV,GAAgCA,OAA9C,CAAP;AACA;;AAED,SAASF,UAAT,CAAoBxB,MAApB,EAA4B;AAC3B,KAAIA,OAAOM,MAAP,CAAcR,MAAd,GAAuB,CAA3B,EAA8B;AAC7B,SAAO,GAAP;AACA;AACD,QAAOE,OAAOiB,QAAP,CAAgBnB,MAAhB,GAAyB,GAAzB,GAA+B,GAAtC;AACA;;AAED,SAAS2B,WAAT,CAAqBzB,MAArB,EAA6B;AAC5B,KAAIA,OAAOM,MAAP,CAAcR,MAAd,GAAuB,CAA3B,EAA8B;AAC7B,SAAO,KAAP;AACA;AACD,QAAOE,OAAOiB,QAAP,CAAgBnB,MAAhB,GAAyB,QAAzB,GAAoC,OAA3C;AACA","file":"index.js","sourcesContent":["import chalk from 'chalk';\n\nconst DEFAULT_SIGNS = [' ', '⚠', '✖'];\nconst DEFAULT_COLORS = ['white', 'yellow', 'red'];\n\nexport default function format(report = {}, options = {}) {\n\tconst {results = []} = report;\n\n\tif (results.length > 0) {\n\t\treturn results\n\t\t\t.map(\n\t\t\t\tresult =>\n\t\t\t\t\t`${formatInput(result, options)}${formatResult(result, options).join(\n\t\t\t\t\t\t'\\n'\n\t\t\t\t\t)}`\n\t\t\t)\n\t\t\t.join('\\n');\n\t}\n\n\t// Output a summary when nothing is found\n\treturn formatResult({}, options).join('\\n');\n}\n\nfunction formatInput(result = {}, options = {}) {\n\tconst {color: enabled = true} = options;\n\tconst {errors = [], input = ''} = result;\n\n\tif (!input) {\n\t\treturn '';\n\t}\n\n\tconst sign = '⧗';\n\tconst decoration = enabled ? chalk.gray(sign) : sign;\n\tconst commitText = errors.length > 0 ? `\\n${input}\\n` : input.split('\\n')[0];\n\n\tconst decoratedInput = enabled ? chalk.bold(commitText) : commitText;\n\n\treturn `\\n${decoration} input: ${decoratedInput}\\n`;\n}\n\nfunction formatResult(result = {}, options = {}) {\n\tconst {\n\t\tsigns = DEFAULT_SIGNS,\n\t\tcolors = DEFAULT_COLORS,\n\t\tcolor: enabled = true\n\t} = options;\n\tconst {errors = [], warnings = []} = result;\n\n\tconst problems = [...errors, ...warnings].map(problem => {\n\t\tconst sign = signs[problem.level] || '';\n\t\tconst color = colors[problem.level] || 'white';\n\t\tconst decoration = enabled ? chalk[color](sign) : sign;\n\t\tconst name = enabled\n\t\t\t? chalk.grey(`[${problem.name}]`)\n\t\t\t: `[${problem.name}]`;\n\t\treturn `${decoration} ${problem.message} ${name}`;\n\t});\n\n\tconst sign = selectSign({errors, warnings});\n\tconst color = selectColor({errors, warnings});\n\n\tconst decoration = enabled ? chalk[color](sign) : sign;\n\tconst summary = `${decoration} found ${errors.length} problems, ${\n\t\twarnings.length\n\t} warnings`;\n\treturn [...problems, enabled ? chalk.bold(summary) : summary];\n}\n\nfunction selectSign(result) {\n\tif (result.errors.length > 0) {\n\t\treturn '✖';\n\t}\n\treturn result.warnings.length ? '⚠' : '✔';\n}\n\nfunction selectColor(result) {\n\tif (result.errors.length > 0) {\n\t\treturn 'red';\n\t}\n\treturn result.warnings.length ? 'yellow' : 'green';\n}\n"]}
package/lib/index.test.js CHANGED
@@ -1,9 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
4
-
5
- var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
6
-
7
3
  var _ava = require('ava');
8
4
 
9
5
  var _ava2 = _interopRequireDefault(_ava);
@@ -26,97 +22,105 @@ const ok = _chalk2.default.bold(`${_chalk2.default.green('✔')} found 0 probl
26
22
 
27
23
  (0, _ava2.default)('does nothing without arguments', t => {
28
24
  const actual = (0, _2.default)();
29
- t.deepEqual(actual, [ok]);
25
+ t.deepEqual(actual, ok);
26
+ });
27
+
28
+ (0, _ava2.default)('does nothing without report results', t => {
29
+ const actual = (0, _2.default)({ results: [] });
30
+ t.deepEqual(actual, ok);
30
31
  });
31
32
 
32
33
  (0, _ava2.default)('does nothing without .errors and .warnings', t => {
33
- const actual = (0, _2.default)({});
34
- t.deepEqual(actual, [ok]);
34
+ const actual = (0, _2.default)({ results: [{}] });
35
+ t.deepEqual(actual, ok);
35
36
  });
36
37
 
37
38
  (0, _ava2.default)('returns empty summary of problems for empty .errors and .warnings', t => {
38
- var _format = (0, _2.default)({
39
- errors: [],
40
- warnings: []
41
- }),
42
- _format2 = (0, _slicedToArray3.default)(_format, 1);
43
-
44
- const msg = _format2[0];
45
-
39
+ const actual = (0, _2.default)({
40
+ results: [{
41
+ errors: [],
42
+ warnings: []
43
+ }]
44
+ });
46
45
 
47
- t.true(msg.includes('0 problems, 0 warnings'));
46
+ t.true(actual.includes('0 problems, 0 warnings'));
48
47
  });
49
48
 
50
49
  (0, _ava2.default)('returns a correct of empty .errors and .warnings', t => {
51
- var _format3 = (0, _2.default)({
52
- errors: [{
53
- level: 2,
54
- name: 'error-name',
55
- message: 'There was an error'
56
- }],
57
- warnings: [{
58
- level: 1,
59
- name: 'warning-name',
60
- message: 'There was a problem'
50
+ const actualError = (0, _2.default)({
51
+ results: [{
52
+ errors: [{
53
+ level: 2,
54
+ name: 'error-name',
55
+ message: 'There was an error'
56
+ }]
61
57
  }]
62
- }),
63
- _format4 = (0, _slicedToArray3.default)(_format3, 3);
64
-
65
- const err = _format4[0],
66
- prob = _format4[1],
67
- msg = _format4[2];
68
-
58
+ });
59
+
60
+ const actualWarning = (0, _2.default)({
61
+ results: [{
62
+ warnings: [{
63
+ level: 1,
64
+ name: 'warning-name',
65
+ message: 'There was a problem'
66
+ }]
67
+ }]
68
+ });
69
69
 
70
- t.true((0, _lodash2.default)(err, 'There was an error'));
71
- t.true((0, _lodash2.default)(prob, 'There was a problem'));
72
- t.true((0, _lodash2.default)(msg, '1 problems, 1 warnings'));
70
+ t.true((0, _lodash2.default)(actualError, 'There was an error'));
71
+ t.true((0, _lodash2.default)(actualError, '1 problems, 0 warnings'));
72
+ t.true((0, _lodash2.default)(actualWarning, 'There was a problem'));
73
+ t.true((0, _lodash2.default)(actualWarning, '0 problems, 1 warnings'));
73
74
  });
74
75
 
75
76
  (0, _ava2.default)('uses appropriate signs by default', t => {
76
- var _format5 = (0, _2.default)({
77
- errors: [{
78
- level: 2,
79
- name: 'error-name',
80
- message: 'There was an error'
81
- }],
82
- warnings: [{
83
- level: 1,
84
- name: 'warning-name',
85
- message: 'There was a problem'
77
+ const actualError = (0, _2.default)({
78
+ results: [{
79
+ errors: [{
80
+ level: 2,
81
+ name: 'error-name',
82
+ message: 'There was an error'
83
+ }]
86
84
  }]
87
- }),
88
- _format6 = (0, _slicedToArray3.default)(_format5, 2);
89
-
90
- const err = _format6[0],
91
- warn = _format6[1];
92
-
85
+ });
86
+
87
+ const actualWarning = (0, _2.default)({
88
+ results: [{
89
+ warnings: [{
90
+ level: 1,
91
+ name: 'warning-name',
92
+ message: 'There was a problem'
93
+ }]
94
+ }]
95
+ });
93
96
 
94
- t.true((0, _lodash2.default)(err, '✖'));
95
- t.true((0, _lodash2.default)(warn, '⚠'));
97
+ t.true((0, _lodash2.default)(actualError, '✖'));
98
+ t.true((0, _lodash2.default)(actualWarning, '⚠'));
96
99
  });
97
100
 
98
101
  (0, _ava2.default)('uses signs as configured', t => {
99
- var _format7 = (0, _2.default)({
100
- errors: [{
101
- level: 2,
102
- name: 'error-name',
103
- message: 'There was an error'
104
- }],
105
- warnings: [{
106
- level: 1,
107
- name: 'warning-name',
108
- message: 'There was a problem'
102
+ const options = { signs: ['HNT', 'WRN', 'ERR'] };
103
+ const actualError = (0, _2.default)({
104
+ results: [{
105
+ errors: [{
106
+ level: 2,
107
+ name: 'error-name',
108
+ message: 'There was an error'
109
+ }]
109
110
  }]
110
- }, {
111
- signs: ['HNT', 'WRN', 'ERR']
112
- }),
113
- _format8 = (0, _slicedToArray3.default)(_format7, 2);
114
-
115
- const err = _format8[0],
116
- warn = _format8[1];
117
-
111
+ }, options);
112
+
113
+ const actualWarning = (0, _2.default)({
114
+ results: [{
115
+ warnings: [{
116
+ level: 1,
117
+ name: 'warning-name',
118
+ message: 'There was a problem'
119
+ }]
120
+ }]
121
+ }, options);
118
122
 
119
- t.true((0, _lodash2.default)(err, 'ERR'));
120
- t.true((0, _lodash2.default)(warn, 'WRN'));
123
+ t.true((0, _lodash2.default)(actualError, 'ERR'));
124
+ t.true((0, _lodash2.default)(actualWarning, 'WRN'));
121
125
  });
122
126
  //# sourceMappingURL=index.test.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.test.js"],"names":["ok","bold","green","t","actual","deepEqual","errors","warnings","msg","true","includes","level","name","message","err","prob","warn","signs"],"mappings":";;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;;;AAEA,MAAMA,KAAK,gBAAMC,IAAN,CAAY,GAAE,gBAAMC,KAAN,CAAY,GAAZ,CAAiB,iCAA/B,CAAX;;AAEA,mBAAK,gCAAL,EAAuCC,KAAK;AAC3C,OAAMC,SAAS,iBAAf;AACAD,GAAEE,SAAF,CAAYD,MAAZ,EAAoB,CAACJ,EAAD,CAApB;AACA,CAHD;;AAKA,mBAAK,4CAAL,EAAmDG,KAAK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ApBD;;AAsBA,mBAAK,0BAAL,EAAiCb,KAAK;AAAA,gBACjB,gBACnB;AACCG,UAAQ,CACP;AACCK,UAAO,CADR;AAECC,SAAM,YAFP;AAGCC,YAAS;AAHV,GADO,CADT;AAQCN,YAAU,CACT;AACCI,UAAO,CADR;AAECC,SAAM,cAFP;AAGCC,YAAS;AAHV,GADS;AARX,EADmB,EAiBnB;AACCI,SAAO,CAAC,KAAD,EAAQ,KAAR,EAAe,KAAf;AADR,EAjBmB,CADiB;AAAA;;AAAA,OAC9BH,GAD8B;AAAA,OACzBE,IADyB;;;AAuBrCb,GAAEM,IAAF,CAAO,sBAASK,GAAT,EAAc,KAAd,CAAP;AACAX,GAAEM,IAAF,CAAO,sBAASO,IAAT,EAAe,KAAf,CAAP;AACA,CAzBD","file":"index.test.js","sourcesContent":["import test from 'ava';\nimport chalk from 'chalk';\nimport includes from 'lodash.includes';\nimport format from '.';\n\nconst ok = chalk.bold(`${chalk.green('✔')} found 0 problems, 0 warnings`);\n\ntest('does nothing without arguments', t => {\n\tconst actual = format();\n\tt.deepEqual(actual, [ok]);\n});\n\ntest('does nothing without .errors and .warnings', t => {\n\tconst actual = format({});\n\tt.deepEqual(actual, [ok]);\n});\n\ntest('returns empty summary of problems for empty .errors and .warnings', t => {\n\tconst [msg] = format({\n\t\terrors: [],\n\t\twarnings: []\n\t});\n\n\tt.true(msg.includes('0 problems, 0 warnings'));\n});\n\ntest('returns a correct of empty .errors and .warnings', t => {\n\tconst [err, prob, msg] = format({\n\t\terrors: [\n\t\t\t{\n\t\t\t\tlevel: 2,\n\t\t\t\tname: 'error-name',\n\t\t\t\tmessage: 'There was an error'\n\t\t\t}\n\t\t],\n\t\twarnings: [\n\t\t\t{\n\t\t\t\tlevel: 1,\n\t\t\t\tname: 'warning-name',\n\t\t\t\tmessage: 'There was a problem'\n\t\t\t}\n\t\t]\n\t});\n\n\tt.true(includes(err, 'There was an error'));\n\tt.true(includes(prob, 'There was a problem'));\n\tt.true(includes(msg, '1 problems, 1 warnings'));\n});\n\ntest('uses appropriate signs by default', t => {\n\tconst [err, warn] = format({\n\t\terrors: [\n\t\t\t{\n\t\t\t\tlevel: 2,\n\t\t\t\tname: 'error-name',\n\t\t\t\tmessage: 'There was an error'\n\t\t\t}\n\t\t],\n\t\twarnings: [\n\t\t\t{\n\t\t\t\tlevel: 1,\n\t\t\t\tname: 'warning-name',\n\t\t\t\tmessage: 'There was a problem'\n\t\t\t}\n\t\t]\n\t});\n\n\tt.true(includes(err, '✖'));\n\tt.true(includes(warn, '⚠'));\n});\n\ntest('uses signs as configured', t => {\n\tconst [err, warn] = format(\n\t\t{\n\t\t\terrors: [\n\t\t\t\t{\n\t\t\t\t\tlevel: 2,\n\t\t\t\t\tname: 'error-name',\n\t\t\t\t\tmessage: 'There was an error'\n\t\t\t\t}\n\t\t\t],\n\t\t\twarnings: [\n\t\t\t\t{\n\t\t\t\t\tlevel: 1,\n\t\t\t\t\tname: 'warning-name',\n\t\t\t\t\tmessage: 'There was a problem'\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\tsigns: ['HNT', 'WRN', 'ERR']\n\t\t}\n\t);\n\n\tt.true(includes(err, 'ERR'));\n\tt.true(includes(warn, 'WRN'));\n});\n"]}
1
+ {"version":3,"sources":["../src/index.test.js"],"names":["ok","bold","green","t","actual","deepEqual","results","errors","warnings","true","includes","actualError","level","name","message","actualWarning","options","signs"],"mappings":";;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;;;AAEA,MAAMA,KAAK,gBAAMC,IAAN,CAAY,GAAE,gBAAMC,KAAN,CAAY,GAAZ,CAAiB,iCAA/B,CAAX;;AAEA,mBAAK,gCAAL,EAAuCC,KAAK;AAC3C,OAAMC,SAAS,iBAAf;AACAD,GAAEE,SAAF,CAAYD,MAAZ,EAAoBJ,EAApB;AACA,CAHD;;AAKA,mBAAK,qCAAL,EAA4CG,KAAK;AAChD,OAAMC,SAAS,gBAAO,EAACE,SAAS,EAAV,EAAP,CA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AApB;;AAcA,OAAMC,gBAAgB,gBAAO;AAC5BT,WAAS,CACR;AACCE,aAAU,CACT;AACCI,WAAO,CADR;AAECC,UAAM,cAFP;AAGCC,aAAS;AAHV,IADS;AADX,GADQ;AADmB,EAAP,CAAtB;;AAcAX,GAAEM,IAAF,CAAO,sBAASE,WAAT,EAAsB,GAAtB,CAAP;AACAR,GAAEM,IAAF,CAAO,sBAASM,aAAT,EAAwB,GAAxB,CAAP;AACA,CA/BD;;AAiCA,mBAAK,0BAAL,EAAiCZ,KAAK;AACrC,OAAMa,UAAU,EAACC,OAAO,CAAC,KAAD,EAAQ,KAAR,EAAe,KAAf,CAAR,EAAhB;AACA,OAAMN,cAAc,gBACnB;AACCL,WAAS,CACR;AACCC,WAAQ,CACP;AACCK,WAAO,CADR;AAECC,UAAM,YAFP;AAGCC,aAAS;AAHV,IADO;AADT,GADQ;AADV,EADmB,EAcnBE,OAdmB,CAApB;;AAiBA,OAAMD,gBAAgB,gBACrB;AACCT,WAAS,CACR;AACCE,aAAU,CACT;AACCI,WAAO,CADR;AAECC,UAAM,cAFP;AAGCC,aAAS;AAHV,IADS;AADX,GADQ;AADV,EADqB,EAcrBE,OAdqB,CAAtB;;AAiBAb,GAAEM,IAAF,CAAO,sBAASE,WAAT,EAAsB,KAAtB,CAAP;AACAR,GAAEM,IAAF,CAAO,sBAASM,aAAT,EAAwB,KAAxB,CAAP;AACA,CAtCD","file":"index.test.js","sourcesContent":["import test from 'ava';\nimport chalk from 'chalk';\nimport includes from 'lodash.includes';\nimport format from '.';\n\nconst ok = chalk.bold(`${chalk.green('✔')} found 0 problems, 0 warnings`);\n\ntest('does nothing without arguments', t => {\n\tconst actual = format();\n\tt.deepEqual(actual, ok);\n});\n\ntest('does nothing without report results', t => {\n\tconst actual = format({results: []});\n\tt.deepEqual(actual, ok);\n});\n\ntest('does nothing without .errors and .warnings', t => {\n\tconst actual = format({results: [{}]});\n\tt.deepEqual(actual, ok);\n});\n\ntest('returns empty summary of problems for empty .errors and .warnings', t => {\n\tconst actual = format({\n\t\tresults: [\n\t\t\t{\n\t\t\t\terrors: [],\n\t\t\t\twarnings: []\n\t\t\t}\n\t\t]\n\t});\n\n\tt.true(actual.includes('0 problems, 0 warnings'));\n});\n\ntest('returns a correct of empty .errors and .warnings', t => {\n\tconst actualError = format({\n\t\tresults: [\n\t\t\t{\n\t\t\t\terrors: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlevel: 2,\n\t\t\t\t\t\tname: 'error-name',\n\t\t\t\t\t\tmessage: 'There was an error'\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t});\n\n\tconst actualWarning = format({\n\t\tresults: [\n\t\t\t{\n\t\t\t\twarnings: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlevel: 1,\n\t\t\t\t\t\tname: 'warning-name',\n\t\t\t\t\t\tmessage: 'There was a problem'\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t});\n\n\tt.true(includes(actualError, 'There was an error'));\n\tt.true(includes(actualError, '1 problems, 0 warnings'));\n\tt.true(includes(actualWarning, 'There was a problem'));\n\tt.true(includes(actualWarning, '0 problems, 1 warnings'));\n});\n\ntest('uses appropriate signs by default', t => {\n\tconst actualError = format({\n\t\tresults: [\n\t\t\t{\n\t\t\t\terrors: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlevel: 2,\n\t\t\t\t\t\tname: 'error-name',\n\t\t\t\t\t\tmessage: 'There was an error'\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t});\n\n\tconst actualWarning = format({\n\t\tresults: [\n\t\t\t{\n\t\t\t\twarnings: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlevel: 1,\n\t\t\t\t\t\tname: 'warning-name',\n\t\t\t\t\t\tmessage: 'There was a problem'\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t});\n\n\tt.true(includes(actualError, '✖'));\n\tt.true(includes(actualWarning, '⚠'));\n});\n\ntest('uses signs as configured', t => {\n\tconst options = {signs: ['HNT', 'WRN', 'ERR']};\n\tconst actualError = format(\n\t\t{\n\t\t\tresults: [\n\t\t\t\t{\n\t\t\t\t\terrors: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlevel: 2,\n\t\t\t\t\t\t\tname: 'error-name',\n\t\t\t\t\t\t\tmessage: 'There was an error'\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\toptions\n\t);\n\n\tconst actualWarning = format(\n\t\t{\n\t\t\tresults: [\n\t\t\t\t{\n\t\t\t\t\twarnings: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlevel: 1,\n\t\t\t\t\t\t\tname: 'warning-name',\n\t\t\t\t\t\t\tmessage: 'There was a problem'\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\toptions\n\t);\n\n\tt.true(includes(actualError, 'ERR'));\n\tt.true(includes(actualWarning, 'WRN'));\n});\n"]}
package/license.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 - present Mario Nebl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commitlint/format",
3
- "version": "7.0.0",
3
+ "version": "7.2.1",
4
4
  "description": "Format commitlint reports",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -59,11 +59,11 @@
59
59
  },
60
60
  "license": "MIT",
61
61
  "devDependencies": {
62
- "@commitlint/test": "^7.0.0",
63
- "@commitlint/utils": "^7.0.0",
62
+ "@commitlint/test": "^7.1.2",
63
+ "@commitlint/utils": "^7.1.2",
64
64
  "ava": "0.22.0",
65
65
  "babel-cli": "6.26.0",
66
- "babel-preset-commitlint": "^7.0.0",
66
+ "babel-preset-commitlint": "^7.1.2",
67
67
  "babel-register": "6.26.0",
68
68
  "concurrently": "3.5.1",
69
69
  "cross-env": "5.1.1",