From 74f8990e6b4bb0dd5114753bf8e2bf8834b52779 Mon Sep 17 00:00:00 2001 From: Andrew Michael McNutt Date: Mon, 26 Feb 2024 12:36:51 -0800 Subject: [PATCH] also complements okay --- src/lib/lints/muth-guidelines.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/lib/lints/muth-guidelines.ts b/src/lib/lints/muth-guidelines.ts index f6d7d864..225f59cd 100644 --- a/src/lib/lints/muth-guidelines.ts +++ b/src/lib/lints/muth-guidelines.ts @@ -159,4 +159,34 @@ const AvoidTooMuchContrastWithTheBackground: CustomLint = { }; lints.push(AvoidTooMuchContrastWithTheBackground); +// use pairs of colors +// this isnt a muth its just sort of implied +const requireColorComplements: CustomLint = { + name: `Require color complements`, + program: JSONToPrettyString({ + // @ts-ignore + $schema: `${location.href}lint-schema.json`, + exist: { + in: "colors", + varbs: ["a", "b"], + predicate: { + similar: { + left: { "hsl.h": "a" }, + right: { "+": { left: { "hsl.h": "b" }, right: 180 } }, + threshold: 5, + }, + }, + }, + }), + taskTypes: ["sequential", "diverging", "categorical"] as const, + affectTypes: [], + level: "warning", + group: "design", + description: `Use color complements whenever possible`, + failMessage: `This palette has colors that do not have good contrast.`, + id: `require-color-complements-built-in`, + blameMode: "pair", +}; +lints.push(requireColorComplements); + export default lints;