UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

27 lines (26 loc) 975 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isHardCodedColor = 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 isHardCodedColor = exports.isHardCodedColor = function isHardCodedColor(value) { if (includesWholeWord(value.toLowerCase(), _namedColors.namedColors)) { return true; } if (value.startsWith('rgb(') || value.startsWith('rgba(') || value.startsWith('hsl(') || value.startsWith('hsla(') || value.startsWith('lch(') || value.startsWith('lab(') || value.startsWith('color(')) { return true; } if (value.startsWith('#') && ( // short hex, hex, or hex with alpha value.length === 4 || value.length === 7 || value.length === 9)) { return true; } return false; };