node_modules/eslint/lib/rules/complexity.js in immosquare-cleaner-0.1.51 vs node_modules/eslint/lib/rules/complexity.js in immosquare-cleaner-0.1.52
- old
+ new
@@ -15,15 +15,19 @@
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
+const THRESHOLD_DEFAULT = 20;
+
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "suggestion",
+ defaultOptions: [THRESHOLD_DEFAULT],
+
docs: {
description: "Enforce a maximum cyclomatic complexity allowed in a program",
recommended: false,
url: "https://eslint.org/docs/latest/rules/complexity"
},
@@ -61,23 +65,23 @@
}
},
create(context) {
const option = context.options[0];
- let THRESHOLD = 20;
+ let threshold = THRESHOLD_DEFAULT;
let VARIANT = "classic";
if (typeof option === "object") {
if (Object.hasOwn(option, "maximum") || Object.hasOwn(option, "max")) {
- THRESHOLD = option.maximum || option.max;
+ threshold = option.maximum || option.max;
}
if (Object.hasOwn(option, "variant")) {
VARIANT = option.variant;
}
} else if (typeof option === "number") {
- THRESHOLD = option;
+ threshold = option;
}
const IS_MODIFIED_COMPLEXITY = VARIANT === "modified";
//--------------------------------------------------------------------------
@@ -158,11 +162,11 @@
codePath.origin !== "class-static-block"
) {
return;
}
- if (complexity > THRESHOLD) {
+ if (complexity > threshold) {
let name;
if (codePath.origin === "class-field-initializer") {
name = "class field initializer";
} else if (codePath.origin === "class-static-block") {
@@ -175,10 +179,10 @@
node,
messageId: "complex",
data: {
name: upperCaseFirst(name),
complexity,
- max: THRESHOLD
+ max: threshold
}
});
}
}
};