Skip to content

Commit

Permalink
fix(): limit ctx warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
weareoutman committed Oct 28, 2022
1 parent e8a42f3 commit 33f2024
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe("LintStoryboard", () => {
test: "<% CTX.abc %>",
another: "<% CTX['xyz'] %>",
dynamic: "<% CTX[fly] %>",
more: "<% CTX.more %>",
},
},
],
Expand All @@ -60,7 +61,7 @@ describe("LintStoryboard", () => {
}),
expect.objectContaining({
code: "USING_CTX_IN_TPL",
list: ["tpl-bad: CTX.abc, CTX['xyz'], CTX[...]"],
list: ["tpl-bad: CTX.abc, CTX['xyz'], CTX[...], ..."],
}),
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ export function doLintStoryboard(storyboard: Storyboard): StoryboardError[] {
);

if (contexts.size > 0) {
warnedUsingCtxTemplates.push(
`${tpl.name}: ${[...contexts].join(", ")}`
);
const limited = [...contexts];
const max = 3;
if (limited.length > max) {
limited.splice(max, limited.length - max);
limited.push("...");
}
warnedUsingCtxTemplates.push(`${tpl.name}: ${limited.join(", ")}`);
}
}
}
Expand Down

0 comments on commit 33f2024

Please sign in to comment.