From 6fc5c166daa7008668061b8c72cdfe9c80d03721 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Wed, 12 Oct 2016 13:26:16 -0500 Subject: [PATCH] Lint fixes --- Makefile | 7 +++++-- app.js | 10 +++++----- lib/asm.js | 7 +++---- lib/compile.js | 6 +++--- lib/diff.js | 3 ++- package.json | 3 ++- static/compiler.js | 8 ++++---- static/editor.js | 4 ++-- static/rison.js | 2 +- 9 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index c79a899a..93e34cf9 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ endif endif .PHONY: clean run test run-amazon c-preload optional-d-support prereqs node_modules bower_modules -.PHONY: dist +.PHONY: dist lint prereqs: optional-d-support node_modules c-preload bower_modules ifeq "" "$(shell which gdc)" @@ -39,12 +39,15 @@ $(BOWER_MODULES): bower.json $(NODE_MODULES) $(NODE) ./node_modules/bower/bin/bower install @touch $@ +lint: $(NODE_MODULES) + $(NODE) ./node_modules/.bin/jshint app.js $(shell find lib static -name '*.js' -not -path 'static/ext/*') + LANG:=C++ node_modules: $(NODE_MODULES) bower_modules: $(BOWER_MODULES) -test: +test: $(NODE_MODULES) lint (cd test; $(NODE) test.js) $(MAKE) -C c-preload test @echo Tests pass diff --git a/app.js b/app.js index f9b5102d..5a20fbcd 100755 --- a/app.js +++ b/app.js @@ -169,7 +169,7 @@ function ClientOptionsHandler(fileSources) { environment: env }; text = JSON.stringify(options); - } + }; this.handler = function getClientOptions(req, res) { res.set('Content-Type', 'application/json'); res.set('Cache-Control', 'public, max-age=' + staticMaxAgeMs); @@ -422,8 +422,8 @@ function shortUrlHandler(req, res, next) { var bits = req.url.split("/"); if (bits.length !== 2 || req.method !== "GET") return next(); var key = process.env.GOOGLE_API_KEY; - var googleApiUrl = 'https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/' - + encodeURIComponent(bits[1]) + '&key=' + key; + var googleApiUrl = 'https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/' + + encodeURIComponent(bits[1]) + '&key=' + key; https.get(googleApiUrl, function (response) { var responseText = ''; response.on('data', function (d) { @@ -431,8 +431,8 @@ function shortUrlHandler(req, res, next) { }); response.on('end', function () { if (response.statusCode != 200) { - console.log("Failed to resolve short URL " + bits[1] + " - got response " - + response.statusCode + " : " + responseText); + console.log("Failed to resolve short URL " + bits[1] + " - got response " + + response.statusCode + " : " + responseText); return next(); } diff --git a/lib/asm.js b/lib/asm.js index b054427a..f5d3b454 100644 --- a/lib/asm.js +++ b/lib/asm.js @@ -82,19 +82,18 @@ // Now follow the chains of used labels, marking any weak references they refer // to as also used. We iteratively do this until either no new labels are found, // or we hit a limit (only here to prevent a pathological case from hanging). + function markUsed(label) { labelsUsed[label] = true; } var MaxLabelIterations = 10; for (var iter = 0; iter < MaxLabelIterations; ++iter) { var toAdd = []; - _.each(labelsUsed, function (t, label) { + _.each(labelsUsed, function (t, label) { // jshint ignore:line _.each(weakUsages[label], function (nowused) { if (labelsUsed[nowused]) return; toAdd.push(nowused); }); }); if (!toAdd) break; - _.each(toAdd, function (label) { - labelsUsed[label] = true; - }); + _.each(toAdd, markUsed); } return labelsUsed; } diff --git a/lib/compile.js b/lib/compile.js index b9320752..09fccc45 100644 --- a/lib/compile.js +++ b/lib/compile.js @@ -28,7 +28,7 @@ var child_process = require('child_process'), httpProxy = require('http-proxy'), LRU = require('lru-cache'), fs = require('fs-extra'), - Promise = require('promise'), + Promise = require('promise'), // jshint ignore:line Queue = require('promise-queue'), asm = require('./asm'); @@ -48,7 +48,7 @@ var stubText = null; function identity(x) { return x; -}; +} function initialise(gccProps_, compilerProps_) { gccProps = gccProps_; @@ -403,7 +403,7 @@ function CompileHandler() { if (source === undefined) { return next(new Error("Bad request")); } - var options = req.body.options.split(' ').filter(identity); + options = req.body.options.split(' ').filter(identity); var filters = req.body.filters; compileObj.compile(source, compiler, options, filters).then( function (result) { diff --git a/lib/diff.js b/lib/diff.js index bf31673c..f78e3234 100644 --- a/lib/diff.js +++ b/lib/diff.js @@ -2,7 +2,8 @@ var fs = require('fs'), child_process = require('child_process'), temp = require('temp'), path = require('path'), - Promise = require('promise'); + Promise = require('promise') // jshint ignore:line + ; function cleanAndGetIndexes(text) { var addRules = { diff --git a/package.json b/package.json index 02f45165..8f6cf518 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "devDependencies": { "supervisor": "*", "bower": "*", - "requirejs": "*" + "requirejs": "*", + "jshint": "*" }, "scripts": { "test": "make test" diff --git a/static/compiler.js b/static/compiler.js index 86c0f7bd..455b4510 100644 --- a/static/compiler.js +++ b/static/compiler.js @@ -117,8 +117,8 @@ define(function (require) { }, this); this.container.layoutManager.createDragSource(this.domRoot.find(".status").parent(), outputConfig); this.domRoot.find(".status").parent().click(_.bind(function () { - var insertPoint = hub.findParentRowOrColumn(this.container) - || this.container.layoutManager.root.contentItems[0]; + var insertPoint = hub.findParentRowOrColumn(this.container) || + this.container.layoutManager.root.contentItems[0]; insertPoint.addChild(outputConfig()); }, this)); @@ -133,8 +133,8 @@ define(function (require) { this.container.layoutManager.createDragSource( this.domRoot.find('.btn.add-compiler'), cloneComponent); this.domRoot.find('.btn.add-compiler').click(_.bind(function () { - var insertPoint = hub.findParentRowOrColumn(this.container) - || this.container.layoutManager.root.contentItems[0]; + var insertPoint = hub.findParentRowOrColumn(this.container) || + this.container.layoutManager.root.contentItems[0]; insertPoint.addChild(cloneComponent()); }, this)); } diff --git a/static/editor.js b/static/editor.js index 9d569acd..0b72ba40 100644 --- a/static/editor.js +++ b/static/editor.js @@ -164,8 +164,8 @@ define(function (require) { this.container.layoutManager.createDragSource( this.domRoot.find('.btn.add-compiler'), compilerConfig); this.domRoot.find('.btn.add-compiler').click(_.bind(function () { - var insertPoint = hub.findParentRowOrColumn(this.container) - || this.container.layoutManager.root.contentItems[0]; + var insertPoint = hub.findParentRowOrColumn(this.container) || + this.container.layoutManager.root.contentItems[0]; insertPoint.addChild(compilerConfig); }, this)); } diff --git a/static/rison.js b/static/rison.js index 205f6463..76390b06 100644 --- a/static/rison.js +++ b/static/rison.js @@ -1,5 +1,5 @@ // Taken from https://github.com/Nanonid/rison at 917679fb6cafa15e2a186cd5a47163792899b321 - +/* jshint ignore:start */ // Uses CommonJS, AMD or browser globals to create a module. // Based on: https://github.com/umdjs/umd/blob/master/commonjsStrict.js (function (root, factory) {