Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 488531 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/load-rules-async.js (+56 lines)
Lines 1204-1209 Link Here
1204
                };
1204
                };
1205
        },
1205
        },
1206
        /** @callback */
1206
        /** @callback */
1207
        'no-undef-expression': function(context){
1208
        	return {
1209
        		'MemberExpression': function(node){
1210
                	try {
1211
                    	if (node.property && node.object && node.object.type !== 'ThisExpression'){
1212
                    		if (node.parent && node.parent.type === 'CallExpression' && node.parent.callee && node.parent.callee === node){
1213
                    			 var tern = context.getTern();
1214
								var query = tern.query;
1215
								query.end = node.property.start;
1216
								var foundType = null;
1217
								try {
1218
									var expr = tern.findExpr(tern.file, query);
1219
									var type = tern.findExprType(tern.server, query, tern.file, expr);
1220
									if (type && type.origin){
1221
										foundType = type;
1222
									}
1223
								} catch(e) {
1224
									//ignore
1225
								}
1226
            	                if (!foundType){
1227
            	                	// If the object cannot be found, there is no way the property could be known
1228
            	                	query.end = node.object.end;
1229
            	                	try {
1230
            	                		expr = tern.findExpr(tern.file, query);
1231
            	                		type = tern.findExprType(tern.server, query, tern.file, expr);
1232
//            	                		if (!type || !type.origin || !type.types || type.types.length === 0){
1233
//            	                			foundType = true; // TODO type might be null so can't save it
1234
//            	                		} else {
1235
										if (type && type.types){
1236
            	                			// If the type has no known properties assume Tern doens't know enough about it to find the declaration
1237
            	                			foundType = true;
1238
            	                			for (var i=0; i<type.types.length; i++) {
1239
            	                				var currentProps = type.types[i].props;
1240
            	                				if (currentProps && Object.keys(currentProps).length > 0){
1241
            	                					foundType = false;
1242
            	                					break;
1243
            	                				}
1244
            	                			}
1245
            	                		}
1246
            	                	} catch (e) {
1247
            	                		//ignore
1248
            	                	}
1249
            	                	if (!foundType){
1250
										context.report(node.property, ProblemMessages['no-undef-defined'], {0:node.property.name, nls: 'no-undef-defined'}); //$NON-NLS-1$
1251
									}
1252
1253
								}
1254
                    		}
1255
                    	}
1256
                	} catch (ex) {
1257
                		Logger.log(ex);
1258
                	}
1259
1260
            	}
1261
        	};
1262
        },
1207
        'no-undef-init': function(context) {
1263
        'no-undef-init': function(context) {
1208
        		return {
1264
        		return {
1209
        			'VariableDeclarator': function(node) {
1265
        			'VariableDeclarator': function(node) {
(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/messages.js (+1 lines)
Lines 70-75 Link Here
70
	'varRedecl' : 'Variable re-declarations:',
70
	'varRedecl' : 'Variable re-declarations:',
71
	'varShadow': 'Variable shadowing:',
71
	'varShadow': 'Variable shadowing:',
72
	'undefMember' : 'Undeclared global reference:',
72
	'undefMember' : 'Undeclared global reference:',
73
	'undefExpression' : 'Undeclared member expression reference:',
73
	'unnecessarySemis' : 'Unnecessary semicolons:',
74
	'unnecessarySemis' : 'Unnecessary semicolons:',
74
	'unusedParams' : 'Unused parameters:',
75
	'unusedParams' : 'Unused parameters:',
75
	'unsupportedJSLint' : 'Unsupported environment directive:',
76
	'unsupportedJSLint' : 'Unsupported environment directive:',
(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js (-2 / +7 lines)
Lines 1443-1450 Link Here
1443
 				 	        	                	defaultValue: error,
1443
 				 	        	                	defaultValue: error,
1444
 				 	        	                	options: severities
1444
 				 	        	                	options: severities
1445
 				 	        	                },
1445
 				 	        	                },
1446
 				 	        	                {
1446
 				 	        	                {	id: "no-undef-expression",  //$NON-NLS-1$
1447
			 	        	                		id: "no-else-return",  //$NON-NLS-1$
1447
 				 	        	                	name: javascriptMessages["undefExpression"],
1448
 				 	        	                	type: "number",  //$NON-NLS-1$
1449
 				 	        	                	defaultValue: ignore,
1450
 				 	        	                	options: severities
1451
 				 	        	                },
1452
 				 	        	                {	id: "no-else-return",  //$NON-NLS-1$
1448
				 	        	                	name: javascriptMessages["no-else-return"],
1453
				 	        	                	name: javascriptMessages["no-else-return"],
1449
				 	        	                	type: "number",  //$NON-NLS-1$
1454
				 	        	                	type: "number",  //$NON-NLS-1$
1450
				 	        	                	defaultValue: warning,
1455
				 	        	                	defaultValue: warning,
(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/ruleData.js (+1 lines)
Lines 65-70 Link Here
65
			"no-sparse-arrays" : 1, 
65
			"no-sparse-arrays" : 1, 
66
			"no-throw-literal" : 1,
66
			"no-throw-literal" : 1,
67
			"no-undef" : 2,
67
			"no-undef" : 2,
68
			"no-undef-expression": 0,
68
			"no-undef-init" : 1,
69
			"no-undef-init" : 1,
69
			"no-unreachable" : 1, 
70
			"no-unreachable" : 1, 
70
			"no-unused-params" : 1,
71
			"no-unused-params" : 1,

Return to bug 488531