]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/lib/config/rule-validator.js
import 8.23.1 source
[pve-eslint.git] / eslint / lib / config / rule-validator.js
index 9172f93568812cccc56af9a679bda4b5710f13a1..0b5858fb30f38bdcff0191485d34656d8f277dfe 100644 (file)
 //-----------------------------------------------------------------------------
 
 const ajv = require("../shared/ajv")();
-const { parseRuleId, getRuleFromConfig } = require("./flat-config-helpers");
+const {
+    parseRuleId,
+    getRuleFromConfig,
+    getRuleOptionsSchema
+} = require("./flat-config-helpers");
 const ruleReplacements = require("../../conf/replacements.json");
 
 //-----------------------------------------------------------------------------
@@ -61,40 +65,6 @@ function throwRuleNotFoundError({ pluginName, ruleName }, config) {
     throw new TypeError(errorMessage);
 }
 
-/**
- * Gets a complete options schema for a rule.
- * @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
- * @returns {Object} JSON Schema for the rule's options.
- */
-function getRuleOptionsSchema(rule) {
-
-    if (!rule) {
-        return null;
-    }
-
-    const schema = rule.schema || rule.meta && rule.meta.schema;
-
-    if (Array.isArray(schema)) {
-        if (schema.length) {
-            return {
-                type: "array",
-                items: schema,
-                minItems: 0,
-                maxItems: schema.length
-            };
-        }
-        return {
-            type: "array",
-            minItems: 0,
-            maxItems: 0
-        };
-
-    }
-
-    // Given a full schema, leave it alone
-    return schema || null;
-}
-
 //-----------------------------------------------------------------------------
 // Exports
 //-----------------------------------------------------------------------------