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

Problem with using object rest and re-exports when rule import/namespace enabled #656

Closed
preco21 opened this issue Nov 7, 2016 · 1 comment · Fixed by Urigo/tortilla#68 · May be fixed by MaxMood96/eslint-plugin-import#28 or MaxMood96/eslint-plugin-import#35

Comments

@preco21
Copy link
Contributor

preco21 commented Nov 7, 2016

Hello, I have some issue with re-exports.

I use babel-eslint parser for some experimental features. And I have used object rest operator for destructuring module. But re-export (in index.js) and object rest operator seems causes some issue with import/namespace rule.

When I enable import/namespace rule, then create few files below, after that run lint, it causes error:

Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
    at testKey (C:\Workspace\sandbox\node_modules\eslint-plugin-import\lib\rules\namespace.js:166:29)
    at EventEmitter.VariableDeclarator (C:\Workspace\sandbox\node_modules\eslint-plugin-import\lib\rules\namespace.js:188:9)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.enterNode (C:\Workspace\sandbox\node_modules\eslint\lib\util\node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (C:\Workspace\sandbox\node_modules\eslint\lib\code-path-analysis\code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode (C:\Workspace\sandbox\node_modules\eslint\lib\util\comment-event-generator.js:97:23)
    at Controller.enter (C:\Workspace\sandbox\node_modules\eslint\lib\eslint.js:927:36)
    at Controller.__execute (C:\Workspace\sandbox\node_modules\estraverse\estraverse.js:397:31)
    at Controller.traverse (C:\Workspace\sandbox\node_modules\estraverse\estraverse.js:501:28)

.eslintrc.yml:

root: true
parser: babel-eslint
plugins:
  - import
parserOptions:
  ecmaVersion: 2017
  sourceType: module
rules:
  import/namespace: error

index.js:

export * from './module'; // re-exports

module.js:

function foo() {
  
}

function bar() {
  
}

function baz() {
  
}

export {
  foo,
  bar,
  baz,
};

test/spec.js:

import * as module from '..';

const {foo, ...moduleRest} = module; // when I comment this line, it works fine

...

Modules:

  • babel-eslint@7.1.0
  • eslint@3.9.1
  • eslint-plugin-import@2.1.0
  • eslint-plugin-babel@3.3.0
preco21 added a commit to preco21/eslint-config-legacy that referenced this issue Nov 7, 2016
@preco21 preco21 changed the title Errored when using object rest and re-exports when rule import/namespace enabled Problem with using object rest and re-exports when rule import/namespace enabled Nov 8, 2016
@evan-scott-zocdoc
Copy link

Seeing this too:

import * as lib from '../';

const {default, ...funcs} = lib;

Same error, with import/namespaces turned on. Commenting out the destructuring fixes it.

Using latest babel-eslint

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