]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/lib/shared/config-validator.js
import 8.3.0 source
[pve-eslint.git] / eslint / lib / shared / config-validator.js
index 03b32f1c9183ed495a1e5428106a990f9e951b58..47353ac4814b72cc77cdbf5c3dc94b05dda034d0 100644 (file)
 const
     util = require("util"),
     configSchema = require("../../conf/config-schema"),
-    BuiltInEnvironments = require("@eslint/eslintrc/conf/environments"),
     BuiltInRules = require("../rules"),
-    ConfigOps = require("@eslint/eslintrc/lib/shared/config-ops"),
+    {
+        Legacy: {
+            ConfigOps,
+            environments: BuiltInEnvironments
+        }
+    } = require("@eslint/eslintrc"),
     { emitDeprecationWarning } = require("./deprecation-warnings");
 
 const ajv = require("./ajv")();
@@ -80,6 +84,7 @@ function getRuleOptionsSchema(rule) {
 /**
  * Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
  * @param {options} options The given options for the rule.
+ * @throws {Error} Wrong severity value.
  * @returns {number|string} The rule's severity value
  */
 function validateRuleSeverity(options) {
@@ -98,6 +103,7 @@ function validateRuleSeverity(options) {
  * Validates the non-severity options passed to a rule, based on its schema.
  * @param {{create: Function}} rule The rule to validate
  * @param {Array} localOptions The options for the rule, excluding severity
+ * @throws {Error} Any rule validation errors.
  * @returns {void}
  */
 function validateRuleSchema(rule, localOptions) {
@@ -128,6 +134,7 @@ function validateRuleSchema(rule, localOptions) {
  * @param {Array|number} options The given options for the rule.
  * @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
  * no source is prepended to the message.
+ * @throws {Error} Upon any bad rule configuration.
  * @returns {void}
  */
 function validateRuleOptions(rule, ruleId, options, source = null) {
@@ -152,7 +159,7 @@ function validateRuleOptions(rule, ruleId, options, source = null) {
  * Validates an environment object
  * @param {Object} environment The environment config object to validate.
  * @param {string} source The name of the configuration source to report in any errors.
- * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments.
+ * @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded environments.
  * @returns {void}
  */
 function validateEnvironment(
@@ -181,7 +188,7 @@ function validateEnvironment(
  * Validates a rules config object
  * @param {Object} rulesConfig The rules config object to validate.
  * @param {string} source The name of the configuration source to report in any errors.
- * @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules
+ * @param {(ruleId:string) => Object} getAdditionalRule A map from strings to loaded rules
  * @returns {void}
  */
 function validateRules(
@@ -225,7 +232,8 @@ function validateGlobals(globalsConfig, source = null) {
  * Validate `processor` configuration.
  * @param {string|undefined} processorName The processor name.
  * @param {string} source The name of config file.
- * @param {function(id:string): Processor} getProcessor The getter of defined processors.
+ * @param {(id:string) => Processor} getProcessor The getter of defined processors.
+ * @throws {Error} For invalid processor configuration.
  * @returns {void}
  */
 function validateProcessor(processorName, source, getProcessor) {
@@ -264,6 +272,7 @@ function formatErrors(errors) {
  * Validates the top level properties of the config object.
  * @param {Object} config The config object to validate.
  * @param {string} source The name of the configuration source to report in any errors.
+ * @throws {Error} For any config invalid per the schema.
  * @returns {void}
  */
 function validateConfigSchema(config, source = null) {
@@ -282,8 +291,8 @@ function validateConfigSchema(config, source = null) {
  * Validates an entire config object.
  * @param {Object} config The config object to validate.
  * @param {string} source The name of the configuration source to report in any errors.
- * @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules.
- * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs.
+ * @param {(ruleId:string) => Object} [getAdditionalRule] A map from strings to loaded rules.
+ * @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded envs.
  * @returns {void}
  */
 function validate(config, source, getAdditionalRule, getAdditionalEnv) {