useSelector-prefer-selectors: Cannot read property 'type' of undefined
AriPerkkio opened this issue · comments
Hello, I'm testing stability of well known community ESlint plugins with eslint-remote-tester
. This ESLint plugin seems to contain a rule which causes linter to crash. ESlint rules should not crash in any condition since this makes all valid linting problems disappear. If this is a false flag please let me know.
CI run: https://github.com/AriPerkkio/eslint-remote-tester/actions/runs/404195599
Crashing rule:
useSelector-prefer-selectors
Minimal repro:
expect(() => useSelector()).toThrow();
Error crashes from real-world examples
Rule: useSelector-prefer-selectors
Message: Cannot read property 'type' of undefined
Path: reduxjs/react-redux/test/hooks/useSelector.spec.js
Link
})
describe('error handling for invalid arguments', () => {
it('throws if no selector is passed', () => {
expect(() => useSelector()).toThrow()
})
})
})
describe('createSelectorHook', () => {
Error:
TypeError: Cannot read property 'type' of undefined
Occurred while linting <text>:419
at CallExpression (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react-redux/lib/rules/useSelector-prefer-selectors.js:31:18)
at /home/runner/work/eslint-remote-tester/eslint-remote-tester/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/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
at NodeEventGenerator.applySelectors (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
at NodeEventGenerator.enterNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
at CodePathAnalyzer.enterNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
at /home/runner/work/eslint-remote-tester/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
at Array.forEach (<anonymous>)