From c76ef32c2e54ca842fe9047e5fdb16e68e00b061 Mon Sep 17 00:00:00 2001 From: Andrew Michael McNutt Date: Wed, 14 Feb 2024 12:14:25 -0800 Subject: [PATCH] fix types --- README.md | 3 +- src/lib/lint-language/lint-language.ts | 6 +- src/lib/lints/fair.ts | 76 -------------------------- src/lib/lints/size-discrim.ts | 9 +-- 4 files changed, 6 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index e0ab3d56..1ca300f0 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,11 @@ First time you start it up you should also run `yarn prep data` # User study burn down -- [ ] Make deactivation story make sense in new context -- [ ] Get most of the lints converted - [ ] Tour? - [ ] roles, palette level semantics - [ ] Design adjustments for smaller screens - [ ] Language Docs?? +- [x] Get most of the lints converted - [x] Make lints fast / non blocking as much as possible # Language todos diff --git a/src/lib/lint-language/lint-language.ts b/src/lib/lint-language/lint-language.ts index b1cd5f9e..087960bd 100644 --- a/src/lib/lint-language/lint-language.ts +++ b/src/lib/lint-language/lint-language.ts @@ -596,7 +596,7 @@ const getOp = } const allParamsFound = x.params.every((key) => key in node); const noExtraParams = Object.keys(node).every( - (key) => x.params.includes(key) || key === x.primaryKey + (key) => (x.params as string[]).includes(key) || key === x.primaryKey ); const allowedParamsMessage = x.params.length ? `Allowed params are ${x.params.map((x) => `"${x}"`).join(", ")}` @@ -909,11 +909,11 @@ export class LLMap extends LLNode { // implicitly ignore the pass back i guess? switch (this.type) { case "map": - return { result: children.map(evalFunc), env }; + return { result: children.map(evalFunc) as RawValues[], env }; case "filter": return { result: children.filter(evalFunc), env }; case "sort": - const childrenCopy = [...children].map(evalFunc); + const childrenCopy = [...children].map(evalFunc) as RawValues[]; childrenCopy.sort(); return { result: childrenCopy, env }; case "reverse": diff --git a/src/lib/lints/fair.ts b/src/lib/lints/fair.ts index 4612c683..cbdc65ad 100644 --- a/src/lib/lints/fair.ts +++ b/src/lib/lints/fair.ts @@ -1,7 +1,3 @@ -// import { Color } from "../Color"; -// import { ColorLint } from "./ColorLint"; -// import type { TaskType } from "./ColorLint"; -// import { extent } from "../utils"; import { JSONToPrettyString } from "../utils"; import type { CustomLint } from "../CustomLint"; @@ -9,78 +5,6 @@ import type { CustomLint } from "../CustomLint"; const cRangeUnfair = 80; const lRangeUnfair = 50; -// const identifyUnfair = ( -// colors: Color[], -// threshold: number, -// channel: number -// ) => { -// const channelRange = extent(colors.map((x) => x.toChannels()[channel])); -// const outOfBoundColors = colors.filter( -// (x) => x.toChannels()[channel] > channelRange[0] + threshold -// ); -// return outOfBoundColors; -// }; - -// const fairMessage = (outOfBandL: Color[], outOfBandC: Color[]) => { -// const lPass = outOfBandL.length === 0; -// const cPass = outOfBandC.length === 0; -// if (lPass && cPass) { -// return ""; -// } -// const baseMessage = `This palette is unfair (meaning that some values may unduely stand out).`; -// const lMsg = lPass -// ? "" -// : `The following colors have a luminance value that is out of range: ${outOfBandL -// .map((x) => x.toHex()) -// .join(", ")}.`; -// const cMsg = cPass -// ? "" -// : `The following colors have a chroma value that is out of range: ${outOfBandC -// .map((x) => x.toHex()) -// .join(", ")}.`; -// return `${baseMessage} ${lMsg} ${cMsg}`; -// }; - -// class FairBase extends ColorLint { -// name = "Fair"; -// group = "design"; -// // hasParam = true; -// level: "error" | "warning" = "warning"; - -// description: string = `Do the colors stand out equally? A color palette is described as fair if both chroma and luminance ranges are below a certain threshold and unfair if one of them is above a certain threshold. For sequential and diverging palettes, only the chroma range is considered.`; -// buildMessage(): string { -// const { outOfBandL, outOfBandC } = this.checkData; -// return fairMessage(outOfBandL, outOfBandC); -// } -// } - -// class FairSequential extends FairBase { -// taskTypes = ["sequential", "diverging"] as TaskType[]; - -// _runCheck() { -// const { colors } = this.palette; -// const outOfBandL = identifyUnfair(colors, lRangeUnfair, 0); -// return { -// passCheck: outOfBandL.length === 0, -// data: { outOfBandL, outOfBandC: [] }, -// }; -// } -// } - -// class FairNominal extends FairBase { -// taskTypes = ["categorical"] as TaskType[]; - -// _runCheck() { -// const { colors } = this.palette; -// const outOfBandL = identifyUnfair(colors, lRangeUnfair, 0); -// const outOfBandC = identifyUnfair(colors, cRangeUnfair, 1); -// return { -// passCheck: !outOfBandL.length && !outOfBandC.length, -// data: { outOfBandL, outOfBandC }, -// }; -// } -// } - const lRangePredicate = { "<": { left: { extent: { sort: "colors", varb: "x", func: { "lch.l": "x" } } }, diff --git a/src/lib/lints/size-discrim.ts b/src/lib/lints/size-discrim.ts index a29e4547..4d9479b4 100644 --- a/src/lib/lints/size-discrim.ts +++ b/src/lib/lints/size-discrim.ts @@ -1,7 +1,5 @@ -// import { Color } from "../Color"; -// import { ColorLint } from "./ColorLint"; -// import type { TaskType } from "./ColorLint"; - +import { JSONToPrettyString } from "../utils"; +import type { CustomLint } from "../CustomLint"; // based on // https://github.com/connorgr/d3-jnd/blob/master/src/jnd.js @@ -31,9 +29,6 @@ function jndLabInterval(p: pType, s: sType) { return nd(pVal, sVal); } -import { JSONToPrettyString } from "../utils"; -import type { CustomLint } from "../CustomLint"; - const lints: CustomLint[] = ["Thin", "Medium", "Wide"].map((key) => { const p = "default"; const s = key as keyof typeof sMap;