From 9bb99d5885a2def4c7c39c9bdff259de210a467c Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Sat, 8 Feb 2014 20:08:21 +0000 Subject: [PATCH] Add initial jscs configuration --- .jscs.json | 109 ++++++++++++++++++ .../angularjs/js/directives/todoEscape.js | 1 - .../angularjs/js/directives/todoFocus.js | 3 +- .../backbone/js/views/app-view.js | 2 +- .../backbone/js/views/todo-view.js | 23 ++-- 5 files changed, 126 insertions(+), 12 deletions(-) create mode 100644 .jscs.json diff --git a/.jscs.json b/.jscs.json new file mode 100644 index 0000000000..3bfc966b9c --- /dev/null +++ b/.jscs.json @@ -0,0 +1,109 @@ +{ + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], + "requireLeftStickedOperators": [","], + "requireParenthesesAroundIIFE": true, + "requireSpacesInFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "disallowEmptyBlocks": true, + "disallowSpacesInsideArrayBrackets": true, + "disallowSpacesInsideParentheses": true, + "disallowQuotedKeysInObjects": true, + "disallowSpaceAfterObjectKeys": true, + "requireCommaBeforeLineBreak": true, + "requireSpaceBeforeBinaryOperators": [ + "+", + "-", + "/", + "*", + "=", + "==", + "===", + "!=", + "!==" + ], + "requireSpaceAfterBinaryOperators": [ + "+", + "-", + "/", + "*", + "=", + "==", + "===", + "!=", + "!==" + ], + "requireCamelCaseOrUpperCaseIdentifiers": true, + "requireOperatorBeforeLineBreak": [ + "?", + "+", + "-", + "/", + "*", + "=", + "==", + "===", + "!=", + "!==", + ">", + ">=", + "<", + "<=" + ], + "disallowLeftStickedOperators": [ + "?", + "+", + "-", + "/", + "*", + "=", + "==", + "===", + "!=", + "!==", + ">", + ">=", + "<", + "<=" + ], + "disallowRightStickedOperators": [ + "?", + "+", + "/", + "*", + ":", + "=", + "==", + "===", + "!=", + "!==", + ">", + ">=", + "<", + "<=" + ], + "requireRightStickedOperators": ["!"], + "disallowImplicitTypeConversion": ["string"], + "disallowKeywords": ["with"], + "disallowMultipleLineStrings": true, + "disallowMultipleLineBreaks": true, + "validateLineBreaks": "LF", + "validateQuoteMarks": true, + "disallowMixedSpacesAndTabs": true, + "requireMultipleVarDecl": true, + "disallowTrailingWhitespace": true, + "disallowKeywordsOnNewLine": ["else"], + "maximumLineLength": 100, + "requireCapitalizedConstructors": true, + "safeContextKeyword": "self", + "requireDotNotation": true, + "requireLineFeedAtFileEnd": true, + "excludeFiles": [], + "validateJSDoc": { + "checkParamNames": true, + "requireParamTypes": true + } +} diff --git a/architecture-examples/angularjs/js/directives/todoEscape.js b/architecture-examples/angularjs/js/directives/todoEscape.js index 9e1f4b3ed0..c9452995a2 100644 --- a/architecture-examples/angularjs/js/directives/todoEscape.js +++ b/architecture-examples/angularjs/js/directives/todoEscape.js @@ -15,4 +15,3 @@ todomvc.directive('todoEscape', function () { }); }; }); - diff --git a/architecture-examples/angularjs/js/directives/todoFocus.js b/architecture-examples/angularjs/js/directives/todoFocus.js index d8167cf15f..07ebb41ca0 100644 --- a/architecture-examples/angularjs/js/directives/todoFocus.js +++ b/architecture-examples/angularjs/js/directives/todoFocus.js @@ -2,7 +2,8 @@ 'use strict'; /** - * Directive that places focus on the element it is applied to when the expression it binds to evaluates to true + * Directive that places focus on the element it is applied to when the + * expression it binds to evaluates to true */ todomvc.directive('todoFocus', function todoFocus($timeout) { return function (scope, elem, attrs) { diff --git a/architecture-examples/backbone/js/views/app-view.js b/architecture-examples/backbone/js/views/app-view.js index b9ec95e2b3..77f2194469 100644 --- a/architecture-examples/backbone/js/views/app-view.js +++ b/architecture-examples/backbone/js/views/app-view.js @@ -123,7 +123,7 @@ var app = app || {}; app.todos.each(function (todo) { todo.save({ - 'completed': completed + completed: completed }); }); } diff --git a/architecture-examples/backbone/js/views/todo-view.js b/architecture-examples/backbone/js/views/todo-view.js index c7cb82ad1b..39f777927d 100644 --- a/architecture-examples/backbone/js/views/todo-view.js +++ b/architecture-examples/backbone/js/views/todo-view.js @@ -25,9 +25,10 @@ var app = app || {}; 'blur .edit': 'close' }, - // The TodoView listens for changes to its model, re-rendering. Since there's - // a one-to-one correspondence between a **Todo** and a **TodoView** in this - // app, we set a direct reference on the model for convenience. + // The TodoView listens for changes to its model, re-rendering. Since + // there's a one-to-one correspondence between a **Todo** and a + // **TodoView** in this app, we set a direct reference on the model for + // convenience. initialize: function () { this.listenTo(this.model, 'change', this.render); this.listenTo(this.model, 'destroy', this.remove); @@ -36,10 +37,12 @@ var app = app || {}; // Re-render the titles of the todo item. render: function () { - // Backbone LocalStorage is adding `id` attribute instantly after creating a model. - // This causes our TodoView to render twice. Once after creating a model and once on `id` change. - // We want to filter out the second redundant render, which is caused by this `id` change. - // It's known Backbone LocalStorage bug, therefore we've to create a workaround. + // Backbone LocalStorage is adding `id` attribute instantly after + // creating a model. This causes our TodoView to render twice. Once + // after creating a model and once on `id` change. We want to + // filter out the second redundant render, which is caused by this + // `id` change. It's known Backbone LocalStorage bug, therefore + // we've to create a workaround. // https://github.com/tastejs/todomvc/issues/469 if (this.model.changed.id !== undefined) { return; @@ -92,8 +95,10 @@ var app = app || {}; this.model.save({ title: trimmedValue }); if (value !== trimmedValue) { - // Model values changes consisting of whitespaces only are not causing change to be triggered - // Therefore we've to compare untrimmed version with a trimmed one to chech whether anything changed + // Model values changes consisting of whitespaces only are + // not causing change to be triggered Therefore we've to + // compare untrimmed version with a trimmed one to chech + // whether anything changed // And if yes, we've to trigger change event ourselves this.model.trigger('change'); }