mjml-validator
Advanced tools
Comparing version 4.5.0 to 4.6.2
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.registerDependencies = undefined; | ||
exports["default"] = exports.registerDependencies = void 0; | ||
var _lodash = require('lodash'); | ||
var _lodash = require("lodash"); | ||
@@ -20,6 +20,8 @@ // eslint-disable-next-line consistent-return | ||
var registerDependencies = exports.registerDependencies = function registerDependencies(dep) { | ||
var registerDependencies = function registerDependencies(dep) { | ||
return (0, _lodash.mergeWith)(dependencies, dep, mergeArrays); | ||
}; | ||
exports.default = dependencies; | ||
exports.registerDependencies = registerDependencies; | ||
var _default = dependencies; | ||
exports["default"] = _default; |
@@ -1,47 +0,53 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.registerDependencies = exports.dependencies = exports.registerRule = exports.rulesCollection = exports.formatValidationError = undefined; | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | ||
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | ||
var _dependencies2 = require('./dependencies'); | ||
Object.defineProperty(exports, 'registerDependencies', { | ||
exports["default"] = MJMLValidator; | ||
Object.defineProperty(exports, "rulesCollection", { | ||
enumerable: true, | ||
get: function get() { | ||
return _dependencies2.registerDependencies; | ||
return _MJMLRulesCollection["default"]; | ||
} | ||
}); | ||
exports.default = MJMLValidator; | ||
Object.defineProperty(exports, "registerRule", { | ||
enumerable: true, | ||
get: function get() { | ||
return _MJMLRulesCollection.registerRule; | ||
} | ||
}); | ||
Object.defineProperty(exports, "dependencies", { | ||
enumerable: true, | ||
get: function get() { | ||
return _dependencies["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "registerDependencies", { | ||
enumerable: true, | ||
get: function get() { | ||
return _dependencies.registerDependencies; | ||
} | ||
}); | ||
exports.formatValidationError = void 0; | ||
var _lodash = require('lodash'); | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _ruleError = require('./rules/ruleError'); | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _ruleError2 = _interopRequireDefault(_ruleError); | ||
var _lodash = require("lodash"); | ||
var _MJMLRulesCollection = require('./MJMLRulesCollection'); | ||
var _ruleError = _interopRequireDefault(require("./rules/ruleError")); | ||
var _MJMLRulesCollection2 = _interopRequireDefault(_MJMLRulesCollection); | ||
var _MJMLRulesCollection = _interopRequireWildcard(require("./MJMLRulesCollection")); | ||
var _dependencies3 = _interopRequireDefault(_dependencies2); | ||
var _dependencies = _interopRequireWildcard(require("./dependencies")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var SKIP_ELEMENTS = ['mjml']; | ||
var formatValidationError = _ruleError["default"]; | ||
exports.formatValidationError = formatValidationError; | ||
var formatValidationError = exports.formatValidationError = _ruleError2.default; | ||
exports.rulesCollection = _MJMLRulesCollection2.default; | ||
exports.registerRule = _MJMLRulesCollection.registerRule; | ||
exports.dependencies = _dependencies3.default; | ||
function MJMLValidator(element) { | ||
@@ -51,10 +57,8 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
tagName = element.tagName; | ||
var errors = void 0; | ||
var errors; | ||
var skipElements = options.skipElements || SKIP_ELEMENTS; | ||
if (!(0, _lodash.includes)(skipElements, tagName)) { | ||
errors = (0, _lodash.flatten)(_lodash.concat.apply(undefined, [errors].concat((0, _toConsumableArray3.default)((0, _lodash.values)(_MJMLRulesCollection2.default).map(function (rule) { | ||
return rule(element, (0, _extends3.default)({ | ||
errors = (0, _lodash.flatten)(_lodash.concat.apply(void 0, [errors].concat((0, _toConsumableArray2["default"])((0, _lodash.values)(_MJMLRulesCollection["default"]).map(function (rule) { | ||
return rule(element, (0, _objectSpread2["default"])({ | ||
skipElements: skipElements | ||
@@ -66,3 +70,3 @@ }, options)); | ||
if (children && children.length > 0) { | ||
errors = (0, _lodash.flatten)(_lodash.concat.apply(undefined, [errors].concat((0, _toConsumableArray3.default)(children.map(function (child) { | ||
errors = (0, _lodash.flatten)(_lodash.concat.apply(void 0, [errors].concat((0, _toConsumableArray2["default"])(children.map(function (child) { | ||
return MJMLValidator(child, options); | ||
@@ -69,0 +73,0 @@ }))))); |
@@ -1,3 +0,7 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,17 +11,10 @@ value: true | ||
exports.registerRule = registerRule; | ||
exports["default"] = void 0; | ||
var _warning = require('warning'); | ||
var _warning = _interopRequireDefault(require("warning")); | ||
var _warning2 = _interopRequireDefault(_warning); | ||
var _lodash = require("lodash"); | ||
var _lodash = require('lodash'); | ||
var rules = _interopRequireWildcard(require("./rules")); | ||
var _rules = require('./rules'); | ||
var rules = _interopRequireWildcard(_rules); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var MJMLRulesCollection = {}; | ||
@@ -27,3 +24,3 @@ | ||
if (typeof rule !== 'function') { | ||
return (0, _warning2.default)(false, 'Your rule must be a function'); | ||
return (0, _warning["default"])(false, 'Your rule must be a function'); | ||
} | ||
@@ -43,3 +40,3 @@ | ||
}); | ||
exports.default = MJMLRulesCollection; | ||
var _default = MJMLRulesCollection; | ||
exports["default"] = _default; |
@@ -1,20 +0,15 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = errorAttr; | ||
exports["default"] = errorAttr; | ||
var _ruleError = require('./ruleError'); | ||
var _ruleError = _interopRequireDefault(require("./ruleError")); | ||
var _ruleError2 = _interopRequireDefault(_ruleError); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function errorAttr(element) { | ||
var errors = element.errors; | ||
if (!errors) return null; | ||
return errors.map(function (error) { | ||
@@ -27,6 +22,5 @@ switch (error.type) { | ||
partialPath = _error$params.partialPath; | ||
return (0, _ruleError["default"])("mj-include fails to read file : ".concat(file, " at ").concat(partialPath), element); | ||
} | ||
return (0, _ruleError2.default)('mj-include fails to read file : ' + file + ' at ' + partialPath, element); | ||
} | ||
default: | ||
@@ -37,2 +31,3 @@ return null; | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
@@ -1,34 +0,47 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.errorAttr = exports.validTypes = exports.validTag = exports.validChildren = exports.validAttributes = undefined; | ||
Object.defineProperty(exports, "validAttributes", { | ||
enumerable: true, | ||
get: function get() { | ||
return _validAttributes["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "validChildren", { | ||
enumerable: true, | ||
get: function get() { | ||
return _validChildren["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "validTag", { | ||
enumerable: true, | ||
get: function get() { | ||
return _validTag["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "validTypes", { | ||
enumerable: true, | ||
get: function get() { | ||
return _validTypes["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "errorAttr", { | ||
enumerable: true, | ||
get: function get() { | ||
return _errorAttr["default"]; | ||
} | ||
}); | ||
var _validAttributes2 = require('./validAttributes'); | ||
var _validAttributes = _interopRequireDefault(require("./validAttributes")); | ||
var _validAttributes3 = _interopRequireDefault(_validAttributes2); | ||
var _validChildren = _interopRequireDefault(require("./validChildren")); | ||
var _validChildren2 = require('./validChildren'); | ||
var _validTag = _interopRequireDefault(require("./validTag")); | ||
var _validChildren3 = _interopRequireDefault(_validChildren2); | ||
var _validTypes = _interopRequireDefault(require("./validTypes")); | ||
var _validTag2 = require('./validTag'); | ||
var _validTag3 = _interopRequireDefault(_validTag2); | ||
var _validTypes2 = require('./validTypes'); | ||
var _validTypes3 = _interopRequireDefault(_validTypes2); | ||
var _errorAttr2 = require('./errorAttr'); | ||
var _errorAttr3 = _interopRequireDefault(_errorAttr2); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.validAttributes = _validAttributes3.default; | ||
exports.validChildren = _validChildren3.default; | ||
exports.validTag = _validTag3.default; | ||
exports.validTypes = _validTypes3.default; | ||
exports.errorAttr = _errorAttr3.default; | ||
var _errorAttr = _interopRequireDefault(require("./errorAttr")); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,15 +6,13 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = ruleError; | ||
exports["default"] = ruleError; | ||
function formatInclude(element) { | ||
var includedIn = element.includedIn; | ||
if (!(includedIn && includedIn.length)) return ''; | ||
var formattedIncluded = includedIn.slice().reverse().map(function (_ref) { | ||
var line = _ref.line, | ||
file = _ref.file; | ||
return 'line ' + line + ' of file ' + file; | ||
return "line ".concat(line, " of file ").concat(file); | ||
}).join(', itself included at '); | ||
return ', included at ' + formattedIncluded; | ||
return ", included at ".concat(formattedIncluded); | ||
} | ||
@@ -26,4 +24,2 @@ | ||
absoluteFilePath = element.absoluteFilePath; | ||
return { | ||
@@ -33,5 +29,6 @@ line: line, | ||
tagName: tagName, | ||
formattedMessage: 'Line ' + line + ' of ' + absoluteFilePath + formatInclude(element) + ' (' + tagName + ') \u2014 ' + message | ||
formattedMessage: "Line ".concat(line, " of ").concat(absoluteFilePath).concat(formatInclude(element), " (").concat(tagName, ") \u2014 ").concat(message) | ||
}; | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
@@ -1,30 +0,20 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = validateAttribute; | ||
exports["default"] = validateAttribute; | ||
var _concat = require('lodash/concat'); | ||
var _concat = _interopRequireDefault(require("lodash/concat")); | ||
var _concat2 = _interopRequireDefault(_concat); | ||
var _keys = _interopRequireDefault(require("lodash/keys")); | ||
var _keys = require('lodash/keys'); | ||
var _includes = _interopRequireDefault(require("lodash/includes")); | ||
var _keys2 = _interopRequireDefault(_keys); | ||
var _filter = _interopRequireDefault(require("lodash/filter")); | ||
var _includes = require('lodash/includes'); | ||
var _ruleError = _interopRequireDefault(require("./ruleError")); | ||
var _includes2 = _interopRequireDefault(_includes); | ||
var _filter = require('lodash/filter'); | ||
var _filter2 = _interopRequireDefault(_filter); | ||
var _ruleError = require('./ruleError'); | ||
var _ruleError2 = _interopRequireDefault(_ruleError); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var WHITELIST = ['mj-class', 'css-class']; | ||
@@ -36,4 +26,2 @@ | ||
tagName = element.tagName; | ||
var Component = components[tagName]; | ||
@@ -45,5 +33,5 @@ | ||
var availableAttributes = (0, _concat2.default)((0, _keys2.default)(Component.allowedAttributes), WHITELIST); | ||
var unknownAttributes = (0, _filter2.default)((0, _keys2.default)(attributes), function (attribute) { | ||
return !(0, _includes2.default)(availableAttributes, attribute); | ||
var availableAttributes = (0, _concat["default"])((0, _keys["default"])(Component.allowedAttributes), WHITELIST); | ||
var unknownAttributes = (0, _filter["default"])((0, _keys["default"])(attributes), function (attribute) { | ||
return !(0, _includes["default"])(availableAttributes, attribute); | ||
}); | ||
@@ -61,6 +49,5 @@ | ||
illegal = _attribute$illegal.illegal; | ||
return (0, _ruleError["default"])("".concat(attribute, " ").concat(unknownAttributes.join(', '), " ").concat(illegal), element); | ||
} | ||
return (0, _ruleError2.default)(attribute + ' ' + unknownAttributes.join(', ') + ' ' + illegal, element); | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
@@ -1,30 +0,20 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = validChildren; | ||
exports["default"] = validChildren; | ||
var _filter = require('lodash/filter'); | ||
var _filter = _interopRequireDefault(require("lodash/filter")); | ||
var _filter2 = _interopRequireDefault(_filter); | ||
var _includes = _interopRequireDefault(require("lodash/includes")); | ||
var _includes = require('lodash/includes'); | ||
var _keys = _interopRequireDefault(require("lodash/keys")); | ||
var _includes2 = _interopRequireDefault(_includes); | ||
var _dependencies = _interopRequireDefault(require("../dependencies")); | ||
var _keys = require('lodash/keys'); | ||
var _ruleError = _interopRequireDefault(require("./ruleError")); | ||
var _keys2 = _interopRequireDefault(_keys); | ||
var _dependencies = require('../dependencies'); | ||
var _dependencies2 = _interopRequireDefault(_dependencies); | ||
var _ruleError = require('./ruleError'); | ||
var _ruleError2 = _interopRequireDefault(_ruleError); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function validChildren(element, _ref) { | ||
@@ -35,4 +25,2 @@ var components = _ref.components, | ||
tagName = element.tagName; | ||
var Component = components[tagName]; | ||
@@ -44,8 +32,8 @@ | ||
return (0, _filter2.default)(children.map(function (child) { | ||
return (0, _filter["default"])(children.map(function (child) { | ||
var childTagName = child.tagName; | ||
var ChildComponent = components[childTagName]; | ||
var parentDependencies = _dependencies2.default[tagName] || []; | ||
var parentDependencies = _dependencies["default"][tagName] || []; | ||
if (!ChildComponent || (0, _includes2.default)(skipElements, childTagName) || (0, _includes2.default)(parentDependencies, childTagName) || parentDependencies.some(function (dep) { | ||
if (!ChildComponent || (0, _includes["default"])(skipElements, childTagName) || (0, _includes["default"])(parentDependencies, childTagName) || parentDependencies.some(function (dep) { | ||
return dep instanceof RegExp && dep.test(childTagName); | ||
@@ -56,11 +44,11 @@ })) { | ||
var allowedDependencies = (0, _keys2.default)(_dependencies2.default).filter(function (key) { | ||
return (0, _includes2.default)(_dependencies2.default[key], childTagName) || _dependencies2.default[key].some(function (dep) { | ||
var allowedDependencies = (0, _keys["default"])(_dependencies["default"]).filter(function (key) { | ||
return (0, _includes["default"])(_dependencies["default"][key], childTagName) || _dependencies["default"][key].some(function (dep) { | ||
return dep instanceof RegExp && dep.test(childTagName); | ||
}); | ||
}); | ||
return (0, _ruleError2.default)(childTagName + ' cannot be used inside ' + tagName + ', only inside: ' + allowedDependencies.join(', '), child); | ||
return (0, _ruleError["default"])("".concat(childTagName, " cannot be used inside ").concat(tagName, ", only inside: ").concat(allowedDependencies.join(', ')), child); | ||
})); | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
@@ -1,16 +0,14 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = validateTag; | ||
exports["default"] = validateTag; | ||
var _lodash = require('lodash'); | ||
var _lodash = require("lodash"); | ||
var _ruleError = require('./ruleError'); | ||
var _ruleError = _interopRequireDefault(require("./ruleError")); | ||
var _ruleError2 = _interopRequireDefault(_ruleError); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// Tags that have no associated components but are allowed even so | ||
@@ -22,10 +20,7 @@ var componentLessTags = ['mj-all', 'mj-class']; | ||
var tagName = element.tagName; | ||
if ((0, _lodash.includes)(componentLessTags, tagName)) return null; | ||
var Component = components[tagName]; | ||
if (!Component) { | ||
return (0, _ruleError2.default)('Element ' + tagName + ' doesn\'t exist or is not registered', element); | ||
return (0, _ruleError["default"])("Element ".concat(tagName, " doesn't exist or is not registered"), element); | ||
} | ||
@@ -35,2 +30,3 @@ | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
@@ -1,16 +0,14 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = validateType; | ||
exports["default"] = validateType; | ||
var _lodash = require('lodash'); | ||
var _lodash = require("lodash"); | ||
var _ruleError = require('./ruleError'); | ||
var _ruleError = _interopRequireDefault(require("./ruleError")); | ||
var _ruleError2 = _interopRequireDefault(_ruleError); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function validateType(element, _ref) { | ||
@@ -21,4 +19,2 @@ var components = _ref.components, | ||
tagName = element.tagName; | ||
var Component = components[tagName]; | ||
@@ -37,5 +33,6 @@ | ||
if (result.isValid()) return null; | ||
return (0, _ruleError2.default)('Attribute ' + attr + ' ' + result.getErrorMessage(), element); | ||
return (0, _ruleError["default"])("Attribute ".concat(attr, " ").concat(result.getErrorMessage()), element); | ||
})); | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
{ | ||
"name": "mjml-validator", | ||
"description": "mjml-validator", | ||
"version": "4.5.0", | ||
"version": "4.6.2", | ||
"main": "lib/index.js", | ||
@@ -16,7 +16,7 @@ "repository": { | ||
"scripts": { | ||
"clean": "cross-env ../../node_modules/.bin/rimraf lib", | ||
"build": "cross-env ../../node_modules/.bin/babel src --out-dir lib" | ||
"clean": "rimraf lib", | ||
"build": "babel src --out-dir lib --root-mode upward" | ||
}, | ||
"dependencies": { | ||
"babel-runtime": "^6.26.0", | ||
"@babel/runtime": "^7.8.7", | ||
"lodash": "^4.17.15", | ||
@@ -26,4 +26,6 @@ "warning": "^3.0.0" | ||
"devDependencies": { | ||
"cross-env": "^5.2.0" | ||
} | ||
"@babel/cli": "^7.8.4", | ||
"rimraf": "^3.0.2" | ||
}, | ||
"gitHead": "d98f4c7ddb6e362ba50e5e6aadc66c32bb02a3ba" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31725
23
622
2
+ Added@babel/runtime@^7.8.7
+ Added@babel/runtime@7.26.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
- Removedbabel-runtime@^6.26.0
- Removedbabel-runtime@6.26.0(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedregenerator-runtime@0.11.1(transitive)