From 8c29afbca6d02b1d576728f92187b6c9d45d579a Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Wed, 9 Dec 2015 01:48:19 +0100 Subject: [PATCH 1/2] chore(package): update grunt-jscs to version 2.5.0 http://greenkeeper.io/ --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2946b406..2f1be382 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,8 @@ "grunt-express": "1.4.1", "grunt-ghost": "1.1.0", "grunt-include-replace": "^3.2.0", - "grunt-jscs": "^1.6.0", - "grunt-karma": "^0.10.1", + "grunt-jscs": "^2.5.0", + "grunt-karma": "^0.12.1", "grunt-leading-indent": "^0.2.0", "grunt-node-webkit-builder": "^1.0.2", "grunt-open": "0.2.3", From 21d4857b74b92ae851a1290bd3f7a16313776572 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Wed, 9 Dec 2015 22:38:58 +0100 Subject: [PATCH 2/2] Update deps, use grunt-connect instead of express, fix jscs errors --- .jscsrc | 75 +++++++++++++++++++ Gruntfile.js | 52 +++++++------ package.json | 42 +++++------ src/js/app.js | 2 +- .../controller/CursorCoordinatesController.js | 10 ++- src/js/controller/PaletteController.js | 4 +- .../service/palette/PaletteImportService.js | 14 ++-- src/js/utils/PixelUtils.js | 6 +- src/js/utils/core.js | 8 +- src/js/widgets/ColorsList.js | 2 +- 10 files changed, 155 insertions(+), 60 deletions(-) create mode 100644 .jscsrc diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 00000000..83968614 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,75 @@ +{ + "requireCurlyBraces": [ + "if", + "else", + "for", + "while", + "do", + "try", + "catch" + ], + "requireOperatorBeforeLineBreak": true, + "requireCamelCaseOrUpperCaseIdentifiers": true, + "maximumLineLength": { + "value": 80, + "allExcept": ["comments", "regex"] + }, + "validateIndentation": 2, + "validateQuoteMarks": "'", + + "disallowMultipleLineStrings": true, + "disallowMixedSpacesAndTabs": true, + "disallowTrailingWhitespace": true, + "disallowSpaceAfterPrefixUnaryOperators": true, + "disallowMultipleVarDecl": true, + "disallowKeywordsOnNewLine": ["else"], + + "requireSpaceAfterKeywords": [ + "if", + "else", + "for", + "while", + "do", + "switch", + "return", + "try", + "catch" + ], + "requireSpaceBeforeBinaryOperators": [ + "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=", + "&=", "|=", "^=", "+=", + + "+", "-", "*", "/", "%", "<<", ">>", ">>>", "&", + "|", "^", "&&", "||", "===", "==", ">=", + "<=", "<", ">", "!=", "!==" + ], + "requireSpaceAfterBinaryOperators": true, + "requireSpacesInConditionalExpression": true, + "requireSpaceBeforeBlockStatements": true, + "requireSpacesInForStatement": true, + "requireLineFeedAtFileEnd": true, + "requireSpacesInFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "disallowSpacesInAnonymousFunctionExpression": { + "beforeOpeningRoundBrace": false + }, + "disallowSpacesInsideObjectBrackets": "all", + "disallowSpacesInsideArrayBrackets": "all", + "disallowSpacesInsideParentheses": true, + + "disallowMultipleLineBreaks": true, + "disallowNewlineBeforeBlockStatements": true, + "disallowKeywords": ["with"], + "disallowSpacesInFunctionExpression": null, + "disallowSpacesInFunctionDeclaration": null, + "disallowSpacesInCallExpression": true, + "disallowSpaceAfterObjectKeys": false, + "requireSpaceBeforeObjectValues": true, + "requireCapitalizedConstructors": true, + "requireDotNotation": true, + "requireSemicolons": true, + "validateParameterSeparator": ", ", + + "jsDoc": null +} \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index e5450997..d0f20f58 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,6 +3,14 @@ module.exports = function(grunt) { // Update this variable if you don't want or can't serve on localhost var hostname = 'localhost'; + var PORT = { + PROD : 9001, + DEV : 9901, + TEST : 9991 + }; + + var DEV_MODE = '?debug'; + // create a version based on the build timestamp var dateFormat = require('dateformat'); var version = '-' + dateFormat(new Date(), "yyyy-mm-dd-hh-MM"); @@ -34,8 +42,8 @@ module.exports = function(grunt) { filesSrc : tests, options : { args : { - baseUrl : 'http://' + host + ':' + '<%= express.test.options.port %>/', - mode : '?debug', + baseUrl : 'http://' + host + ':' + PORT.TEST, + mode : DEV_MODE, delay : delay }, async : false, @@ -47,16 +55,16 @@ module.exports = function(grunt) { }; }; - var getExpressConfig = function (sourceFolders, port, host) { - if (typeof sourceFolders === 'string') { - sourceFolders = [sourceFolders]; + var getConnectConfig = function (base, port, host) { + if (typeof base === 'string') { + base = [base]; } return { options: { port: port, hostname : host, - bases: sourceFolders + base: base } }; }; @@ -85,7 +93,7 @@ module.exports = function(grunt) { jscs : { options : { - "preset": "google", + "config": ".jscsrc", "maximumLineLength": 120, "requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties", "validateQuoteMarks": { "mark": "'", "escape": true }, @@ -116,18 +124,18 @@ module.exports = function(grunt) { * SERVERS, BROWSER LAUNCHERS */ - express: { - regular: getExpressConfig('dest/prod', 9001, hostname), - test: getExpressConfig(['dest/dev', 'test'], 9991, hostname), - debug: getExpressConfig(['dest/dev', 'test'], 9901, hostname) + connect: { + prod: getConnectConfig('dest/prod', PORT.PROD, hostname), + test: getConnectConfig(['dest/dev', 'test'], PORT.TEST, hostname), + dev: getConnectConfig(['dest/dev', 'test'], PORT.DEV, hostname) }, open : { - regular : { - path : 'http://' + hostname + ':9001/' + prod : { + path : 'http://' + hostname + ':' + PORT.PROD + '/' }, - debug : { - path : 'http://' + hostname + ':9901/?debug' + dev : { + path : 'http://' + hostname + ':' + PORT.DEV + '/' + DEV_MODE } }, @@ -297,10 +305,10 @@ module.exports = function(grunt) { grunt.registerTask('unit-test', ['karma']); // Validate & Test - grunt.registerTask('test-travis', ['lint', 'unit-test', 'build-dev', 'express:test', 'ghost:travis']); + grunt.registerTask('test-travis', ['lint', 'unit-test', 'build-dev', 'connect:test', 'ghost:travis']); // Validate & Test (faster version) will NOT work on travis !! - grunt.registerTask('test-local', ['lint', 'unit-test', 'build-dev', 'express:test', 'ghost:local']); - grunt.registerTask('test-local-nolint', ['unit-test', 'build-dev', 'express:test', 'ghost:local']); + grunt.registerTask('test-local', ['lint', 'unit-test', 'build-dev', 'connect:test', 'ghost:local']); + grunt.registerTask('test-local-nolint', ['unit-test', 'build-dev', 'connect:test', 'ghost:local']); grunt.registerTask('test', ['test-travis']); grunt.registerTask('precommit', ['test-local']); @@ -318,8 +326,10 @@ module.exports = function(grunt) { grunt.registerTask('desktop-mac', ['clean:desktop', 'default', 'nodewebkit:macos']); // Start webserver and watch for changes - grunt.registerTask('serve', ['build', 'express:regular', 'open:regular', 'watch:prod']); + grunt.registerTask('serve', ['build', 'connect:prod', 'open:prod', 'watch:prod']); // Start webserver on src folder, in debug mode - grunt.registerTask('serve-debug', ['build-dev', 'express:debug', 'open:debug', 'watch:dev']); - grunt.registerTask('play', ['serve-debug']); + grunt.registerTask('serve-dev', ['build-dev', 'connect:dev', 'open:dev', 'watch:dev']); + + grunt.registerTask('serve-debug', ['serve-dev']); + grunt.registerTask('play', ['serve-dev']); }; diff --git a/package.json b/package.json index 2f1be382..f1215717 100644 --- a/package.json +++ b/package.json @@ -14,30 +14,30 @@ "start": "nodewebkit" }, "devDependencies": { - "dateformat": "^1.0.11", - "grunt": "~0.4.5", - "grunt-contrib-clean": "^0.6.0", - "grunt-contrib-concat": "^0.5.1", - "grunt-contrib-copy": "^0.8.0", - "grunt-contrib-jshint": "^0.11.1", - "grunt-contrib-uglify": "^0.9.1", + "dateformat": "1.0.11", + "grunt": "0.4.5", + "grunt-contrib-clean": "0.7.0", + "grunt-contrib-concat": "0.5.1", + "grunt-contrib-connect": "0.11.2", + "grunt-contrib-copy": "0.8.0", + "grunt-contrib-jshint": "0.11.1", + "grunt-contrib-uglify": "0.11.0", "grunt-contrib-watch": "0.6.1", - "grunt-express": "1.4.1", "grunt-ghost": "1.1.0", - "grunt-include-replace": "^3.2.0", - "grunt-jscs": "^2.5.0", - "grunt-karma": "^0.12.1", - "grunt-leading-indent": "^0.2.0", - "grunt-node-webkit-builder": "^1.0.2", + "grunt-include-replace": "3.2.0", + "grunt-jscs": "2.5.0", + "grunt-karma": "0.12.1", + "grunt-leading-indent": "0.2.0", + "grunt-node-webkit-builder": "1.0.2", "grunt-open": "0.2.3", - "grunt-replace": "^0.8.0", - "grunt-spritesmith": "^6.1.0", - "jasmine-core": "^2.1.0", - "karma": "0.12.31", - "karma-chrome-launcher": "^0.1.4", - "karma-jasmine": "^0.3.5", - "karma-phantomjs-launcher": "^0.1.4", - "load-grunt-tasks": "^3.1.0" + "grunt-replace": "0.11.0", + "grunt-spritesmith": "6.1.0", + "jasmine-core": "2.1.0", + "karma": "0.13.15", + "karma-chrome-launcher": "0.2.2", + "karma-jasmine": "0.3.5", + "karma-phantomjs-launcher": "0.1.4", + "load-grunt-tasks": "3.1.0" }, "window": { "title": "Piskel", diff --git a/src/js/app.js b/src/js/app.js index 6c7985a8..a410009f 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -167,7 +167,7 @@ if (pskl.utils.Environment.detectNodeWebkit() && pskl.utils.UserAgent.isMac) { var gui = require('nw.gui'); - var mb = new gui.Menu({type:'menubar'}); + var mb = new gui.Menu({type : 'menubar'}); mb.createMacBuiltin('Piskel'); gui.Window.get().menu = mb; } diff --git a/src/js/controller/CursorCoordinatesController.js b/src/js/controller/CursorCoordinatesController.js index 952db3ae..6e494ec2 100644 --- a/src/js/controller/CursorCoordinatesController.js +++ b/src/js/controller/CursorCoordinatesController.js @@ -49,12 +49,18 @@ }; ns.CursorCoordinatesController.prototype.onCursorMoved_ = function (event, x, y) { - this.coordinates = {x:x, y:y}; + this.coordinates = { + x : x, + y : y + }; this.redraw(); }; ns.CursorCoordinatesController.prototype.onDragStart_ = function (event, x, y) { - this.origin = {x:x, y:y}; + this.origin = { + x : x, + y : y + }; this.redraw(); }; diff --git a/src/js/controller/PaletteController.js b/src/js/controller/PaletteController.js index 3cdda4bc..9bc45fff 100644 --- a/src/js/controller/PaletteController.js +++ b/src/js/controller/PaletteController.js @@ -7,8 +7,8 @@ * @public */ ns.PaletteController.prototype.init = function() { - $.subscribe(Events.SELECT_PRIMARY_COLOR, this.onColorSelected_.bind(this, {isPrimary:true})); - $.subscribe(Events.SELECT_SECONDARY_COLOR, this.onColorSelected_.bind(this, {isPrimary:false})); + $.subscribe(Events.SELECT_PRIMARY_COLOR, this.onColorSelected_.bind(this, {isPrimary : true})); + $.subscribe(Events.SELECT_SECONDARY_COLOR, this.onColorSelected_.bind(this, {isPrimary : false})); var shortcuts = pskl.service.keyboard.Shortcuts; pskl.app.shortcutService.registerShortcut(shortcuts.COLOR.SWAP, this.swapColors.bind(this)); diff --git a/src/js/service/palette/PaletteImportService.js b/src/js/service/palette/PaletteImportService.js index e723c1da..3e81e935 100644 --- a/src/js/service/palette/PaletteImportService.js +++ b/src/js/service/palette/PaletteImportService.js @@ -24,23 +24,23 @@ }; ns.PaletteImportService.prototype.getReader_ = function (file, onSuccess, onError) { - var readerClass = this.getReaderClass_(file); - if (readerClass) { - return new readerClass(file, onSuccess, onError); + var ReaderClass = this.getReaderClass_(file); + if (ReaderClass) { + return new ReaderClass(file, onSuccess, onError); } else { return null; } }; ns.PaletteImportService.prototype.getReaderClass_ = function (file) { - var readerClass; + var ReaderClass; if (this.isImage_(file)) { - readerClass = fileReaders.img; + ReaderClass = fileReaders.img; } else { var extension = this.getExtension_(file); - readerClass = fileReaders[extension]; + ReaderClass = fileReaders[extension]; } - return readerClass; + return ReaderClass; }; ns.PaletteImportService.prototype.getExtension_ = function (file) { diff --git a/src/js/utils/PixelUtils.js b/src/js/utils/PixelUtils.js index 92d4232a..c67c5d49 100644 --- a/src/js/utils/PixelUtils.js +++ b/src/js/utils/PixelUtils.js @@ -157,7 +157,11 @@ return; } - var paintedPixels = pskl.PixelUtils.visitConnectedPixels({col:col, row:row}, frame, function (pixel) { + var startPixel = { + col : col, + row : row + }; + var paintedPixels = pskl.PixelUtils.visitConnectedPixels(startPixel, frame, function (pixel) { if (frame.containsPixel(pixel.col, pixel.row) && frame.getPixel(pixel.col, pixel.row) == targetColor) { frame.setPixel(pixel.col, pixel.row, replacementColor); return true; diff --git a/src/js/utils/core.js b/src/js/utils/core.js index b996e4ac..7525d013 100644 --- a/src/js/utils/core.js +++ b/src/js/utils/core.js @@ -25,14 +25,14 @@ if (!Function.prototype.bind) { var bindArgs = Array.prototype.slice.call(arguments, 1); var fToBind = this; - var fNOP = function () {}; + var FNOP = function () {}; var fBound = function () { var args = bindArgs.concat(Array.prototype.slice.call(arguments)); - return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, args); + return fToBind.apply(this instanceof FNOP && oThis ? this : oThis, args); }; - fNOP.prototype = this.prototype; - fBound.prototype = new fNOP(); + FNOP.prototype = this.prototype; + fBound.prototype = new FNOP(); return fBound; }; diff --git a/src/js/widgets/ColorsList.js b/src/js/widgets/ColorsList.js index e5041d6e..97a62cbe 100644 --- a/src/js/widgets/ColorsList.js +++ b/src/js/widgets/ColorsList.js @@ -105,7 +105,7 @@ var isSelected = (index === this.selectedIndex); html += pskl.utils.Template.replace(tpl, { - 'color' : color, index:index, + 'color' : color, index : index, ':selected' : isSelected, ':light-color' : this.isLight_(color) });