eslint-plugin-react-redux
Advanced tools
Comparing version
const rules = { | ||
'connect-prefer-minimum-two-arguments': require('./lib/rules/connect-prefer-minimum-two-arguments'), | ||
'connect-prefer-named-arguments': require('./lib/rules/connect-prefer-named-arguments'), | ||
'mapDispatchToProps-returns-object': require('./lib/rules/mapDispatchToProps-returns-object'), | ||
'mapDispatchToProps-prefer-object': require('./lib/rules/mapDispatchToProps-prefer-object'), | ||
'mapDispatchToProps-prefer-parameters-names': require('./lib/rules/mapDispatchToProps-prefer-parameters-names'), | ||
@@ -30,3 +30,3 @@ 'mapStateToProps-no-store': require('./lib/rules/mapStateToProps-no-store'), | ||
'react-redux/mapDispatchToProps-prefer-parameters-names': 2, | ||
'react-redux/mapDispatchToProps-returns-object': 2, | ||
'react-redux/mapDispatchToProps-prefer-object': 2, | ||
'react-redux/mapStateToProps-no-store': 2, | ||
@@ -33,0 +33,0 @@ 'react-redux/mapStateToProps-prefer-parameters-names': 2, |
'use strict'; | ||
const isObject = node => node && ( | ||
node.type === 'ObjectExpression' || node.type === 'Identifier' | ||
); | ||
const getReturnNode = (node) => { | ||
const body = node.body; | ||
if (!body) { | ||
if (!body || !body.length) { | ||
return node; | ||
} else if (isObject(body)) { | ||
return body; | ||
} else if (body.type === 'BlockStatement') { | ||
return getReturnNode(body); | ||
} | ||
for (let i = body.length - 1; i >= 0; i -= 1) { | ||
if (body[i].type === 'ReturnStatement') { | ||
const arg = body[i].argument; | ||
if (arg.type === 'ArrowFunctionExpression' || arg.type === 'FunctionExpression') { | ||
return getReturnNode(arg); | ||
} | ||
return arg; | ||
return body[i].argument; | ||
} | ||
@@ -30,3 +18,2 @@ } | ||
getReturnNode, | ||
isObject, | ||
}; |
{ | ||
"name": "eslint-plugin-react-redux", | ||
"version": "1.4.0", | ||
"version": "2.0.0", | ||
"description": "Enforcing best practices for react-redux", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
35301
-5.21%856
-1.15%