|
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, this.PACKAGE_JSON]; |
| 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 |
return; |
| 323 |
} |
325 |
} |
| 324 |
return this.getFile(this.ESLINTRC).then(function(file) { |
326 |
} |
| 325 |
vals = readAndMap(this.map, file, "eslint"); |
327 |
deferred.resolve(null); |
| 326 |
if(vals) { |
328 |
}.bind(this)) |
| 327 |
return vals; |
329 |
} |
| 328 |
} |
330 |
return this.getFile(next).then(function(file) { |
| 329 |
return this.getFile(this.ESLINTRC_YAML).then(function(file) { |
331 |
var vals = readAndMap(this.map, file, "eslint"); |
| 330 |
vals = readAndMap(this.map, file, "eslint"); |
332 |
if(vals) { |
| 331 |
if (vals) { |
333 |
deferred.resolve(vals); |
| 332 |
return vals; |
334 |
throw new Error("stop"); |
| 333 |
} |
335 |
} |
| 334 |
return this.getFile(this.ESLINTRC_YML).then(function(file) { |
336 |
}.bind(this)); |
| 335 |
vals = readAndMap(this.map, file, "eslint"); |
337 |
}.bind(this) , new Deferred().resolve()); |
| 336 |
if (vals) { |
338 |
}.bind(this)); |
| 337 |
return vals; |
339 |
return deferred; |
| 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 |
}; |
340 |
}; |
| 355 |
|
341 |
|
| 356 |
/** |
342 |
/** |
|
Lines 416-421
define([
Link Here
|
| 416 |
initialized = true; |
402 |
initialized = true; |
| 417 |
var file = evnt.file; |
403 |
var file = evnt.file; |
| 418 |
resolveProject.call(this, file).then(function(project) { |
404 |
resolveProject.call(this, file).then(function(project) { |
|
|
405 |
this.projectPromise.resolve(project); |
| 419 |
if (project) { |
406 |
if (project) { |
| 420 |
if(!this.projectMeta || project.Location !== this.projectMeta.Location) { |
407 |
if(!this.projectMeta || project.Location !== this.projectMeta.Location) { |
| 421 |
this.projectMeta = project; |
408 |
this.projectMeta = project; |
|
Lines 449-458
define([
Link Here
|
| 449 |
*/ |
436 |
*/ |
| 450 |
function resolveProject(file) { |
437 |
function resolveProject(file) { |
| 451 |
var deferred = new Deferred(); |
438 |
var deferred = new Deferred(); |
|
|
439 |
this.projectPromise = new Deferred(); |
| 452 |
if(file) { |
440 |
if(file) { |
| 453 |
if(this.projectMeta && file.Location && file.Location.startsWith(this.projectMeta.Location)) { |
441 |
var floc = file.Location ? file.Location : file.location; |
|
|
442 |
if(this.projectMeta && floc && floc.startsWith(this.projectMeta.Location)) { |
| 454 |
deferred.resolve(this.projectMeta); |
443 |
deferred.resolve(this.projectMeta); |
| 455 |
return; |
444 |
return deferred; |
| 456 |
} |
445 |
} |
| 457 |
var parents = file.parents ? file.parents : file.Parents; |
446 |
var parents = file.parents ? file.parents : file.Parents; |
| 458 |
if(!Array.isArray(parents) || parents.length < 1) { |
447 |
if(!Array.isArray(parents) || parents.length < 1) { |
|
Lines 463-481
define([
Link Here
|
| 463 |
var promises = [], |
452 |
var promises = [], |
| 464 |
prnt = parents[parents.length-1]; |
453 |
prnt = parents[parents.length-1]; |
| 465 |
this.projectFiles.forEach(function(_f) { |
454 |
this.projectFiles.forEach(function(_f) { |
| 466 |
promises.push(this.getFile(_f, prnt.Location)); |
455 |
promises.push({f: _f, p: prnt.Location}); |
| 467 |
promises.push(this.getFile(_f, "/file/")); |
456 |
promises.push({p: "/file/", f:_f}); |
| 468 |
}.bind(this)); |
457 |
}.bind(this)); |
| 469 |
promises.reduce(/* @callback */ function(prev, item) { |
458 |
promises.reduce(/* @callback */ function(prev, item) { |
| 470 |
return prev.then(/* @callback */ function(value) { |
459 |
return this.getFile(item.f, item.p).then(function(_file) { |
| 471 |
return item.then(function(_file) { |
460 |
if(_file && _file.contents) { |
| 472 |
if(_file) { |
461 |
deferred.resolve({Location: _file.project}); |
| 473 |
deferred.resolve({Location: _file.project}); |
462 |
throw new Error("stop"); |
| 474 |
throw new Error("stop"); |
463 |
} |
| 475 |
} |
464 |
}); |
| 476 |
}); |
465 |
}.bind(this), new Deferred().resolve()); |
| 477 |
}); |
|
|
| 478 |
}, new Deferred().resolve()); |
| 479 |
} else { |
466 |
} else { |
| 480 |
deferred.resolve(parents[parents.length-1]); |
467 |
deferred.resolve(parents[parents.length-1]); |
| 481 |
} |
468 |
} |