Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-ssr-friendly

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-ssr-friendly - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

2

package.json
{
"name": "eslint-plugin-ssr-friendly",
"version": "1.2.0",
"version": "1.3.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -10,2 +10,10 @@ const { browser: browserGlobals, node: nodeGlobals } = require("globals");

const isJSXElementOrFragment = (argumentType) => {
return argumentType === "JSXElement" || argumentType === "JSXFragment";
};
const isReturnValueNull = (argument) => {
return argument.type === "Literal" && argument.value === null;
};
const isReturnValueJSXOrNull = (scope) => {

@@ -20,11 +28,23 @@ if (

scope.type === "function" &&
scope.block.body.body.find(
(e) =>
e &&
e.type === "ReturnStatement" &&
e.argument &&
(e.argument.type === "JSXElement" ||
e.argument.type === "JSXFragment" ||
(e.argument.type === "Literal" && e.argument.value === null))
)
scope.block.body.body.find((e) => {
if (!(e && e.type === "ReturnStatement" && e.argument)) {
return false;
}
if (
isJSXElementOrFragment(e.argument.type) ||
isReturnValueNull(e.argument)
) {
return true;
}
if (
e.argument.type === "ConditionalExpression" &&
(isJSXElementOrFragment(e.argument.consequent.type) ||
isReturnValueNull(e.argument.consequent)) &&
(isJSXElementOrFragment(e.argument.alternate.type) ||
isReturnValueNull(e.argument.alternate))
) {
return true;
}
return false;
})
);

@@ -39,2 +59,11 @@ }

function isReactFunction(node, functionName) {
return (
node.name === functionName ||
(node.type === "MemberExpression" &&
node.object.name === "React" &&
node.property.name === functionName)
);
}
const isReactFunctionComponent = (scope) => {

@@ -56,2 +85,8 @@ // eslint-disable-next-line default-case

}
if (
scope.block.parent.type === "CallExpression" &&
isReactFunction(scope.block.parent.callee, "forwardRef")
) {
return true;
}
}

@@ -58,0 +93,0 @@ return false;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc