Skip to content

Commit 554586f

Browse files
committed
stricter validation on plugin name
1 parent 9d2ccda commit 554586f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

cli/js/40_lint.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,21 @@ function installPlugin(plugin) {
276276
if (typeof plugin.name !== "string") {
277277
throw new Error("Linter plugin name must be a string");
278278
}
279-
// TODO(bartlomieju): lowercase and dashes for plugin.name
279+
if (!/^[a-z-]+$/.test(plugin.name)) {
280+
throw new Error(
281+
"Linter plugin name must only contain lowercase letters (a-z) or hyphens (-).",
282+
);
283+
}
284+
if (plugin.name.startsWith("-") || plugin.name.endsWith("-")) {
285+
throw new Error(
286+
"Linter plugin name must start and end with a lowercase letter.",
287+
);
288+
}
289+
if (plugin.name.includes("--")) {
290+
throw new Error(
291+
"Linter plugin name must not have consequtive hyphens.",
292+
);
293+
}
280294
if (typeof plugin.rules !== "object") {
281295
throw new Error("Linter plugin rules must be an object");
282296
}

0 commit comments

Comments
 (0)