Socket
Socket
Sign inDemoInstall

@commitlint/format

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commitlint/format - npm Package Compare versions

Comparing version 6.1.3 to 7.0.0

53

lib/index.js

@@ -6,7 +6,2 @@ 'use strict';

});
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
exports.default = format;

@@ -20,34 +15,32 @@

var DEFAULT_SIGNS = [' ', '⚠', '✖'];
var DEFAULT_COLORS = ['white', 'yellow', 'red'];
const DEFAULT_SIGNS = [' ', '⚠', '✖'];
const DEFAULT_COLORS = ['white', 'yellow', 'red'];
function format() {
var report = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$signs = options.signs,
signs = _options$signs === undefined ? DEFAULT_SIGNS : _options$signs,
_options$colors = options.colors,
colors = _options$colors === undefined ? DEFAULT_COLORS : _options$colors,
_options$color = options.color,
enabled = _options$color === undefined ? true : _options$color;
var _report$errors = report.errors,
errors = _report$errors === undefined ? [] : _report$errors,
_report$warnings = report.warnings,
warnings = _report$warnings === undefined ? [] : _report$warnings;
function format(report = {}, options = {}) {
var _options$signs = options.signs;
const signs = _options$signs === undefined ? DEFAULT_SIGNS : _options$signs;
var _options$colors = options.colors;
const colors = _options$colors === undefined ? DEFAULT_COLORS : _options$colors;
var _options$color = options.color;
const enabled = _options$color === undefined ? true : _options$color;
var _report$errors = report.errors;
const errors = _report$errors === undefined ? [] : _report$errors;
var _report$warnings = report.warnings;
const warnings = _report$warnings === undefined ? [] : _report$warnings;
var problems = [].concat((0, _toConsumableArray3.default)(errors), (0, _toConsumableArray3.default)(warnings)).map(function (problem) {
var sign = signs[problem.level] || '';
var color = colors[problem.level] || 'white';
var decoration = enabled ? _chalk2.default[color](sign) : sign;
var name = enabled ? _chalk2.default.grey(`[${problem.name}]`) : `[${problem.name}]`;
const problems = [...errors, ...warnings].map(problem => {
const sign = signs[problem.level] || '';
const color = colors[problem.level] || 'white';
const decoration = enabled ? _chalk2.default[color](sign) : sign;
const name = enabled ? _chalk2.default.grey(`[${problem.name}]`) : `[${problem.name}]`;
return `${decoration} ${problem.message} ${name}`;
});
var sign = selectSign({ errors, warnings });
var color = selectColor({ errors, warnings });
const sign = selectSign({ errors, warnings });
const color = selectColor({ errors, warnings });
var decoration = enabled ? _chalk2.default[color](sign) : sign;
var summary = `${decoration} found ${errors.length} problems, ${warnings.length} warnings`;
return [].concat((0, _toConsumableArray3.default)(problems), [enabled ? _chalk2.default.bold(summary) : summary]);
const decoration = enabled ? _chalk2.default[color](sign) : sign;
const summary = `${decoration} found ${errors.length} problems, ${warnings.length} warnings`;
return [...problems, enabled ? _chalk2.default.bold(summary) : summary];
}

@@ -54,0 +47,0 @@

@@ -25,15 +25,15 @@ 'use strict';

var ok = _chalk2.default.bold(`${_chalk2.default.green('✔')} found 0 problems, 0 warnings`);
const ok = _chalk2.default.bold(`${_chalk2.default.green('✔')} found 0 problems, 0 warnings`);
(0, _ava2.default)('does nothing without arguments', function (t) {
var actual = (0, _2.default)();
(0, _ava2.default)('does nothing without arguments', t => {
const actual = (0, _2.default)();
t.deepEqual(actual, [ok]);
});
(0, _ava2.default)('does nothing without .errors and .warnings', function (t) {
var actual = (0, _2.default)({});
(0, _ava2.default)('does nothing without .errors and .warnings', t => {
const actual = (0, _2.default)({});
t.deepEqual(actual, [ok]);
});
(0, _ava2.default)('returns empty summary of problems for empty .errors and .warnings', function (t) {
(0, _ava2.default)('returns empty summary of problems for empty .errors and .warnings', t => {
var _format = (0, _2.default)({

@@ -43,9 +43,11 @@ errors: [],

}),
_format2 = (0, _slicedToArray3.default)(_format, 1),
msg = _format2[0];
_format2 = (0, _slicedToArray3.default)(_format, 1);
const msg = _format2[0];
t.true(msg.includes('0 problems, 0 warnings'));
});
(0, _ava2.default)('returns a correct of empty .errors and .warnings', function (t) {
(0, _ava2.default)('returns a correct of empty .errors and .warnings', t => {
var _format3 = (0, _2.default)({

@@ -63,7 +65,9 @@ errors: [{

}),
_format4 = (0, _slicedToArray3.default)(_format3, 3),
err = _format4[0],
prob = _format4[1],
msg = _format4[2];
_format4 = (0, _slicedToArray3.default)(_format3, 3);
const err = _format4[0],
prob = _format4[1],
msg = _format4[2];
t.true((0, _lodash2.default)(err, 'There was an error'));

@@ -74,3 +78,3 @@ t.true((0, _lodash2.default)(prob, 'There was a problem'));

(0, _ava2.default)('uses appropriate signs by default', function (t) {
(0, _ava2.default)('uses appropriate signs by default', t => {
var _format5 = (0, _2.default)({

@@ -88,6 +92,8 @@ errors: [{

}),
_format6 = (0, _slicedToArray3.default)(_format5, 2),
err = _format6[0],
warn = _format6[1];
_format6 = (0, _slicedToArray3.default)(_format5, 2);
const err = _format6[0],
warn = _format6[1];
t.true((0, _lodash2.default)(err, '✖'));

@@ -97,3 +103,3 @@ t.true((0, _lodash2.default)(warn, '⚠'));

(0, _ava2.default)('uses signs as configured', function (t) {
(0, _ava2.default)('uses signs as configured', t => {
var _format7 = (0, _2.default)({

@@ -113,6 +119,8 @@ errors: [{

}),
_format8 = (0, _slicedToArray3.default)(_format7, 2),
err = _format8[0],
warn = _format8[1];
_format8 = (0, _slicedToArray3.default)(_format7, 2);
const err = _format8[0],
warn = _format8[1];
t.true((0, _lodash2.default)(err, 'ERR'));

@@ -119,0 +127,0 @@ t.true((0, _lodash2.default)(warn, 'WRN'));

{
"name": "@commitlint/format",
"version": "6.1.3",
"version": "7.0.0",
"description": "Format commitlint reports",

@@ -62,7 +62,7 @@ "main": "lib/index.js",

"devDependencies": {
"@commitlint/test": "^6.1.3",
"@commitlint/utils": "^6.1.3",
"@commitlint/test": "^7.0.0",
"@commitlint/utils": "^7.0.0",
"ava": "0.22.0",
"babel-cli": "6.26.0",
"babel-preset-commitlint": "^6.1.3",
"babel-preset-commitlint": "^7.0.0",
"babel-register": "6.26.0",

@@ -69,0 +69,0 @@ "concurrently": "3.5.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc