Skip to content

Commit

Permalink
Add initial jscs configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
passy committed Feb 8, 2014
1 parent a42eb2b commit 9bb99d5
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 12 deletions.
109 changes: 109 additions & 0 deletions .jscs.json
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ todomvc.directive('todoEscape', function () {
});
};
});

3 changes: 2 additions & 1 deletion architecture-examples/angularjs/js/directives/todoFocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion architecture-examples/backbone/js/views/app-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ var app = app || {};

app.todos.each(function (todo) {
todo.save({
'completed': completed
completed: completed
});
});
}
Expand Down
23 changes: 14 additions & 9 deletions architecture-examples/backbone/js/views/todo-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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');
}
Expand Down

0 comments on commit 9bb99d5

Please sign in to comment.