UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

23 lines (22 loc) 770 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.includesHardCodedColor = void 0; var _namedColors = require("./named-colors"); var includesWholeWord = function includesWholeWord(value, options) { var values = value.replace(/[^a-zA-Z ]/g, ' ').trim().split(/(?:,|\.| )+/); return values.some(function (value) { return options.has(value); }); }; var includesHardCodedColor = exports.includesHardCodedColor = function includesHardCodedColor(raw) { var value = raw.toLowerCase(); if (/#(?:[a-f0-9]{3}|[a-f0-9]{6}|[a-f0-9]{8})\b|((?:rgb|hsl)a?|(lch|lab|color))\([^\)]*\)/.exec(value.toLowerCase())) { return true; } if (includesWholeWord(value, _namedColors.namedColors)) { return true; } return false; };