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

@zohodesk/eslint-plugin-react-performance

Package Overview
Dependencies
Maintainers
9
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zohodesk/eslint-plugin-react-performance - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

8

lib/rules/no-ref-mapstatetoprops.js

@@ -66,2 +66,10 @@ /**

}
if (
node.parent.type === 'ArrowFunctionExpression' &&
node.parent.parent &&
node.parent.parent.callee &&
node.parent.parent.callee.name === 'connect'
) {
return;
}

@@ -68,0 +76,0 @@ context.report({

2

package.json
{
"name": "@zohodesk/eslint-plugin-react-performance",
"version": "1.0.0",
"version": "1.0.1",
"description": "To improve performance in react redux applications",

@@ -5,0 +5,0 @@ "keywords": [

@@ -5,3 +5,3 @@ /**

*/
"use strict";
'use strict';

@@ -12,4 +12,4 @@ //------------------------------------------------------------------------------

var rule = require("../../../lib/rules/no-ref-mapstatetoprops"),
RuleTester = require("eslint").RuleTester;
var rule = require('../../../lib/rules/no-ref-mapstatetoprops'),
RuleTester = require('eslint').RuleTester;

@@ -22,17 +22,18 @@ //------------------------------------------------------------------------------

const ERROR_MESSAGE =
"Causes performance issue as it creates a new reference each time when redux calls this connect.";
ruleTester.run("no-ref-mapstatetoprops", rule, {
'Causes performance issue as it creates a new reference each time when redux calls this connect.';
ruleTester.run('no-ref-mapstatetoprops', rule, {
valid: [
"function mapStateToProps(state) {return {id: state.agent.id}}",
"const mapStateToProps = state => {return {arr: state.arr}}",
"connect(function(state) {return {id: state.module.id, name: state.name}})",
"connect(state => {return {arr: state.arr}})"
'function mapStateToProps(state) {return {id: state.agent.id}}',
'const mapStateToProps = state => {return {arr: state.arr}}',
'connect(function(state) {return {id: state.module.id, name: state.name}})',
'connect(state => {return {arr: state.arr}})',
'connect(state => ({}))'
],
invalid: [
{
code: "function mapStateToProps(state) {return {mode: []}}",
code: 'function mapStateToProps(state) {return {mode: []}}',
errors: [
{
message: ERROR_MESSAGE,
type: "ArrayExpression"
type: 'ArrayExpression'
}

@@ -42,7 +43,7 @@ ]

{
code: "connect((state) => { return { mode: state.mode || {} } })",
code: 'connect((state) => { return { mode: state.mode || {} } })',
errors: [
{
message: ERROR_MESSAGE,
type: "ObjectExpression"
type: 'ObjectExpression'
}

@@ -52,7 +53,7 @@ ]

{
code: "function mapStateToProps(state) {return {mode: state.mode || {}}}",
code: 'function mapStateToProps(state) {return {mode: state.mode || {}}}',
errors: [
{
message: ERROR_MESSAGE,
type: "ObjectExpression"
type: 'ObjectExpression'
}

@@ -63,7 +64,7 @@ ]

code:
"function mapStateToProps(state) { let { preference = {} } = state.userObj; return {mode: state.mode}}",
'function mapStateToProps(state) { let { preference = {} } = state.userObj; return {mode: state.mode}}',
errors: [
{
message: ERROR_MESSAGE,
type: "ObjectExpression"
type: 'ObjectExpression'
}

@@ -70,0 +71,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