Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/eslint-plugin-react-refresh/index.js
r0c6b92a r79a0317 21 21 var src_exports = {}; 22 22 __export(src_exports, { 23 configs: () => configs, 23 24 default: () => src_default, 24 25 rules: () => rules … … 27 28 28 29 // src/only-export-components.ts 29 var possibleReactExportRE = /^[A-Z][a-zA-Z0-9]*$/u; 30 var strictReactExportRE = /^[A-Z][a-zA-Z0-9]*[a-z]+[a-zA-Z0-9]*$/u; 30 var reactComponentNameRE = /^[A-Z][a-zA-Z0-9]*$/u; 31 31 var onlyExportComponents = { 32 32 meta: { … … 44 44 type: "object", 45 45 properties: { 46 allowExportNames: { type: "array", items: { type: "string" } }, 46 47 allowConstantExport: { type: "boolean" }, 47 c heckJS: { type: "boolean"},48 allowExportNames: { type: "array", items: { type: "string" }}48 customHOCs: { type: "array", items: { type: "string" } }, 49 checkJS: { type: "boolean" } 49 50 }, 50 51 additionalProperties: false … … 55 56 create: (context) => { 56 57 const { 58 allowExportNames, 57 59 allowConstantExport = false, 58 c heckJS = false,59 allowExportNames60 customHOCs = [], 61 checkJS = false 60 62 } = context.options[0] ?? {}; 61 63 const filename = context.filename; … … 67 69 return {}; 68 70 const allowExportNamesSet = allowExportNames ? new Set(allowExportNames) : void 0; 71 const reactHOCs = ["memo", "forwardRef", ...customHOCs]; 72 const canBeReactFunctionComponent = (init) => { 73 if (!init) 74 return false; 75 if (init.type === "ArrowFunctionExpression") 76 return true; 77 if (init.type === "CallExpression" && init.callee.type === "Identifier") { 78 return reactHOCs.includes(init.callee.name); 79 } 80 return false; 81 }; 69 82 return { 70 83 Program(program) { 71 84 let hasExports = false; 72 let mayHaveReactExport = false;85 let hasReactExport = false; 73 86 let reactIsInScope = false; 74 87 const localComponents = []; … … 78 91 if (identifierNode.type !== "Identifier") 79 92 return; 80 if ( possibleReactExportRE.test(identifierNode.name)) {93 if (reactComponentNameRE.test(identifierNode.name)) { 81 94 localComponents.push(identifierNode); 82 95 } … … 96 109 } 97 110 if (isFunction) { 98 if ( possibleReactExportRE.test(identifierNode.name)) {99 mayHaveReactExport = true;111 if (reactComponentNameRE.test(identifierNode.name)) { 112 hasReactExport = true; 100 113 } else { 101 114 nonComponentExports.push(identifierNode); … … 112 125 return; 113 126 } 114 if (!mayHaveReactExport && possibleReactExportRE.test(identifierNode.name)) { 115 mayHaveReactExport = true; 116 } 117 if (!strictReactExportRE.test(identifierNode.name)) { 127 if (reactComponentNameRE.test(identifierNode.name)) { 128 hasReactExport = true; 129 } else { 118 130 nonComponentExports.push(identifierNode); 119 131 } … … 138 150 } else if (node.type === "CallExpression") { 139 151 if (node.callee.type === "CallExpression" && node.callee.callee.type === "Identifier" && node.callee.callee.name === "connect") { 140 mayHaveReactExport = true;152 hasReactExport = true; 141 153 } 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;154 if (node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && reactHOCs.includes(node.callee.property.name)) { 155 hasReactExport = true; 144 156 } else { 145 157 context.report({ messageId: "anonymousExport", node }); 146 158 } 147 } else if (!reactHOCs. has(node.callee.name)) {159 } else if (!reactHOCs.includes(node.callee.name)) { 148 160 context.report({ messageId: "anonymousExport", node }); 149 161 } else if (((_a = node.arguments[0]) == null ? void 0 : _a.type) === "FunctionExpression" && node.arguments[0].id) { 150 162 handleExportIdentifier(node.arguments[0].id, true); 151 163 } else if (((_b = node.arguments[0]) == null ? void 0 : _b.type) === "Identifier") { 152 mayHaveReactExport = true;164 hasReactExport = true; 153 165 } else { 154 166 context.report({ messageId: "anonymousExport", node }); … … 200 212 return; 201 213 if (hasExports) { 202 if ( mayHaveReactExport) {214 if (hasReactExport) { 203 215 for (const node of nonComponentExports) { 204 216 context.report({ messageId: "namedExport", node }); … … 220 232 }; 221 233 } 222 };223 var reactHOCs = /* @__PURE__ */ new Set(["memo", "forwardRef"]);224 var canBeReactFunctionComponent = (init) => {225 if (!init)226 return false;227 if (init.type === "ArrowFunctionExpression")228 return true;229 if (init.type === "CallExpression" && init.callee.type === "Identifier") {230 return reactHOCs.has(init.callee.name);231 }232 return false;233 234 }; 234 235 var notReactComponentExpression = /* @__PURE__ */ new Set([ … … 251 252 "only-export-components": onlyExportComponents 252 253 }; 253 var src_default = { rules }; 254 var plugin = { rules }; 255 var configs = { 256 recommended: { 257 plugins: { "react-refresh": plugin }, 258 rules: { "react-refresh/only-export-components": "error" } 259 }, 260 vite: { 261 plugins: { "react-refresh": plugin }, 262 rules: { 263 "react-refresh/only-export-components": [ 264 "error", 265 { allowConstantExport: true } 266 ] 267 } 268 } 269 }; 270 var src_default = { rules, configs }; 254 271 // Annotate the CommonJS export names for ESM import in node: 255 272 0 && (module.exports = { 273 configs, 256 274 rules 257 275 });
Note:
See TracChangeset
for help on using the changeset viewer.