eslint-plugin-react-refresh
Advanced tools
Comparing version 0.4.8 to 0.4.9
21
index.js
@@ -66,2 +66,3 @@ "use strict"; | ||
return {}; | ||
const allowExportNamesSet = allowExportNames ? new Set(allowExportNames) : void 0; | ||
return { | ||
@@ -86,3 +87,3 @@ Program(program) { | ||
} | ||
if (allowExportNames == null ? void 0 : allowExportNames.includes(identifierNode.name)) | ||
if (allowExportNamesSet == null ? void 0 : allowExportNamesSet.has(identifierNode.name)) | ||
return; | ||
@@ -103,3 +104,3 @@ if (allowConstantExport && init && (init.type === "Literal" || // 1, "foo" | ||
if (init && // Switch to allowList? | ||
notReactComponentExpression.includes(init.type)) { | ||
notReactComponentExpression.has(init.type)) { | ||
nonComponentExports.push(identifierNode); | ||
@@ -117,3 +118,3 @@ return; | ||
const handleExportDeclaration = (node) => { | ||
var _a; | ||
var _a, _b; | ||
if (node.type === "VariableDeclaration") { | ||
@@ -134,4 +135,8 @@ for (const variable of node.declarations) { | ||
} else if (node.type === "CallExpression") { | ||
if (node.callee.type === "Identifier" && reactHOCs.includes(node.callee.name) && ((_a = node.arguments[0]) == null ? void 0 : _a.type) === "FunctionExpression" && node.arguments[0].id) { | ||
if (node.callee.type !== "Identifier" || !reactHOCs.has(node.callee.name)) { | ||
context.report({ messageId: "anonymousExport", node }); | ||
} else if (((_a = node.arguments[0]) == null ? void 0 : _a.type) === "FunctionExpression" && node.arguments[0].id) { | ||
handleExportIdentifier(node.arguments[0].id, true); | ||
} else if (((_b = node.arguments[0]) == null ? void 0 : _b.type) === "Identifier") { | ||
mayHaveReactExport = true; | ||
} else { | ||
@@ -201,3 +206,3 @@ context.report({ messageId: "anonymousExport", node }); | ||
}; | ||
var reactHOCs = ["memo", "forwardRef"]; | ||
var reactHOCs = /* @__PURE__ */ new Set(["memo", "forwardRef"]); | ||
var canBeReactFunctionComponent = (init) => { | ||
@@ -209,7 +214,7 @@ if (!init) | ||
if (init.type === "CallExpression" && init.callee.type === "Identifier") { | ||
return reactHOCs.includes(init.callee.name); | ||
return reactHOCs.has(init.callee.name); | ||
} | ||
return false; | ||
}; | ||
var notReactComponentExpression = [ | ||
var notReactComponentExpression = /* @__PURE__ */ new Set([ | ||
"ArrayExpression", | ||
@@ -227,3 +232,3 @@ "AwaitExpression", | ||
"UpdateExpression" | ||
]; | ||
]); | ||
@@ -230,0 +235,0 @@ // src/index.ts |
{ | ||
"name": "eslint-plugin-react-refresh", | ||
"description": "Validate that your components can safely be updated with fast refresh", | ||
"version": "0.4.8", | ||
"version": "0.4.9", | ||
"author": "Arnaud Barré (https://github.com/ArnaudBarre)", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14130
231