Skip to content

Commit 526aae9

Browse files
authored
ESLint: enable indent, multiline-ternary, operator-linebreak rules (#130)
Probably it will need some adjustment but at least indent rule is finally enabled.
1 parent 91714d5 commit 526aae9

File tree

116 files changed

+1995
-1817
lines changed

Some content is hidden

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

116 files changed

+1995
-1817
lines changed

.eslintrc.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,20 @@ module.exports = {
7777
"computed-property-spacing": "error",
7878
"eol-last": "error",
7979
"func-call-spacing": "error",
80-
"indent": ["warn", 4, { "SwitchCase": 1 }],
80+
"indent": ["error", 4, {
81+
"SwitchCase": 1,
82+
"VariableDeclarator": 1,
83+
"FunctionDeclaration": { "parameters": "first", body: 1 },
84+
"FunctionExpression": { "parameters": "first", body: 1 },
85+
"CallExpression": { "arguments": 1 },
86+
"ArrayExpression": 1,
87+
"ObjectExpression": 1,
88+
"ImportDeclaration": 1,
89+
"flatTernaryExpressions": false
90+
}],
8191
"key-spacing": ["off", { beforeColon: false, afterColon: true }],
8292
"max-len": ["off", 120],
93+
"multiline-ternary": ["error", "always-multiline"],
8394
"new-cap": ["off", {
8495
"capIsNewExceptions": [
8596
"$.Deferred",
@@ -95,6 +106,12 @@ module.exports = {
95106
"no-mixed-spaces-and-tabs": "error",
96107
"no-new-object": "error",
97108
"no-trailing-spaces": "error",
109+
"operator-linebreak": ["error", "after", {
110+
"overrides": {
111+
"?": "before",
112+
":": "before"
113+
}
114+
}],
98115
"quotes": ["error", "double", { "allowTemplateLiterals": true }],
99116
"semi-spacing": "error",
100117
"semi": "error",

app/xml-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
const xml2js = require("xml2js");
44

55
const xmlParser = new xml2js.Parser({
6-
trim: true,
7-
emptyTag: null,
8-
explicitArray: false
6+
trim: true,
7+
emptyTag: null,
8+
explicitArray: false
99
});
1010

1111
export function parseXml(xmlString: string) {

src/LiveDevelopment/Agents/DOMAgent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ define(function DOMAgent(require, exports, module) {
201201
}
202202
}
203203

204-
// WebInspector Event: DOM.documentUpdated
204+
// WebInspector Event: DOM.documentUpdated
205205
function _onDocumentUpdated(event, res) {
206206
// res = {}
207207
}

src/LiveDevelopment/Agents/DOMNode.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,12 @@ define(function DOMNodeModule(require, exports, module) {
440440
};
441441

442442

443-
/** Node Info ***********************************************************/
443+
/** Node Info ***********************************************************/
444444

445-
/** Test if the given location is inside this node
446-
* @param {integer} location
447-
* @param {boolean} also include children
448-
*/
445+
/** Test if the given location is inside this node
446+
* @param {integer} location
447+
* @param {boolean} also include children
448+
*/
449449
DOMNode.prototype.isAtLocation = function isAtLocation(location, includeChildren) {
450450
if (includeChildren === undefined) {
451451
includeChildren = true;

src/LiveDevelopment/Agents/RemoteFunctions.js

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ function RemoteFunctions(config, remoteWSPort) {
292292
}
293293

294294
var realElBorder = {
295-
right: elementStyling.getPropertyValue("border-right-width"),
296-
left: elementStyling.getPropertyValue("border-left-width"),
297-
top: elementStyling.getPropertyValue("border-top-width"),
298-
bottom: elementStyling.getPropertyValue("border-bottom-width")
295+
right: elementStyling.getPropertyValue("border-right-width"),
296+
left: elementStyling.getPropertyValue("border-left-width"),
297+
top: elementStyling.getPropertyValue("border-top-width"),
298+
bottom: elementStyling.getPropertyValue("border-bottom-width")
299299
};
300300

301301
var borderBox = elementStyling.boxSizing === "border-box";
@@ -320,58 +320,58 @@ function RemoteFunctions(config, remoteWSPort) {
320320
};
321321

322322
var drawPaddingRect = function(side) {
323-
var elStyling = {};
323+
var elStyling = {};
324324

325-
if (visualisations.horizontal.indexOf(side) >= 0) {
326-
elStyling["width"] = elementStyling.getPropertyValue("padding-" + side);
327-
elStyling["height"] = innerHeight + "px";
328-
elStyling["top"] = 0;
325+
if (visualisations.horizontal.indexOf(side) >= 0) {
326+
elStyling["width"] = elementStyling.getPropertyValue("padding-" + side);
327+
elStyling["height"] = innerHeight + "px";
328+
elStyling["top"] = 0;
329329

330-
if (borderBox) {
331-
elStyling["height"] = innerHeight - parseFloat(realElBorder.top) - parseFloat(realElBorder.bottom) + "px";
332-
}
330+
if (borderBox) {
331+
elStyling["height"] = innerHeight - parseFloat(realElBorder.top) - parseFloat(realElBorder.bottom) + "px";
332+
}
333333

334-
} else {
335-
elStyling["height"] = elementStyling.getPropertyValue("padding-" + side);
336-
elStyling["width"] = innerWidth + "px";
337-
elStyling["left"] = 0;
334+
} else {
335+
elStyling["height"] = elementStyling.getPropertyValue("padding-" + side);
336+
elStyling["width"] = innerWidth + "px";
337+
elStyling["left"] = 0;
338338

339-
if (borderBox) {
340-
elStyling["width"] = innerWidth - parseFloat(realElBorder.left) - parseFloat(realElBorder.right) + "px";
341-
}
342-
}
339+
if (borderBox) {
340+
elStyling["width"] = innerWidth - parseFloat(realElBorder.left) - parseFloat(realElBorder.right) + "px";
341+
}
342+
}
343343

344-
elStyling[side] = 0;
345-
elStyling["position"] = "absolute";
344+
elStyling[side] = 0;
345+
elStyling["position"] = "absolute";
346346

347-
return elStyling;
347+
return elStyling;
348348
};
349349

350-
var drawMarginRect = function(side) {
351-
var elStyling = {};
350+
var drawMarginRect = function(side) {
351+
var elStyling = {};
352352

353-
var margin = [];
354-
margin["right"] = parseFloat(elementStyling.getPropertyValue("margin-right"));
355-
margin["top"] = parseFloat(elementStyling.getPropertyValue("margin-top"));
356-
margin["bottom"] = parseFloat(elementStyling.getPropertyValue("margin-bottom"));
357-
margin["left"] = parseFloat(elementStyling.getPropertyValue("margin-left"));
353+
var margin = [];
354+
margin["right"] = parseFloat(elementStyling.getPropertyValue("margin-right"));
355+
margin["top"] = parseFloat(elementStyling.getPropertyValue("margin-top"));
356+
margin["bottom"] = parseFloat(elementStyling.getPropertyValue("margin-bottom"));
357+
margin["left"] = parseFloat(elementStyling.getPropertyValue("margin-left"));
358358

359-
if(visualisations["horizontal"].indexOf(side) >= 0) {
359+
if(visualisations["horizontal"].indexOf(side) >= 0) {
360360

361-
elStyling["width"] = elementStyling.getPropertyValue("margin-" + side);
362-
elStyling["height"] = outerHeight + margin["top"] + margin["bottom"] + "px";
363-
elStyling["top"] = "-" + (margin["top"] + parseFloat(realElBorder.top)) + "px";
364-
} else {
365-
elStyling["height"] = elementStyling.getPropertyValue("margin-" + side);
366-
elStyling["width"] = outerWidth + "px";
367-
elStyling["left"] = "-" + realElBorder.left;
368-
}
361+
elStyling["width"] = elementStyling.getPropertyValue("margin-" + side);
362+
elStyling["height"] = outerHeight + margin["top"] + margin["bottom"] + "px";
363+
elStyling["top"] = "-" + (margin["top"] + parseFloat(realElBorder.top)) + "px";
364+
} else {
365+
elStyling["height"] = elementStyling.getPropertyValue("margin-" + side);
366+
elStyling["width"] = outerWidth + "px";
367+
elStyling["left"] = "-" + realElBorder.left;
368+
}
369369

370-
elStyling[side] = "-" + (margin[side] + parseFloat(realElBorder[side])) + "px";
371-
elStyling["position"] = "absolute";
370+
elStyling[side] = "-" + (margin[side] + parseFloat(realElBorder[side])) + "px";
371+
elStyling["position"] = "absolute";
372372

373-
return elStyling;
374-
};
373+
return elStyling;
374+
};
375375

376376
var setVisibility = function (el) {
377377
if (
@@ -386,17 +386,17 @@ function RemoteFunctions(config, remoteWSPort) {
386386
};
387387

388388
var paddingVisualisations = [
389-
drawPaddingRect("top"),
390-
drawPaddingRect("right"),
391-
drawPaddingRect("bottom"),
392-
drawPaddingRect("left")
389+
drawPaddingRect("top"),
390+
drawPaddingRect("right"),
391+
drawPaddingRect("bottom"),
392+
drawPaddingRect("left")
393393
];
394394

395395
var marginVisualisations = [
396-
drawMarginRect("top"),
397-
drawMarginRect("right"),
398-
drawMarginRect("bottom"),
399-
drawMarginRect("left")
396+
drawMarginRect("top"),
397+
drawMarginRect("right"),
398+
drawMarginRect("bottom"),
399+
drawMarginRect("left")
400400
];
401401

402402
var setupVisualisations = function (arr, config) {
@@ -408,10 +408,10 @@ function RemoteFunctions(config, remoteWSPort) {
408408
arr[i]["transform"] = "none";
409409
var el = window.document.createElement("div"),
410410
styles = Object.assign(
411-
{},
412-
config,
413-
arr[i]
414-
);
411+
{},
412+
config,
413+
arr[i]
414+
);
415415

416416
_setStyleValues(styles, el.style);
417417

@@ -431,14 +431,14 @@ function RemoteFunctions(config, remoteWSPort) {
431431
highlight.className = HIGHLIGHT_CLASSNAME;
432432

433433
var el = element,
434-
offsetLeft = 0,
435-
offsetTop = 0;
434+
offsetLeft = 0,
435+
offsetTop = 0;
436436

437437
// Probably the easiest way to get elements position without including transform
438438
do {
439-
offsetLeft += el.offsetLeft;
440-
offsetTop += el.offsetTop;
441-
el = el.offsetParent;
439+
offsetLeft += el.offsetLeft;
440+
offsetTop += el.offsetTop;
441+
el = el.offsetParent;
442442
} while(el);
443443

444444
var stylesToSet = {

src/LiveDevelopment/Documents/HTMLDocument.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -334,21 +334,21 @@ define(function HTMLDocumentModule(require, exports, module) {
334334
});
335335
}
336336

337-
// var marker = HTMLInstrumentation._getMarkerAtDocumentPos(
338-
// this.editor,
339-
// editor.getCursorPos()
340-
// );
341-
//
342-
// if (marker && marker.tagID) {
343-
// var range = marker.find(),
344-
// text = marker.doc.getRange(range.from, range.to);
345-
//
346-
// // HACK maintain ID
347-
// text = text.replace(">", " data-brackets-id='" + marker.tagID + "'>");
348-
//
349-
// // FIXME incorrectly replaces body elements with content only, missing body element
350-
// RemoteAgent.remoteElement(marker.tagID).replaceWith(text);
351-
// }
337+
// var marker = HTMLInstrumentation._getMarkerAtDocumentPos(
338+
// this.editor,
339+
// editor.getCursorPos()
340+
// );
341+
//
342+
// if (marker && marker.tagID) {
343+
// var range = marker.find(),
344+
// text = marker.doc.getRange(range.from, range.to);
345+
//
346+
// // HACK maintain ID
347+
// text = text.replace(">", " data-brackets-id='" + marker.tagID + "'>");
348+
//
349+
// // FIXME incorrectly replaces body elements with content only, missing body element
350+
// RemoteAgent.remoteElement(marker.tagID).replaceWith(text);
351+
// }
352352

353353
// if (!this.editor) {
354354
// return;

src/LiveDevelopment/Inspector/Inspector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/*jslint forin: true */
2626
/*global FileError */
2727

28-
/**
28+
/**
2929
* Inspector manages the connection to Chrome/Chromium's remote debugger.
3030
* See inspector.html for the documentation of the remote debugger.
3131
*

src/LiveDevelopment/LiveDevMultiBrowser.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,10 @@ define(function (require, exports, module) {
455455
_server = null;
456456
}
457457
}
458-
//TODO: implement closeWindow together with launchers.
459-
// if (doCloseWindow) {
460-
//
461-
// }
458+
// TODO: implement closeWindow together with launchers.
459+
// if (doCloseWindow) {
460+
//
461+
// }
462462
_setStatus(STATUS_INACTIVE, reason || "explicit_close");
463463
}
464464

@@ -510,7 +510,7 @@ define(function (require, exports, module) {
510510
}
511511

512512

513-
/**
513+
/**
514514
* Launches the given URL in the default browser.
515515
* @param {string} url
516516
* TODO: launchers for multiple browsers

src/LiveDevelopment/MultiBrowserImpl/documents/LiveDocument.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ define(function (require, exports, module) {
150150
*/
151151
LiveDocument.prototype._onActiveEditorChange = function (event, newActive, oldActive) {
152152

153-
//FIXME: #7 prevents the page to be reloaded when editing JS files.
154-
// Temporarily disabling this code to make JS editing work.
155-
// this._detachFromEditor();
153+
// FIXME: #7 prevents the page to be reloaded when editing JS files.
154+
// Temporarily disabling this code to make JS editing work.
155+
// this._detachFromEditor();
156156

157157
if (newActive && newActive.document === this.doc) {
158158
this._attachToEditor(newActive);

src/LiveDevelopment/MultiBrowserImpl/documents/LiveHTMLDocument.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ define(function (require, exports, module) {
275275
return;
276276
};
277277

278-
/**
278+
/**
279279
* @private
280280
* Handles message Script.Removed from the browser.
281281
* @param {$.Event} event
@@ -286,7 +286,7 @@ define(function (require, exports, module) {
286286
return;
287287
};
288288

289-
/**
289+
/**
290290
* For the given path, check if the document is related to the live HTML document.
291291
* Related means that is an external Javascript or CSS file that is included as part of the DOM.
292292
* @param {String} fullPath.

src/LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ define(function (require, exports, module) {
112112
return markCache[mark.tagID];
113113
});
114114
marks.sort(function (mark1, mark2) {
115-
return (mark1.range.from.line === mark2.range.from.line ?
116-
mark1.range.from.ch - mark2.range.from.ch :
117-
mark1.range.from.line - mark2.range.from.line);
115+
return (mark1.range.from.line === mark2.range.from.line
116+
? mark1.range.from.ch - mark2.range.from.ch
117+
: mark1.range.from.line - mark2.range.from.line);
118118
});
119119

120120
return marks;
@@ -679,11 +679,12 @@ define(function (require, exports, module) {
679679
if (!_cachedValues.hasOwnProperty(doc.file.fullPath)) {
680680
// TODO: this doesn't seem to be correct any more. The DOM should never be "dirty" (i.e., out of sync
681681
// with the editor) unless the doc is invalid.
682-
// $(doc).on("change.htmlInstrumentation", function () {
683-
// if (_cachedValues[doc.file.fullPath]) {
684-
// _cachedValues[doc.file.fullPath].dirty = true;
685-
// }
686-
// });
682+
//
683+
// $(doc).on("change.htmlInstrumentation", function () {
684+
// if (_cachedValues[doc.file.fullPath]) {
685+
// _cachedValues[doc.file.fullPath].dirty = true;
686+
// }
687+
// });
687688

688689
// Assign to cache, but don't set a value yet
689690
_cachedValues[doc.file.fullPath] = null;

src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ define(function (require, exports, module) {
147147
return result.promise();
148148
}
149149

150-
/**
150+
/**
151151
* @private
152152
* Handles when a connection is made to the live development protocol handler.
153153
* Injects the RemoteFunctions script in order to provide highlighting and live DOM editing functionality.
@@ -275,7 +275,7 @@ define(function (require, exports, module) {
275275
);
276276
}
277277

278-
/**
278+
/**
279279
* Protocol method. Rretrieves the content of a given stylesheet (for unit testing)
280280
* @param {number|Array.<number>} clients A client ID or array of client IDs that should navigate to the given URL.
281281
* @param {string} url Absolute URL that identifies the stylesheet.

0 commit comments

Comments
 (0)