MethodDefinition()

in tools/eslint/rules/valid-constructors.js [123:168]


      MethodDefinition(node) {
        if (node.kind !== "constructor") return NO_LINT_ERRORS;
        if (node.accessibility === "private") return NO_LINT_ERRORS;

        const params = node.value.params;

        if (!Array.isArray(params)) {
          return context.report({
            node,
            message: "Constructors must take at least one parameter",
            loc: params.loc,
          });
        }

        switch (params.length) {
          case 1: {
            const [scope] = params;
            return lintParameter(scope, node, context, scopeParamSpec) ?? NO_LINT_ERRORS;
          }
          case 2: {
            const [scope, props] = params;

            return (
              lintParameter(scope, node, context, scopeParamSpec) ??
              lintParameter(props, node, context, propsAsSecondParamSpec) ??
              NO_LINT_ERRORS
            );
          }
          case 3: {
            const [scope, id, props] = params;

            return (
              lintParameter(scope, node, context, scopeParamSpec) ??
              lintParameter(id, node, context, idParamSpec) ??
              lintParameter(props, node, context, propsAsThirdParamSpec) ??
              NO_LINT_ERRORS
            );
          }
          default:
            return context.report({
              node,
              message: `Constructors can take a maximum of three parameters - there are ${params.length} params here!`,
              loc: params.loc,
            });
        }
      },