Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@commitlint/format

Package Overview
Dependencies
Maintainers
4
Versions
57
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 8.3.4 to 9.0.0

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

# [9.0.0](https://github.com/conventional-changelog/commitlint/compare/v8.3.5...v9.0.0) (2020-05-21)
**Note:** Version bump only for package @commitlint/format
## [8.3.4](https://github.com/conventional-changelog/commitlint/compare/v8.3.3...v8.3.4) (2020-01-03)

@@ -8,0 +16,0 @@

103

lib/format.js
"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
var chalk_1 = __importDefault(require("chalk"));
var DEFAULT_SIGNS = [' ', '⚠', '✖'];
var DEFAULT_COLORS = ['white', 'yellow', 'red'];
function format(report, options) {
if (report === void 0) { report = {}; }
if (options === void 0) { options = {}; }
var _a = report.results, results = _a === void 0 ? [] : _a;
var fi = function (result) {
return formatInput(result, options);
};
var fr = function (result) { return formatResult(result, options); };
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const DEFAULT_SIGNS = [' ', '⚠', '✖'];
const DEFAULT_COLORS = ['white', 'yellow', 'red'];
function format(report = {}, options = {}) {
const { results = [] } = report;
const fi = (result) => formatInput(result, options);
const fr = (result) => formatResult(result, options);
return results
.filter(function (r) { return Array.isArray(r.warnings) || Array.isArray(r.errors); })
.map(function (result) { return __spreadArrays(fi(result), fr(result)); })
.reduce(function (acc, item) { return (Array.isArray(item) ? __spreadArrays(acc, item) : __spreadArrays(acc, [item])); }, [])
.filter(r => Array.isArray(r.warnings) || Array.isArray(r.errors))
.map(result => [...fi(result), ...fr(result)])
.reduce((acc, item) => (Array.isArray(item) ? [...acc, ...item] : [...acc, item]), [])
.join('\n');
}
exports.format = format;
function formatInput(result, options) {
if (options === void 0) { options = {}; }
var _a = options.color, enabled = _a === void 0 ? true : _a;
var _b = result.errors, errors = _b === void 0 ? [] : _b, _c = result.warnings, warnings = _c === void 0 ? [] : _c, _d = result.input, input = _d === void 0 ? '' : _d;
function formatInput(result, options = {}) {
const { color: enabled = true } = options;
const { errors = [], warnings = [], input = '' } = result;
if (!input) {
return [''];
}
var sign = '⧗';
var decoration = enabled ? chalk_1["default"].gray(sign) : sign;
var commitText = errors.length > 0 ? input : input.split('\n')[0];
var decoratedInput = enabled ? chalk_1["default"].bold(commitText) : commitText;
var hasProblems = errors.length > 0 || warnings.length > 0;
const sign = '⧗';
const decoration = enabled ? chalk_1.default.gray(sign) : sign;
const commitText = errors.length > 0 ? input : input.split('\n')[0];
const decoratedInput = enabled ? chalk_1.default.bold(commitText) : commitText;
const hasProblems = errors.length > 0 || warnings.length > 0;
return options.verbose || hasProblems
? [decoration + " input: " + decoratedInput]
? [`${decoration} input: ${decoratedInput}`]
: [];
}
function formatResult(result, options) {
if (result === void 0) { result = {}; }
if (options === void 0) { options = {}; }
var _a = options.signs, signs = _a === void 0 ? DEFAULT_SIGNS : _a, _b = options.colors, colors = _b === void 0 ? DEFAULT_COLORS : _b, _c = options.color, enabled = _c === void 0 ? true : _c;
var _d = result.errors, errors = _d === void 0 ? [] : _d, _e = result.warnings, warnings = _e === void 0 ? [] : _e;
var problems = __spreadArrays(errors, warnings).map(function (problem) {
var sign = signs[problem.level] || '';
var color = colors[problem.level] || 'white';
var decoration = enabled ? chalk_1["default"][color](sign) : sign;
var name = enabled
? chalk_1["default"].grey("[" + problem.name + "]")
: "[" + problem.name + "]";
return decoration + " " + problem.message + " " + name;
function formatResult(result = {}, options = {}) {
const { signs = DEFAULT_SIGNS, colors = DEFAULT_COLORS, color: enabled = true } = options;
const { errors = [], warnings = [] } = result;
const problems = [...errors, ...warnings].map(problem => {
const sign = signs[problem.level] || '';
const color = colors[problem.level] || 'white';
const decoration = enabled ? chalk_1.default[color](sign) : sign;
const name = enabled
? chalk_1.default.grey(`[${problem.name}]`)
: `[${problem.name}]`;
return `${decoration} ${problem.message} ${name}`;
});
var sign = selectSign(result);
var color = selectColor(result);
var deco = enabled ? chalk_1["default"][color](sign) : sign;
var el = errors.length;
var wl = warnings.length;
var hasProblems = problems.length > 0;
var summary = options.verbose || hasProblems
? deco + " found " + el + " problems, " + wl + " warnings"
const sign = selectSign(result);
const color = selectColor(result);
const deco = enabled ? chalk_1.default[color](sign) : sign;
const el = errors.length;
const wl = warnings.length;
const hasProblems = problems.length > 0;
const summary = options.verbose || hasProblems
? `${deco} found ${el} problems, ${wl} warnings`
: undefined;
var fmtSummary = enabled && typeof summary === 'string' ? chalk_1["default"].bold(summary) : summary;
var help = hasProblems ? "\u24D8 Get help: " + options.helpUrl : undefined;
return __spreadArrays(problems, [
const fmtSummary = enabled && typeof summary === 'string' ? chalk_1.default.bold(summary) : summary;
const help = hasProblems ? `ⓘ Get help: ${options.helpUrl}` : undefined;
return [
...problems,
hasProblems ? '' : undefined,

@@ -77,6 +64,6 @@ fmtSummary,

help ? '' : undefined
]).filter(function (line) { return typeof line === 'string'; });
].filter((line) => typeof line === 'string');
}
exports.formatResult = formatResult;
exports["default"] = format;
exports.default = format;
function selectSign(result) {

@@ -83,0 +70,0 @@ if ((result.errors || []).length > 0) {

@@ -5,6 +5,6 @@ "use strict";

}
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
var format_1 = require("./format");
exports["default"] = format_1["default"];
exports.default = format_1.default;
__export(require("./format"));
//# sourceMappingURL=index.js.map
{
"name": "@commitlint/format",
"version": "8.3.4",
"version": "9.0.0",
"description": "Format commitlint reports",

@@ -15,3 +15,3 @@ "main": "lib/index.js",

"engines": {
"node": ">=4"
"node": ">=8"
},

@@ -38,11 +38,8 @@ "repository": {

"devDependencies": {
"@commitlint/utils": "^8.3.4",
"@types/lodash": "4.14.144",
"lodash": "4.17.15",
"typescript": "3.6.4"
"@commitlint/utils": "^9.0.0"
},
"dependencies": {
"chalk": "^2.0.1"
"chalk": "^3.0.0"
},
"gitHead": "3fce33999e1e5f23b15545f1c6f3e7bd78e8d37b"
"gitHead": "71f0194f33943954a8dac1c458be47e5049717cd"
}

@@ -16,37 +16,40 @@ > Format commitlint reports

const output = format({
valid: false,
errorCount: 1,
warningCount: 1,
results: [
{
valid: false,
input: 'some: commit message',
errors: [
{
valid: false,
level: 2,
name: 'some-error',
message: 'This will show up red as it has level 2'
}
],
warnings: [
{
valid: true,
level: 0,
name: 'some-hint',
message: 'This will not show up as it has level 0'
},
{
valid: false,
level: 1,
name: 'some-warning',
message: 'This will show up yellow as it has level 1'
}
]
}
]
}, {
color: false
});
const output = format(
{
valid: false,
errorCount: 1,
warningCount: 1,
results: [
{
valid: false,
input: 'some: commit message',
errors: [
{
valid: false,
level: 2,
name: 'some-error',
message: 'This will show up red as it has level 2'
}
],
warnings: [
{
valid: true,
level: 0,
name: 'some-hint',
message: 'This will not show up as it has level 0'
},
{
valid: false,
level: 1,
name: 'some-warning',
message: 'This will show up yellow as it has level 1'
}
]
}
]
},
{
color: false
}
);

@@ -64,2 +67,1 @@ process.stdout.write(output);

Consult [docs/api](https://conventional-changelog.github.io/commitlint/#/reference-api) for comprehensive documentation.

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc