export const componentNameValidationMixin = (superclass) =>
  class ComponentNameValidationMixinClass extends superclass {
    #checkComponentName() {
      const currentComponentName = this.localName;

      if (!superclass.componentName) {
        throw Error(
          `component name is not defined on super class, make sure you have a static get for "componentName"`
        );
      }

      if (currentComponentName !== superclass.componentName) {
        throw Error(
          `component name mismatch, expected "${superclass.componentName}", current "${currentComponentName}"`
        );
      }
    }

    init() {
      super.init?.();
      this.#checkComponentName();
    }
  };
