eslint-plugin-reanimated
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -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", |
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
10456
191