Skip to content

Commit 91714d5

Browse files
authored
ESLint: enable more rules (#129)
no-else-return comma-spacing comma-style computed-property-spacing func-call-spacing semi-spacing
1 parent a47a3a0 commit 91714d5

File tree

91 files changed

+730
-610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+730
-610
lines changed

.eslintrc.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ module.exports = {
3333
"valid-typeof": "error",
3434
// http://eslint.org/docs/rules/#best-practices
3535
"curly": "error",
36-
"eqeqeq": ["error", "always", {"null": "ignore"}],
36+
"eqeqeq": ["error", "always", { "null": "ignore" }],
3737
"guard-for-in": "off",
3838
"no-caller": "error",
3939
"no-case-declarations": "error",
40-
"no-else-return": "warn",
40+
"no-else-return": ["error", { allowElseIf: false }],
4141
"no-empty-pattern": "error",
4242
"no-fallthrough": "error",
4343
"no-global-assign": "error",
@@ -63,7 +63,7 @@ module.exports = {
6363
"no-shadow-restricted-names": "error",
6464
"no-shadow": "warn",
6565
"no-undef": "error",
66-
"no-unused-vars": ["error", {"vars": "all", "args": "none"}],
66+
"no-unused-vars": ["error", { "vars": "all", "args": "none" }],
6767
"no-use-before-define": "off",
6868
// http://eslint.org/docs/rules/#nodejs-and-commonjs
6969
"no-new-require": "error",
@@ -72,11 +72,11 @@ module.exports = {
7272
"brace-style": ["error", "1tbs", { allowSingleLine: true }],
7373
"camelcase": "warn",
7474
"comma-dangle": "error",
75-
"comma-spacing": "warn",
76-
"comma-style": ["warn", "last"],
77-
"computed-property-spacing": "warn",
75+
"comma-spacing": "error",
76+
"comma-style": ["error", "last"],
77+
"computed-property-spacing": "error",
7878
"eol-last": "error",
79-
"func-call-spacing": "warn",
79+
"func-call-spacing": "error",
8080
"indent": ["warn", 4, { "SwitchCase": 1 }],
8181
"key-spacing": ["off", { beforeColon: false, afterColon: true }],
8282
"max-len": ["off", 120],
@@ -96,7 +96,7 @@ module.exports = {
9696
"no-new-object": "error",
9797
"no-trailing-spaces": "error",
9898
"quotes": ["error", "double", { "allowTemplateLiterals": true }],
99-
"semi-spacing": "warn",
99+
"semi-spacing": "error",
100100
"semi": "error",
101101
// https://eslint.org/docs/rules/#ecmascript-6
102102
"constructor-super": "error",

app/socket-server/BaseDomain.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ function cmdLoadDomainModulesFromPaths(paths: string[]): boolean {
4141
_domainManager.emitEvent("base", "newDomains");
4242
}
4343
return success;
44-
} else {
45-
return false;
4644
}
45+
46+
return false;
4747
}
4848

4949
/**

src/LiveDevelopment/Agents/RemoteFunctions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ function RemoteFunctions(config, remoteWSPort) {
6969
if (window.navigator.platform.substr(0, 3) === "Mac") {
7070
// Mac
7171
return event.metaKey;
72-
} else {
73-
// Windows
74-
return event.ctrlKey;
7572
}
73+
74+
// Windows
75+
return event.ctrlKey;
7676
}
7777

7878
// determine the color for a type

src/LiveDevelopment/LiveDevelopment.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -857,13 +857,13 @@ define(function LiveDevelopment(require, exports, module) {
857857
WebSocketTransport.closeWebSocketServer();
858858
if (_closeDeferred) {
859859
return _closeDeferred;
860-
} else {
861-
_closeDeferred = new $.Deferred();
862-
_closeDeferred.always(function () {
863-
_closeDeferred = null;
864-
});
865860
}
866861

862+
_closeDeferred = new $.Deferred();
863+
_closeDeferred.always(function () {
864+
_closeDeferred = null;
865+
});
866+
867867
var promise = _closeDeferred.promise();
868868

869869
/*
@@ -1338,12 +1338,12 @@ define(function LiveDevelopment(require, exports, module) {
13381338
// Return existing promise if it is still pending
13391339
if (_isPromisePending(_openDeferred)) {
13401340
return _openDeferred;
1341-
} else {
1342-
_openDeferred = new $.Deferred();
1343-
_openDeferred.always(function () {
1344-
_openDeferred = null;
1345-
});
13461341
}
1342+
1343+
_openDeferred = new $.Deferred();
1344+
_openDeferred.always(function () {
1345+
_openDeferred = null;
1346+
});
13471347
}
13481348

13491349
// Register user defined server provider and keep handlers for further clean-up

src/LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,12 +585,12 @@ define(function (require, exports, module) {
585585
// TODO: should we consider ripping through the dom and fixing up other offsets?
586586
result.dom.fullBuild = false;
587587
return { edits: result.edits };
588-
} else {
589-
if (cachedValue) {
590-
cachedValue.invalid = true;
591-
}
592-
return { errors: result.errors };
593588
}
589+
590+
if (cachedValue) {
591+
cachedValue.invalid = true;
592+
}
593+
return { errors: result.errors };
594594
}
595595

596596
/**
@@ -829,7 +829,9 @@ define(function (require, exports, module) {
829829
if (!dom) {
830830
console.error("Couldn't find the dom for " + editor.document.file.fullPath);
831831
return;
832-
} else if (!dom.fullBuild) {
832+
}
833+
834+
if (!dom.fullBuild) {
833835
console.error("Tried to mark text from a stale DOM for " + editor.document.file.fullPath);
834836
return;
835837
}

src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,9 @@ define(function (require, exports, module) {
306306
PerfUtils.addMeasurement(timerBuildPart); // use
307307
this._logError(token);
308308
return null;
309-
} else if (token.type === "opentagname") {
309+
}
310+
311+
if (token.type === "opentagname") {
310312
var newTagName = token.contents.toLowerCase(),
311313
newTag;
312314

@@ -457,15 +459,15 @@ define(function (require, exports, module) {
457459
PerfUtils.addMeasurement(timerBuildPart);
458460
this._logError(token);
459461
return null;
460-
} else {
461-
// Manually compute the position of the end of the text (we can't rely on the
462-
// tokenizer for this since it may not get to the very end)
463-
// TODO: should probably make the tokenizer get to the end...
464-
var lines = this.text.split("\n"),
465-
lastPos = {line: lines.length - 1, ch: lines[lines.length - 1].length};
466-
while (stack.length) {
467-
closeTag(this.text.length, lastPos);
468-
}
462+
}
463+
464+
// Manually compute the position of the end of the text (we can't rely on the
465+
// tokenizer for this since it may not get to the very end)
466+
// TODO: should probably make the tokenizer get to the end...
467+
var lines = this.text.split("\n"),
468+
lastPos = {line: lines.length - 1, ch: lines[lines.length - 1].length};
469+
while (stack.length) {
470+
closeTag(this.text.length, lastPos);
469471
}
470472
}
471473

src/LiveDevelopment/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ define(function main(require, exports, module) {
386386
config.remoteHighlight = prefs.get(PREF_REMOTEHIGHLIGHT);
387387

388388
if (LiveDevImpl && LiveDevImpl.status >= LiveDevImpl.STATUS_ACTIVE) {
389-
LiveDevImpl.agents.remote.call("updateConfig",JSON.stringify(config));
389+
LiveDevImpl.agents.remote.call("updateConfig", JSON.stringify(config));
390390
}
391391
});
392392

src/command/CommandManager.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ define(function (require, exports, module) {
9696
// If command does not return a promise, assume that it handled the
9797
// command and return a resolved promise
9898
return (new $.Deferred()).resolve().promise();
99-
} else {
100-
return result;
10199
}
100+
101+
return result;
102102
};
103103

104104
/**
@@ -286,9 +286,9 @@ define(function (require, exports, module) {
286286
}
287287

288288
return command.execute.apply(command, Array.prototype.slice.call(arguments, 1));
289-
} else {
290-
return (new $.Deferred()).reject().promise();
291289
}
290+
291+
return (new $.Deferred()).reject().promise();
292292
}
293293

294294
EventDispatcher.makeEventDispatcher(exports);

src/command/KeyBindingManager.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,11 @@ define(function (require, exports, module) {
437437
// by subtracting KeyEvent.DOM_VK_0 from keycode. ie. [48-57] --> [0-9]
438438
if (keycode >= KeyEvent.DOM_VK_0 && keycode <= KeyEvent.DOM_VK_9) {
439439
return String(keycode - KeyEvent.DOM_VK_0);
440+
}
441+
440442
// Do the same with the numpad numbers
441443
// by subtracting KeyEvent.DOM_VK_NUMPAD0 from keycode. ie. [96-105] --> [0-9]
442-
} else if (keycode >= KeyEvent.DOM_VK_NUMPAD0 && keycode <= KeyEvent.DOM_VK_NUMPAD9) {
444+
if (keycode >= KeyEvent.DOM_VK_NUMPAD0 && keycode <= KeyEvent.DOM_VK_NUMPAD9) {
443445
return String(keycode - KeyEvent.DOM_VK_NUMPAD0);
444446
}
445447

src/command/Menus.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ define(function (require, exports, module) {
430430

431431
return $relativeElement;
432432

433-
} else if (position && position !== FIRST && position !== LAST) {
433+
}
434+
435+
if (position && position !== FIRST && position !== LAST) {
434436
console.error("Bad Parameter in _getRelativeMenuItem(): relative position specified with no relativeID");
435437
return null;
436438
}

src/document/Document.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,14 @@ define(function (require, exports, module) {
305305
}
306306
}
307307
return codeMirrorText;
308+
}
308309

309-
} else {
310-
// Optimized path that doesn't require creating master editor
311-
if (useOriginalLineEndings) {
312-
return this._text;
313-
} else {
314-
return Document.normalizeText(this._text);
315-
}
310+
// Optimized path that doesn't require creating master editor
311+
if (useOriginalLineEndings) {
312+
return this._text;
316313
}
314+
315+
return Document.normalizeText(this._text);
317316
};
318317

319318
/** Normalizes line endings the same way CodeMirror would */
@@ -640,11 +639,13 @@ define(function (require, exports, module) {
640639
// doesn't really matter, as long as they sort out of the way of the real edits).
641640
if (!edit1) {
642641
return -1;
643-
} else if (!edit2) {
642+
}
643+
644+
if (!edit2) {
644645
return 1;
645-
} else {
646-
return CodeMirror.cmpPos(edit2.start, edit1.start);
647646
}
647+
648+
return CodeMirror.cmpPos(edit2.start, edit1.start);
648649
});
649650

650651
// Pull out the selections, in the same order as the edits.

src/document/DocumentCommandHandlers.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ define(function (require, exports, module) {
240240
// current project or the full absolute path if it's not in the project.
241241
if (doc.isUntitled()) {
242242
return fullPath.substring(fullPath.lastIndexOf("/") + 1);
243-
} else {
244-
return ProjectManager.makeProjectRelativeIfPossible(fullPath);
245243
}
244+
245+
return ProjectManager.makeProjectRelativeIfPossible(fullPath);
246246
}
247247

248248
/**
@@ -1028,9 +1028,9 @@ define(function (require, exports, module) {
10281028
}
10291029

10301030
return _doSaveAs(doc, settings);
1031-
} else {
1032-
return doSave(doc);
10331031
}
1032+
1033+
return doSave(doc);
10341034
}
10351035

10361036
return $.Deferred().reject().promise();
@@ -1075,11 +1075,11 @@ define(function (require, exports, module) {
10751075
}
10761076
});
10771077
return savePromise;
1078-
} else {
1079-
// workingset entry that was never actually opened - ignore
1080-
filesAfterSave.push(file);
1081-
return (new $.Deferred()).resolve().promise();
10821078
}
1079+
1080+
// workingset entry that was never actually opened - ignore
1081+
filesAfterSave.push(file);
1082+
return (new $.Deferred()).resolve().promise();
10831083
},
10841084
false // if any save fails, continue trying to save other files anyway; then reject at end
10851085
).then(function () {

0 commit comments

Comments
 (0)