eslint-plugin-orbit-components
Advanced tools
Comparing version 0.5.4 to 0.5.5
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.default = void 0; | ||
var internal = { | ||
const internal = { | ||
plugins: ["orbit-components"], | ||
@@ -10,0 +10,0 @@ rules: { |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.default = void 0; | ||
var recommended = { | ||
const recommended = { | ||
plugins: ["orbit-components"], | ||
@@ -10,0 +10,0 @@ rules: { |
@@ -32,3 +32,3 @@ "use strict"; | ||
var rules = { | ||
const rules = { | ||
"button-has-title": _buttonHasTitle.default, | ||
@@ -45,3 +45,3 @@ "default-theme": _defaultTheme.default, | ||
exports.rules = rules; | ||
var configs = { | ||
const configs = { | ||
recommended: _recommended.default, | ||
@@ -48,0 +48,0 @@ internal: _internal.default |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -18,17 +16,17 @@ value: true | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var _default = { | ||
create: function create(context) { | ||
var importedOrbitComponents = {}; | ||
var JSXElements = []; | ||
var variables = {}; | ||
var Buttons = ["Button", "ButtonLink"]; | ||
create: context => { | ||
const importedOrbitComponents = {}; | ||
const JSXElements = []; | ||
const variables = {}; | ||
const Buttons = ["Button", "ButtonLink"]; | ||
var registerImport = function registerImport(ctx, node, name) { | ||
const registerImport = (ctx, node, name) => { | ||
if ((0, _isOrbitComponent.default)(name)) { | ||
var ORIGINAL_ORBIT_NAME = (0, _detectOriginalOrbitName.default)(node); | ||
var LOCAL_NAME = node.specifiers[0].local.name; | ||
const ORIGINAL_ORBIT_NAME = (0, _detectOriginalOrbitName.default)(node); | ||
const LOCAL_NAME = node.specifiers[0].local.name; | ||
importedOrbitComponents[LOCAL_NAME] = ORIGINAL_ORBIT_NAME; | ||
@@ -39,31 +37,12 @@ } | ||
return { | ||
JSXElement: function (_JSXElement) { | ||
function JSXElement(_x) { | ||
return _JSXElement.apply(this, arguments); | ||
} | ||
JSXElement.toString = function () { | ||
return _JSXElement.toString(); | ||
}; | ||
return JSXElement; | ||
}(function (node) { | ||
JSXElement(node) { | ||
JSXElements.push(node); | ||
}), | ||
VariableDeclaration: function (_VariableDeclaration) { | ||
function VariableDeclaration(_x2) { | ||
return _VariableDeclaration.apply(this, arguments); | ||
} | ||
}, | ||
VariableDeclaration.toString = function () { | ||
return _VariableDeclaration.toString(); | ||
}; | ||
return VariableDeclaration; | ||
}(function (node) { | ||
node.declarations.forEach(function (declaration) { | ||
VariableDeclaration(node) { | ||
node.declarations.forEach(declaration => { | ||
if (t.isObjectExpression(declaration.init)) { | ||
if (declaration.init.properties.length > 0) { | ||
if (t.isIdentifier(declaration.id)) { | ||
variables[declaration.id.name] = declaration.init.properties.map(function (property) { | ||
variables[declaration.id.name] = declaration.init.properties.map(property => { | ||
if (t.isProperty(property) && t.isIdentifier(property.key)) { | ||
@@ -79,27 +58,16 @@ return property.key.name; | ||
}); | ||
}), | ||
ImportDeclaration: function (_ImportDeclaration) { | ||
function ImportDeclaration(_x3) { | ||
return _ImportDeclaration.apply(this, arguments); | ||
} | ||
}, | ||
ImportDeclaration.toString = function () { | ||
return _ImportDeclaration.toString(); | ||
}; | ||
return ImportDeclaration; | ||
}(function (node) { | ||
ImportDeclaration: node => { | ||
if (node.specifiers.length) { | ||
var name = node.source.value; | ||
const name = node.source.value; | ||
registerImport(context, node, name); | ||
} | ||
}), | ||
"Program:exit": function ProgramExit() { | ||
JSXElements.forEach(function (node) { | ||
}, | ||
"Program:exit": () => { | ||
JSXElements.forEach(node => { | ||
if (t.isJSXIdentifier(node.openingElement.name)) { | ||
var localName = node.openingElement.name.name; | ||
const localName = node.openingElement.name.name; | ||
if (localName in importedOrbitComponents && Buttons.find(function (x) { | ||
return x === importedOrbitComponents[localName]; | ||
})) { | ||
if (localName in importedOrbitComponents && Buttons.find(x => x === importedOrbitComponents[localName])) { | ||
/* | ||
@@ -115,5 +83,3 @@ We can safely return, because the JSXElement is not selfClosing - does have children. | ||
var spread = node.openingElement.attributes.filter(function (n) { | ||
return n.type === "JSXSpreadAttribute"; | ||
}) || []; | ||
const spread = node.openingElement.attributes.filter(n => n.type === "JSXSpreadAttribute") || []; | ||
@@ -126,5 +92,7 @@ if (spread.length > 0) { | ||
if (Object.keys(variables).length === 0) return; | ||
spread.forEach(function (s) { | ||
spread.forEach(s => { | ||
if (t.isJSXSpreadAttribute(s) && t.isIdentifier(s.argument)) { | ||
var name = s.argument.name; | ||
const { | ||
name | ||
} = s.argument; | ||
/* | ||
@@ -136,8 +104,6 @@ If the spreading variable name is in object declarations, we can check if "title" | ||
if (!(name in variables)) return; | ||
if (variables[name].find(function (v) { | ||
return v === "title"; | ||
})) return; | ||
if (variables[name].find(v => v === "title")) return; | ||
context.report({ | ||
// @ts-expect-error TODO | ||
node: node, | ||
node, | ||
message: "".concat(localName, " doesn't have children. Please provide title property to add aria-label, so it's accessible for screen readers.") | ||
@@ -150,8 +116,6 @@ }); | ||
*/ | ||
} else if (!node.openingElement.attributes.find(function (n) { | ||
return n.type === "JSXAttribute" && n.name.name === "title"; | ||
})) { | ||
} else if (!node.openingElement.attributes.find(n => n.type === "JSXAttribute" && n.name.name === "title")) { | ||
context.report({ | ||
// @ts-expect-error TODO | ||
node: node, | ||
node, | ||
message: "".concat(localName, " doesn't have children. Please provide title property to add aria-label, so it's accessible for screen readers.") | ||
@@ -158,0 +122,0 @@ }); |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -12,7 +10,7 @@ value: true | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var ERRORS = { | ||
const ERRORS = { | ||
variableDeclaration: "Do not use defaultTheme as value, use useTheme() hook or ThemeConsumer", | ||
@@ -24,3 +22,3 @@ styled: "Do not use defaultTheme directly inside styled components, either create defaultProps or consume the theme from with arrow function expression.", | ||
exports.ERRORS = ERRORS; | ||
var defaultThemeRule = { | ||
const defaultThemeRule = { | ||
meta: { | ||
@@ -35,18 +33,8 @@ type: "problem", | ||
// @ts-expect-error todo | ||
create: function create(context) { | ||
var specifier = ""; | ||
create: context => { | ||
let specifier = ""; | ||
return { | ||
ImportDeclaration: function (_ImportDeclaration) { | ||
function ImportDeclaration(_x) { | ||
return _ImportDeclaration.apply(this, arguments); | ||
} | ||
ImportDeclaration.toString = function () { | ||
return _ImportDeclaration.toString(); | ||
}; | ||
return ImportDeclaration; | ||
}(function (node) { | ||
ImportDeclaration(node) { | ||
if (node.source.value === "@kiwicom/orbit-components/lib/defaultTheme") { | ||
node.specifiers.forEach(function (s) { | ||
node.specifiers.forEach(s => { | ||
if (t.isImportDefaultSpecifier(s)) { | ||
@@ -56,3 +44,3 @@ if (s.local.name === "theme") { | ||
// @ts-expect-error TODO | ||
node: node, | ||
node, | ||
message: ERRORS.import | ||
@@ -66,3 +54,3 @@ }); | ||
} | ||
}), | ||
}, | ||
@@ -76,17 +64,7 @@ /** | ||
*/ | ||
VariableDeclaration: function (_VariableDeclaration) { | ||
function VariableDeclaration(_x2) { | ||
return _VariableDeclaration.apply(this, arguments); | ||
} | ||
VariableDeclaration.toString = function () { | ||
return _VariableDeclaration.toString(); | ||
}; | ||
return VariableDeclaration; | ||
}(function (node) { | ||
node.declarations.forEach(function (n) { | ||
VariableDeclaration(node) { | ||
node.declarations.forEach(n => { | ||
if (t.isVariableDeclarator(n)) { | ||
if (t.isObjectExpression(n.init)) { | ||
n.init.properties.forEach(function (p) { | ||
n.init.properties.forEach(p => { | ||
if (t.isProperty(p)) { | ||
@@ -124,3 +102,3 @@ if (t.isMemberExpression(p.value)) { | ||
// @ts-expect-error TODO | ||
node: node, | ||
node, | ||
message: ERRORS.destructured | ||
@@ -133,3 +111,3 @@ }); | ||
}); | ||
}), | ||
}, | ||
@@ -142,14 +120,4 @@ /** | ||
*/ | ||
TemplateLiteral: function (_TemplateLiteral) { | ||
function TemplateLiteral(_x3) { | ||
return _TemplateLiteral.apply(this, arguments); | ||
} | ||
TemplateLiteral.toString = function () { | ||
return _TemplateLiteral.toString(); | ||
}; | ||
return TemplateLiteral; | ||
}(function (node) { | ||
node.expressions.forEach(function (exp) { | ||
TemplateLiteral(node) { | ||
node.expressions.forEach(exp => { | ||
if (t.isMemberExpression(exp)) { | ||
@@ -167,3 +135,4 @@ if (t.isMemberExpression(exp.object) && t.isIdentifier(exp.object.object)) { | ||
}); | ||
}) | ||
} | ||
}; | ||
@@ -170,0 +139,0 @@ } |
@@ -7,15 +7,2 @@ "use strict"; | ||
exports.default = void 0; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var _default = { | ||
@@ -30,34 +17,15 @@ meta: { | ||
}, | ||
create: function create(context) { | ||
var allowed = ["background", "background-color", "color"]; | ||
create: context => { | ||
const allowed = ["background", "background-color", "color"]; | ||
return { | ||
TemplateElement: function (_TemplateElement) { | ||
function TemplateElement(_x) { | ||
return _TemplateElement.apply(this, arguments); | ||
} | ||
TemplateElement.toString = function () { | ||
return _TemplateElement.toString(); | ||
}; | ||
return TemplateElement; | ||
}(function (node) { | ||
TemplateElement(node) { | ||
if (node.value.cooked) { | ||
var _node$value$cooked; | ||
var properties = (_node$value$cooked = node.value.cooked) === null || _node$value$cooked === void 0 ? void 0 : _node$value$cooked.replace(/\n/gm, "").trim().split(";").map(function (v) { | ||
return v.trim(); | ||
}).filter(Boolean).map(function (p) { | ||
return p.split(":"); | ||
}).filter(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 1), | ||
n = _ref2[0]; | ||
return allowed.includes(n); | ||
}); | ||
properties.forEach(function (p) { | ||
const properties = (_node$value$cooked = node.value.cooked) === null || _node$value$cooked === void 0 ? void 0 : _node$value$cooked.replace(/\n/gm, "").trim().split(";").map(v => v.trim()).filter(Boolean).map(p => p.split(":")).filter(([n]) => allowed.includes(n)); | ||
properties.forEach(p => { | ||
if (p[1]) { | ||
context.report({ | ||
// @ts-expect-error TODO | ||
node: node, | ||
node, | ||
message: "".concat(p[0], " should be replaced with Orbit design token") | ||
@@ -68,3 +36,4 @@ }); | ||
} | ||
}) | ||
} | ||
}; | ||
@@ -71,0 +40,0 @@ } |
@@ -7,15 +7,2 @@ "use strict"; | ||
exports.default = void 0; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var _default = { | ||
@@ -30,35 +17,16 @@ meta: { | ||
}, | ||
create: function create(context) { | ||
var ALLOWED_PROPS = ["font-size", "font-family", "line-height"]; | ||
var ALLOWED_VALUES = ["inherit", "initial", "unset"]; | ||
create: context => { | ||
const ALLOWED_PROPS = ["font-size", "font-family", "line-height"]; | ||
const ALLOWED_VALUES = ["inherit", "initial", "unset"]; | ||
return { | ||
TemplateElement: function (_TemplateElement) { | ||
function TemplateElement(_x) { | ||
return _TemplateElement.apply(this, arguments); | ||
} | ||
TemplateElement.toString = function () { | ||
return _TemplateElement.toString(); | ||
}; | ||
return TemplateElement; | ||
}(function (node) { | ||
TemplateElement(node) { | ||
if (node.value.cooked) { | ||
var _node$value$cooked; | ||
var properties = (_node$value$cooked = node.value.cooked) === null || _node$value$cooked === void 0 ? void 0 : _node$value$cooked.replace(/\n/gm, "").trim().split(";").map(function (v) { | ||
return v.trim(); | ||
}).filter(Boolean).map(function (p) { | ||
return p.split(":"); | ||
}).filter(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 1), | ||
n = _ref2[0]; | ||
return ALLOWED_PROPS.includes(n); | ||
}); | ||
properties.forEach(function (p) { | ||
const properties = (_node$value$cooked = node.value.cooked) === null || _node$value$cooked === void 0 ? void 0 : _node$value$cooked.replace(/\n/gm, "").trim().split(";").map(v => v.trim()).filter(Boolean).map(p => p.split(":")).filter(([n]) => ALLOWED_PROPS.includes(n)); | ||
properties.forEach(p => { | ||
if (p[1] && !ALLOWED_VALUES.includes(p[1].trim())) { | ||
context.report({ | ||
// @ts-expect-error TODO | ||
node: node, | ||
node, | ||
message: "The value ".concat(p[1].trim(), " used for CSS property ").concat(p[0], " should be replaced with an existing design token. Check orbit.kiwi/design-tokens to find which token you might use.") | ||
@@ -69,3 +37,4 @@ }); | ||
} | ||
}) | ||
} | ||
}; | ||
@@ -72,0 +41,0 @@ } |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -12,10 +10,10 @@ value: true | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var LIMIT = 1; | ||
var ERROR = "Using many arrow function expressions in a single styled component can negatively impact performance. Consider using one single function to destructure all props and return one single css helper function if possible."; | ||
const LIMIT = 1; | ||
const ERROR = "Using many arrow function expressions in a single styled component can negatively impact performance. Consider using one single function to destructure all props and return one single css helper function if possible."; | ||
exports.ERROR = ERROR; | ||
var preferSingleDestructure = { | ||
const preferSingleDestructure = { | ||
meta: { | ||
@@ -30,40 +28,20 @@ type: "suggestion", | ||
// @ts-expect-error TODO | ||
create: function create(context) { | ||
var specifier = ""; | ||
create: context => { | ||
let specifier = ""; | ||
return { | ||
ImportDeclaration: function (_ImportDeclaration) { | ||
function ImportDeclaration(_x) { | ||
return _ImportDeclaration.apply(this, arguments); | ||
} | ||
ImportDeclaration(node) { | ||
if (node.source.value === "styled-components") { | ||
const def = node.specifiers.filter(s => t.isImportDefaultSpecifier(s)); | ||
ImportDeclaration.toString = function () { | ||
return _ImportDeclaration.toString(); | ||
}; | ||
return ImportDeclaration; | ||
}(function (node) { | ||
if (node.source.value === "styled-components") { | ||
var def = node.specifiers.filter(function (s) { | ||
return t.isImportDefaultSpecifier(s); | ||
}); | ||
specifier = def[0].local.name; | ||
if (def.length > 0) { | ||
specifier = def[0].local.name; | ||
} | ||
} | ||
}), | ||
TaggedTemplateExpression: function (_TaggedTemplateExpression) { | ||
function TaggedTemplateExpression(_x2) { | ||
return _TaggedTemplateExpression.apply(this, arguments); | ||
} | ||
}, | ||
TaggedTemplateExpression.toString = function () { | ||
return _TaggedTemplateExpression.toString(); | ||
}; | ||
return TaggedTemplateExpression; | ||
}(function (node) { | ||
TaggedTemplateExpression(node) { | ||
if (t.isMemberExpression(node.tag)) { | ||
if (t.isIdentifier(node.tag.object) && node.tag.object.name === specifier) { | ||
if (t.isTemplateLiteral(node.quasi)) { | ||
var count = node.quasi.expressions.filter(function (e) { | ||
return t.isArrowFunctionExpression(e); | ||
}).length; | ||
const count = node.quasi.expressions.filter(e => t.isArrowFunctionExpression(e)).length; | ||
@@ -73,3 +51,3 @@ if (count > LIMIT) { | ||
// @ts-expect-error TODO | ||
node: node, | ||
node, | ||
message: ERROR | ||
@@ -81,3 +59,4 @@ }); | ||
} | ||
}) | ||
} | ||
}; | ||
@@ -84,0 +63,0 @@ } |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -12,11 +10,11 @@ value: true | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var RightOrLeftError = "Do not use theme.rtl as the test value of conditional expression. Consider importing either left or right function from @kiwicom/orbit-components. See more on https://orbit.kiwi/utilities/right-to-left-languages/."; | ||
const RightOrLeftError = "Do not use theme.rtl as the test value of conditional expression. Consider importing either left or right function from @kiwicom/orbit-components. See more on https://orbit.kiwi/utilities/right-to-left-languages/."; | ||
exports.RightOrLeftError = RightOrLeftError; | ||
var SpacingError = "Do not use theme.rtl as the test value of conditional expression. Consider importing rtlSpacing function from @kiwicom/orbit-components. See more on https://orbit.kiwi/utilities/right-to-left-languages/."; | ||
const SpacingError = "Do not use theme.rtl as the test value of conditional expression. Consider importing rtlSpacing function from @kiwicom/orbit-components. See more on https://orbit.kiwi/utilities/right-to-left-languages/."; | ||
exports.SpacingError = SpacingError; | ||
var rtlUtils = { | ||
const rtlUtils = { | ||
meta: { | ||
@@ -31,38 +29,17 @@ type: "problem", | ||
// @ts-expect-error TODO | ||
create: function create(context) { | ||
var specifier = ""; | ||
create: context => { | ||
let specifier = ""; | ||
return { | ||
ImportDeclaration: function (_ImportDeclaration) { | ||
function ImportDeclaration(_x) { | ||
return _ImportDeclaration.apply(this, arguments); | ||
} | ||
ImportDeclaration.toString = function () { | ||
return _ImportDeclaration.toString(); | ||
}; | ||
return ImportDeclaration; | ||
}(function (node) { | ||
ImportDeclaration(node) { | ||
if (node.source.value === "styled-components") { | ||
var def = node.specifiers.filter(function (s) { | ||
return t.isImportDefaultSpecifier(s); | ||
}); | ||
const def = node.specifiers.filter(s => t.isImportDefaultSpecifier(s)); | ||
specifier = def[0].local.name; | ||
} | ||
}), | ||
TaggedTemplateExpression: function (_TaggedTemplateExpression) { | ||
function TaggedTemplateExpression(_x2) { | ||
return _TaggedTemplateExpression.apply(this, arguments); | ||
} | ||
}, | ||
TaggedTemplateExpression.toString = function () { | ||
return _TaggedTemplateExpression.toString(); | ||
}; | ||
return TaggedTemplateExpression; | ||
}(function (node) { | ||
TaggedTemplateExpression(node) { | ||
if (t.isMemberExpression(node.tag)) { | ||
if (t.isIdentifier(node.tag.object) && node.tag.object.name === specifier) { | ||
if (t.isTemplateLiteral(node.quasi)) { | ||
node.quasi.expressions.forEach(function (e) { | ||
node.quasi.expressions.forEach(e => { | ||
if (t.isArrowFunctionExpression(e)) { | ||
@@ -72,7 +49,9 @@ if (t.isConditionalExpression(e.body)) { | ||
if (e.body.test.property.name === "rtl") { | ||
var consequent = e.body.consequent; // if it's literal value of which matches patterns | ||
const { | ||
consequent | ||
} = e.body; // if it's literal value of which matches patterns | ||
// @ts-expect-error babel-types | ||
if (t.isLiteral(consequent) && consequent.value) { | ||
var regexWithProp = new RegExp(/left|right|margin-left|margin-right|padding-left|padding-right/g); // @ts-expect-error babel-types | ||
const regexWithProp = new RegExp(/left|right|margin-left|margin-right|padding-left|padding-right/g); // @ts-expect-error babel-types | ||
@@ -109,3 +88,4 @@ if (consequent.value.match(regexWithProp)) { | ||
} | ||
}) | ||
} | ||
}; | ||
@@ -112,0 +92,0 @@ } |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -12,7 +10,7 @@ value: true | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var uniqueId = { | ||
const uniqueId = { | ||
meta: { | ||
@@ -27,15 +25,5 @@ type: "problem", | ||
// @ts-expect-error node | ||
create: function create(context) { | ||
create: context => { | ||
return { | ||
JSXAttribute: function (_JSXAttribute) { | ||
function JSXAttribute(_x) { | ||
return _JSXAttribute.apply(this, arguments); | ||
} | ||
JSXAttribute.toString = function () { | ||
return _JSXAttribute.toString(); | ||
}; | ||
return JSXAttribute; | ||
}(function (node) { | ||
JSXAttribute(node) { | ||
if (node.value) { | ||
@@ -45,3 +33,3 @@ if (node.name.name === "id" && !t.isJSXExpressionContainer(node.value)) { | ||
// @ts-expect-error node | ||
node: node, | ||
node, | ||
// @ts-expect-error node | ||
@@ -52,3 +40,4 @@ message: "".concat(node.name.name, "=\"").concat(node.value.value, "\", do not use literal value as ID, you should use randomID utility function") | ||
} | ||
}) | ||
} | ||
}; | ||
@@ -55,0 +44,0 @@ } |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -18,16 +16,16 @@ value: true | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var _default = { | ||
create: function create(context) { | ||
var importedOrbitComponents = {}; | ||
var JSXElements = []; | ||
var doNotUseTextIn = ["Button", "Heading"]; | ||
create: context => { | ||
const importedOrbitComponents = {}; | ||
const JSXElements = []; | ||
const doNotUseTextIn = ["Button", "Heading"]; | ||
var registerImport = function registerImport(ctx, node, name) { | ||
const registerImport = (ctx, node, name) => { | ||
if ((0, _isOrbitComponent.default)(name)) { | ||
var ORIGINAL_ORBIT_NAME = (0, _detectOriginalOrbitName.default)(node); | ||
var LOCAL_NAME = node.specifiers[0].local.name; | ||
const ORIGINAL_ORBIT_NAME = (0, _detectOriginalOrbitName.default)(node); | ||
const LOCAL_NAME = node.specifiers[0].local.name; | ||
@@ -41,40 +39,19 @@ if (ORIGINAL_ORBIT_NAME) { | ||
return { | ||
JSXElement: function (_JSXElement) { | ||
function JSXElement(_x) { | ||
return _JSXElement.apply(this, arguments); | ||
} | ||
JSXElement.toString = function () { | ||
return _JSXElement.toString(); | ||
}; | ||
return JSXElement; | ||
}(function (node) { | ||
JSXElement(node) { | ||
JSXElements.push(node); | ||
}), | ||
ImportDeclaration: function (_ImportDeclaration) { | ||
function ImportDeclaration(_x2) { | ||
return _ImportDeclaration.apply(this, arguments); | ||
} | ||
}, | ||
ImportDeclaration.toString = function () { | ||
return _ImportDeclaration.toString(); | ||
}; | ||
return ImportDeclaration; | ||
}(function (node) { | ||
ImportDeclaration: node => { | ||
if (node.specifiers.length) { | ||
var name = node.source.value; | ||
const name = node.source.value; | ||
registerImport(context, node, name); | ||
} | ||
}), | ||
"Program:exit": function ProgramExit() { | ||
JSXElements.forEach(function (node) { | ||
}, | ||
"Program:exit": () => { | ||
JSXElements.forEach(node => { | ||
if (t.isJSXIdentifier(node.openingElement.name)) { | ||
var localName = node.openingElement.name.name; | ||
const localName = node.openingElement.name.name; | ||
if (localName in importedOrbitComponents && doNotUseTextIn.find(function (x) { | ||
return x === importedOrbitComponents[localName]; | ||
}) && node.children) { | ||
node.children.forEach(function (child) { | ||
if (localName in importedOrbitComponents && doNotUseTextIn.find(x => x === importedOrbitComponents[localName]) && node.children) { | ||
node.children.forEach(child => { | ||
if (t.isJSXElement(child)) { | ||
@@ -84,3 +61,3 @@ if (!child.openingElement) return; | ||
if (t.isJSXIdentifier(child.openingElement.name)) { | ||
var childElementName = child.openingElement.name.name; | ||
const childElementName = child.openingElement.name.name; | ||
@@ -87,0 +64,0 @@ if (importedOrbitComponents[childElementName] === "Text") { |
@@ -7,35 +7,16 @@ "use strict"; | ||
exports.default = exports.errorBasic = exports.ERROR_BORDER_RADIUS = exports.ERROR_RTL_SPACING = void 0; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var ERROR_RTL_SPACING = "Use Orbit's rtlSpacing utility because values for right and left edges are different. https://orbit.kiwi/utilities/right-to-left-languages/#rtlspacing"; | ||
const ERROR_RTL_SPACING = "Use Orbit's rtlSpacing utility because values for right and left edges are different. https://orbit.kiwi/utilities/right-to-left-languages/#rtlspacing"; | ||
exports.ERROR_RTL_SPACING = ERROR_RTL_SPACING; | ||
var ERROR_BORDER_RADIUS = "border-radius edge values are different. Use borderRadius utility."; | ||
const ERROR_BORDER_RADIUS = "border-radius edge values are different. Use borderRadius utility."; | ||
exports.ERROR_BORDER_RADIUS = ERROR_BORDER_RADIUS; | ||
var errorBasic = "Values for right and left edges are different. Use Orbit's rtl utility. https://orbit.kiwi/utilities/right-to-left-languages"; | ||
const errorBasic = "Values for right and left edges are different. Use Orbit's rtl utility. https://orbit.kiwi/utilities/right-to-left-languages"; | ||
exports.errorBasic = errorBasic; | ||
var parseVals = function parseVals(str) { | ||
return str.trim().split(" ").map(function (v) { | ||
return parseInt(v, 10); | ||
}); | ||
}; | ||
const parseVals = str => str.trim().split(" ").map(v => parseInt(v, 10)); | ||
var rtlSpacingCheck = function rtlSpacingCheck(str) { | ||
var arr = parseVals(str); // for instance: margin: 0 10px 20px 15px; | ||
const rtlSpacingCheck = str => { | ||
const arr = parseVals(str); // for instance: margin: 0 10px 20px 15px; | ||
if (arr.length === 4) { | ||
var vals = arr.filter(function (_, i) { | ||
return i === 1 || i === 3; | ||
}); | ||
const vals = arr.filter((_, i) => i === 1 || i === 3); | ||
return vals[0] !== vals[1]; | ||
@@ -47,8 +28,8 @@ } | ||
var borderRadiusCheck = function borderRadiusCheck(str) { | ||
var arr = parseVals(str); | ||
const borderRadiusCheck = str => { | ||
const arr = parseVals(str); | ||
if (arr.length === 4) { | ||
var isTopEqual = arr[0] === arr[1]; | ||
var isBottomEqual = arr[2] === arr[3]; // border-radius: 3px 3px 5px 5px; | ||
const isTopEqual = arr[0] === arr[1]; | ||
const isBottomEqual = arr[2] === arr[3]; // border-radius: 3px 3px 5px 5px; | ||
@@ -64,3 +45,3 @@ if (isTopEqual && isBottomEqual) return undefined; // border-radius: 3px 5px 5px 5px or 3px 3px 5px 6px; | ||
var useRtl = { | ||
const useRtl = { | ||
meta: { | ||
@@ -75,35 +56,12 @@ type: "problem", | ||
// @ts-expect-error TODO | ||
create: function create(context) { | ||
var basic = ["right", "left", "text-align", "padding-left", "padding-right", "margin-left", "margin-right"]; | ||
var allowed = basic.concat(["padding", "margin", "border-radius", "transform"]); | ||
create: context => { | ||
const basic = ["right", "left", "text-align", "padding-left", "padding-right", "margin-left", "margin-right"]; | ||
const allowed = basic.concat(["padding", "margin", "border-radius", "transform"]); | ||
return { | ||
TemplateElement: function (_TemplateElement) { | ||
function TemplateElement(_x) { | ||
return _TemplateElement.apply(this, arguments); | ||
} | ||
TemplateElement.toString = function () { | ||
return _TemplateElement.toString(); | ||
}; | ||
return TemplateElement; | ||
}(function (node) { | ||
TemplateElement(node) { | ||
if (node.value.cooked) { | ||
var _node$value$cooked; | ||
var properties = (_node$value$cooked = node.value.cooked) === null || _node$value$cooked === void 0 ? void 0 : _node$value$cooked.replace(/\n/gm, "").trim().split(";").map(function (v) { | ||
return v.trim(); | ||
}).filter(Boolean).map(function (p) { | ||
return p.split(":"); | ||
}).filter(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 1), | ||
n = _ref2[0]; | ||
return allowed.includes(n); | ||
}); | ||
properties.forEach(function (_ref3) { | ||
var _ref4 = _slicedToArray(_ref3, 2), | ||
prop = _ref4[0], | ||
value = _ref4[1]; | ||
const properties = (_node$value$cooked = node.value.cooked) === null || _node$value$cooked === void 0 ? void 0 : _node$value$cooked.replace(/\n/gm, "").trim().split(";").map(v => v.trim()).filter(Boolean).map(p => p.split(":")).filter(([n]) => allowed.includes(n)); | ||
properties.forEach(([prop, value]) => { | ||
if (prop === "margin" || prop === "padding") { | ||
@@ -113,3 +71,3 @@ if (rtlSpacingCheck(value)) { | ||
// @ts-expect-error todo | ||
node: node, | ||
node, | ||
message: ERROR_RTL_SPACING | ||
@@ -124,3 +82,3 @@ }); | ||
// @ts-expect-error todo | ||
node: node, | ||
node, | ||
message: ERROR_BORDER_RADIUS | ||
@@ -134,3 +92,3 @@ }); | ||
// @ts-expect-error todo | ||
node: node, | ||
node, | ||
message: errorBasic | ||
@@ -143,3 +101,3 @@ }); | ||
// @ts-expect-error todo | ||
node: node, | ||
node, | ||
message: errorBasic | ||
@@ -150,3 +108,4 @@ }); | ||
} | ||
}) | ||
} | ||
}; | ||
@@ -153,0 +112,0 @@ } |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -12,8 +10,8 @@ value: true | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var detectOriginalOrbitName = function detectOriginalOrbitName(node) { | ||
var specifier = node.specifiers[0]; // IF NAMED import | ||
const detectOriginalOrbitName = node => { | ||
const specifier = node.specifiers[0]; // IF NAMED import | ||
@@ -24,3 +22,3 @@ if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) { | ||
var originalImport = node.source.value.match(/@kiwicom\/orbit-components\/(?:lib|es)\/([^/]*)/); | ||
const originalImport = node.source.value.match(/@kiwicom\/orbit-components\/(?:lib|es)\/([^/]*)/); | ||
if (originalImport) return originalImport[1]; | ||
@@ -27,0 +25,0 @@ return undefined; |
@@ -8,7 +8,5 @@ "use strict"; | ||
var isOrbitComponent = function isOrbitComponent(name) { | ||
return /@kiwicom\/orbit-components/.test(name); | ||
}; | ||
const isOrbitComponent = name => /@kiwicom\/orbit-components/.test(name); | ||
var _default = isOrbitComponent; | ||
exports.default = _default; |
{ | ||
"name": "eslint-plugin-orbit-components", | ||
"description": "Collection of ESLint rules to enforce the best usage practices of @kiwicom/orbit-components", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"author": "Kiwi.com", | ||
@@ -49,3 +49,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "26fae6afa12153cba8fe47928ad540e48f2f09be" | ||
"gitHead": "95059393d82e8164b0675a10663e1e434e1d2eec" | ||
} |
47831
721