UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

41 lines 1.28 kB
var getNodeValue = function getNodeValue(node) { var _node$value; switch (node.type) { case 'Identifier': return node.name; case 'Literal': return typeof node.value === 'string' ? node.value : null; case 'CallExpression': return node.callee.type === 'Identifier' ? node.callee.name : null; case 'JSXAttribute': return ((_node$value = node.value) === null || _node$value === void 0 ? void 0 : _node$value.type) === 'Literal' && typeof node.value.value === 'string' ? node.value.value : null; default: return null; } }; export var getIsException = function getIsException(exceptions) { if (!(exceptions !== null && exceptions !== void 0 && exceptions.length)) { return function () { return false; }; } var exceptionsSet = new Set(exceptions.map(function (x) { return x.toLowerCase(); })); var _isException = function isException(node) { var value = getNodeValue(node); if (value) { var splitValues = value.split(/[-_\s]+/); if (splitValues.some(function (v) { return exceptionsSet.has(v.toLowerCase()); })) { return true; } } if (node.parent) { return _isException(node.parent); } return false; }; return _isException; };