From 9a566b35812732d17716a1cdf035fad990637744 Mon Sep 17 00:00:00 2001 From: Matt Wilkinson Date: Mon, 17 Jul 2023 21:17:54 +0100 Subject: [PATCH] fix: Allow specifying arbitrarily named processors in configs --- lib/config/flat-config-schema.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/config/flat-config-schema.js b/lib/config/flat-config-schema.js index 10d6b50ef1ff..a97d0417900a 100644 --- a/lib/config/flat-config-schema.js +++ b/lib/config/flat-config-schema.js @@ -188,18 +188,6 @@ function assertIsRuleSeverity(ruleId, value) { } } -/** - * Validates that a given string is the form pluginName/objectName. - * @param {string} value The string to check. - * @returns {void} - * @throws {TypeError} If the string isn't in the correct format. - */ -function assertIsPluginMemberName(value) { - if (!/[@a-z0-9-_$]+(?:\/(?:[a-z0-9-_$]+))+$/iu.test(value)) { - throw new TypeError(`Expected string in the form "pluginName/objectName" but found "${value}".`); - } -} - /** * Validates that a value is an object. * @param {any} value The value to check. @@ -323,7 +311,9 @@ const processorSchema = { merge: "replace", validate(value) { if (typeof value === "string") { - assertIsPluginMemberName(value); + if (value.includes("/") === -1) { + throw new TypeError(`Expected string in the form "pluginName/processorName" but found "${value}".`); + } } else if (value && typeof value === "object") { if (typeof value.preprocess !== "function" || typeof value.postprocess !== "function") { throw new TypeError("Object must have a preprocess() and a postprocess() method.");