Skip to content

Commit 92d36d3

Browse files
committed
Added "do you mean" to filter name errors
1 parent 51ad567 commit 92d36d3

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"deepmerge": "^4.2.2",
3232
"lodash": "^4.17.21",
3333
"plotly.js": "^2.14.0",
34+
"propose": "^0.0.5",
3435
"simple-statistics": "^7.8.0"
3536
}
3637
}

src/parse-config/parse-config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Cache from "../cache/Cache";
22
import getThemedLayout, { defaultLayout, HATheme } from "./themed-layout";
33

4+
import propose from "propose";
5+
46
import merge from "lodash/merge";
57
import get from "lodash/get";
68
import {
@@ -371,7 +373,10 @@ class ConfigParser {
371373
const filter = filters[filterName];
372374
if (!filter) {
373375
throw new Error(
374-
`Filter '${filterName} must be [${Object.keys(filters)}]`
376+
`Filter '${filterName}' doesn't exist. Did you mean <b>${propose(
377+
filterName,
378+
Object.keys(filters)
379+
)}<b>?`
375380
);
376381
}
377382
const filterfn = config === null ? filter() : filter(config);

0 commit comments

Comments
 (0)