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

eslint-plugin-reanimated

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-reanimated - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

54

dist/rules/js-function-in-worklet.js

@@ -22,19 +22,2 @@ "use strict";

]);
const builtInFunctions = [
"Array",
"ArrayConstructor",
"Date",
"DateConstructor",
"Function",
"Math",
"NumberConstructor",
"ObjectConstructor",
"ReadonlyArray",
"RegExp",
"RegExpConstructor",
"String",
"StringConstructor",
"Number",
"CallableFunction",
];
const functionNames = Array.from(functionHooks.keys());

@@ -56,2 +39,14 @@ const matchFunctions = `/${functionNames.join("|")}/`;

};
const WORKLET = "worklet";
const URI_PREFIX = "/node_modules/";
const getModuleURI = (n) => {
if (n === undefined) {
return "";
}
else if (typescript_1.isSourceFile(n)) {
const start = n.fileName.indexOf(URI_PREFIX) + URI_PREFIX.length;
return n.fileName.substring(start);
}
return getModuleURI(n.parent);
};
exports.default = createRule({

@@ -79,13 +74,14 @@ name: "js-function-in-worklet",

const calleeIsWorklet = (tsNode) => {
var _a;
const signature = checker.getResolvedSignature(tsNode);
const decl = signature === null || signature === void 0 ? void 0 : signature.declaration;
if (decl !== undefined && typescript_1.isFunctionTypeNode(decl)) {
const { parent } = decl;
if (typescript_1.isFunctionDeclaration(parent) &&
((_a = parent.name) === null || _a === void 0 ? void 0 : _a.getText()) === "createWorklet") {
const uri = getModuleURI(decl);
if (decl !== undefined &&
(typescript_1.isFunctionTypeNode(decl) || typescript_1.isMethodSignature(decl))) {
if (uri === "react-native-reanimated/react-native-reanimated.d.ts" ||
uri.startsWith("typescript/")) {
return true;
}
const tags = typescript_1.getJSDocTags(decl.parent);
return (tags.filter((tag) => tag.tagName.getText() === "worklet").length > 0);
const { parent } = decl;
const tags = typescript_1.getJSDocTags(parent);
return (tags.filter((tag) => tag.tagName.getText() === WORKLET).length > 0);
}

@@ -99,3 +95,3 @@ else if (decl !== undefined &&

.getText()
.substring(1, "worklet".length + 1) === "worklet");
.substring(1, WORKLET.length + 1) === WORKLET);
}

@@ -118,3 +114,3 @@ }

// eslint-disable-next-line @typescript-eslint/no-explicit-any
((_a = node.body.body[0]) === null || _a === void 0 ? void 0 : _a.directive) === "worklet") {
((_a = node.body.body[0]) === null || _a === void 0 ? void 0 : _a.directive) === WORKLET) {
currentCodePath = codePath.id;

@@ -154,8 +150,2 @@ callerIsWorklet = true;

if (declaration &&
typescript_1.isMethodSignature(declaration) &&
typescript_1.isInterfaceDeclaration(declaration.parent) &&
builtInFunctions.indexOf(declaration.parent.name.getText()) !== -1) {
return;
}
else if (declaration &&
typescript_1.isFunctionTypeNode(declaration) &&

@@ -162,0 +152,0 @@ typescript_1.isFunctionDeclaration(declaration.parent) &&

{
"name": "eslint-plugin-reanimated",
"version": "1.0.11",
"version": "1.0.12",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

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