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

@eslint-react/ast

Package Overview
Dependencies
Maintainers
1
Versions
815
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eslint-react/ast - npm Package Compare versions

Comparing version 1.20.2-next.2 to 1.20.2-next.3

79

dist/index.js
'use strict';
var tools = require('@eslint-react/tools');
var eff = require('@eslint-react/eff');
var types = require('@typescript-eslint/types');

@@ -8,2 +8,3 @@ var utils = require('@typescript-eslint/utils');

var typescriptEstree = require('@typescript-eslint/typescript-estree');
var types$1 = require('@eslint-react/types');
var stringTs = require('string-ts');

@@ -14,5 +15,5 @@

const { parent } = node;
if (node.type === types.AST_NODE_TYPES.FunctionDeclaration) return tools.O.some([node]);
if (node.type === types.AST_NODE_TYPES.FunctionDeclaration) return eff.O.some([node]);
if (parent.type === types.AST_NODE_TYPES.VariableDeclarator) {
return tools.O.some([
return eff.O.some([
parent.parent,

@@ -24,3 +25,3 @@ parent,

if (parent.type === types.AST_NODE_TYPES.CallExpression && parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator) {
return tools.O.some([
return eff.O.some([
parent.parent.parent,

@@ -33,3 +34,3 @@ parent.parent,

if (parent.type === types.AST_NODE_TYPES.CallExpression && parent.parent.type === types.AST_NODE_TYPES.CallExpression && parent.parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator) {
return tools.O.some([
return eff.O.some([
parent.parent.parent.parent,

@@ -43,3 +44,3 @@ parent.parent.parent,

if (parent.type === types.AST_NODE_TYPES.Property && parent.parent.type === types.AST_NODE_TYPES.ObjectExpression && parent.parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator) {
return tools.O.some([
return eff.O.some([
parent.parent.parent.parent,

@@ -53,3 +54,3 @@ parent.parent.parent,

if (parent.type === types.AST_NODE_TYPES.MethodDefinition && parent.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration) {
return tools.O.some([
return eff.O.some([
parent.parent.parent,

@@ -62,3 +63,3 @@ parent.parent,

if (parent.type === types.AST_NODE_TYPES.PropertyDefinition && parent.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration) {
return tools.O.some([
return eff.O.some([
parent.parent.parent,

@@ -70,10 +71,10 @@ parent.parent,

}
return tools.O.none();
return eff.O.none();
}
function hasCallInFunctionInitPath(callName) {
return (initPath) => {
return tools.F.pipe(
return eff.F.pipe(
initPath,
tools.O.filter((p) => p.length > 0),
tools.O.exists((nodes) => {
eff.O.filter((p) => p.length > 0),
eff.O.exists((nodes) => {
return nodes.some(

@@ -107,7 +108,7 @@ // TODO: Re-evaluate dot notation callName

function getClassIdentifier(node) {
if (node.id) return tools.O.fromNullable(node.id);
if (node.id) return eff.O.fromNullable(node.id);
if (node.parent.type === types.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === types.AST_NODE_TYPES.Identifier) {
return tools.O.fromNullable(node.parent.id);
return eff.O.fromNullable(node.parent.id);
}
return tools.O.none();
return eff.O.none();
}

@@ -140,3 +141,3 @@ var is = utils.ASTUtils.isNodeOfType;

]);
var isControlFlow = tools.or(
var isControlFlow = eff.or(
isLoop,

@@ -148,3 +149,3 @@ isOneOf([

);
var isConditional = tools.or(
var isConditional = eff.or(
isControlFlow,

@@ -249,17 +250,17 @@ isOneOf([

case ("id" in node && !!node.id):
return tools.O.some(node.id);
return eff.O.some(node.id);
// const whatever = function MaybeComponent() {};
case (node.parent.type === types.AST_NODE_TYPES.VariableDeclarator && node.parent.init === node && node.parent.id.type === types.AST_NODE_TYPES.Identifier):
return tools.O.some(node.parent.id);
return eff.O.some(node.parent.id);
// MaybeComponent = () => {};
case (node.parent.type === types.AST_NODE_TYPES.AssignmentExpression && node.parent.right === node && node.parent.operator === "=" && node.parent.left.type === types.AST_NODE_TYPES.Identifier):
return tools.O.some(node.parent.left);
return eff.O.some(node.parent.left);
// {MaybeComponent: () => {}}
// {MaybeComponent() {}}
case (node.parent.type === types.AST_NODE_TYPES.Property && node.parent.value === node && !node.parent.computed && node.parent.key.type === types.AST_NODE_TYPES.Identifier):
return tools.O.some(node.parent.key);
return eff.O.some(node.parent.key);
// class {MaybeComponent = () => {}}
// class {MaybeComponent() {}}
case (isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node.parent) && node.parent.value === node && node.parent.key.type === types.AST_NODE_TYPES.Identifier):
return tools.O.some(node.parent.key);
return eff.O.some(node.parent.key);
// Follow spec convention for `IsAnonymousFunctionDefinition()` usage.

@@ -270,3 +271,3 @@ //

case (node.parent.type === types.AST_NODE_TYPES.AssignmentPattern && node.parent.right === node && node.parent.left.type === types.AST_NODE_TYPES.Identifier):
return tools.O.some(node.parent.left);
return eff.O.some(node.parent.left);
// const MaybeComponent = (() => {}) as FunctionComponent;

@@ -277,3 +278,3 @@ // const MaybeComponent = (() => {}) satisfies FunctionComponent;

}
return tools.O.none();
return eff.O.none();
}

@@ -427,6 +428,6 @@ function getIdentifiersFromBinaryExpression(side) {

var getNestedNewExpressions = getNestedExpressionsOfType(typescriptEstree.AST_NODE_TYPES.NewExpression);
var traverseUpGuard = tools.F.dual(2, (node, predicate) => {
var traverseUpGuard = eff.F.dual(2, (node, predicate) => {
const { parent } = node;
if (!parent || parent.type === types.AST_NODE_TYPES.Program) return tools.O.none();
return predicate(parent) ? tools.O.some(parent) : traverseUpGuard(parent, predicate);
if (!parent || parent.type === types.AST_NODE_TYPES.Program) return eff.O.none();
return predicate(parent) ? eff.O.some(parent) : traverseUpGuard(parent, predicate);
});

@@ -437,7 +438,7 @@

const returnStatements = [];
const functionNode = isFunction(node) ? node : tools.O.getOrNull(traverseUpGuard(node, isFunction));
const functionNode = isFunction(node) ? node : eff.O.getOrNull(traverseUpGuard(node, isFunction));
typescriptEstree.simpleTraverse(node, {
enter(node2) {
if (node2.type !== types.AST_NODE_TYPES.ReturnStatement) return;
const parentFunction = tools.O.getOrNull(traverseUpGuard(node2, isFunction));
const parentFunction = eff.O.getOrNull(traverseUpGuard(node2, isFunction));
if (parentFunction !== functionNode) return;

@@ -452,7 +453,7 @@ returnStatements.push(node2);

case types.AST_NODE_TYPES.Identifier:
return tools.O.some(node);
return eff.O.some(node);
case types.AST_NODE_TYPES.MemberExpression:
return getTopLevelIdentifier(node.object);
default:
return tools.O.none();
return eff.O.none();
}

@@ -494,3 +495,3 @@ }

function isKeyLiteralLike(node, property) {
return tsPattern.match(property).with({ type: types.AST_NODE_TYPES.Literal }, tools.F.constTrue).with({ type: types.AST_NODE_TYPES.TemplateLiteral, expressions: [] }, tools.F.constTrue).with({ type: types.AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(tools.F.constFalse);
return tsPattern.match(property).with({ type: types.AST_NODE_TYPES.Literal }, eff.F.constTrue).with({ type: types.AST_NODE_TYPES.TemplateLiteral, expressions: [] }, eff.F.constTrue).with({ type: types.AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(eff.F.constFalse);
}

@@ -509,3 +510,3 @@ function isMapCallLoose(node) {

}
var isNodeEqual = tools.F.dual(2, (a, b) => {
var isNodeEqual = eff.F.dual(2, (a, b) => {
if (a.type !== b.type) return false;

@@ -519,4 +520,4 @@ if (a.type === types.AST_NODE_TYPES.ThisExpression && b.type === types.AST_NODE_TYPES.ThisExpression) return true;

if (a.quasis.length !== b.quasis.length || a.expressions.length !== b.expressions.length) return false;
if (!tools.zip(a.quasis, b.quasis).every(([a2, b2]) => isNodeEqual(a2, b2))) return false;
if (!tools.zip(a.expressions, b.expressions).every(([a2, b2]) => isNodeEqual(a2, b2))) return false;
if (!types$1.zip(a.quasis, b.quasis).every(([a2, b2]) => isNodeEqual(a2, b2))) return false;
if (!types$1.zip(a.expressions, b.expressions).every(([a2, b2]) => isNodeEqual(a2, b2))) return false;
return true;

@@ -537,3 +538,3 @@ }

function isStringLiteral(node) {
return node.type === types.AST_NODE_TYPES.Literal && tools.isString(node.value);
return node.type === types.AST_NODE_TYPES.Literal && eff.isString(node.value);
}

@@ -576,6 +577,6 @@ function isThisExpression(node) {

}
var traverseUp = tools.F.dual(2, (node, predicate) => {
var traverseUp = eff.F.dual(2, (node, predicate) => {
const { parent } = node;
if (!parent || parent.type === types.AST_NODE_TYPES.Program) return tools.O.none();
return predicate(parent) ? tools.O.some(parent) : traverseUp(parent, predicate);
if (!parent || parent.type === types.AST_NODE_TYPES.Program) return eff.O.none();
return predicate(parent) ? eff.O.some(parent) : traverseUp(parent, predicate);
});

@@ -582,0 +583,0 @@

{
"name": "@eslint-react/ast",
"version": "1.20.2-next.2",
"version": "1.20.2-next.3",
"description": "ESLint React's TSESTree AST utility module.",

@@ -44,4 +44,4 @@ "homepage": "https://github.com/rel1cx/eslint-react",

"ts-pattern": "^5.6.0",
"@eslint-react/tools": "1.20.2-next.2",
"@eslint-react/types": "1.20.2-next.2"
"@eslint-react/eff": "1.20.2-next.3",
"@eslint-react/types": "1.20.2-next.3"
},

@@ -48,0 +48,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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