Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useSelector-prefer-selectors: Cannot read property 'type' of undefined #59

Closed
AriPerkkio opened this issue Dec 7, 2020 · 0 comments · Fixed by #60
Closed

useSelector-prefer-selectors: Cannot read property 'type' of undefined #59

AriPerkkio opened this issue Dec 7, 2020 · 0 comments · Fixed by #60

Comments

@AriPerkkio
Copy link

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>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant