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

Cannot read property 'namespace' of undefined #416

Closed
CarlosAmaral opened this issue Jul 5, 2016 · 15 comments · Fixed by Urigo/tortilla#68
Closed

Cannot read property 'namespace' of undefined #416

CarlosAmaral opened this issue Jul 5, 2016 · 15 comments · Fixed by Urigo/tortilla#68
Labels
Milestone

Comments

@CarlosAmaral
Copy link

TypeError: Cannot read property 'namespace' of undefined from eslint-plugin-import/lib/rules/namespace.js

Getting this error and not exactly sure why. Thanks.

@benmosher
Copy link
Member

Are you running 1.10.1? I think I totally botched the publish and accidentally packaged the build products for v2.

@CarlosAmaral
Copy link
Author

@benmosher Yes I am

@benmosher
Copy link
Member

Just published 1.10.2, can you try it?

@CarlosAmaral
Copy link
Author

Thanks. Just tried, the error persists.

Cannot read property 'namespace' of undefined
TypeError: Cannot read property 'namespace' of undefined
    at EventEmitter.MemberExpression (/Users/carlosamaral/Documents/www/romanticism-react/node_modules/eslint-plugin-import/lib/rules/namespace.js:132:61)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.enterNode (/Users/carlosamaral/Documents/www/romanticism-react/node_modules/eslint/lib/util/node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (/Users/carlosamaral/Documents/www/romanticism-react/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:607:23)
    at CommentEventGenerator.enterNode (/Users/carlosamaral/Documents/www/romanticism-react/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.traverser.traverse.enter (/Users/carlosamaral/Documents/www/romanticism-react/node_modules/eslint/lib/eslint.js:905:36)
    at Controller.__execute (/Users/carlosamaral/Documents/www/romanticism-react/node_modules/eslint/node_modules/estraverse/estraverse.js:397:31)
    at Controller.traverse (/Users/carlosamaral/Documents/www/romanticism-react/node_modules/eslint/node_modules/estraverse/estraverse.js:501:28)
    at Controller.Traverser.controller.traverse (/Users/carlosamaral/Documents/www/romanticism-react/node_modules/eslint/lib/util/traverser.js:36:33)

@benmosher
Copy link
Member

Hmm, tough to say without more info. Looks like a legitimate bug.

Can you isolate to specific lines of code and post them?

@CarlosAmaral
Copy link
Author

Might reside here but I'm not sure. Let me know.
https://gist.github.com/anonymous/197ac98462ce78087136f3262dc91068

@benmosher
Copy link
Member

Hmm, if any of them, probably one of these lets:

import * as ReactMDL from 'react-mdl';
let Navigation = ReactMDL.Navigation;
let Drawer = ReactMDL.Drawer;
let Layout = ReactMDL.Layout;
let Content = ReactMDL.Content;
let Header = ReactMDL.Content;

Can you try commenting them and see if it goes away?

@CarlosAmaral
Copy link
Author

You're correct. The error is gone. Thanks. What I should use instead? const?

@benmosher
Copy link
Member

It's definitely a bug in the rule. It shouldn't do anything in these lines, much less throw an exception. I will try to fix ASAP.

In the meantime,

import {
  Navigation,
  Drawer,
  Layout,
  Content,
  Header,
} from 'react-mdl'

is roughly equivalent, and hopefully doesn't throw any errors. 😳

@benmosher benmosher added the bug label Jul 5, 2016
@benmosher benmosher added this to the patch milestone Jul 5, 2016
@CarlosAmaral
Copy link
Author

Thanks bro.

@CarlosAmaral
Copy link
Author

PS: I got these errors, not entirely sure if they're related, but the imports are working though.

!  3:27  '/Users/carlosamaral/Documents/www/romanticism-react/node_modules/react-mdl/src/index.js' imported multiple times                                                                         import/no-duplicates
  ✖  4:9   Navigation not found via ../../../node_modules/react-mdl/src/index.js -> ../../../node_modules/react-mdl/src/Layout/index.js -> ../../../node_modules/react-mdl/src/Layout/Navigation.js  import/named
  ✖  4:21  Drawer not found via ../../../node_modules/react-mdl/src/index.js -> ../../../node_modules/react-mdl/src/Layout/index.js -> ../../../node_modules/react-mdl/src/Layout/Drawer.js          import/named
  ✖  4:29  Layout not found via ../../../node_modules/react-mdl/src/index.js -> ../../../node_modules/react-mdl/src/Layout/index.js -> ../../../node_modules/react-mdl/src/Layout/Layout.js          import/named
  ✖  4:37  Content not found via ../../../node_modules/react-mdl/src/index.js -> ../../../node_modules/react-mdl/src/Layout/index.js -> ../../../node_modules/react-mdl/src/Layout/Content.js        import/named
  ✖  4:46  Header not found via ../../../node_modules/react-mdl/src/index.js -> ../../../node_modules/react-mdl/src/Layout/index.js -> ../../../node_modules/react-mdl/src/Layout/Header.js          import/named
  !  4:59  '/Users/carlosamaral/Documents/www/romanticism-react/node_modules/react-mdl/src/index.js' imported multiple times                                                                         import/no-duplicates

@benmosher
Copy link
Member

Probably are related. Thanks!

@benmosher
Copy link
Member

Did some digging. Turns out it's because the ES6 behind react-mdl is using object-spread, and ESLint doesn't handle it by default.

Not sure how to resolve. I probably need to handle somehow in the plugin, short-term. You can use these settings in your eslintrc to resolve for now:

{
  parserOptions: {
    sourceType: 'module',
    ecmaVersion: 6,
    ecmaFeatures: { experimentalObjectRestSpread: true, jsx: true }
  }
}

@CarlosAmaral
Copy link
Author

@benmosher It did the trick. Thanks!

@ljharb
Copy link
Member

ljharb commented Jun 24, 2018

This seems long since resolved.

@ljharb ljharb closed this as completed Jun 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants