Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

TypeError: Cannot read property 'type' of undefined - When creating React Component with wrap-regex rule #126

Closed
soda0289 opened this issue Dec 13, 2016 · 2 comments
Labels

Comments

@soda0289
Copy link
Member

What version of TypeScript are you using?
2.0.10

What version of typescript-eslint-parser are you using?
1.0.0

What code were you trying to parse?

import * as React from 'react';

class WrapRegex {
    public render() {
        return (
            <div>
            </div>
        );
    }
}

Eslint Config

{
    "extends": ["plugin:react/recommended"],
    "parser": "typescript-eslint-parser",
        "parserOptions": {
                "ecmaVersion": 6,
                "sourceType": "module",
                "ecmaFeatures": {
                  "modules": true
                }
        },
    "plugins": [
        "react"
    ],
    "rules": {
        "wrap-regex": [
            "error"
        ]
    }
}

What did you expect to happen?
It to parse

What happened?
Uncaught Exception

Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
    at EventEmitter.Literal (/usr/lib/node_modules/eslint/lib/rules/wrap-regex.js:32:37)
    at emitOne (events.js:77:13)
    at EventEmitter.emit (events.js:169:7)
    at NodeEventGenerator.enterNode (/usr/lib/node_modules/eslint/lib/util/node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (/usr/lib/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode (/usr/lib/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.enter (/usr/lib/node_modules/eslint/lib/eslint.js:925:36)
    at Controller.__execute (/usr/lib/node_modules/eslint/node_modules/estraverse/estraverse.js:397:31)
    at Controller.traverse (/usr/lib/node_modules/eslint/node_modules/estraverse/estraverse.js:501:28)
    at Controller.Traverser.controller.traverse (/usr/lib/node_modules/eslint/lib/util/traverser.js:36:33)

@soda0289 soda0289 changed the title TypeError: Cannot read property 'type' of undefined - When using React JSX and wrap-regex TypeError: Cannot read property 'type' of undefined - When creating React Component and wrap-regex Dec 13, 2016
@soda0289 soda0289 changed the title TypeError: Cannot read property 'type' of undefined - When creating React Component and wrap-regex TypeError: Cannot read property 'type' of undefined - When creating React Component with wrap-regex rule Dec 13, 2016
@soda0289
Copy link
Member Author

soda0289 commented Dec 13, 2016

Most likely duplicate of Issues #70 and #125

@JamesHenry
Copy link
Member

Yes, this is a duplicate of #70 - there is no issue with (the whitespace between the JSX nodes removed):

return (
  <div></div>
);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants