Skip to content

TypeError: Cannot read property 'type' of null #129

Closed
@roadhump

Description

@roadhump

Got an error, probably some es7 case?

Cannot read property 'type' of null
TypeError: Cannot read property 'type' of null
    at EventEmitter.ClassProperty (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint-plugin-react/lib/rules/jsx-sort-prop-types.js:64:53)
    at emitOne (events.js:82:20)
    at EventEmitter.emit (events.js:169:7)
    at Controller.controller.traverse.enter (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/lib/eslint.js:728:25)
    at Controller.__execute (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/node_modules/estraverse/estraverse.js:393:31)
    at Controller.traverse (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/node_modules/estraverse/estraverse.js:491:28)
    at EventEmitter.module.exports.api.verify (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/lib/eslint.js:721:24)
    at processText (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/lib/cli-engine.js:201:27)
    at CLIEngine.executeOnText (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/lib/cli-engine.js:361:26)
    at Object.cli.execute (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/lib/cli.js:179:70) 

.babelrc

{
  "stage": 0
}

Code

var React, {Component, PropTypes} = require('react');
export default class HelpTooltipsManager extends Component {

    propTypes: {
        dispatch: PropTypes.func.isRequired,
        items: PropTypes.array.isRequired,
        visibility: PropTypes.object.isRequired
    }
}

Activity

mathieumg

mathieumg commented on Jun 25, 2015

@mathieumg
Contributor

Totally unrelated, by just out of curiosity, why do you not use the import syntax?

yannickcr

yannickcr commented on Jun 25, 2015

@yannickcr
Member

Seems your code is not valid, it should be propTypes = instead of propTypes:.

In this case Babel do not trigger any error but it does not attach the propTypes method to the outputed class.

However, I will patch the rule to avoid the crash but I will be difficult for us to validate the propTypes order since Babel does not output much informations here.

roadhump

roadhump commented on Jun 25, 2015

@roadhump
Author

@mathieumg I just rewrite my old code and some things are out of my attention, it will be import there.

roadhump

roadhump commented on Jun 25, 2015

@roadhump
Author

@yannickcr thanks. I thought that if code are not valid, babel will not parse it at all.

yannickcr

yannickcr commented on Jun 25, 2015

@yannickcr
Member

@roadhump yes, in it should not parse it, but there is a few cases were it accept invalid code (like in #125). I don't know if it can be considered as a bug or not.

added a commit that references this issue on Jun 26, 2015
b1e1f40

32 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @yannickcr@roadhump@mathieumg

        Issue actions

          TypeError: Cannot read property 'type' of null · Issue #129 · jsx-eslint/eslint-plugin-react