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

Bug 494082

Summary: [eslint][es6] Expand no-use-before-define to handle class declarations
Product: [ECD] Orion Reporter: Curtis Windatt <curtis.windatt.public>
Component: JS ToolsAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Michael_Rennie
Version: 12.0Flags: Michael_Rennie: review+
Target Milestone: 12.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Curtis Windatt CLA 2016-05-19 16:51:19 EDT
http://eslint.org/docs/rules/no-use-before-define
Upstream ESLint already handles this case

new A();
class A {
}

This will throw an exception because class declarations are not hoisted.

We could consider making this a separate rule as its severity should be Error as doing this breaks your code.
Comment 1 Curtis Windatt CLA 2016-06-01 17:25:52 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=79518d711c4bab04468b0d03db299d4679a6e41b
Expanded the rule for classes, also added handling for switch/arrow/blocks.  Tests added for both es6 constructs and standard validator tests.

Wiki page updated too.
Comment 2 Michael Rennie CLA 2016-06-13 13:19:28 EDT
Reopening, this change causes multiple warnings tp be reported in the following scenario:

/*globals a b*/
var func = function() {
	if (a) {
		if (b) {} 
		else {}
	} else {}
	hey = "geez";
};
var hey;

where the project options are set to:

{
    "plugins": {
        "node": {}
    },
    "libs": [
        "ecma5",
        "browser"
    ],
    "ecmaVersion": 5,
    "sourceType": "script"
}
Comment 3 Curtis Windatt CLA 2016-06-13 15:37:46 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=b58c5eb398e5a9951be74763fd847b76ff8ecd32
Adds different behaviour for ES5 vs ES6.