eslint-plugin-react-redux
Advanced tools
Comparing version
@@ -7,3 +7,3 @@ # Enforces that connect function is provided with at least 2 arguments. (react-redux/connect-prefer-minimum-two-arguments) | ||
This rule enforces that Second argument is provided explicitly. | ||
This rule enforces that the second argument is provided explicitly. | ||
@@ -10,0 +10,0 @@ ## Rule details |
@@ -1,2 +0,2 @@ | ||
# Enforces that all connect arguments have specific names. (react-redux/connect-prefer-named-arguments) | ||
# Enforces that all connect arguments have recommended names. (react-redux/connect-prefer-named-arguments) | ||
@@ -3,0 +3,0 @@ [react-redux connect](https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options) function has 4 optional arguments: |
@@ -47,3 +47,5 @@ const utils = require('../utils'); | ||
const mapStateToProps = node.arguments && node.arguments[0]; | ||
checkFunction(context, mapStateToProps.body, getFirstParamName(mapStateToProps)); | ||
if (mapStateToProps.body) { | ||
checkFunction(context, mapStateToProps.body, getFirstParamName(mapStateToProps)); | ||
} | ||
} | ||
@@ -50,0 +52,0 @@ }, |
{ | ||
"name": "eslint-plugin-react-redux", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Enforcing best practices for react-redux", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -50,7 +50,7 @@ # eslint-plugin-react-redux | ||
* [react-redux/connect-prefer-minimum-two-arguments](docs/rules/connect-prefer-minimum-two-arguments.md) Enforces that connect function has at least 2 arguments. | ||
* [react-redux/connect-prefer-named-arguments](docs/rules/connect-prefer-named-arguments.md) Enforces that all connect arguments have specific names. | ||
* [react-redux/mapDispatchToProps-prefer-object](docs/rules/mapDispatchToProps-prefer-object.md) Enforces that all mapDispatchToProps parameters have specific names. | ||
* [react-redux/mapDispatchToProps-prefer-parameters-names](docs/rules/mapDispatchToProps-prefer-parameters-names.md) Enforces that mapDispatchToProps returns an object. | ||
* [react-redux/connect-prefer-named-arguments](docs/rules/connect-prefer-named-arguments.md) Enforces that all connect arguments have recommended names. | ||
* [react-redux/mapDispatchToProps-prefer-object](docs/rules/mapDispatchToProps-prefer-object.md) Enforces that mapDispatchToProps returns an object. | ||
* [react-redux/mapDispatchToProps-prefer-parameters-names](docs/rules/mapDispatchToProps-prefer-parameters-names.md) Enforces that all mapDispatchToProps parameters have specific names. | ||
* [react-redux/mapStateToProps-no-store](docs/rules/mapStateToProps-no-store.md) Prohibits binding a whole store object to a component. | ||
* [react-redux/mapStateToProps-prefer-parameters-names](docs/rules/mapStateToProps-prefer-parameters-names.md) Enforces that all mapStateToProps parameters have specific names. | ||
* [react-redux/prefer-separate-component-file](docs/rules/prefer-separate-component-file.md) Enforces that all connected components are defined in a separate file. |
@@ -18,2 +18,5 @@ require('babel-eslint'); | ||
valid: [ | ||
'export default connect(() => {})(Alert)', | ||
'export default connect(() => {})(Alert)', | ||
'export default connect(null, null)(Alert)', | ||
'connect((state) => ({isActive: state.isActive}), null)(App)', | ||
@@ -45,2 +48,4 @@ `connect( | ||
'const mapStateToProps = (state) => {isActive: state.isActive}', | ||
`const mapStateToProps = (state, ownProps) => {}; | ||
connect(mapStateToProps, null)(Alert);`, | ||
], | ||
@@ -97,3 +102,11 @@ invalid: [{ | ||
], | ||
}, { | ||
code: `const mapStateToProps = (state, ownProps) => state; | ||
connect(mapStateToProps, null)(Alert);`, | ||
errors: [ | ||
{ | ||
message: 'mapStateToProps should not return complete store object', | ||
}, | ||
], | ||
}], | ||
}); |
27790
1.96%637
2.41%