[PATCH 1 of 2] hgweb: fix jshint issues in mercurial.js

Anton Shestakov av6 at dwimlabs.net
Sat Nov 11 02:40:35 EST 2017


# HG changeset patch
# User Anton Shestakov <av6 at dwimlabs.net>
# Date 1510380878 -28800
#      Sat Nov 11 14:14:38 2017 +0800
# Node ID 36e26161d81233a8ef18e40b4198d86b23113159
# Parent  981d7ebd7dc74a88493f39982649a52ed09a199b
hgweb: fix jshint issues in mercurial.js

Everything is pretty self-explanatory except the last hunk, where jshint
complains: "Misleading line break before '||'; readers may interpret this as an
expression boundary."

There is a tweakable called "laxbreak" that allows line breaks before
operators, but I think it's fine to simply join this one line and avoid extra
config for now (we can cook up and add a sensible .jshintrc later).

diff --git a/mercurial/templates/static/mercurial.js b/mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js
+++ b/mercurial/templates/static/mercurial.js
@@ -42,13 +42,13 @@ function Graph() {
 		this.columns = 0;
 		document.getElementById('nodebgs').innerHTML = '';
 		document.getElementById('graphnodes').innerHTML = '';
-	}
+	};
 
 	this.scale = function(height) {
 		this.bg_height = height;
 		this.box_size = Math.floor(this.bg_height / 1.2);
 		this.cell_height = this.box_size;
-	}
+	};
 
 	this.setColor = function(color, bg, fg) {
 
@@ -78,7 +78,7 @@ function Graph() {
 		this.ctx.fillStyle = s;
 		return s;
 
-	}
+	};
 
 	this.edge = function(x0, y0, x1, y1, color, width) {
 
@@ -90,7 +90,7 @@ function Graph() {
 		this.ctx.lineTo(x1, y1);
 		this.ctx.stroke();
 
-	}
+	};
 
 	this.render = function(data) {
 
@@ -127,7 +127,7 @@ function Graph() {
 				}
 
 				if (start == this.columns && start > end) {
-					var fold = true;
+					fold = true;
 				}
 
 				x0 = this.cell[0] + this.box_size * start + this.box_size / 2;
@@ -142,8 +142,8 @@ function Graph() {
 
 			// Draw the revision node in the right column
 
-			column = node[0]
-			color = node[1]
+			column = node[0];
+			color = node[1];
 
 			radius = this.box_size / 8;
 			x = this.cell[0] + this.box_size * column + this.box_size / 2;
@@ -159,7 +159,7 @@ function Graph() {
 		document.getElementById('nodebgs').innerHTML += backgrounds;
 		document.getElementById('graphnodes').innerHTML += nodedata;
 
-	}
+	};
 
 }
 
@@ -228,7 +228,7 @@ function process_dates(parentSelector){
 			return shortdate(once);
 		}
 
-		for (unit in scales){
+		for (var unit in scales){
 			var s = scales[unit];
 			var n = Math.floor(delta / s);
 			if ((n >= 2) || (s == 1)){
@@ -273,7 +273,8 @@ function toggleLinewrap() {
 
     function setLinewrap(enable) {
         var nodes = document.getElementsByClassName('sourcelines');
-        for (var i = 0; i < nodes.length; i++) {
+        var i;
+        for (i = 0; i < nodes.length; i++) {
             if (enable) {
                 nodes[i].classList.add('wrap');
             } else {
@@ -282,7 +283,7 @@ function toggleLinewrap() {
         }
 
         var links = document.getElementsByClassName('linewraplink');
-        for (var i = 0; i < links.length; i++) {
+        for (i = 0; i < links.length; i++) {
             links[i].innerHTML = enable ? 'on' : 'off';
         }
     }
@@ -354,8 +355,7 @@ function ajaxScrollInit(urlFormat,
 
         var scrollHeight = document.documentElement.scrollHeight;
         var clientHeight = document.documentElement.clientHeight;
-        var scrollTop = document.body.scrollTop
-            || document.documentElement.scrollTop;
+        var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
 
         if (scrollHeight - (scrollTop + clientHeight) < 50) {
             updateInitiated = true;


More information about the Mercurial-devel mailing list