Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 493947

Summary: Error opening file with import declaration
Product: [ECD] Orion Reporter: Olivier Thomann <Olivier_Thomann>
Component: JS ToolsAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public, Michael_Rennie
Version: 11.0   
Target Milestone: 12.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Olivier Thomann CLA 2016-05-18 16:08:08 EDT
Opening this file:
import { cube } from 'myModule'

cube(4)

Where myModule.js is defined as:
// module "myModule.js"
export function cube(x) {
	return x * x * x;
}

var a; export { a as b }

leads to this error:
TypeError: Cannot read property 'range' of undefined
    at http://oliviert.orion.eclipse.org:9000/eslint/lib/load-rules-async.js:1722:20
    at Array.forEach (native)
    at EventEmitter.check (http://oliviert.orion.eclipse.org:9000/eslint/lib/load-rules-async.js:1716:29)
    at http://oliviert.orion.eclipse.org:9000/eslint/lib/events.js:109:14
    at Array.forEach (native)
    at EventEmitter.emit (http://oliviert.orion.eclipse.org:9000/eslint/lib/events.js:107:14)
    at NodeEventGenerator.enterNode (http://oliviert.orion.eclipse.org:9000/eslint/lib/node-event-generator.js:45:22)
    at CommentEventGenerator.enterNode (http://oliviert.orion.eclipse.org:9000/eslint/lib/comment-event-generator.js:101:23)
    at Controller.enter (http://oliviert.orion.eclipse.org:9000/eslint/lib/eslint.js:770:36)
    at Controller.__execute (http://oliviert.orion.eclipse.org:9000/estraverse/estraverse.js:398:31)
Comment 1 Olivier Thomann CLA 2016-05-18 16:08:44 EDT
I think we should just check if id exists before calling id.range.
Comment 2 Olivier Thomann CLA 2016-05-18 16:59:29 EDT
This only happens if the source type is script and module is not enabled. I added a regression test.
Comment 3 Olivier Thomann CLA 2016-05-18 17:00:49 EDT
Delivered as commit 25f8b542769b5ce467b423210a533f37033fba71.