@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
21 lines • 827 B
JavaScript
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 isHardCodedColor = function isHardCodedColor(value) {
if (includesWholeWord(value.toLowerCase(), 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;
};