Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/eslint-plugin-react-refresh/index.js
rd565449 r0c6b92a 21 21 var src_exports = {}; 22 22 __export(src_exports, { 23 default: () => src_default, 23 24 rules: () => rules 24 25 }); … … 35 36 anonymousExport: "Fast refresh can't handle anonymous components. Add a name to your export.", 36 37 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." 38 40 }, 39 41 type: "problem", … … 57 59 allowExportNames 58 60 } = context.options[0] ?? {}; 59 const filename = context. getFilename();61 const filename = context.filename; 60 62 if (filename.includes(".test.") || filename.includes(".spec.") || filename.includes(".cy.") || filename.includes(".stories.")) { 61 63 return {}; … … 72 74 const localComponents = []; 73 75 const nonComponentExports = []; 76 const reactContextExports = []; 74 77 const handleLocalIdentifier = (identifierNode) => { 75 78 if (identifierNode.type !== "Identifier") … … 99 102 } 100 103 } 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 } 101 109 if (init && // Switch to allowList? 102 110 notReactComponentExpression.has(init.type)) { … … 129 137 } 130 138 } 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)) { 132 148 context.report({ messageId: "anonymousExport", node }); 133 149 } else if (((_a = node.arguments[0]) == null ? void 0 : _a.type) === "FunctionExpression" && node.arguments[0].id) { … … 150 166 } else if (node.type === "ExportDefaultDeclaration") { 151 167 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") { 159 176 context.report({ messageId: "anonymousExport", node }); 160 177 } 161 178 } else if (node.type === "ExportNamedDeclaration") { 179 if (node.exportKind === "type") 180 continue; 162 181 hasExports = true; 163 182 if (node.declaration) … … 165 184 for (const specifier of node.specifiers) { 166 185 handleExportIdentifier( 167 specifier.exported. name === "default" ? specifier.local : specifier.exported186 specifier.exported.type === "Identifier" && specifier.exported.name === "default" ? specifier.local : specifier.exported 168 187 ); 169 188 } … … 184 203 for (const node of nonComponentExports) { 185 204 context.report({ messageId: "namedExport", node }); 205 } 206 for (const node of reactContextExports) { 207 context.report({ messageId: "reactContext", node }); 186 208 } 187 209 } else if (localComponents.length) { … … 229 251 "only-export-components": onlyExportComponents 230 252 }; 253 var src_default = { rules }; 231 254 // Annotate the CommonJS export names for ESM import in node: 232 255 0 && (module.exports = {
Note:
See TracChangeset
for help on using the changeset viewer.