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

@commitlint/lint

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commitlint/lint - npm Package Compare versions

Comparing version 6.2.0 to 7.0.0

215

lib/index.js

@@ -33,9 +33,5 @@ 'use strict';

var buildCommitMesage = function buildCommitMesage(_ref) {
var header = _ref.header,
body = _ref.body,
footer = _ref.footer;
const buildCommitMesage = ({ header, body, footer }) => {
let message = header;
var message = header;
message = body ? `${message}\n\n${body}` : message;

@@ -47,142 +43,131 @@ message = footer ? `${message}\n\n${footer}` : message;

exports.default = function (message) {
var $args = arguments;return new Promise(function ($return, $error) {
var rules, opts, parsed, missing, names, invalid, results, errors, warnings, valid;
rules = $args.length > 1 && $args[1] !== undefined ? $args[1] : {};
opts = $args.length > 2 && $args[2] !== undefined ? $args[2] : {};
exports.default = (message, rules = {}, opts = {}) => new Promise(function ($return, $error) {
var parsed, missing, names, invalid, results, errors, warnings, valid;
// Found a wildcard match, skip
if ((0, _isIgnored2.default)(message)) {
return $return({
valid: true,
errors: [],
warnings: [],
input: message
});
}
// Found a wildcard match, skip
if ((0, _isIgnored2.default)(message)) {
return $return({
valid: true,
errors: [],
warnings: [],
input: message
});
}
// Parse the commit message
return Promise.resolve((0, _parse2.default)(message, undefined, opts.parserOpts)).then(function ($await_1) {
try {
parsed = $await_1;
// Parse the commit message
return Promise.resolve((0, _parse2.default)(message, undefined, opts.parserOpts)).then(function ($await_1) {
try {
parsed = $await_1;
missing = Object.keys(rules).filter(name => typeof _rules2.default[name] !== 'function');
missing = Object.keys(rules).filter(function (name) {
return typeof _rules2.default[name] !== 'function';
});
if (missing.length > 0) {
names = Object.keys(_rules2.default);
return $error(new RangeError(`Found missing rule names: ${missing.join(', ')}. Supported rule names are: ${names.join(', ')}`));
}
if (missing.length > 0) {
names = Object.keys(_rules2.default);
invalid = (0, _lodash2.default)(rules).map(function (_ref2) {
var _ref3 = (0, _slicedToArray3.default)(_ref2, 2),
name = _ref3[0],
config = _ref3[1];
return $error(new RangeError(`Found missing rule names: ${missing.join(', ')}. Supported rule names are: ${names.join(', ')}`));
}
if (!Array.isArray(config)) {
return new Error(`config for rule ${name} must be array, received ${_util2.default.inspect(config)} of type ${typeof config}`);
}
invalid = (0, _lodash2.default)(rules).map(([name, config]) => {
if (!Array.isArray(config)) {
return new Error(`config for rule ${name} must be array, received ${_util2.default.inspect(config)} of type ${typeof config}`);
}
var _config = (0, _slicedToArray3.default)(config, 2),
level = _config[0],
when = _config[1];
var _config = (0, _slicedToArray3.default)(config, 2);
if (typeof level !== 'number' || isNaN(level)) {
return new Error(`level for rule ${name} must be number, received ${_util2.default.inspect(level)} of type ${typeof level}`);
}
const level = _config[0],
when = _config[1];
if (level === 0 && config.length === 1) {
return null;
}
if (config.length !== 2 && config.length !== 3) {
return new Error(`config for rule ${name} must be 2 or 3 items long, received ${_util2.default.inspect(config)} of length ${config.length}`);
}
if (typeof level !== 'number' || isNaN(level)) {
return new Error(`level for rule ${name} must be number, received ${_util2.default.inspect(level)} of type ${typeof level}`);
}
if (level < 0 || level > 2) {
return new RangeError(`level for rule ${name} must be between 0 and 2, received ${_util2.default.inspect(level)}`);
}
if (level === 0 && config.length === 1) {
return null;
}
if (typeof when !== 'string') {
return new Error(`condition for rule ${name} must be string, received ${_util2.default.inspect(when)} of type ${typeof when}`);
}
if (config.length !== 2 && config.length !== 3) {
return new Error(`config for rule ${name} must be 2 or 3 items long, received ${_util2.default.inspect(config)} of length ${config.length}`);
}
if (when !== 'never' && when !== 'always') {
return new Error(`condition for rule ${name} must be "always" or "never", received ${_util2.default.inspect(when)}`);
}
if (level < 0 || level > 2) {
return new RangeError(`level for rule ${name} must be between 0 and 2, received ${_util2.default.inspect(level)}`);
}
return null;
}).filter(function (item) {
return item instanceof Error;
});
if (typeof when !== 'string') {
return new Error(`condition for rule ${name} must be string, received ${_util2.default.inspect(when)} of type ${typeof when}`);
}
if (invalid.length > 0) {
return $error(new Error(invalid.map(function (i) {
return i.message;
}).join('\n')));
if (when !== 'never' && when !== 'always') {
return new Error(`condition for rule ${name} must be "always" or "never", received ${_util2.default.inspect(when)}`);
}
// Validate against all rules
results = (0, _lodash2.default)(rules).filter(function (entry) {
var _entry = (0, _slicedToArray3.default)(entry, 2),
_entry$ = (0, _slicedToArray3.default)(_entry[1], 1),
level = _entry$[0];
return null;
}).filter(item => item instanceof Error);
return level > 0;
}).map(function (entry) {
var _entry2 = (0, _slicedToArray3.default)(entry, 2),
name = _entry2[0],
config = _entry2[1];
var _config2 = (0, _slicedToArray3.default)(config, 3),
level = _config2[0],
when = _config2[1],
value = _config2[2];
if (invalid.length > 0) {
return $error(new Error(invalid.map(i => i.message).join('\n')));
}
// Level 0 rules are ignored
// Validate against all rules
results = (0, _lodash2.default)(rules).filter(entry => {
var _entry = (0, _slicedToArray3.default)(entry, 2),
_entry$ = (0, _slicedToArray3.default)(_entry[1], 1);
const level = _entry$[0];
if (level === 0) {
return null;
}
return level > 0;
}).map(entry => {
var _entry2 = (0, _slicedToArray3.default)(entry, 2);
var rule = _rules2.default[name];
const name = _entry2[0],
config = _entry2[1];
var _rule = rule(parsed, when, value),
_rule2 = (0, _slicedToArray3.default)(_rule, 2),
valid = _rule2[0],
message = _rule2[1];
var _config2 = (0, _slicedToArray3.default)(config, 3);
return {
level,
valid,
name,
message
};
}).filter(Boolean);
const level = _config2[0],
when = _config2[1],
value = _config2[2];
errors = results.filter(function (result) {
return result.level === 2 && !result.valid;
});
warnings = results.filter(function (result) {
return result.level === 1 && !result.valid;
});
// Level 0 rules are ignored
valid = errors.length === 0;
if (level === 0) {
return null;
}
return $return({
const rule = _rules2.default[name];
var _rule = rule(parsed, when, value),
_rule2 = (0, _slicedToArray3.default)(_rule, 2);
const valid = _rule2[0],
message = _rule2[1];
return {
level,
valid,
errors,
warnings,
input: buildCommitMesage(parsed)
});
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
};
name,
message
};
}).filter(Boolean);
errors = results.filter(result => result.level === 2 && !result.valid);
warnings = results.filter(result => result.level === 1 && !result.valid);
valid = errors.length === 0;
return $return({
valid,
errors,
warnings,
input: buildCommitMesage(parsed)
});
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
module.exports = exports['default'];
//# sourceMappingURL=index.js.map

@@ -13,423 +13,395 @@ 'use strict';

(0, _ava2.default)('throws without params', function (t) {
return new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)())).then(function ($await_1) {
try {
error = $await_1;
t.is(error.message, 'Expected a raw commit');
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
(0, _ava2.default)('throws without params', t => new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)())).then(function ($await_1) {
try {
error = $await_1;
(0, _ava2.default)('throws with empty message', function (t) {
return new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)(''))).then(function ($await_2) {
try {
error = $await_2;
t.is(error.message, 'Expected a raw commit');
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.is(error.message, 'Expected a raw commit');
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('positive on stub message and no rule', function (t) {
return new Promise(function ($return, $error) {
var actual;
return Promise.resolve((0, _2.default)('foo: bar')).then(function ($await_3) {
try {
actual = $await_3;
t.true(actual.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
(0, _ava2.default)('throws with empty message', t => new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)(''))).then(function ($await_2) {
try {
error = $await_2;
(0, _ava2.default)('positive on stub message and adhered rule', function (t) {
return new Promise(function ($return, $error) {
var actual;
return Promise.resolve((0, _2.default)('foo: bar', {
'type-enum': [2, 'always', ['foo']]
})).then(function ($await_4) {
try {
actual = $await_4;
t.true(actual.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.is(error.message, 'Expected a raw commit');
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('negative on stub message and broken rule', function (t) {
return new Promise(function ($return, $error) {
var actual;
return Promise.resolve((0, _2.default)('foo: bar', {
'type-enum': [2, 'never', ['foo']]
})).then(function ($await_5) {
try {
actual = $await_5;
t.false(actual.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
(0, _ava2.default)('positive on stub message and no rule', t => new Promise(function ($return, $error) {
var actual;
return Promise.resolve((0, _2.default)('foo: bar')).then(function ($await_3) {
try {
actual = $await_3;
(0, _ava2.default)('positive on ignored message and broken rule', function (t) {
return new Promise(function ($return, $error) {
var actual;
return Promise.resolve((0, _2.default)('Revert "some bogus commit"', {
'type-empty': [2, 'never']
})).then(function ($await_6) {
try {
actual = $await_6;
t.true(actual.valid);
t.is(actual.input, 'Revert "some bogus commit"');
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.true(actual.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('positive on stub message and opts', function (t) {
return new Promise(function ($return, $error) {
var actual;
return Promise.resolve((0, _2.default)('foo-bar', {
'type-enum': [2, 'always', ['foo']],
'type-empty': [2, 'never']
}, {
parserOpts: {
headerPattern: /^(\w*)(?:\((.*)\))?-(.*)$/
}
})).then(function ($await_7) {
try {
actual = $await_7;
t.true(actual.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
(0, _ava2.default)('positive on stub message and adhered rule', t => new Promise(function ($return, $error) {
var actual;
return Promise.resolve((0, _2.default)('foo: bar', {
'type-enum': [2, 'always', ['foo']]
})).then(function ($await_4) {
try {
actual = $await_4;
(0, _ava2.default)('throws for invalid rule names', function (t) {
return new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('foo', { foo: [2, 'always'], bar: [1, 'never'] }))).then(function ($await_8) {
try {
error = $await_8;
t.true(actual.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
t.is(error.message.indexOf('Found missing rule names: foo, bar'), 0);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
(0, _ava2.default)('negative on stub message and broken rule', t => new Promise(function ($return, $error) {
var actual;
return Promise.resolve((0, _2.default)('foo: bar', {
'type-enum': [2, 'never', ['foo']]
})).then(function ($await_5) {
try {
actual = $await_5;
(0, _ava2.default)('throws for invalid rule config', function (t) {
return new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', {
'type-enum': 1,
'scope-enum': { 0: 2, 1: 'never', 2: ['foo'], length: 3 }
}))).then(function ($await_9) {
try {
error = $await_9;
t.false(actual.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
t.true(error.message.indexOf('type-enum must be array') > -1);
t.true(error.message.indexOf('scope-enum must be array') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
(0, _ava2.default)('positive on ignored message and broken rule', t => new Promise(function ($return, $error) {
var actual;
return Promise.resolve((0, _2.default)('Revert "some bogus commit"', {
'type-empty': [2, 'never']
})).then(function ($await_6) {
try {
actual = $await_6;
(0, _ava2.default)('allows disable shorthand', function (t) {
return new Promise(function ($return, $error) {
return Promise.resolve(t.notThrows((0, _2.default)('foo', { 'type-enum': [0], 'scope-enum': [0] }))).then(function ($await_10) {
try {
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.true(actual.valid);
t.is(actual.input, 'Revert "some bogus commit"');
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('throws for rule with invalid length', function (t) {
return new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', { 'scope-enum': [1, 2, 3, 4] }))).then(function ($await_11) {
try {
error = $await_11;
(0, _ava2.default)('positive on stub message and opts', t => new Promise(function ($return, $error) {
var actual;
return Promise.resolve((0, _2.default)('foo-bar', {
'type-enum': [2, 'always', ['foo']],
'type-empty': [2, 'never']
}, {
parserOpts: {
headerPattern: /^(\w*)(?:\((.*)\))?-(.*)$/
}
})).then(function ($await_7) {
try {
actual = $await_7;
t.true(error.message.indexOf('scope-enum must be 2 or 3 items long') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.true(actual.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('throws for rule with invalid level', function (t) {
return new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', {
'type-enum': ['2', 'always'],
'header-max-length': [{}, 'always']
}))).then(function ($await_12) {
try {
error = $await_12;
(0, _ava2.default)('throws for invalid rule names', t => new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('foo', { foo: [2, 'always'], bar: [1, 'never'] }))).then(function ($await_8) {
try {
error = $await_8;
t.true(error.message.indexOf('rule type-enum must be number') > -1);
t.true(error.message.indexOf('rule type-enum must be number') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
(0, _ava2.default)('throws for rule with out of range level', function (t) {
return new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', {
'type-enum': [-1, 'always'],
'header-max-length': [3, 'always']
}))).then(function ($await_13) {
try {
error = $await_13;
t.is(error.message.indexOf('Found missing rule names: foo, bar'), 0);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
t.true(error.message.indexOf('rule type-enum must be between 0 and 2') > -1);
t.true(error.message.indexOf('rule type-enum must be between 0 and 2') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
(0, _ava2.default)('throws for invalid rule config', t => new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', {
'type-enum': 1,
'scope-enum': { 0: 2, 1: 'never', 2: ['foo'], length: 3 }
}))).then(function ($await_9) {
try {
error = $await_9;
(0, _ava2.default)('throws for rule with invalid condition', function (t) {
return new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', {
'type-enum': [1, 2],
'header-max-length': [1, {}]
}))).then(function ($await_14) {
try {
error = $await_14;
t.true(error.message.indexOf('type-enum must be string') > -1);
t.true(error.message.indexOf('header-max-length must be string') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.true(error.message.indexOf('type-enum must be array') > -1);
t.true(error.message.indexOf('scope-enum must be array') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('throws for rule with out of range condition', function (t) {
return new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', {
'type-enum': [1, 'foo'],
'header-max-length': [1, 'bar']
}))).then(function ($await_15) {
try {
error = $await_15;
(0, _ava2.default)('allows disable shorthand', t => new Promise(function ($return, $error) {
return Promise.resolve(t.notThrows((0, _2.default)('foo', { 'type-enum': [0], 'scope-enum': [0] }))).then(function ($await_10) {
try {
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
t.true(error.message.indexOf('type-enum must be "always" or "never"') > -1);
t.true(error.message.indexOf('header-max-length must be "always" or "never"') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
(0, _ava2.default)('throws for rule with invalid length', t => new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', { 'scope-enum': [1, 2, 3, 4] }))).then(function ($await_11) {
try {
error = $await_11;
(0, _ava2.default)('succeds for issue', function (t) {
return new Promise(function ($return, $error) {
var report;
return Promise.resolve((0, _2.default)('somehting #1', {
'references-empty': [2, 'never']
})).then(function ($await_16) {
try {
report = $await_16;
t.true(report.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.true(error.message.indexOf('scope-enum must be 2 or 3 items long') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('fails for issue', function (t) {
return new Promise(function ($return, $error) {
var report;
return Promise.resolve((0, _2.default)('somehting #1', {
'references-empty': [2, 'always']
})).then(function ($await_17) {
try {
report = $await_17;
(0, _ava2.default)('throws for rule with invalid level', t => new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', {
'type-enum': ['2', 'always'],
'header-max-length': [{}, 'always']
}))).then(function ($await_12) {
try {
error = $await_12;
t.false(report.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
(0, _ava2.default)('succeds for custom issue prefix', function (t) {
return new Promise(function ($return, $error) {
var report;
return Promise.resolve((0, _2.default)('somehting REF-1', {
'references-empty': [2, 'never']
}, {
parserOpts: {
issuePrefixes: ['REF-']
}
})).then(function ($await_18) {
try {
report = $await_18;
t.true(error.message.indexOf('rule type-enum must be number') > -1);
t.true(error.message.indexOf('rule type-enum must be number') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
t.true(report.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
(0, _ava2.default)('throws for rule with out of range level', t => new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', {
'type-enum': [-1, 'always'],
'header-max-length': [3, 'always']
}))).then(function ($await_13) {
try {
error = $await_13;
(0, _ava2.default)('fails for custom issue prefix', function (t) {
return new Promise(function ($return, $error) {
var report;
return Promise.resolve((0, _2.default)('somehting #1', {
'references-empty': [2, 'never']
}, {
parserOpts: {
issuePrefixes: ['REF-']
}
})).then(function ($await_19) {
try {
report = $await_19;
t.false(report.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.true(error.message.indexOf('rule type-enum must be between 0 and 2') > -1);
t.true(error.message.indexOf('rule type-enum must be between 0 and 2') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('returns original message only with commit header', function (t) {
return new Promise(function ($return, $error) {
var message, report;
(0, _ava2.default)('throws for rule with invalid condition', t => new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', {
'type-enum': [1, 2],
'header-max-length': [1, {}]
}))).then(function ($await_14) {
try {
error = $await_14;
message = 'foo: bar';
return Promise.resolve((0, _2.default)(message)).then(function ($await_20) {
try {
report = $await_20;
t.is(report.input, message);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.true(error.message.indexOf('type-enum must be string') > -1);
t.true(error.message.indexOf('header-max-length must be string') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('returns original message with commit header and body', function (t) {
return new Promise(function ($return, $error) {
var message, report;
(0, _ava2.default)('throws for rule with out of range condition', t => new Promise(function ($return, $error) {
var error;
return Promise.resolve(t.throws((0, _2.default)('type(scope): foo', {
'type-enum': [1, 'foo'],
'header-max-length': [1, 'bar']
}))).then(function ($await_15) {
try {
error = $await_15;
message = 'foo: bar/n/nFoo bar bizz buzz.';
return Promise.resolve((0, _2.default)(message)).then(function ($await_21) {
try {
report = $await_21;
t.is(report.input, message);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.true(error.message.indexOf('type-enum must be "always" or "never"') > -1);
t.true(error.message.indexOf('header-max-length must be "always" or "never"') > -1);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('returns original message with commit header, body and footer', function (t) {
return new Promise(function ($return, $error) {
var message, report;
(0, _ava2.default)('succeds for issue', t => new Promise(function ($return, $error) {
var report;
return Promise.resolve((0, _2.default)('somehting #1', {
'references-empty': [2, 'never']
})).then(function ($await_16) {
try {
report = $await_16;
message = 'foo: bar/n/nFoo bar bizz buzz./n/nCloses #1';
return Promise.resolve((0, _2.default)(message)).then(function ($await_22) {
try {
report = $await_22;
t.is(report.input, message);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.true(report.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('returns original message with commit header, body and footer, parsing comments', function (t) {
return new Promise(function ($return, $error) {
var expected, message, report;
(0, _ava2.default)('fails for issue', t => new Promise(function ($return, $error) {
var report;
return Promise.resolve((0, _2.default)('somehting #1', {
'references-empty': [2, 'always']
})).then(function ($await_17) {
try {
report = $await_17;
expected = 'foo: bar/n/nFoo bar bizz buzz./n/nCloses #1';
message = `${expected}\n\n# Some comment to ignore`;
return Promise.resolve((0, _2.default)(message, {
'references-empty': [2, 'never']
}, {
parserOpts: {
commentChar: '#'
}
})).then(function ($await_23) {
try {
report = $await_23;
t.is(report.input, expected);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
});
t.false(report.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('succeds for custom issue prefix', t => new Promise(function ($return, $error) {
var report;
return Promise.resolve((0, _2.default)('somehting REF-1', {
'references-empty': [2, 'never']
}, {
parserOpts: {
issuePrefixes: ['REF-']
}
})).then(function ($await_18) {
try {
report = $await_18;
t.true(report.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('fails for custom issue prefix', t => new Promise(function ($return, $error) {
var report;
return Promise.resolve((0, _2.default)('somehting #1', {
'references-empty': [2, 'never']
}, {
parserOpts: {
issuePrefixes: ['REF-']
}
})).then(function ($await_19) {
try {
report = $await_19;
t.false(report.valid);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('returns original message only with commit header', t => new Promise(function ($return, $error) {
var message, report;
message = 'foo: bar';
return Promise.resolve((0, _2.default)(message)).then(function ($await_20) {
try {
report = $await_20;
t.is(report.input, message);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('returns original message with commit header and body', t => new Promise(function ($return, $error) {
var message, report;
message = 'foo: bar/n/nFoo bar bizz buzz.';
return Promise.resolve((0, _2.default)(message)).then(function ($await_21) {
try {
report = $await_21;
t.is(report.input, message);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('returns original message with commit header, body and footer', t => new Promise(function ($return, $error) {
var message, report;
message = 'foo: bar/n/nFoo bar bizz buzz./n/nCloses #1';
return Promise.resolve((0, _2.default)(message)).then(function ($await_22) {
try {
report = $await_22;
t.is(report.input, message);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
(0, _ava2.default)('returns original message with commit header, body and footer, parsing comments', t => new Promise(function ($return, $error) {
var expected, message, report;
expected = 'foo: bar/n/nFoo bar bizz buzz./n/nCloses #1';
message = `${expected}\n\n# Some comment to ignore`;
return Promise.resolve((0, _2.default)(message, {
'references-empty': [2, 'never']
}, {
parserOpts: {
commentChar: '#'
}
})).then(function ($await_23) {
try {
report = $await_23;
t.is(report.input, expected);
return $return();
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this)));
//# sourceMappingURL=index.test.js.map
{
"name": "@commitlint/lint",
"version": "6.2.0",
"version": "7.0.0",
"description": "Lint a string against commitlint rules",

@@ -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",

@@ -78,5 +78,5 @@ "concurrently": "3.5.1",

"dependencies": {
"@commitlint/is-ignored": "^6.1.3",
"@commitlint/parse": "^6.1.3",
"@commitlint/rules": "^6.2.0",
"@commitlint/is-ignored": "^7.0.0",
"@commitlint/parse": "^7.0.0",
"@commitlint/rules": "^7.0.0",
"babel-runtime": "^6.23.0",

@@ -83,0 +83,0 @@ "lodash.topairs": "4.3.0"

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