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

eslint-plugin-neverthrow

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-neverthrow - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

37

dist/src/rules/must-use-result.js
"use strict";
const tsutils_1 = require("tsutils");
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const utils_1 = require("../utils");

@@ -9,5 +8,5 @@ function matchAny(nodeTypes) {

const resultSelector = matchAny([
// AST_NODE_TYPES.Identifier,
experimental_utils_1.AST_NODE_TYPES.CallExpression,
experimental_utils_1.AST_NODE_TYPES.NewExpression,
// 'Identifier',
'CallExpression',
'NewExpression',
]);

@@ -47,3 +46,3 @@ const resultProperties = [

return null;
if (node.property.type !== experimental_utils_1.AST_NODE_TYPES.Identifier)
if (node.property.type !== 'Identifier')
return null;

@@ -54,3 +53,3 @@ return node.property.name;

var _a;
if (((_a = node === null || node === void 0 ? void 0 : node.parent) === null || _a === void 0 ? void 0 : _a.type) !== experimental_utils_1.AST_NODE_TYPES.CallExpression)
if (((_a = node === null || node === void 0 ? void 0 : node.parent) === null || _a === void 0 ? void 0 : _a.type) !== 'CallExpression')
return false;

@@ -62,3 +61,3 @@ return node.parent.callee === node;

const memberExpresion = node.parent;
if ((memberExpresion === null || memberExpresion === void 0 ? void 0 : memberExpresion.type) === experimental_utils_1.AST_NODE_TYPES.MemberExpression) {
if ((memberExpresion === null || memberExpresion === void 0 ? void 0 : memberExpresion.type) === 'MemberExpression') {
const methodName = findMemberName(memberExpresion);

@@ -70,3 +69,3 @@ const methodIsCalled = isMemberCalledFn(memberExpresion);

const parent = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent; // search for chain method .map().handler
if (parent && (parent === null || parent === void 0 ? void 0 : parent.type) !== experimental_utils_1.AST_NODE_TYPES.ExpressionStatement) {
if (parent && (parent === null || parent === void 0 ? void 0 : parent.type) !== 'ExpressionStatement') {
return isHandledResult(parent);

@@ -77,7 +76,7 @@ }

}
const endTransverse = [experimental_utils_1.AST_NODE_TYPES.BlockStatement, experimental_utils_1.AST_NODE_TYPES.Program];
const endTransverse = ['BlockStatement', 'Program'];
function getAssignation(checker, parserServices, node) {
if (node.type === experimental_utils_1.AST_NODE_TYPES.VariableDeclarator &&
if (node.type === 'VariableDeclarator' &&
isResultLike(checker, parserServices, node.init) &&
node.id.type === experimental_utils_1.AST_NODE_TYPES.Identifier) {
node.id.type === 'Identifier') {
return node.id;

@@ -91,9 +90,9 @@ }

function isReturned(checker, parserServices, node) {
if (node.type === experimental_utils_1.AST_NODE_TYPES.ReturnStatement) {
if (node.type === 'ReturnStatement') {
return true;
}
if (node.type === experimental_utils_1.AST_NODE_TYPES.BlockStatement) {
if (node.type === 'BlockStatement') {
return false;
}
if (node.type === experimental_utils_1.AST_NODE_TYPES.Program) {
if (node.type === 'Program') {
return false;

@@ -107,6 +106,6 @@ }

const ignoreParents = [
experimental_utils_1.AST_NODE_TYPES.ClassDeclaration,
experimental_utils_1.AST_NODE_TYPES.FunctionDeclaration,
experimental_utils_1.AST_NODE_TYPES.MethodDefinition,
experimental_utils_1.AST_NODE_TYPES.ClassProperty,
'ClassDeclaration',
'FunctionDeclaration',
'MethodDefinition',
'ClassProperty',
];

@@ -151,4 +150,4 @@ function processSelector(context, checker, parserServices, node, reportAs = node) {

description: 'Not handling neverthrow result is a possible error because errors could remain unhandleds.',
recommended: 'error',
category: 'Possible Errors',
recommended: 'error',
url: '',

@@ -155,0 +154,0 @@ },

{
"name": "eslint-plugin-neverthrow",
"version": "1.1.1",
"version": "1.1.2",
"description": "",

@@ -38,3 +38,2 @@ "engines": {

"@types/eslint-utils": "^3.0.0",
"@typescript-eslint/experimental-utils": "^4.20.0",
"eslint-utils": "3.0.0",

@@ -44,2 +43,3 @@ "tsutils": "3.21.0"

"devDependencies": {
"@typescript-eslint/experimental-utils": "^4.0.0",
"@types/eslint": "^7.2.8",

@@ -46,0 +46,0 @@ "@typescript-eslint/eslint-plugin": "^4.20.0",

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