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

prefer-user-event: Cannot read property 'value' of undefined #405

Closed
AriPerkkio opened this issue Jul 9, 2021 · 3 comments · Fixed by #422
Closed

prefer-user-event: Cannot read property 'value' of undefined #405

AriPerkkio opened this issue Jul 9, 2021 · 3 comments · Fixed by #422
Assignees
Labels
bug Something isn't working released

Comments

@AriPerkkio
Copy link
Contributor

Hello, prefer-user-event rule seems to crash in certain cases. This issue was spotted by automated CI run - it is not blocking my development or anything.

AriPerkkio/eslint-remote-tester#210 (comment)

"eslint-plugin-testing-library": "^4.9.0"
module.exports = {
    root: true,
    env: {
        es6: true,
        node: true,
    },
    parserOptions: {
        ecmaVersion: 2020,
        sourceType: "module",
        ecmaFeatures: {
            jsx: true,
        },
    },
    plugins: ["testing-library"],
    rules: {
        "testing-library/prefer-user-event": "error",
    },
};

Minimal repro:

const createEvent = () => "Event";
const event = createEvent();
TypeError: Cannot read property 'value' of undefined
Occurred while linting /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/doasync/trace-router/src/router.ts:35
    at Object.VariableDeclarator (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-user-event.js:139:26)
    at enhancedRuleInstructions.<computed> (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/create-testing-library-rule/detect-testing-library-utils.js:518:105)
Crash reports from real projects

Rule: prefer-user-event

  • Message: Cannot read property 'value' of undefined Occurred while linting /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/doasync/trace-router/src/route.ts:114
  • Path: doasync/trace-router/src/route.ts
  • Link
  112 |   const { path, matchOptions } = config;
  113 |   const match = createMatch<P>(path, matchOptions);
> 114 |   const navigate = createEvent<P | void>();
  115 |   const redirect = createEvent<P | void>();
  116 |   const $params = createStore<P | null>(null);
  117 |   const $visible = $params.map(Boolean);
TypeError: Cannot read property 'value' of undefined
Occurred while linting /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/doasync/trace-router/src/route.ts:114
    at Object.VariableDeclarator (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-user-event.js:139:26)
    at enhancedRuleInstructions.<computed> (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/create-testing-library-rule/detect-testing-library-utils.js:518:105)
    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:293:26)
    at NodeEventGenerator.applySelectors (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:322:22)
    at NodeEventGenerator.enterNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:336:14)
    at CodePathAnalyzer.enterNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/linter.js:960:32

Rule: prefer-user-event

  • Message: Cannot read property 'value' of undefined Occurred while linting /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/doasync/trace-router/src/router.ts:35
  • Path: doasync/trace-router/src/router.ts
  • Link
  33 |   let history = userHistory! ?? createHistory<S>(root);
  34 |
> 35 |   const historyUpdated = createEvent<Update<S>>();
  36 |   const $historyUpdate = createStore<Update<S>>({
  37 |     location: history.location,
  38 |     action: history.action,
TypeError: Cannot read property 'value' of undefined
Occurred while linting /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/doasync/trace-router/src/router.ts:35
    at Object.VariableDeclarator (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-user-event.js:139:26)
    at enhancedRuleInstructions.<computed> (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/create-testing-library-rule/detect-testing-library-utils.js:518:105)
    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:293:26)
    at NodeEventGenerator.applySelectors (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:322:22)
    at NodeEventGenerator.enterNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/node-event-generator.js:336:14)
    at CodePathAnalyzer.enterNode (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/linter.js:960:32
@Belco90
Copy link
Member

Belco90 commented Jul 9, 2021

@AriPerkkio Interesting, thanks for reporting!

@gndelia do you think it could be related to #261 ?

@gndelia
Copy link
Collaborator

gndelia commented Jul 10, 2021

There's a high chance. I'll look into it during the weekend!

@gndelia gndelia self-assigned this Jul 10, 2021
Belco90 added a commit that referenced this issue Jul 20, 2021
#422) (#422)

Closes #405

Co-authored-by: Mario Beltrán Alarcón <belco90@gmail.com>
@github-actions
Copy link

🎉 This issue has been resolved in version 4.9.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
4 participants