Skip to content

prefer-wait-for: Cannot read property 'arguments' of null #272

Closed
@AriPerkkio

Description

@AriPerkkio

Hello, prefer-wait-for rule seems to crash in certain cases. This issue was spotted by automated CI run - it is not blocking my development or anything. 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.

https://github.com/AriPerkkio/eslint-remote-tester/runs/1551964310?check_suite_focus=true

Complete list of dependencies and .eslintrc is available at CI runs logs, steps Run yarn list | grep eslint and Run yarn log --config ./plugin-configs/eslint-plugin-testing-library.config.js.

eslint-plugin-testing-library@3.10.1
rules: {
    'testing-library/prefer-wait-for': 'error',
}

Minimal repro:

import { waitForElement } from '@testing-library/react';

global.waitForElement = waitForElement;
TypeError: Cannot read property 'arguments' of null Occurred while linting <text>:2
    at Object.fix (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:61:50)
Crash reports from real projects

Rule: prefer-wait-for

  • Message: Cannot read property 'arguments' of null Occurred while linting <text>:2
  • Path: diondirza/rexr/test/test-utils.js
  • Link
import React from 'react';
import { fireEvent, render, waitForElement } from '@testing-library/react';
import { HelmetProvider } from 'react-helmet-async';
import { Router } from 'react-router-dom';
import { createBrowserHistory } from 'history';

import { GlobalProvider } from '@context';
TypeError: Cannot read property 'arguments' of null Occurred while linting <text>:2
    at Object.fix (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:61:50)
    at normalizeFixes (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:178:28)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:347:49
    at Object.report (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/linter.js:920:41)
    at reportWait (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:53:21)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:97:36
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:96:52
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:95:26

Rule: prefer-wait-for

  • Message: Cannot read property 'arguments' of null Occurred while linting <text>:18
  • Path: gravitational/webapps/packages/design/src/utils/testing.tsx
  • Link
 * limitations under the License.
 */

import React from 'react';
import {
  render as testingRender,
  act,
  fireEvent,
  waitForElement,
} from '@testing-library/react';
TypeError: Cannot read property 'arguments' of null Occurred while linting <text>:18
    at Object.fix (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:61:50)
    at normalizeFixes (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:178:28)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:347:49
    at Object.report (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/linter.js:920:41)
    at reportWait (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:53:21)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:97:36
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:96:52
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:95:26

Rule: prefer-wait-for

  • Message: Cannot read property 'arguments' of null Occurred while linting <text>:2
  • Path: faultable/wardex/src/setupTests.js
  • Link
import React from 'react'
import {
  afterEach,
  render,
  cleanup,
  fireEvent,
  wait,
TypeError: Cannot read property 'arguments' of null Occurred while linting <text>:2
    at Object.fix (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:61:50)
    at normalizeFixes (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:178:28)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:347:49
    at Object.report (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/linter.js:920:41)
    at reportWait (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:53:21)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:97:36
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:96:52
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:95:26

Rule: prefer-wait-for

  • Message: Cannot read property 'arguments' of null Occurred while linting <text>:2
  • Path: activewidgets/react/test/adapter/react.js
  • Link
import {render, fireEvent, wait, waitForElement} from '@testing-library/react';
import {h} from '@activewidgets/components';


export function mount(component, props){
    return render(h(component, props));
TypeError: Cannot read property 'arguments' of null Occurred while linting <text>:2
    at Object.fix (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:61:50)
    at normalizeFixes (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:178:28)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:347:49
    at Object.report (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/linter.js:920:41)
    at reportWait (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:53:21)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:97:36
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:96:52
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:95:26

Rule: prefer-wait-for

  • Message: Cannot read property 'arguments' of null Occurred while linting <text>:3
  • Path: w-sr/React-Storybook-Game/src/setupTests.js
  • Link
import React from 'react';
import '@testing-library/jest-dom/extend-expect';
import { render, fireEvent, waitForElement } from '@testing-library/react';
import renderer from 'react-test-renderer';
import sinon from 'sinon';
import { act } from 'react-dom/test-utils';
import 'jest-styled-components';
TypeError: Cannot read property 'arguments' of null Occurred while linting <text>:3
    at Object.fix (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:61:50)
    at normalizeFixes (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:178:28)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:347:49
    at Object.report (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/linter.js:920:41)
    at reportWait (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:53:21)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:97:36
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:96:52
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:95:26

Rule: prefer-wait-for

  • Message: Cannot read property 'arguments' of null Occurred while linting <text>:20
  • Path: sumup-oss/circuit-ui/src/util/test-utils.tsx
  • Link
import React, { FunctionComponent } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import '@testing-library/jest-dom/extend-expect';
import { configureAxe } from 'jest-axe';
import {
  render as renderTest,
  wait,
  act,
  RenderResult,
} from '@testing-library/react';
TypeError: Cannot read property 'arguments' of null Occurred while linting <text>:20
    at Object.fix (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:61:50)
    at normalizeFixes (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:178:28)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/report-translator.js:347:49
    at Object.report (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint/lib/linter/linter.js:920:41)
    at reportWait (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:53:21)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:97:36
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:96:52
    at Array.forEach (<anonymous>)
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-testing-library/rules/prefer-wait-for.js:95:26

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions