Skip to content

no-typos: Cannot read property 'toLowerCase' of undefined #2870

Closed
@AriPerkkio

Description

@AriPerkkio

Hello, no-typos 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/1506856587?check_suite_focus=true

"eslint-plugin-react": "^7.21.5"
"extends": ["plugin:react/all"]

Minimal repro:

import React from 'react';

const A = { B: 'C' };

export default class MyComponent extends React.Component {
  [A.B] () {
    return null
  }
}
Crash reports from real-world examples

Rule: no-typos

Message: Cannot read property 'toLowerCase' of undefined
Path: zooniverse/front-end-monorepo/packages/lib-classifier/src/components/Classifier/components/TaskArea/components/Tasks/Tasks.js
Link

  }
}

class Tasks extends React.Component {
  [asyncStates.initialized] () {
    return null
  }

  [asyncStates.loading] () {
    return (<Paragraph>{counterpart('Tasks.loading')}</Paragraph>)
Error:
TypeError: Cannot read property 'toLowerCase' of undefined
Occurred while linting <text>:32
    at /home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/rules/no-typos.js:155:41
    at Array.forEach (<anonymous>)
    at reportErrorIfLifecycleMethodCasingTypo (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/rules/no-typos.js:154:32)
    at Object.MethodDefinition (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/rules/no-typos.js:232:9)
    at updatedRuleInstructions.<computed> (/home/runner/work/eslint-remote-tester/eslint-remote-tester/ci/node_modules/eslint-plugin-react/lib/util/Components.js:986:45)
    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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions