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

fela-plugin-validator

Package Overview
Dependencies
Maintainers
2
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fela-plugin-validator - npm Package Compare versions

Comparing version 11.7.0 to 12.0.0-rc.0

umd/index.js

43

es/index.js

@@ -1,13 +0,14 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(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; }
import { RULE_TYPE, KEYFRAME_TYPE, isNestedSelector, isMediaQuery, isSupport } from 'fela-utils';
import cssifyDeclaration from 'css-in-js-utils/lib/cssifyDeclaration';
import { cssifyDeclaration } from 'css-in-js-utils';
import isPlainObject from 'isobject';
import { CSSLint } from 'csslint';
var defaultRules = CSSLint.getRules().reduce(function (rules, _ref) {
var id = _ref.id;
return _extends({}, rules, _defineProperty({}, id, 1));
return _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, id, 1));
}, {});

@@ -19,5 +20,6 @@

}
if (logInvalid) {
/* eslint-disable-next-line no-console */
console.error('' + (deleteInvalid ? '[Deleted] ' : ' ') + message, logObject);
console.error("".concat(deleteInvalid ? '[Deleted] ' : ' ').concat(message), logObject);
}

@@ -34,3 +36,3 @@ }

} else {
handleError(property, style, logInvalid, deleteInvalid, 'Invalid nested property. Only use nested media queries, pseudo classes, child selectors or &-combinators.\n Maybe you forgot to add a plugin that resolves "' + property + '".', {
handleError(property, style, logInvalid, deleteInvalid, "Invalid nested property. Only use nested media queries, pseudo classes, child selectors or &-combinators.\n Maybe you forgot to add a plugin that resolves \"".concat(property, "\"."), {
property: property,

@@ -41,3 +43,3 @@ value: value

} else if (useCSSLint) {
var _CSSLint$verify = CSSLint.verify('.fela {' + cssifyDeclaration(property, value) + ';}', cssRules),
var _CSSLint$verify = CSSLint.verify(".fela {".concat(cssifyDeclaration(property, value), ";}"), cssRules),
messages = _CSSLint$verify.messages;

@@ -47,4 +49,3 @@

var message = _ref2.message;
handleError(property, style, logInvalid, deleteInvalid, 'Invalid property "' + property + '" with value "' + value + '". ' + message.replace(/ at line .+, col .+\./, '.'), {
handleError(property, style, logInvalid, deleteInvalid, "Invalid property \"".concat(property, "\" with value \"").concat(value, "\". ").concat(message.replace(/ at line .+, col .+\./, '.')), {
property: property,

@@ -64,3 +65,2 @@ value: value

var percentageValue = parseFloat(percentage);
return percentage.indexOf('%') !== -1 && percentageValue >= 0 && percentageValue <= 100;

@@ -71,16 +71,16 @@ }

for (var percentage in style) {
var _value = style[percentage];
if (!isPlainObject(_value)) {
var value = style[percentage];
if (!isPlainObject(value)) {
handleError(percentage, style, logInvalid, deleteInvalid, 'Invalid keyframe value. An object was expected.', {
percentage: percentage,
style: _value
});
// check for invalid percentage values, it only allows from, to or 0% - 100%
style: value
}); // check for invalid percentage values, it only allows from, to or 0% - 100%
} else if (percentage !== 'from' && percentage !== 'to' && !isValidPercentage(percentage)) {
handleError(percentage, style, logInvalid, deleteInvalid, 'Invalid keyframe property.\n Expected either `to`, `from` or a percentage value between 0 and 100.', {
handleError(percentage, style, logInvalid, deleteInvalid, "Invalid keyframe property.\n Expected either `to`, `from` or a percentage value between 0 and 100.", {
percentage: percentage,
style: _value
style: value
});
} else {
validateStyleObject(_value, logInvalid, deleteInvalid, useCSSLint, cssRules);
validateStyleObject(value, logInvalid, deleteInvalid, useCSSLint, cssRules);
}

@@ -96,3 +96,2 @@ }

if (type === KEYFRAME_TYPE) {

@@ -112,3 +111,2 @@ validateKeyframeObject(style, logInvalid, deleteInvalid, useCSSLint, cssRules);

};
export default function validator() {

@@ -118,6 +116,5 @@ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

var preparedOptions = _extends({}, defaultOptions, options);
var preparedOptions = _objectSpread(_objectSpread({}, defaultOptions), options);
preparedOptions.cssRules = isPlainObject(useCSSLint) ? _extends({}, defaultRules, useCSSLint) : defaultRules;
preparedOptions.cssRules = isPlainObject(useCSSLint) ? _objectSpread(_objectSpread({}, defaultRules), useCSSLint) : defaultRules;
return function (style, type) {

@@ -124,0 +121,0 @@ return validateStyle(style, type, preparedOptions);

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,21 +6,18 @@ Object.defineProperty(exports, "__esModule", {

});
exports["default"] = validator;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _felaUtils = require("fela-utils");
exports.default = validator;
var _cssInJsUtils = require("css-in-js-utils");
var _felaUtils = require('fela-utils');
var _isobject = _interopRequireDefault(require("isobject"));
var _cssifyDeclaration = require('css-in-js-utils/lib/cssifyDeclaration');
var _csslint = require("csslint");
var _cssifyDeclaration2 = _interopRequireDefault(_cssifyDeclaration);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _isobject = require('isobject');
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
var _isobject2 = _interopRequireDefault(_isobject);
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _csslint = require('csslint');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(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; }

@@ -30,3 +27,3 @@

var id = _ref.id;
return _extends({}, rules, _defineProperty({}, id, 1));
return _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, id, 1));
}, {});

@@ -38,5 +35,6 @@

}
if (logInvalid) {
/* eslint-disable-next-line no-console */
console.error('' + (deleteInvalid ? '[Deleted] ' : ' ') + message, logObject);
console.error("".concat(deleteInvalid ? '[Deleted] ' : ' ').concat(message), logObject);
}

@@ -49,7 +47,7 @@ }

if ((0, _isobject2.default)(value)) {
if ((0, _isobject["default"])(value)) {
if ((0, _felaUtils.isNestedSelector)(property) || (0, _felaUtils.isMediaQuery)(property) || (0, _felaUtils.isSupport)(property)) {
validateStyleObject(value, logInvalid, deleteInvalid, useCSSLint, cssRules);
} else {
handleError(property, style, logInvalid, deleteInvalid, 'Invalid nested property. Only use nested media queries, pseudo classes, child selectors or &-combinators.\n Maybe you forgot to add a plugin that resolves "' + property + '".', {
handleError(property, style, logInvalid, deleteInvalid, "Invalid nested property. Only use nested media queries, pseudo classes, child selectors or &-combinators.\n Maybe you forgot to add a plugin that resolves \"".concat(property, "\"."), {
property: property,

@@ -60,3 +58,3 @@ value: value

} else if (useCSSLint) {
var _CSSLint$verify = _csslint.CSSLint.verify('.fela {' + (0, _cssifyDeclaration2.default)(property, value) + ';}', cssRules),
var _CSSLint$verify = _csslint.CSSLint.verify(".fela {".concat((0, _cssInJsUtils.cssifyDeclaration)(property, value), ";}"), cssRules),
messages = _CSSLint$verify.messages;

@@ -66,4 +64,3 @@

var message = _ref2.message;
handleError(property, style, logInvalid, deleteInvalid, 'Invalid property "' + property + '" with value "' + value + '". ' + message.replace(/ at line .+, col .+\./, '.'), {
handleError(property, style, logInvalid, deleteInvalid, "Invalid property \"".concat(property, "\" with value \"").concat(value, "\". ").concat(message.replace(/ at line .+, col .+\./, '.')), {
property: property,

@@ -83,3 +80,2 @@ value: value

var percentageValue = parseFloat(percentage);
return percentage.indexOf('%') !== -1 && percentageValue >= 0 && percentageValue <= 100;

@@ -90,16 +86,16 @@ }

for (var percentage in style) {
var _value = style[percentage];
if (!(0, _isobject2.default)(_value)) {
var value = style[percentage];
if (!(0, _isobject["default"])(value)) {
handleError(percentage, style, logInvalid, deleteInvalid, 'Invalid keyframe value. An object was expected.', {
percentage: percentage,
style: _value
});
// check for invalid percentage values, it only allows from, to or 0% - 100%
style: value
}); // check for invalid percentage values, it only allows from, to or 0% - 100%
} else if (percentage !== 'from' && percentage !== 'to' && !isValidPercentage(percentage)) {
handleError(percentage, style, logInvalid, deleteInvalid, 'Invalid keyframe property.\n Expected either `to`, `from` or a percentage value between 0 and 100.', {
handleError(percentage, style, logInvalid, deleteInvalid, "Invalid keyframe property.\n Expected either `to`, `from` or a percentage value between 0 and 100.", {
percentage: percentage,
style: _value
style: value
});
} else {
validateStyleObject(_value, logInvalid, deleteInvalid, useCSSLint, cssRules);
validateStyleObject(value, logInvalid, deleteInvalid, useCSSLint, cssRules);
}

@@ -115,3 +111,2 @@ }

if (type === _felaUtils.KEYFRAME_TYPE) {

@@ -136,6 +131,5 @@ validateKeyframeObject(style, logInvalid, deleteInvalid, useCSSLint, cssRules);

var preparedOptions = _extends({}, defaultOptions, options);
var preparedOptions = _objectSpread(_objectSpread({}, defaultOptions), options);
preparedOptions.cssRules = (0, _isobject2.default)(useCSSLint) ? _extends({}, defaultRules, useCSSLint) : defaultRules;
preparedOptions.cssRules = (0, _isobject["default"])(useCSSLint) ? _objectSpread(_objectSpread({}, defaultRules), useCSSLint) : defaultRules;
return function (style, type) {

@@ -142,0 +136,0 @@ return validateStyle(style, type, preparedOptions);

{
"name": "fela-plugin-validator",
"version": "11.7.0",
"version": "12.0.0-rc.0",
"description": "Fela plugin to validate style objects",

@@ -13,4 +13,18 @@ "main": "lib/index.js",

"lib/**",
"es/**"
"es/**",
"umd/**"
],
"scripts": {
"setup": "yarn build",
"clean": "rimraf lib es coverage",
"build": "yarn clean && yarn build:es && yarn build:lib",
"build:es": "babel src --out-dir es --ignore **/__tests__",
"build:lib": "cross-env BABEL_ENV=commonjs babel src --out-dir lib --ignore **/__tests__",
"build:umd": "webpack --config webpack.config.js",
"watch": "npm run watch:lib & npm run watch:es",
"watch:lib": "BABEL_ENV=commonjs babel src -d lib -w",
"watch:es": "babel src -d es -w",
"test": "jest --config=jest.config.js",
"coverage": "yarn test --coverage"
},
"repository": "https://github.com/robinweser/fela/",

@@ -29,6 +43,23 @@ "keywords": [

"csslint": "^1.0.5",
"fela-utils": "^11.7.0",
"fela-utils": "^12.0.0-rc.0",
"isobject": "^3.0.1"
},
"gitHead": "e067b284984d3dbfc259fcbffde9bb50679fda9b"
"devDependencies": {
"@babel/cli": "^7.2.0",
"@babel/core": "^7.2.2",
"@babel/node": "^7.13.0",
"@babel/plugin-transform-modules-commonjs": "^7.5.0",
"@babel/polyfill": "^7.7.0",
"@babel/preset-env": "^7.5.5",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^26.6.0",
"babel-loader": "^8.2.3",
"clean-webpack-plugin": "^3.0.0",
"cross-env": "^6.0.3",
"jest": "^26.6.0",
"rimraf": "^3.0.0",
"webpack": "^4.41.6",
"webpack-cli": "^3.3.10"
},
"gitHead": "00f02f410f17a7693479ea3349bb3a9f223359af"
}

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