Merge pull request #365 from juliandescottes/greenkeeper-grunt-jscs-2.5.0

grunt-jscs@2.5.0 breaks build ⚠️
This commit is contained in:
Julian Descottes 2015-12-09 22:44:08 +01:00
commit 22e876c844
10 changed files with 155 additions and 60 deletions

75
.jscsrc Normal file
View File

@ -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
}

View File

@ -3,6 +3,14 @@ module.exports = function(grunt) {
// Update this variable if you don't want or can't serve on localhost // Update this variable if you don't want or can't serve on localhost
var hostname = 'localhost'; var hostname = 'localhost';
var PORT = {
PROD : 9001,
DEV : 9901,
TEST : 9991
};
var DEV_MODE = '?debug';
// create a version based on the build timestamp // create a version based on the build timestamp
var dateFormat = require('dateformat'); var dateFormat = require('dateformat');
var version = '-' + dateFormat(new Date(), "yyyy-mm-dd-hh-MM"); var version = '-' + dateFormat(new Date(), "yyyy-mm-dd-hh-MM");
@ -34,8 +42,8 @@ module.exports = function(grunt) {
filesSrc : tests, filesSrc : tests,
options : { options : {
args : { args : {
baseUrl : 'http://' + host + ':' + '<%= express.test.options.port %>/', baseUrl : 'http://' + host + ':' + PORT.TEST,
mode : '?debug', mode : DEV_MODE,
delay : delay delay : delay
}, },
async : false, async : false,
@ -47,16 +55,16 @@ module.exports = function(grunt) {
}; };
}; };
var getExpressConfig = function (sourceFolders, port, host) { var getConnectConfig = function (base, port, host) {
if (typeof sourceFolders === 'string') { if (typeof base === 'string') {
sourceFolders = [sourceFolders]; base = [base];
} }
return { return {
options: { options: {
port: port, port: port,
hostname : host, hostname : host,
bases: sourceFolders base: base
} }
}; };
}; };
@ -85,7 +93,7 @@ module.exports = function(grunt) {
jscs : { jscs : {
options : { options : {
"preset": "google", "config": ".jscsrc",
"maximumLineLength": 120, "maximumLineLength": 120,
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties", "requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
"validateQuoteMarks": { "mark": "'", "escape": true }, "validateQuoteMarks": { "mark": "'", "escape": true },
@ -116,18 +124,18 @@ module.exports = function(grunt) {
* SERVERS, BROWSER LAUNCHERS * SERVERS, BROWSER LAUNCHERS
*/ */
express: { connect: {
regular: getExpressConfig('dest/prod', 9001, hostname), prod: getConnectConfig('dest/prod', PORT.PROD, hostname),
test: getExpressConfig(['dest/dev', 'test'], 9991, hostname), test: getConnectConfig(['dest/dev', 'test'], PORT.TEST, hostname),
debug: getExpressConfig(['dest/dev', 'test'], 9901, hostname) dev: getConnectConfig(['dest/dev', 'test'], PORT.DEV, hostname)
}, },
open : { open : {
regular : { prod : {
path : 'http://' + hostname + ':9001/' path : 'http://' + hostname + ':' + PORT.PROD + '/'
}, },
debug : { dev : {
path : 'http://' + hostname + ':9901/?debug' path : 'http://' + hostname + ':' + PORT.DEV + '/' + DEV_MODE
} }
}, },
@ -297,10 +305,10 @@ module.exports = function(grunt) {
grunt.registerTask('unit-test', ['karma']); grunt.registerTask('unit-test', ['karma']);
// Validate & Test // 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 !! // 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', ['lint', 'unit-test', 'build-dev', 'connect:test', 'ghost:local']);
grunt.registerTask('test-local-nolint', ['unit-test', 'build-dev', 'express:test', 'ghost:local']); grunt.registerTask('test-local-nolint', ['unit-test', 'build-dev', 'connect:test', 'ghost:local']);
grunt.registerTask('test', ['test-travis']); grunt.registerTask('test', ['test-travis']);
grunt.registerTask('precommit', ['test-local']); grunt.registerTask('precommit', ['test-local']);
@ -318,8 +326,10 @@ module.exports = function(grunt) {
grunt.registerTask('desktop-mac', ['clean:desktop', 'default', 'nodewebkit:macos']); grunt.registerTask('desktop-mac', ['clean:desktop', 'default', 'nodewebkit:macos']);
// Start webserver and watch for changes // 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 // Start webserver on src folder, in debug mode
grunt.registerTask('serve-debug', ['build-dev', 'express:debug', 'open:debug', 'watch:dev']); grunt.registerTask('serve-dev', ['build-dev', 'connect:dev', 'open:dev', 'watch:dev']);
grunt.registerTask('play', ['serve-debug']);
grunt.registerTask('serve-debug', ['serve-dev']);
grunt.registerTask('play', ['serve-dev']);
}; };

View File

@ -14,30 +14,30 @@
"start": "nodewebkit" "start": "nodewebkit"
}, },
"devDependencies": { "devDependencies": {
"dateformat": "^1.0.11", "dateformat": "1.0.11",
"grunt": "~0.4.5", "grunt": "0.4.5",
"grunt-contrib-clean": "^0.6.0", "grunt-contrib-clean": "0.7.0",
"grunt-contrib-concat": "^0.5.1", "grunt-contrib-concat": "0.5.1",
"grunt-contrib-copy": "^0.8.0", "grunt-contrib-connect": "0.11.2",
"grunt-contrib-jshint": "^0.11.1", "grunt-contrib-copy": "0.8.0",
"grunt-contrib-uglify": "^0.9.1", "grunt-contrib-jshint": "0.11.1",
"grunt-contrib-uglify": "0.11.0",
"grunt-contrib-watch": "0.6.1", "grunt-contrib-watch": "0.6.1",
"grunt-express": "1.4.1",
"grunt-ghost": "1.1.0", "grunt-ghost": "1.1.0",
"grunt-include-replace": "^3.2.0", "grunt-include-replace": "3.2.0",
"grunt-jscs": "^1.6.0", "grunt-jscs": "2.5.0",
"grunt-karma": "^0.10.1", "grunt-karma": "0.12.1",
"grunt-leading-indent": "^0.2.0", "grunt-leading-indent": "0.2.0",
"grunt-node-webkit-builder": "^1.0.2", "grunt-node-webkit-builder": "1.0.2",
"grunt-open": "0.2.3", "grunt-open": "0.2.3",
"grunt-replace": "^0.8.0", "grunt-replace": "0.11.0",
"grunt-spritesmith": "^6.1.0", "grunt-spritesmith": "6.1.0",
"jasmine-core": "^2.1.0", "jasmine-core": "2.1.0",
"karma": "0.12.31", "karma": "0.13.15",
"karma-chrome-launcher": "^0.1.4", "karma-chrome-launcher": "0.2.2",
"karma-jasmine": "^0.3.5", "karma-jasmine": "0.3.5",
"karma-phantomjs-launcher": "^0.1.4", "karma-phantomjs-launcher": "0.1.4",
"load-grunt-tasks": "^3.1.0" "load-grunt-tasks": "3.1.0"
}, },
"window": { "window": {
"title": "Piskel", "title": "Piskel",

View File

@ -167,7 +167,7 @@
if (pskl.utils.Environment.detectNodeWebkit() && pskl.utils.UserAgent.isMac) { if (pskl.utils.Environment.detectNodeWebkit() && pskl.utils.UserAgent.isMac) {
var gui = require('nw.gui'); var gui = require('nw.gui');
var mb = new gui.Menu({type:'menubar'}); var mb = new gui.Menu({type : 'menubar'});
mb.createMacBuiltin('Piskel'); mb.createMacBuiltin('Piskel');
gui.Window.get().menu = mb; gui.Window.get().menu = mb;
} }

View File

@ -49,12 +49,18 @@
}; };
ns.CursorCoordinatesController.prototype.onCursorMoved_ = function (event, x, y) { ns.CursorCoordinatesController.prototype.onCursorMoved_ = function (event, x, y) {
this.coordinates = {x:x, y:y}; this.coordinates = {
x : x,
y : y
};
this.redraw(); this.redraw();
}; };
ns.CursorCoordinatesController.prototype.onDragStart_ = function (event, x, y) { ns.CursorCoordinatesController.prototype.onDragStart_ = function (event, x, y) {
this.origin = {x:x, y:y}; this.origin = {
x : x,
y : y
};
this.redraw(); this.redraw();
}; };

View File

@ -7,8 +7,8 @@
* @public * @public
*/ */
ns.PaletteController.prototype.init = function() { ns.PaletteController.prototype.init = function() {
$.subscribe(Events.SELECT_PRIMARY_COLOR, this.onColorSelected_.bind(this, {isPrimary:true})); $.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_SECONDARY_COLOR, this.onColorSelected_.bind(this, {isPrimary : false}));
var shortcuts = pskl.service.keyboard.Shortcuts; var shortcuts = pskl.service.keyboard.Shortcuts;
pskl.app.shortcutService.registerShortcut(shortcuts.COLOR.SWAP, this.swapColors.bind(this)); pskl.app.shortcutService.registerShortcut(shortcuts.COLOR.SWAP, this.swapColors.bind(this));

View File

@ -24,23 +24,23 @@
}; };
ns.PaletteImportService.prototype.getReader_ = function (file, onSuccess, onError) { ns.PaletteImportService.prototype.getReader_ = function (file, onSuccess, onError) {
var readerClass = this.getReaderClass_(file); var ReaderClass = this.getReaderClass_(file);
if (readerClass) { if (ReaderClass) {
return new readerClass(file, onSuccess, onError); return new ReaderClass(file, onSuccess, onError);
} else { } else {
return null; return null;
} }
}; };
ns.PaletteImportService.prototype.getReaderClass_ = function (file) { ns.PaletteImportService.prototype.getReaderClass_ = function (file) {
var readerClass; var ReaderClass;
if (this.isImage_(file)) { if (this.isImage_(file)) {
readerClass = fileReaders.img; ReaderClass = fileReaders.img;
} else { } else {
var extension = this.getExtension_(file); var extension = this.getExtension_(file);
readerClass = fileReaders[extension]; ReaderClass = fileReaders[extension];
} }
return readerClass; return ReaderClass;
}; };
ns.PaletteImportService.prototype.getExtension_ = function (file) { ns.PaletteImportService.prototype.getExtension_ = function (file) {

View File

@ -157,7 +157,11 @@
return; 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) { if (frame.containsPixel(pixel.col, pixel.row) && frame.getPixel(pixel.col, pixel.row) == targetColor) {
frame.setPixel(pixel.col, pixel.row, replacementColor); frame.setPixel(pixel.col, pixel.row, replacementColor);
return true; return true;

View File

@ -25,14 +25,14 @@ if (!Function.prototype.bind) {
var bindArgs = Array.prototype.slice.call(arguments, 1); var bindArgs = Array.prototype.slice.call(arguments, 1);
var fToBind = this; var fToBind = this;
var fNOP = function () {}; var FNOP = function () {};
var fBound = function () { var fBound = function () {
var args = bindArgs.concat(Array.prototype.slice.call(arguments)); 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; FNOP.prototype = this.prototype;
fBound.prototype = new fNOP(); fBound.prototype = new FNOP();
return fBound; return fBound;
}; };

View File

@ -105,7 +105,7 @@
var isSelected = (index === this.selectedIndex); var isSelected = (index === this.selectedIndex);
html += pskl.utils.Template.replace(tpl, { html += pskl.utils.Template.replace(tpl, {
'color' : color, index:index, 'color' : color, index : index,
':selected' : isSelected, ':selected' : isSelected,
':light-color' : this.isLight_(color) ':light-color' : this.isLight_(color)
}); });