Skip to content

Commit

Permalink
fix: Allow specifying arbitrarily named processors in configs
Browse files Browse the repository at this point in the history
  • Loading branch information
matwilko committed Jul 17, 2023
1 parent 0ea97f4 commit 9a566b3
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions lib/config/flat-config-schema.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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.");
Expand Down

0 comments on commit 9a566b3

Please sign in to comment.