Skip to content

Commit

Permalink
fix some bugs identified by the global lint thing
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Feb 25, 2024
1 parent 7237043 commit c50aaa1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
$: selectedLint = $lintStore.focusedLint;
const bindStr = "!!";
// it appears that there is a bug in the vega debounce implementation, that causes the second argument to not fire
$: updateSearchDebounced = debounce(10, (x: [any, string]) => {
let updateSearchDebounced = debounce(10, (x: [any, string]) => {
const [pal, ignoreString] = x;
// keep the noise down on the console
if (!selectedLint && pal) {
Expand All @@ -51,9 +51,7 @@
globallyIgnoredLints: ignoreString.split(bindStr),
},
};
console.log("linting", ignoreString);
lint(outPal, true).then((res): void => {
console.log("lint result", res);
lintStore.postCurrentChecks(res);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/lints/name-discrim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const lint: CustomLint = {
},
}),
name: "Color Name Discriminability",
taskTypes: ["sequential"] as const,
taskTypes: ["sequential", "categorical", "diverging"] as const,
level: "error",
group: "usability",
description: `Being able to identify colors by name is important for usability and for memorability.`,
Expand Down
21 changes: 13 additions & 8 deletions src/lib/lints/size-discrim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ function jndLabInterval(p: pType, s: sType) {
return nd(pVal, sVal);
}

const lints: CustomLint[] = ["Thin", "Medium", "Wide"].map((key) => {
const itemSizeDescriptions = {
Thin: "small blocks such as small circles or lines",
Medium: "medium blocks such as bars in a bar chart or small graphics",
Wide: "large blocks of color such as backgrounds or countries on a map",
} as const;
const keys = ["Thin", "Medium", "Wide"] as const;
const lints: CustomLint[] = keys.map((key) => {
const p = "default";
const s = key as keyof typeof sMap;
const jnd = jndLabInterval(p, s);
return {
name: `Works for ${key} marks`,
name: `Mark size legibility: ${key}`,
program: JSONToPrettyString({
// @ts-ignore
$schema: `${location.href}lint-schema.json`,
Expand All @@ -47,10 +53,9 @@ const lints: CustomLint[] = ["Thin", "Medium", "Wide"].map((key) => {
or: [
{
">": {
// left: {
// absDiff: { left: { "lab.l": "x" }, right: { "lab.l": "y" } },
// },
left: { absDiff: { left: 0, right: 1 } },
left: {
absDiff: { left: { "lab.l": "x" }, right: { "lab.l": "y" } },
},
right: jnd.l,
},
},
Expand All @@ -77,8 +82,8 @@ const lints: CustomLint[] = ["Thin", "Medium", "Wide"].map((key) => {
taskTypes: ["sequential", "diverging", "categorical"] as const,
level: "warning",
group: "usability",
description: `Pairs of colors in a palette should be differentiable from each other in ${key} lines. `,
failMessage: `This palette has some colors ({{blame}}) that are close to each other in perceptual space and will not be resolvable for ${key} areas.`,
description: `Pairs of colors in a palette should be differentiable from each other in ${key} marks. `,
failMessage: `This palette has some colors ({{blame}}) that are close to each other in perceptual space and will not be resolvable for ${key} areas. This involves elements like ${itemSizeDescriptions[key]}`,
id: `${key}-discrim-built-in`,
blameMode: "pair",
};
Expand Down
1 change: 1 addition & 0 deletions src/linting/GlobalLintConfig.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<input
type="checkbox"
checked={ignoredSet.has(lint.id)}
class="mr-2"
on:change={() => {
const newLints = [...ignoreList];
if (ignoredSet.has(lint.id)) {
Expand Down

0 comments on commit c50aaa1

Please sign in to comment.