Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 344486 - Distinguish jslint errors from warnings
Summary: Distinguish jslint errors from warnings
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: 0.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 0.3 RC1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-02 12:52 EDT by Jay Arthanareeswaran CLA
Modified: 2011-09-26 15:46 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jay Arthanareeswaran CLA 2011-05-02 12:52:05 EDT
I am not sure if Orion can do anything here. Anyway, here it goes. 

In the following code, there are error markers on both conditions. The message expects '!==' and '===' respectively. Note the additional '=' in the expected operators.

function foo(i) {
	if (i != 10) {
		// Do something
	}
	else if (i == 15) {
		// Do something else
	}
}

Steps:
1. Create a new folder, a new JavaScript file, let's say abc.js and enter the code given above.
Comment 1 John Arthorne CLA 2011-05-02 16:19:15 EDT
This comes from jslint. They should really only be considered warnings.
Comment 2 John Arthorne CLA 2011-05-02 16:21:07 EDT
In case you don't understand why jslint complains, see:

http://rayfd.wordpress.com/2007/03/18/really-understanding-javascripts-equality-and-identity/
Comment 3 Mark Macdonald CLA 2011-09-23 13:24:56 EDT
Here are some errors that we should consider displaying as warnings:
- == versus ===
- != versus !==
- One-line if/else statement with no braces
- Unfiltered for..in loop
- Use of 'new' for side effects
- Making functions inside a loop

IMO error markers should be limited to code that will cause parse errors or exceptions at runtime (TypeErrors etc). Warnings are more appropriate for programming mistakes that might lead to unintended behavior.