Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'toLowerCase' of undefined in jsx-no-target-blank #821

Closed
chalisegrogan opened this issue Sep 13, 2016 · 18 comments
Assignees
Labels

Comments

@chalisegrogan
Copy link

chalisegrogan commented Sep 13, 2016

As of fa99e13#diff-05dfa6b555ee6724cba772b5d07e4d1c, installing eslint/eslint-plugin-react with

npm install eslint eslint-plugin-react

and running the following eslint command in Codeship...

node_modules/eslint/bin/eslint.js -c .eslintrc --ext .jsx,.js path/to/code

is resulting in:

Cannot read property 'toLowerCase' of 
TypeError: Cannot read property 'toLowerCase' of undefined
at EventEmitter.JSXAttribute (/home/rof/src/github.com/newsela/newsela/node_modules/eslint-plugin-react/lib/rules/jsx-no-target-blank.js:28:60)
at emitOne (events.js:82:20)
at EventEmitter.emit (events.js:169:7)
at NodeEventGenerator.enterNode (/home/rof/src/github.com/newsela/newsela/node_modules/eslint/lib/util/node-event-generator.js:40:22)
at CodePathAnalyzer.enterNode (/home/rof/src/github.com/newsela/newsela/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
at CommentEventGenerator.enterNode (/home/rof/src/github.com/newsela/newsela/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
at Controller.enter (/home/rof/src/github.com/newsela/newsela/node_modules/eslint/lib/eslint.js:918:36)
at Controller.__execute (/home/rof/src/github.com/newsela/newsela/node_modules/eslint/node_modules/estraverse/estraverse.js:397:31)
at Controller.traverse (/home/rof/src/github.com/newsela/newsela/node_modules/eslint/node_modules/estraverse/estraverse.js:501:28)
at Controller.Traverser.controller.traverse (/home/rof/src/github.com/newsela/newsela/node_modules/eslint/lib/util/traverser.js:36:33)

To be clear, this seems to be only happening on Codeship. We've temporarily solved this by commenting out the offending rule (jsx-no-target-blank). Is this something others are seeing or should I bring this up with Codeship instead?

@ljharb
Copy link
Member

ljharb commented Sep 13, 2016

What version of node does codeship run?

@kouhin
Copy link

kouhin commented Sep 13, 2016

Same problem.

Cannot read property 'toLowerCase' of undefined
TypeError: Cannot read property 'toLowerCase' of undefined
    at EventEmitter.JSXAttribute (/Users/myabc/git/myproj/node_modules/eslint-plugin-react/lib/rules/jsx-no-target-blank.js:28:60)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.enterNode (/Users/myabc/git/myproj/node_modules/eslint/lib/util/node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (/Users/myabc/git/myproj/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode (/Users/myabc/git/myproj/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.enter (/Users/myabc/git/myproj/node_modules/eslint/lib/eslint.js:918:36)
    at Controller.__execute (/Users/myabc/git/myproj/node_modules/estraverse/estraverse.js:397:31)
    at Controller.traverse (/Users/myabc/git/myproj/node_modules/estraverse/estraverse.js:501:28)
    at Controller.Traverser.controller.traverse (/Users/myabc/git/myproj/node_modules/eslint/lib/util/traverser.js:36:33)

Version:

    "eslint": "^3.3.0",
    "eslint-config-airbnb": "^11.1.0",
    "eslint-plugin-babel": "^3.3.0",
    "eslint-plugin-import": "^1.14.0",
    "eslint-plugin-jsx-a11y": "^2.2.2",
    "eslint-plugin-react": "^6.2.1",

@ljharb
Copy link
Member

ljharb commented Sep 13, 2016

@kouhin as i commented in the other issue, your versions are incompatible - npm ls should be complaining, because you need eslint v3.5 with eslint-config-airbnb v11.1.

@ljharb
Copy link
Member

ljharb commented Sep 13, 2016

@chalisegrogan what versions of eslint everything is in your package.json?

@riquito
Copy link

riquito commented Sep 13, 2016

I'm getting this error with eslint@3.5.0 and eslint-config-airbnb@11.1.0. Yesterday it wasn't manifesting.

EDIT: I'm not using codeship

@kouhin
Copy link

kouhin commented Sep 13, 2016

I can't help myself to create this repository https://github.com/kouhin/eslint-config-airbnb-deps

npm install eslint-config-airbnb-deps --save-dev

Currently I'm using npm install eslint-config-airbnb-deps@10.0.2 --save-dev

Everything works well. 😉

@PEM--
Copy link

PEM-- commented Sep 13, 2016

@kouhin Thanks, this leads me on the right track. eslint-config-airbnb-deps uses the 6.2.0.

The error has been introduce with 6.2.1.

I suggest updating your package.json to use the 6.2.0.

@pirm-in
Copy link

pirm-in commented Sep 13, 2016

Just ran into the same problem (TypeError: Cannot read property 'toLowerCase' of undefined) with 6.2.1. Switching to 6.2.0 works.

"eslint": "^3.5.0",
"eslint-config-airbnb": "^11.1.0",
"eslint-plugin-import": "^1.15.0",
"eslint-plugin-jsx-a11y": "^2.2.2",
"eslint-plugin-react": "6.2.0",

@riquito
Copy link

riquito commented Sep 13, 2016

This is a simple component that triggers the error

import React, { PropTypes } from 'react';

export default function Foo() {
    const targetValue = '_blank';

    return (
        <a target={targetValue}>bar</a>
    );
};
Cannot read property 'toLowerCase' of undefined
TypeError: Cannot read property 'toLowerCase' of undefined
    at EventEmitter.JSXAttribute (/var/www/test/node_modules/eslint-plugin-react/lib/rules/jsx-no-target-blank.js:28:60)
    at emitOne (events.js:82:20)
    at EventEmitter.emit (events.js:169:7)
    at NodeEventGenerator.enterNode (/var/www/test/node_modules/eslint/lib/util/node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (/var/www/test/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode (/var/www/test/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.enter (/var/www/test/node_modules/eslint/lib/eslint.js:918:36)
    at Controller.__execute (/var/www/test/node_modules/eslint/node_modules/estraverse/estraverse.js:397:31)
    at Controller.traverse (/var/www/test/node_modules/eslint/node_modules/estraverse/estraverse.js:501:28)
    at Controller.Traverser.controller.traverse (/var/www/test/node_modules/eslint/lib/util/traverser.js:36:33)

@chalisegrogan
Copy link
Author

@ljharb Codeship is set up to run with: "node": "~4.2.2".

As for eslint, this was the package json at the time of running:

"eslint": "^2.12.0",
"eslint-loader": "^1.3.0",
"eslint-plugin-react": "^5.1.1",
"eslint-plugin-jsx-a11y": "^2.2.0",

note: we're now specifically targeting "eslint-plugin-react": "6.2.0",

@ljharb
Copy link
Member

ljharb commented Sep 13, 2016

@chalisegrogan can you rerun it with all the latest of eslint, eslint-plugin-react, and eslint-plugin-jsx-a11y?

@chalisegrogan
Copy link
Author

@ljharb set up as follows:

"eslint": "^3.5.0",
"eslint-plugin-react": "6.2.1",
"eslint-plugin-jsx-a11y": "^2.2.2",

is still failing with the same error.

@ljharb
Copy link
Member

ljharb commented Sep 13, 2016

@chalisegrogan and presumably if you lock eslint-plugin-react to 6.2.0, the error goes away?

@ljharb ljharb added the bug label Sep 13, 2016
@chalisegrogan
Copy link
Author

@ljharb correct.

@lencioni lencioni changed the title Running eslint in Codeship fails with undefined error. TypeError: Cannot read property 'toLowerCase' of undefined in jsx-no-target-blank Sep 13, 2016
@lencioni
Copy link
Collaborator

I'm guessing this was introduced by fa99e13. @dmnd any chance you can take a look at this?

@yannickcr
Copy link
Member

Working on a fix.

@chalisegrogan
Copy link
Author

Awesome, thank you @yannickcr !

@alpertuna
Copy link

+1

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

No branches or pull requests

9 participants