'': function()

in packages/eslint-plugin-elastic-charts/rules/no_different_release_tag.js [44:107]


      'ExportNamedDeclaration[specifiers=""]:not(ExportAllDeclaration)': function (node) {
        if (!initialized) {
          initialized = true;
          const { variables } = context.getScope();
          variables
            .filter(({ defs }) => defs.some(isVariable) && defs.some(isType))
            .forEach(({ name, defs = [] }) => {
              const type = getExportParent(defs.find(isType)?.node);
              const variable = getExportParent(defs.find(isVariable)?.node);

              if (type && variable) {
                variableTypePairs.set(name, { type, variable });
              }
            });
        }

        const name = utils.getExportName(node);
        if (!seen.has(name) && variableTypePairs.has(name)) {
          seen.add(name);
          const { type, variable } = variableTypePairs.get(name) ?? {};

          const typeComment = utils.getTSDocComment(context, type);
          const variableComment = utils.getTSDocComment(context, variable);

          if (typeComment && variableComment) {
            const typeTag = utils.getReleaseTag(typeComment.value);
            const variableTag = utils.getReleaseTag(variableComment.value);

            if (typeTag && variableTag && typeTag !== variableTag) {
              const tag = [ALPHA_TAG, BETA_TAG, PUBLIC_TAG, INTERNAL_TAG].find(
                (t) => variableTag === t || typeTag === t,
              );

              if (typeTag !== tag) {
                context.report({
                  loc: typeComment.loc,
                  message: 'Release tag should match {{ name }} type',
                  data: {
                    name,
                  },
                  fix(fixer) {
                    const value = replaceTag(typeComment, typeTag, tag);
                    return fixer.replaceTextRange(typeComment.range, value);
                  },
                });
              }

              if (variableTag !== tag) {
                context.report({
                  loc: variableComment.loc,
                  message: 'Release tag should match {{ name }} type',
                  data: {
                    name,
                  },
                  fix(fixer) {
                    const value = replaceTag(variableComment, variableTag, tag);
                    return fixer.replaceTextRange(variableComment.range, value);
                  },
                });
              }
            }
          }
        }
      },