New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-sonarjs

Package Overview
Dependencies
Maintainers
5
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-sonarjs - npm Package Compare versions

Comparing version 0.24.0 to 0.25.0

2

lib/index.d.ts

@@ -1,2 +0,2 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const sonarjsRuleModules: {

@@ -3,0 +3,0 @@ [key: string]: any;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, (number | 'metric' | 'sonar-runtime')[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,4 +0,4 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare type Options = [number];
declare const rule: TSESLint.RuleModule<string, Options>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,2 +0,2 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare type Options = [{

@@ -3,0 +3,0 @@ threshold?: number;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,4 +0,4 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare type Options = (number | 'sonar-runtime')[];
declare const rule: TSESLint.RuleModule<string, Options>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -37,3 +37,3 @@ "use strict";

},
// @ts-ignore The typings of @typescript-eslint/experimental-utils does not contain the 'onX' methods.
// @ts-ignore The typings of @typescript-eslint/utils does not contain the 'onX' methods.
create(context) {

@@ -40,0 +40,0 @@ const loopingNodes = new Set();

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -156,4 +156,3 @@ "use strict";

function isMemberExpressionReference(lhs, ref) {
return (lhs.type === 'MemberExpression' &&
(isReferenceTo(ref, lhs.object) || isMemberExpressionReference(lhs.object, ref)));
return lhs.type === 'MemberExpression' && isReferenceTo(ref, lhs.object);
}

@@ -160,0 +159,0 @@ function isIdentifier(node, ...values) {

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -22,4 +22,10 @@ "use strict";

// https://sonarsource.github.io/rspec/#/rspec/S3699
const utils_1 = require("@typescript-eslint/utils");
const nodes_1 = require("../utils/nodes");
const docs_url_1 = require("../utils/docs-url");
const EMPTY_RETURN_VALUE_KEYWORDS = new Set([
utils_1.TSESTree.AST_NODE_TYPES.TSVoidKeyword,
utils_1.TSESTree.AST_NODE_TYPES.TSNeverKeyword,
utils_1.TSESTree.AST_NODE_TYPES.TSUndefinedKeyword,
]);
function isReturnValueUsed(callExpr) {

@@ -30,17 +36,17 @@ const { parent } = callExpr;

}
if (parent.type === 'LogicalExpression') {
if (parent.type === utils_1.TSESTree.AST_NODE_TYPES.LogicalExpression) {
return parent.left === callExpr;
}
if (parent.type === 'SequenceExpression') {
if (parent.type === utils_1.TSESTree.AST_NODE_TYPES.SequenceExpression) {
return parent.expressions[parent.expressions.length - 1] === callExpr;
}
if (parent.type === 'ConditionalExpression') {
if (parent.type === utils_1.TSESTree.AST_NODE_TYPES.ConditionalExpression) {
return parent.test === callExpr;
}
return (parent.type !== 'ExpressionStatement' &&
parent.type !== 'ArrowFunctionExpression' &&
parent.type !== 'UnaryExpression' &&
parent.type !== 'AwaitExpression' &&
parent.type !== 'ReturnStatement' &&
parent.type !== 'ThrowStatement');
return (parent.type !== utils_1.TSESTree.AST_NODE_TYPES.ExpressionStatement &&
parent.type !== utils_1.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression &&
parent.type !== utils_1.TSESTree.AST_NODE_TYPES.UnaryExpression &&
parent.type !== utils_1.TSESTree.AST_NODE_TYPES.AwaitExpression &&
parent.type !== utils_1.TSESTree.AST_NODE_TYPES.ReturnStatement &&
parent.type !== utils_1.TSESTree.AST_NODE_TYPES.ThrowStatement);
}

@@ -91,5 +97,5 @@ const rule = {

const ancestors = [...context.getAncestors()].reverse();
const functionNode = ancestors.find(node => node.type === 'FunctionExpression' ||
node.type === 'FunctionDeclaration' ||
node.type === 'ArrowFunctionExpression');
const functionNode = ancestors.find(node => node.type === utils_1.TSESTree.AST_NODE_TYPES.FunctionExpression ||
node.type === utils_1.TSESTree.AST_NODE_TYPES.FunctionDeclaration ||
node.type === utils_1.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression);
functionsWithReturnValue.add(functionNode);

@@ -112,2 +118,9 @@ }

},
TSDeclareFunction(node) {
const declareFunction = node;
if (declareFunction.returnType?.typeAnnotation.type &&
!EMPTY_RETURN_VALUE_KEYWORDS.has(declareFunction.returnType?.typeAnnotation.type)) {
functionsWithReturnValue.add(declareFunction);
}
},
'Program:exit'() {

@@ -114,0 +127,0 @@ callExpressionsToCheck.forEach((functionDeclaration, callee) => {

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,3 +0,3 @@

import type { TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESLint } from '@typescript-eslint/utils';
declare const rule: TSESLint.RuleModule<string, string[]>;
export = rule;

@@ -1,2 +0,2 @@

import type { TSESTree } from '@typescript-eslint/experimental-utils';
import type { TSESTree } from '@typescript-eslint/utils';
/** Returns a list of statements corresponding to a `if - else if - else` chain */

@@ -3,0 +3,0 @@ export declare function collectIfBranches(node: TSESTree.IfStatement): {

@@ -1,2 +0,2 @@

import type { TSESTree, TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESTree, TSESLint } from '@typescript-eslint/utils';
/**

@@ -3,0 +3,0 @@ * Equivalence is implemented by comparing node types and their tokens.

@@ -1,2 +0,2 @@

import type { TSESTree } from '@typescript-eslint/experimental-utils';
import type { TSESTree } from '@typescript-eslint/utils';
export declare function getJsxShortCircuitNodes(logicalExpression: TSESTree.LogicalExpression): TSESTree.LogicalExpression[] | null;

@@ -1,2 +0,2 @@

import type { TSESTree, TSESLint } from '@typescript-eslint/experimental-utils';
import type { TSESTree, TSESLint } from '@typescript-eslint/utils';
declare type Writeable<T> = {

@@ -3,0 +3,0 @@ -readonly [P in keyof T]: T[P];

@@ -1,2 +0,2 @@

import type { TSESTree } from '@typescript-eslint/experimental-utils';
import type { TSESTree } from '@typescript-eslint/utils';
export declare function isArrowFunctionExpression(node: TSESTree.Node | undefined): node is TSESTree.ArrowFunctionExpression;

@@ -3,0 +3,0 @@ export declare function isAssignmentExpression(node: TSESTree.Node | undefined): node is TSESTree.AssignmentExpression;

@@ -1,2 +0,2 @@

import type { ParserServices } from '@typescript-eslint/experimental-utils';
import type { ParserServices } from '@typescript-eslint/utils';
export declare type RequiredParserServices = {

@@ -3,0 +3,0 @@ [k in keyof ParserServices]: Exclude<ParserServices[k], undefined>;

@@ -1,3 +0,3 @@

import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
export declare function isIdentifier(node: TSESTree.Node, ...values: string[]): node is TSESTree.Identifier;
export declare function isReferenceTo(ref: TSESLint.Scope.Reference, node: TSESTree.Node): boolean;

@@ -1,3 +0,3 @@

import type { TSESTree } from '@typescript-eslint/experimental-utils';
import type { TSESTree } from '@typescript-eslint/utils';
export declare function findFirstMatchingAncestor(node: TSESTree.Node, predicate: (node: TSESTree.Node) => boolean): TSESTree.Node | undefined;
export declare function ancestorsChain(node: TSESTree.Node, boundaryTypes: Set<string>): TSESTree.Node[];

@@ -1,3 +0,3 @@

import type { TSESTree } from '@typescript-eslint/experimental-utils';
import type { TSESTree } from '@typescript-eslint/utils';
import { RequiredParserServices } from './parser-services';
export declare function getTypeFromTreeNode(node: TSESTree.Node, services: RequiredParserServices): import("typescript").Type;
{
"name": "eslint-plugin-sonarjs",
"version": "0.24.0",
"version": "0.25.0",
"description": "SonarJS rules for ESLint",

@@ -47,4 +47,4 @@ "main": "lib/index.js",

"@types/node": "14.14.31",
"@typescript-eslint/experimental-utils": "5.30.7",
"@typescript-eslint/parser": "5.30.7",
"@typescript-eslint/utils": "5.30.7",
"eslint": "8.47.0",

@@ -51,0 +51,0 @@ "eslint-config-prettier": "8.5.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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