Skip to content

TypeError: Cannot read property 'match' of undefined with prefer-stateless-function #2596

Closed
@garyking

Description

@garyking

With the code:

/**
 * @param a.
 */
function Comp() {
  return <a></a>
}

Lint it with this rule, version eslint-plugin-react@7.19.0.

I get the error:

[Error - 11:18:15 PM] ESLint stack trace:
[Error - 11:18:15 PM] TypeError: Cannot read property 'match' of undefined
Occurred while linting test.tsx:4
    at scanIdentifier (eslint-plugin-react/node_modules/doctrine/lib/doctrine.js:259:96)
    at parseName (eslint-plugin-react/node_modules/doctrine/lib/doctrine.js:317:29)
    at TagParser.parseName (eslint-plugin-react/node_modules/doctrine/lib/doctrine.js:500:34)
    at TagParser.parse (eslint-plugin-react/node_modules/doctrine/lib/doctrine.js:769:34)
    at parseTag (eslint-plugin-react/node_modules/doctrine/lib/doctrine.js:790:26)
    at Object.parse (eslint-plugin-react/node_modules/doctrine/lib/doctrine.js:868:23)
    at Object.isExplicitComponent (eslint-plugin-react/lib/util/Components.js:269:35)
    at Object.isES6Component (eslint-plugin-react/lib/util/Components.js:237:17)
    at eslint-plugin-react/lib/rules/prefer-stateless-function.js:365:68
    at Array.forEach (<anonymous>)

This happens in particular, when I have ESLint linting while I type.

I managed to fix the issue in doctrine by adding && source[index], but then I find out that the package is archived on GitHub!

This bug might have been introduced recently (in the past week?), as I haven't seen it before.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions