DianaSuvorova / eslint-plugin-react-redux

Enforcing best practices for react-redux

Home Page:https://www.npmjs.com/package/eslint-plugin-react-redux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mapStateToProps-prefer-hoisted: Cannot read property 'type' of null

AriPerkkio opened this issue · comments

Hello, mapStateToProps-prefer-hoisted rule seems to crash in certain cases. This issue was spotted by automated CI run - it is not blocking my development or anything. https://github.com/AriPerkkio/eslint-remote-tester/runs/1569548843?check_suite_focus=true

This plugin had only a single rule crashing after linting over 10K repositories in 6 hours. [INFO/STATUS] Repositories (11428/14527) 👍

"eslint-plugin-react-redux": "3.3.1",
  "plugins": ["react-redux"],
  "rules": {
    "react-redux/mapStateToProps-prefer-hoisted": "error"
  }

Minimal repro:

const mapStateToProps = () => {
    return;
};
TypeError: Cannot read property 'type' of null
Occurred while linting <text>:74
    at Object.getReturnNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react-redux/lib/utils.js:19:15)
    at checkFunction(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react-redux/lib/rules/mapStateToProps-prefer-hoisted.js:34:28)
Crash reports from real projects

Rule: mapStateToProps-prefer-hoisted

  • Message: Cannot read property 'type' of null Occurred while linting <text>:74
  • Path: kaanbayram/React.js_Kafka_Node.js_Chat_app/kafka_client/src/components/CreateTopic.js
  • Link
}


const mapStateToProps = ({messagesResponse}) => {
    return ;
};


export default connect(mapStateToProps,
{createTopic,getTopics,set_Topic,postTopic})(CreateTopic);
TypeError: Cannot read property 'type' of null
Occurred while linting <text>:74
    at Object.getReturnNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react-redux/lib/utils.js:19:15)
    at checkFunction(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react-redux/lib/rules/mapStateToProps-prefer-hoisted.js:34:28)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react-redux/lib/rules/mapStateToProps-prefer-hoisted.js:46:11
    at Array.forEach (<anonymous>)
    at VariableDeclaration(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react-redux/lib/rules/mapStateToProps-prefer-hoisted.js:43:25)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors(/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:283:22)

🎉 This issue has been resolved in version 3.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀