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 'name' of undefined in jsx-no-target-blank #1296

Closed
green-arrow opened this issue Jul 12, 2017 · 11 comments · Fixed by #1298
Closed

TypeError: Cannot read property 'name' of undefined in jsx-no-target-blank #1296

green-arrow opened this issue Jul 12, 2017 · 11 comments · Fixed by #1298

Comments

@green-arrow
Copy link

green-arrow commented Jul 12, 2017

I'm getting this error after upgrading react-scripts to the latest version. Example code:

<a target="_blank" rel="noreferrer noopener" href="https://www.example.com">

The source line from the error is line 28, where it does attr.name.name.

@ljharb
Copy link
Member

ljharb commented Jul 12, 2017

That's an unclosed element; what's the full source?

@ljharb ljharb added the bug label Jul 12, 2017
@green-arrow
Copy link
Author

Sorry about that, here's the full source:

<a
  {...css(
    styles.muted,
    styles.footerItem,
    styles.fullWidthOnMobile
  )}
  target="_blank"
  rel="noopener noreferrer"
  href="https://www.company.com/about"
>
  about company
</a>

@green-arrow
Copy link
Author

FWIW, I can't replicate this on a freshly created create-react-app. It only occurs after upgrading from 1.0.4 to 1.0.10.

@ljharb
Copy link
Member

ljharb commented Jul 12, 2017

Any chance the upgrade isn't bumping eslint-plugin-react? If you do the upgrade and then npm install eslint-plugin-react, what happens?

@green-arrow
Copy link
Author

I compared yarn.lock files between a fresh app and my upgraded one, and the version numbers for eslint and eslint-plugin-react match up between the two.

Here is the result of upgrading react-scripts:

screen shot 2017-07-12 at 2 53 39 pm

It looks like eslint-plugin-react was updated to the latest version alright.

When running npm install eslint-plugin-react after doing the upgrade above, I still get the TypeError.

@ljharb
Copy link
Member

ljharb commented Jul 12, 2017

It's likely the spread that's doing it.

@ljharb
Copy link
Member

ljharb commented Jul 12, 2017

Can you confirm by removing it temporarily?

@green-arrow
Copy link
Author

green-arrow commented Jul 12, 2017

@ljharb - you're completely right, removing the spread on css fixes the issue.

Any way to work around this?

Edit: I can workaround this for now by using a different method of passing styles. Not sure if there's any way to work around this that lets you keep the spread.

@ljharb
Copy link
Member

ljharb commented Jul 12, 2017

I don't think there's a workaround short of disabling the rule entirely for that file.

@jseminck
Copy link
Contributor

Working on a fix.

@green-arrow
Copy link
Author

Thanks for the fix, you all are awesome! 😄

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

Successfully merging a pull request may close this issue.

3 participants