@zohodesk/eslint-plugin-react-performance
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -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({ |
{ | ||
"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 @@ ] |
7890
171