Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/eslint-plugin-react-refresh/index.js

    rd565449 r0c6b92a  
    2121var src_exports = {};
    2222__export(src_exports, {
     23  default: () => src_default,
    2324  rules: () => rules
    2425});
     
    3536      anonymousExport: "Fast refresh can't handle anonymous components. Add a name to your export.",
    3637      localComponents: "Fast refresh only works when a file only exports components. Move your component(s) to a separate file.",
    37       noExport: "Fast refresh only works when a file has exports. Move your component(s) to a separate file."
     38      noExport: "Fast refresh only works when a file has exports. Move your component(s) to a separate file.",
     39      reactContext: "Fast refresh only works when a file only exports components. Move your React context(s) to a separate file."
    3840    },
    3941    type: "problem",
     
    5759      allowExportNames
    5860    } = context.options[0] ?? {};
    59     const filename = context.getFilename();
     61    const filename = context.filename;
    6062    if (filename.includes(".test.") || filename.includes(".spec.") || filename.includes(".cy.") || filename.includes(".stories.")) {
    6163      return {};
     
    7274        const localComponents = [];
    7375        const nonComponentExports = [];
     76        const reactContextExports = [];
    7477        const handleLocalIdentifier = (identifierNode) => {
    7578          if (identifierNode.type !== "Identifier")
     
    99102            }
    100103          } else {
     104            if (init && init.type === "CallExpression" && // createContext || React.createContext
     105            (init.callee.type === "Identifier" && init.callee.name === "createContext" || init.callee.type === "MemberExpression" && init.callee.property.type === "Identifier" && init.callee.property.name === "createContext")) {
     106              reactContextExports.push(identifierNode);
     107              return;
     108            }
    101109            if (init && // Switch to allowList?
    102110            notReactComponentExpression.has(init.type)) {
     
    129137            }
    130138          } else if (node.type === "CallExpression") {
    131             if (node.callee.type !== "Identifier" || !reactHOCs.has(node.callee.name)) {
     139            if (node.callee.type === "CallExpression" && node.callee.callee.type === "Identifier" && node.callee.callee.name === "connect") {
     140              mayHaveReactExport = true;
     141            } else if (node.callee.type !== "Identifier") {
     142              if (node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && reactHOCs.has(node.callee.property.name)) {
     143                mayHaveReactExport = true;
     144              } else {
     145                context.report({ messageId: "anonymousExport", node });
     146              }
     147            } else if (!reactHOCs.has(node.callee.name)) {
    132148              context.report({ messageId: "anonymousExport", node });
    133149            } else if (((_a = node.arguments[0]) == null ? void 0 : _a.type) === "FunctionExpression" && node.arguments[0].id) {
     
    150166          } else if (node.type === "ExportDefaultDeclaration") {
    151167            hasExports = true;
    152             if (node.declaration.type === "VariableDeclaration" || node.declaration.type === "FunctionDeclaration" || node.declaration.type === "CallExpression") {
    153               handleExportDeclaration(node.declaration);
    154             }
    155             if (node.declaration.type === "Identifier") {
    156               handleExportIdentifier(node.declaration);
    157             }
    158             if (node.declaration.type === "ArrowFunctionExpression") {
     168            const declaration = node.declaration.type === "TSAsExpression" || node.declaration.type === "TSSatisfiesExpression" ? node.declaration.expression : node.declaration;
     169            if (declaration.type === "VariableDeclaration" || declaration.type === "FunctionDeclaration" || declaration.type === "CallExpression") {
     170              handleExportDeclaration(declaration);
     171            }
     172            if (declaration.type === "Identifier") {
     173              handleExportIdentifier(declaration);
     174            }
     175            if (declaration.type === "ArrowFunctionExpression") {
    159176              context.report({ messageId: "anonymousExport", node });
    160177            }
    161178          } else if (node.type === "ExportNamedDeclaration") {
     179            if (node.exportKind === "type")
     180              continue;
    162181            hasExports = true;
    163182            if (node.declaration)
     
    165184            for (const specifier of node.specifiers) {
    166185              handleExportIdentifier(
    167                 specifier.exported.name === "default" ? specifier.local : specifier.exported
     186                specifier.exported.type === "Identifier" && specifier.exported.name === "default" ? specifier.local : specifier.exported
    168187              );
    169188            }
     
    184203            for (const node of nonComponentExports) {
    185204              context.report({ messageId: "namedExport", node });
     205            }
     206            for (const node of reactContextExports) {
     207              context.report({ messageId: "reactContext", node });
    186208            }
    187209          } else if (localComponents.length) {
     
    229251  "only-export-components": onlyExportComponents
    230252};
     253var src_default = { rules };
    231254// Annotate the CommonJS export names for ESM import in node:
    2322550 && (module.exports = {
Note: See TracChangeset for help on using the changeset viewer.