UNPKG

svg-color-linter

Version:

Linting tool to check if SVG files use only colors of a given color palette

31 lines (30 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getInvalidColorsOfFile = void 0; const minimatch_1 = require("minimatch"); const suggestions_1 = require("./suggestions"); const utils_1 = require("./utils"); const validate_color_1 = require("./validate-color"); const getInvalidColorsOfFile = (colors, config, fileName) => { if (config.exclude?.some((pattern) => (0, minimatch_1.minimatch)(fileName, pattern))) { return []; } return colors.reduce((result, color) => { if (!(0, utils_1.isValidColor)(color)) { result.push({ file: fileName, invalidColor: color, suggestions: [], }); } else if (!(0, validate_color_1.validateColor)(color, config.colors)) { result.push({ file: fileName, invalidColor: color, suggestions: (0, suggestions_1.getSuggestions)(color, config.colors), }); } return result; }, []); }; exports.getInvalidColorsOfFile = getInvalidColorsOfFile;