UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

17 lines 610 B
import { namedColors } from './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); }); }; export var 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)) { return true; } return false; };