fela-plugin-validator
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -14,2 +14,17 @@ (function (global, factory) { | ||
babelHelpers.defineProperty = function (obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
}; | ||
babelHelpers.extends = Object.assign || function (target) { | ||
@@ -32,4 +47,7 @@ for (var i = 1; i < arguments.length; i++) { | ||
/* weak */ | ||
var RULE_TYPE = 1; | ||
var KEYFRAME_TYPE = 2; | ||
function validateStyleObject(style, logInvalid, deleteInvalid) { | ||
Object.keys(style).forEach(function (property) { | ||
for (var property in style) { | ||
var value = style[property]; | ||
@@ -51,6 +69,6 @@ if (value instanceof Object && !Array.isArray(value)) { | ||
} | ||
}); | ||
} | ||
} | ||
function validator(style, meta, options) { | ||
function validator(style, type, options) { | ||
var logInvalid = options.logInvalid, | ||
@@ -60,4 +78,4 @@ deleteInvalid = options.deleteInvalid; | ||
if (meta.type === 'keyframe') { | ||
Object.keys(style).forEach(function (percentage) { | ||
if (type === KEYFRAME_TYPE) { | ||
for (var percentage in style) { | ||
var percentageValue = parseFloat(percentage); | ||
@@ -89,4 +107,4 @@ var value = style[percentage]; | ||
} | ||
}); | ||
} else if (meta.type === 'rule') { | ||
} | ||
} else if (type === RULE_TYPE) { | ||
validateStyleObject(style, logInvalid, deleteInvalid); | ||
@@ -100,4 +118,4 @@ } | ||
var validator$1 = (function (options) { | ||
return function (style, meta) { | ||
return validator(style, meta, babelHelpers.extends({}, defaultOptions, options)); | ||
return function (style, type) { | ||
return validator(style, type, babelHelpers.extends({}, defaultOptions, options)); | ||
}; | ||
@@ -104,0 +122,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.FelaPluginValidator=t()}(this,function(){"use strict";function e(t,o,n){Object.keys(t).forEach(function(r){var a=t[r];a instanceof Object&&!Array.isArray(a)&&(/^(@media|:|\[|>)/.test(r)?e(a,o,n):(n&&delete t[r],o&&console.error((n?"[Deleted] ":" ")+"Invalid nested property. Only use nested `@media` queries or `:` pseudo classes. Maybe you forgot to add a plugin that resolves `"+r+"`.",{property:r,value:a})))})}function t(t,o,n){var r=n.logInvalid,a=n.deleteInvalid;return"keyframe"===o.type?Object.keys(t).forEach(function(e){var o=parseFloat(e),n=t[e];n instanceof Object==!1?(r&&console.error((a?"[Deleted] ":" ")+"Invalid keyframe value. An object was expected.",{percentage:e,style:n}),a&&delete t[e]):(!e.match(/from|to|%/)||e.indexOf("%")>-1&&(o<0||o>100))&&(r&&console.error((a?"[Deleted] ":" ")+"Invalid keyframe property. Expected either `to`, `from` or a percentage value between 0 and 100.",{percentage:e,style:n}),a&&delete t[e])}):"rule"===o.type&&e(t,r,a),t}var o={};o.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o.extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e};var n={logInvalid:!0,deleteInvalid:!1},r=function(e){return function(r,a){return t(r,a,o.extends({},n,e))}};return r}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.FelaPluginValidator=t()}(this,function(){"use strict";function e(t,r,o){for(var n in t){var a=t[n];a instanceof Object&&!Array.isArray(a)&&(/^(@media|:|\[|>)/.test(n)?e(a,r,o):(o&&delete t[n],r&&console.error((o?"[Deleted] ":" ")+"Invalid nested property. Only use nested `@media` queries or `:` pseudo classes. Maybe you forgot to add a plugin that resolves `"+n+"`.",{property:n,value:a})))}}function t(t,r,a){var l=a.logInvalid,i=a.deleteInvalid;if(r===n)for(var f in t){var d=parseFloat(f),u=t[f];u instanceof Object==!1?(l&&console.error((i?"[Deleted] ":" ")+"Invalid keyframe value. An object was expected.",{percentage:f,style:u}),i&&delete t[f]):(!f.match(/from|to|%/)||f.indexOf("%")>-1&&(d<0||d>100))&&(l&&console.error((i?"[Deleted] ":" ")+"Invalid keyframe property. Expected either `to`, `from` or a percentage value between 0 and 100.",{percentage:f,style:u}),i&&delete t[f])}else r===o&&e(t,l,i);return t}var r={};r.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r.defineProperty=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},r.extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e};var o=1,n=2,a={logInvalid:!0,deleteInvalid:!1},l=function(e){return function(o,n){return t(o,n,r.extends({},a,e))}};return l}); |
{ | ||
"name": "fela-plugin-validator", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Fela plugin to validate style objects", | ||
@@ -23,4 +23,4 @@ "main": "index.js", | ||
"peerDependencies": { | ||
"fela": "4.0.1" | ||
"fela": "4.1.0" | ||
} | ||
} |
@@ -5,3 +5,3 @@ # fela-plugin-validator | ||
<img alt="npm downloads" src="https://img.shields.io/npm/dm/fela-plugin-validator.svg"> | ||
<img alt="gzipped size" src="https://img.shields.io/badge/gzipped-0.80kb-brightgreen.svg"> | ||
<img alt="gzipped size" src="https://img.shields.io/badge/gzipped-0.85kb-brightgreen.svg"> | ||
@@ -15,9 +15,9 @@ Enforces object validation for keyframes and rules. | ||
``` | ||
Assuming you are using [npm](https://www.npmjs.com) as your package mananger you can just `npm install`.<br> | ||
Assuming you are using [npm](https://www.npmjs.com) as your package manager you can just `npm install`.<br> | ||
Otherwise we also provide a [UMD](https://github.com/umdjs/umd). You can easily use it via [unpkg](https://unpkg.com/). It registers a `FelaPluginValidator` global. | ||
```HTML | ||
<!-- Fela (Development): Unminified version including all warnings --> | ||
<script src="https://unpkg.com/fela-plugin-validator@4.0.1/dist/fela-plugin-validator.js"></script> | ||
<script src="https://unpkg.com/fela-plugin-validator@4.1.0/dist/fela-plugin-validator.js"></script> | ||
<!-- Fela (Production): Minified version --> | ||
<script src="https://unpkg.com/fela-plugin-validator@4.0.1/dist/fela-plugin-validator.min.js"></script> | ||
<script src="https://unpkg.com/fela-plugin-validator@4.1.0/dist/fela-plugin-validator.min.js"></script> | ||
``` | ||
@@ -24,0 +24,0 @@ |
Sorry, the diff of this file is not supported yet
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
15253
105