From 4df145f35b71db0fb8bee02a896c657bb0253290 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 10 Feb 2018 20:23:07 +0400 Subject: [PATCH] remove confusing globals from eslint config --- .eslintrc | 44 ++++++++++++++++++- plugins/c9.cli.sync/sync.js | 4 +- plugins/c9.core/ext.js | 2 + plugins/c9.core/http-xhr.js | 25 +++++------ plugins/c9.ide.behaviors/tabs.js | 1 - plugins/c9.ide.console/console_test.js | 2 +- .../jumptodef_test.js | 2 +- plugins/c9.ide.navigate/heap.js | 4 +- plugins/c9.ide.panels/panels_test.js | 4 +- plugins/c9.ide.run.build/gui_test.js | 2 +- plugins/c9.ide.scm/git.js | 2 +- plugins/c9.ide.upload/upload_manager_test.js | 2 +- plugins/c9.ide.welcome/welcome_test.js | 2 +- 13 files changed, 68 insertions(+), 28 deletions(-) diff --git a/.eslintrc b/.eslintrc index 1f8a62b4..3eda39b2 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,13 +3,44 @@ ecmaFeatures: env: node: true - browser: true amd: true builtin: true mocha: true jasmine: false es6: true +globals: + importScripts: true + document: true + window: true + location: true + navigator: true + console: true + Worker: true + postMessage: true + setTimeout: true + clearTimeout: true + setInterval: true + clearInterval: true + Blob: true + XMLHttpRequest: true + localStorage: true + requestAnimationFrame: true + KeyboardEvent: true + onload: true # for tests + btoa: true + atob: true + apf: true + alert: true + prompt: true + Image: true + URL: true + FileReader: true + FileReaderSync: true + WebSocket: true + sessionStorage: true + localStorage: true + plugins: - react @@ -103,3 +134,14 @@ rules: no-multi-spaces: 1 no-lone-blocks: 1 // valid-jsdoc: [1, { requireReturn: false, requireParamDescription: false, prefer: { "return": "return" } }] + no-empty: [1, {"allowEmptyCatch": true}] + no-useless-escape: [0] // broken for regexps + no-ex-assign: 0 + no-fallthrough: 0 + no-sparse-arrays: 0 + no-control-regex: 0 + no-unsafe-finally: 0 + no-mixed-spaces-and-tabs: 0 + no-constant-condition: [1, { "checkLoops": false }] + + \ No newline at end of file diff --git a/plugins/c9.cli.sync/sync.js b/plugins/c9.cli.sync/sync.js index c5bce607..ab2dc7fa 100755 --- a/plugins/c9.cli.sync/sync.js +++ b/plugins/c9.cli.sync/sync.js @@ -64,7 +64,7 @@ define(function(require, exports, module) { var targets = {}; function getWorkspace(wsname, callback) { - emit("connecting", { wspath: wspath }); + emit("connecting", { wsname: wsname }); workspace.connect(wsname, function(err, ws) { ws.setupSshConnection(function(err) { @@ -247,7 +247,7 @@ define(function(require, exports, module) { }); plugin.on("unload", function() { - loaded = false; + }); /***** Register and define API *****/ diff --git a/plugins/c9.core/ext.js b/plugins/c9.core/ext.js index 8e07a19f..1ffa0303 100644 --- a/plugins/c9.core/ext.js +++ b/plugins/c9.core/ext.js @@ -1,3 +1,4 @@ +/*global apf*/ define(function(require, exports, module) { main.consumes = ["app"]; main.provides = ["ext", "Plugin"]; @@ -157,6 +158,7 @@ define(function(require, exports, module) { } function unloadRemotePlugin(id, options, callback) { + var vfs = architectApp.services.vfs; if (typeof options == "function") { callback = options; options = {}; diff --git a/plugins/c9.core/http-xhr.js b/plugins/c9.core/http-xhr.js index 5293b99a..cbecccab 100644 --- a/plugins/c9.core/http-xhr.js +++ b/plugins/c9.core/http-xhr.js @@ -115,7 +115,7 @@ define(function(require, module, exports) { try { data = JSON.parse(data); } catch (e) { - return done(e); + return done(new Error("JSON parsing error")); } } @@ -131,17 +131,13 @@ define(function(require, module, exports) { }; xhr.onerror = function(e) { - if (typeof XMLHttpRequestProgressEvent == "function" && e instanceof XMLHttpRequestProgressEvent) { - // No useful information in this object. - // Possibly CORS error if code was 0. - var err = new Error("Failed to retrieve resource from " + parsedUrl.host); - err.cause = e; - err.code = e.target.status; - return done(err); - } - e.code = e.target.status; - done(e); - }; + // No useful information in this object. Possibly CORS error if code was 0. + var code = e.target.status; + var err = new Error("Failed to retrieve resource from " + parsedUrl.href + " with code " + code); + err.cause = e; + err.code = code; + return done(err); + }; var called = false; function done(err, data, res) { @@ -196,9 +192,10 @@ define(function(require, module, exports) { function parseHeaders(headerString) { return headerString - .split('\u000d\u000a') + .trim() // on ie11 header string can start with single \n + .split("\r\n") .reduce(function(headers, headerPair) { - var index = headerPair.indexOf('\u003a\u0020'); + var index = headerPair.indexOf(": "); if (index > 0) { var key = headerPair.substring(0, index).toLowerCase(); var val = headerPair.substring(index + 2); diff --git a/plugins/c9.ide.behaviors/tabs.js b/plugins/c9.ide.behaviors/tabs.js index 9299c88e..92018fe1 100644 --- a/plugins/c9.ide.behaviors/tabs.js +++ b/plugins/c9.ide.behaviors/tabs.js @@ -1680,7 +1680,6 @@ define(function(require, exports, module) { mnuContext = null; mnuEditors = null; mnuTabs = null; - accessedTab = null; paneList = null; accessedPane = null; cycleKeyPressed = null; diff --git a/plugins/c9.ide.console/console_test.js b/plugins/c9.ide.console/console_test.js index bdaf1da5..361b8fb8 100644 --- a/plugins/c9.ide.console/console_test.js +++ b/plugins/c9.ide.console/console_test.js @@ -1,4 +1,4 @@ -/*global describe it before after = */ +/*global describe it before after bar */ "use client"; diff --git a/plugins/c9.ide.language.javascript/jumptodef_test.js b/plugins/c9.ide.language.javascript/jumptodef_test.js index 9346a0f5..0504b37d 100644 --- a/plugins/c9.ide.language.javascript/jumptodef_test.js +++ b/plugins/c9.ide.language.javascript/jumptodef_test.js @@ -1,4 +1,4 @@ -/*global describe it before disabledFeatures*/ +/*global describe, it, before, disabledFeatures:true*/ "use client"; diff --git a/plugins/c9.ide.navigate/heap.js b/plugins/c9.ide.navigate/heap.js index 514039a0..b9fe7eb1 100755 --- a/plugins/c9.ide.navigate/heap.js +++ b/plugins/c9.ide.navigate/heap.js @@ -33,7 +33,7 @@ function Heap(param) { }; this.min = function() { - if (this.empty()) throw new Exception("Priority queue underflow"); + if (this.empty()) throw new Error("Priority queue underflow"); return this.pq[1]; }; @@ -43,7 +43,7 @@ function Heap(param) { }; this.pop = function() { - if (this.empty()) throw new Exception("Priority queue underflow"); + if (this.empty()) throw new Error("Priority queue underflow"); this.$exch(1, this.N); var min = this.pq.splice(this.pq.length - 1, 1)[0]; this.sink(1); diff --git a/plugins/c9.ide.panels/panels_test.js b/plugins/c9.ide.panels/panels_test.js index a9b1bed7..01802552 100644 --- a/plugins/c9.ide.panels/panels_test.js +++ b/plugins/c9.ide.panels/panels_test.js @@ -1,4 +1,4 @@ -/*global describe it before after bar bar2 */ +/*global describe it before after bar */ "use client"; @@ -43,7 +43,7 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], var layout = imports.layout; var emitter = require("events").EventEmitter; - + var bar2; var p = []; diff --git a/plugins/c9.ide.run.build/gui_test.js b/plugins/c9.ide.run.build/gui_test.js index a16a9ef9..acb1d7aa 100644 --- a/plugins/c9.ide.run.build/gui_test.js +++ b/plugins/c9.ide.run.build/gui_test.js @@ -1,4 +1,4 @@ -/*global describe it before after = */ +/*global describe it before after bar */ "use client"; diff --git a/plugins/c9.ide.scm/git.js b/plugins/c9.ide.scm/git.js index e65b616b..d39475d5 100644 --- a/plugins/c9.ide.scm/git.js +++ b/plugins/c9.ide.scm/git.js @@ -666,7 +666,7 @@ define(function(require, exports, module) { }, function(err, p) { if (err) return cb(err); - process = p.process; + var process = p.process; var stderr = ""; var stdout = ""; process.stdout.on("data", function(e) { diff --git a/plugins/c9.ide.upload/upload_manager_test.js b/plugins/c9.ide.upload/upload_manager_test.js index 43a4495f..b4d268c9 100644 --- a/plugins/c9.ide.upload/upload_manager_test.js +++ b/plugins/c9.ide.upload/upload_manager_test.js @@ -187,7 +187,7 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai) fileEntry.file(function(file) { file.entry = fileEntry; next(null, file); - }, onerror); + }, next); }; fileWriter.onerror = next; diff --git a/plugins/c9.ide.welcome/welcome_test.js b/plugins/c9.ide.welcome/welcome_test.js index 197a174b..68369e68 100644 --- a/plugins/c9.ide.welcome/welcome_test.js +++ b/plugins/c9.ide.welcome/welcome_test.js @@ -1,4 +1,4 @@ -/*global describe it before after */ +/*global describe it before after bar */ "use client";