Skip to content

Commit

Permalink
stricter validation on plugin name
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Feb 5, 2025
1 parent 9d2ccda commit 554586f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cli/js/40_lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,21 @@ function installPlugin(plugin) {
if (typeof plugin.name !== "string") {
throw new Error("Linter plugin name must be a string");
}
// TODO(bartlomieju): lowercase and dashes for plugin.name
if (!/^[a-z-]+$/.test(plugin.name)) {
throw new Error(
"Linter plugin name must only contain lowercase letters (a-z) or hyphens (-).",
);
}
if (plugin.name.startsWith("-") || plugin.name.endsWith("-")) {
throw new Error(
"Linter plugin name must start and end with a lowercase letter.",
);
}
if (plugin.name.includes("--")) {
throw new Error(
"Linter plugin name must not have consequtive hyphens.",
);
}
if (typeof plugin.rules !== "object") {
throw new Error("Linter plugin rules must be an object");
}
Expand Down

0 comments on commit 554586f

Please sign in to comment.