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 511478 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/javascriptProject.js (-53 / +38 lines)
Lines 79-84 define([ Link Here
79
		this.fileClient = null;
79
		this.fileClient = null;
80
		this.handlers = [eslintHandler];
80
		this.handlers = [eslintHandler];
81
		this.projectFiles = [this.PACKAGE_JSON, this.TERN_PROJECT, this.ESLINTRC, this.ESLINTRC_JS, this.ESLINTRC_JSON, this.ESLINTRC_YAML, this.ESLINTRC_YML];
81
		this.projectFiles = [this.PACKAGE_JSON, this.TERN_PROJECT, this.ESLINTRC, this.ESLINTRC_JS, this.ESLINTRC_JSON, this.ESLINTRC_YAML, this.ESLINTRC_YML];
82
        this.lintFiles = [this.ESLINTRC_JS, this.ESLINTRC_JSON, this.ESLINTRC, this.ESLINTRC_YAML, this.ESLINTRC_YML];
82
	}
83
	}
83
	/**
84
	/**
84
	 * The .tern-project file name
85
	 * The .tern-project file name
Lines 307-356 define([ Link Here
307
	 * @see http://eslint.org/docs/user-guide/configuring
308
	 * @see http://eslint.org/docs/user-guide/configuring
308
	 */
309
	 */
309
	JavaScriptProject.prototype.getESlintOptions = function getESlintOptions() {
310
	JavaScriptProject.prototype.getESlintOptions = function getESlintOptions() {
311
        var deferred = new Deferred();
310
		if(this.map.eslint) {
312
		if(this.map.eslint) {
311
			return new Deferred().resolve(this.map.eslint);
313
			return deferred.resolve(this.map.eslint);
312
		}
314
		}
313
		var vals;
315
        this.projectPromise.then(function() {
314
		return this.getFile(this.ESLINTRC_JS).then(function(file) {
316
            this.lintFiles.reduce(function(prev, next) {
315
			vals = readAndMap(this.map, file, "eslint");
317
                if(next === this.PACKAGE_JSON) {
316
			if(vals) {
318
                    return this.getFile(next).then(function(file) {
317
				return vals;
319
                        if(file && file.contents) {
318
			}
320
                            var vals = JSON.parse(file.contents);
319
			return this.getFile(this.ESLINTRC_JSON).then(function(file) {
321
                            if(vals.eslintConfig !== null && typeof vals.eslintConfig === 'object' && Object.keys(vals.eslintConfig).length > 0) {
320
				vals = readAndMap(this.map, file, "eslint");
322
                                this.map.eslint = vals.eslintConfig;
321
				if(vals) {
323
                                deferred.resolve(this.map.eslint);
322
					return vals;
324
                            }
323
				}
325
                        }
324
				return this.getFile(this.ESLINTRC).then(function(file) {
326
                        return null;
325
					vals = readAndMap(this.map, file, "eslint");
327
                    }.bind(this))
326
					if(vals) {
328
                }
327
						return vals;
329
                return this.getFile(next).then(function(file) {
328
					}
330
                    var vals = readAndMap(this.map, file, "eslint");
329
					return this.getFile(this.ESLINTRC_YAML).then(function(file) {
331
                    if(vals) {
330
						vals = readAndMap(this.map, file, "eslint");
332
                        deferred.resolve(vals);
331
						if (vals) {
333
                        throw new Error("stop");
332
							return vals;
334
                    }
333
						}
335
                }.bind(this));
334
						return this.getFile(this.ESLINTRC_YML).then(function(file) {
336
            }.bind(this) , new Deferred().resolve());
335
							vals = readAndMap(this.map, file, "eslint");
337
        }.bind(this));
336
							if (vals) {
338
        return deferred;
337
								return vals;
338
							}
339
							return this.getFile(this.PACKAGE_JSON).then(function(file) {
340
								if(file && file.contents) {
341
									vals = JSON.parse(file.contents);
342
									if(vals.eslintConfig !== null && typeof vals.eslintConfig === 'object' && Object.keys(vals.eslintConfig).length > 0) {
343
										this.map.eslint = vals.eslintConfig;
344
										return this.map.eslint;
345
									}
346
								}
347
								return null;
348
							}.bind(this));
349
						}.bind(this));
350
					}.bind(this));
351
				}.bind(this));
352
			}.bind(this));
353
		}.bind(this));
354
	};
339
	};
355
340
356
	/**
341
	/**
Lines 416-421 define([ Link Here
416
		initialized = true;
401
		initialized = true;
417
		var file = evnt.file;
402
		var file = evnt.file;
418
		resolveProject.call(this, file).then(function(project) {
403
		resolveProject.call(this, file).then(function(project) {
404
            this.projectPromise.resolve(project);
419
			if (project) {
405
			if (project) {
420
				if(!this.projectMeta || project.Location !== this.projectMeta.Location) {
406
				if(!this.projectMeta || project.Location !== this.projectMeta.Location) {
421
					this.projectMeta = project;
407
					this.projectMeta = project;
Lines 449-454 define([ Link Here
449
	 */
435
	 */
450
	function resolveProject(file) {
436
	function resolveProject(file) {
451
		var deferred = new Deferred();
437
		var deferred = new Deferred();
438
        this.projectPromise = new Deferred();
452
		if(file) {
439
		if(file) {
453
			if(this.projectMeta && file.Location && file.Location.startsWith(this.projectMeta.Location)) {
440
			if(this.projectMeta && file.Location && file.Location.startsWith(this.projectMeta.Location)) {
454
				deferred.resolve(this.projectMeta);
441
				deferred.resolve(this.projectMeta);
Lines 463-481 define([ Link Here
463
					var promises = [],
450
					var promises = [],
464
						prnt = parents[parents.length-1];
451
						prnt = parents[parents.length-1];
465
					this.projectFiles.forEach(function(_f) {
452
					this.projectFiles.forEach(function(_f) {
466
						promises.push(this.getFile(_f, prnt.Location));
453
						promises.push({f: _f, p: prnt.Location});
467
						promises.push(this.getFile(_f, "/file/"));
454
						promises.push({p: "/file/", f:_f});
468
					}.bind(this));
455
					}.bind(this));
469
					promises.reduce(/* @callback */ function(prev, item) {
456
					promises.reduce(/* @callback */ function(prev, item) {
470
						return prev.then(/* @callback */ function(value) {
457
                        return this.getFile(item.f, item.p).then(function(_file) {
471
							return item.then(function(_file) {
458
                            if(_file && _file.contents) {
472
								if(_file) {
459
                                deferred.resolve({Location: _file.project});
473
									deferred.resolve({Location: _file.project});
460
                                throw new Error("stop");
474
									throw new Error("stop");
461
                            }
475
								}
462
                        });
476
							});
463
					}.bind(this), new Deferred().resolve());
477
						});
478
					}, new Deferred().resolve());
479
				} else {
464
				} else {
480
					deferred.resolve(parents[parents.length-1]);
465
					deferred.resolve(parents[parents.length-1]);
481
				}
466
				}

Return to bug 511478