diff --git a/.jscs.json b/.jscs.json index 4e0292635483..e6e74d36c51a 100644 --- a/.jscs.json +++ b/.jscs.json @@ -1,6 +1,7 @@ { "excludeFiles": ["src/ngLocale/**"], "disallowKeywords": ["with"], + "disallowKeywordsOnNewLine": ["else"], "disallowMixedSpacesAndTabs": true, "disallowMultipleLineStrings": true, "disallowNewlineBeforeBlockStatements": true, @@ -11,6 +12,7 @@ "disallowSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true }, + "disallowSpacesInCallExpression": true, "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, @@ -18,6 +20,11 @@ "beforeOpeningRoundBrace": true }, "disallowSpacesInsideArrayBrackets": true, + "requireSpaceBeforeKeywords": [ + "else", + "while", + "catch" + ], "disallowSpacesInsideParentheses": true, "disallowTrailingComma": true, "disallowTrailingWhitespace": true, @@ -33,6 +40,7 @@ "afterConsequent": true, "beforeAlternate": true }, + "requireSpacesInForStatement": true, "requireSpacesInFunction": { "beforeOpeningCurlyBrace": true }, diff --git a/.jscs.json.todo b/.jscs.json.todo index 3bc5806e86e0..7102c481ba85 100644 --- a/.jscs.json.todo +++ b/.jscs.json.todo @@ -7,7 +7,6 @@ "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], "disallowImplicitTypeConversion": ["string"], "disallowMultipleLineBreaks": true, - "disallowKeywordsOnNewLine": ["else"], "validateJSDoc": { "checkParamNames": true, "requireParamTypes": true diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 23f6fd0d32b2..3a45f5fef4d7 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -2346,23 +2346,29 @@ "resolved": "git://github.com/vojtajina/grunt-jasmine-node.git#ced17cbe52c1412b2ada53160432a5b681f37cd7" }, "grunt-jscs": { - "version": "0.7.1", + "version": "1.2.0", "dependencies": { "hooker": { "version": "0.2.3" }, "jscs": { - "version": "1.6.2", + "version": "1.10.0", "dependencies": { "colors": { - "version": "0.6.2" + "version": "1.0.3" }, "commander": { - "version": "2.3.0" + "version": "2.5.1" }, "esprima": { "version": "1.2.2" }, + "esprima-harmony-jscs": { + "version": "1.1.0-regex-token-fix" + }, + "estraverse": { + "version": "1.9.1" + }, "exit": { "version": "0.1.2" }, @@ -2370,11 +2376,22 @@ "version": "4.0.6", "dependencies": { "graceful-fs": { - "version": "3.0.4" + "version": "3.0.5" }, "inherits": { "version": "2.0.1" }, + "minimatch": { + "version": "1.0.0", + "dependencies": { + "lru-cache": { + "version": "2.5.0" + }, + "sigmund": { + "version": "1.0.0" + } + } + }, "once": { "version": "1.3.1", "dependencies": { @@ -2386,54 +2403,61 @@ } }, "minimatch": { - "version": "1.0.0", + "version": "2.0.1", "dependencies": { - "lru-cache": { - "version": "2.5.0" - }, - "sigmund": { - "version": "1.0.0" + "brace-expansion": { + "version": "1.1.0", + "dependencies": { + "balanced-match": { + "version": "0.2.0" + }, + "concat-map": { + "version": "0.0.1" + } + } } } }, "strip-json-comments": { - "version": "1.0.1" + "version": "1.0.2" }, "vow-fs": { - "version": "0.3.2", + "version": "0.3.4", "dependencies": { "node-uuid": { - "version": "1.4.0" - }, - "vow": { - "version": "0.4.4" + "version": "1.4.2" }, "vow-queue": { - "version": "0.3.1" + "version": "0.4.1" }, "glob": { - "version": "3.2.8", + "version": "4.3.5", "dependencies": { - "minimatch": { - "version": "0.2.14", + "inflight": { + "version": "1.0.4", "dependencies": { - "lru-cache": { - "version": "2.5.0" - }, - "sigmund": { - "version": "1.0.0" + "wrappy": { + "version": "1.0.1" } } }, "inherits": { "version": "2.0.1" + }, + "once": { + "version": "1.3.1", + "dependencies": { + "wrappy": { + "version": "1.0.1" + } + } } } } } }, "xmlbuilder": { - "version": "2.4.4", + "version": "2.4.5", "dependencies": { "lodash-node": { "version": "2.4.1" @@ -2441,12 +2465,12 @@ } }, "supports-color": { - "version": "1.1.0" + "version": "1.2.0" } } }, "vow": { - "version": "0.4.5" + "version": "0.4.7" } } }, diff --git a/package.json b/package.json index d8b79d45d618..b0498c823ac8 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "grunt-contrib-jshint": "~0.10.0", "grunt-ddescribe-iit": "~0.0.1", "grunt-jasmine-node": "git://github.com/vojtajina/grunt-jasmine-node.git#fix-grunt-exit-code", - "grunt-jscs": "~0.7.1", + "grunt-jscs": "~1.2.0", "grunt-merge-conflict": "~0.0.1", "grunt-shell": "~1.1.1", "gulp": "~3.8.0", diff --git a/src/Angular.js b/src/Angular.js index 52e74cbf396c..04e973e3545f 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -317,8 +317,7 @@ function nextUid() { function setHashKey(obj, h) { if (h) { obj.$$hashKey = h; - } - else { + } else { delete obj.$$hashKey; } } @@ -627,7 +626,7 @@ function isElement(node) { function makeMap(str) { var obj = {}, items = str.split(","), i; for (i = 0; i < items.length; i++) - obj[ items[i] ] = true; + obj[items[i]] = true; return obj; } diff --git a/src/ng/compile.js b/src/ng/compile.js index bef8873816d1..98a4e1311e62 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -887,8 +887,8 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { this.$get = [ '$injector', '$interpolate', '$exceptionHandler', '$templateRequest', '$parse', '$controller', '$rootScope', '$document', '$sce', '$animate', '$$sanitizeUri', - function($injector, $interpolate, $exceptionHandler, $templateRequest, $parse, - $controller, $rootScope, $document, $sce, $animate, $$sanitizeUri) { + function($injector, $interpolate, $exceptionHandler, $templateRequest, $parse, + $controller, $rootScope, $document, $sce, $animate, $$sanitizeUri) { var Attributes = function(element, attributesToCopy) { if (attributesToCopy) { diff --git a/src/ng/directive/ngInclude.js b/src/ng/directive/ngInclude.js index cc6525b6f686..381011c288dd 100644 --- a/src/ng/directive/ngInclude.js +++ b/src/ng/directive/ngInclude.js @@ -179,7 +179,7 @@ * @param {String} src URL of content to load. */ var ngIncludeDirective = ['$templateRequest', '$anchorScroll', '$animate', '$sce', - function($templateRequest, $anchorScroll, $animate, $sce) { + function($templateRequest, $anchorScroll, $animate, $sce) { return { restrict: 'ECA', priority: 400, diff --git a/src/ng/interval.js b/src/ng/interval.js index 1afaec797041..73fc0b9589c8 100644 --- a/src/ng/interval.js +++ b/src/ng/interval.js @@ -3,7 +3,7 @@ function $IntervalProvider() { this.$get = ['$rootScope', '$window', '$q', '$$q', - function($rootScope, $window, $q, $$q) { + function($rootScope, $window, $q, $$q) { var intervals = {}; diff --git a/src/ng/q.js b/src/ng/q.js index 7353be52e18d..dcfd7d71476a 100644 --- a/src/ng/q.js +++ b/src/ng/q.js @@ -347,8 +347,7 @@ function qFactory(nextTick, exceptionHandler) { 'qcycle', "Expected promise to be resolved with value other than itself '{0}'", val)); - } - else { + } else { this.$$resolve(val); } diff --git a/src/ng/sce.js b/src/ng/sce.js index 67be4997fb8f..5f04965a90bb 100644 --- a/src/ng/sce.js +++ b/src/ng/sce.js @@ -719,7 +719,7 @@ function $SceProvider() { */ this.$get = ['$parse', '$sceDelegate', function( - $parse, $sceDelegate) { + $parse, $sceDelegate) { // Prereq: Ensure that we're not running in IE<11 quirks mode. In that mode, IE < 11 allow // the "expression(javascript expression)" syntax which is insecure. if (enabled && msie < 8) { diff --git a/src/ng/testability.js b/src/ng/testability.js index c9d0afd2c38e..7fad4f26a304 100644 --- a/src/ng/testability.js +++ b/src/ng/testability.js @@ -3,7 +3,7 @@ function $$TestabilityProvider() { this.$get = ['$rootScope', '$browser', '$location', - function($rootScope, $browser, $location) { + function($rootScope, $browser, $location) { /** * @name $testability diff --git a/src/ng/timeout.js b/src/ng/timeout.js index 90555830c0b7..5352099466b7 100644 --- a/src/ng/timeout.js +++ b/src/ng/timeout.js @@ -3,7 +3,7 @@ function $TimeoutProvider() { this.$get = ['$rootScope', '$browser', '$q', '$$q', '$exceptionHandler', - function($rootScope, $browser, $q, $$q, $exceptionHandler) { + function($rootScope, $browser, $q, $$q, $exceptionHandler) { var deferreds = {}; diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js index 7c6a59d7be7e..98f4a6385d58 100644 --- a/src/ngAnimate/animate.js +++ b/src/ngAnimate/animate.js @@ -476,7 +476,7 @@ angular.module('ngAnimate', ['ng']) var $$jqLite; $provide.decorator('$animate', ['$delegate', '$$q', '$injector', '$sniffer', '$rootElement', '$$asyncCallback', '$rootScope', '$document', '$templateRequest', '$$jqLite', - function($delegate, $$q, $injector, $sniffer, $rootElement, $$asyncCallback, $rootScope, $document, $templateRequest, $$$jqLite) { + function($delegate, $$q, $injector, $sniffer, $rootElement, $$asyncCallback, $rootScope, $document, $templateRequest, $$$jqLite) { $$jqLite = $$$jqLite; $rootElement.data(NG_ANIMATE_STATE, rootAnimateState); @@ -1327,8 +1327,7 @@ angular.module('ngAnimate', ['ng']) } else if (lastAnimation.event == 'setClass') { animationsToCancel.push(lastAnimation); cleanup(element, className); - } - else if (runningAnimations[className]) { + } else if (runningAnimations[className]) { var current = runningAnimations[className]; if (current.event == animationEvent) { skipAnimation = true; @@ -1579,7 +1578,7 @@ angular.module('ngAnimate', ['ng']) }]); $animateProvider.register('', ['$window', '$sniffer', '$timeout', '$$animateReflow', - function($window, $sniffer, $timeout, $$animateReflow) { + function($window, $sniffer, $timeout, $$animateReflow) { // Detect proper transitionend/animationend event names. var CSS_PREFIX = '', TRANSITION_PROP, TRANSITIONEND_EVENT, ANIMATION_PROP, ANIMATIONEND_EVENT; diff --git a/src/ngMessages/messages.js b/src/ngMessages/messages.js index 90d8c9cd3bab..a04b3ddd1608 100644 --- a/src/ngMessages/messages.js +++ b/src/ngMessages/messages.js @@ -229,7 +229,7 @@ angular.module('ngMessages', []) * */ .directive('ngMessages', ['$compile', '$animate', '$templateRequest', - function($compile, $animate, $templateRequest) { + function($compile, $animate, $templateRequest) { var ACTIVE_CLASS = 'ng-active'; var INACTIVE_CLASS = 'ng-inactive'; diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 553f203c2743..e597af8f6e53 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -455,7 +455,7 @@ angular.mock.$LogProvider = function() { */ angular.mock.$IntervalProvider = function() { this.$get = ['$browser', '$rootScope', '$q', '$$q', - function($browser, $rootScope, $q, $$q) { + function($browser, $rootScope, $q, $$q) { var repeatFns = [], nextRepeatId = 0, now = 0; @@ -783,7 +783,7 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng']) }); $provide.decorator('$animate', ['$delegate', '$$asyncCallback', '$timeout', '$browser', - function($delegate, $$asyncCallback, $timeout, $browser) { + function($delegate, $$asyncCallback, $timeout, $browser) { var animate = { queue: [], cancel: $delegate.cancel, diff --git a/src/ngRoute/route.js b/src/ngRoute/route.js index 56ec491a207e..3edfd9d1e1b9 100644 --- a/src/ngRoute/route.js +++ b/src/ngRoute/route.js @@ -490,8 +490,7 @@ function $RouteProvider() { newParams = angular.extend({}, this.current.params, newParams); $location.path(interpolate(this.current.$$route.originalPath, newParams)); $location.search(angular.extend({}, $location.search(), searchParams)); - } - else { + } else { throw $routeMinErr('norout', 'Tried updating route when with no current route'); } } diff --git a/src/ngSanitize/sanitize.js b/src/ngSanitize/sanitize.js index 7fba26a79527..cadbb7c8543e 100644 --- a/src/ngSanitize/sanitize.js +++ b/src/ngSanitize/sanitize.js @@ -271,14 +271,14 @@ function htmlParser(html, handler) { } } var index, chars, match, stack = [], last = html, text; - stack.last = function() { return stack[ stack.length - 1 ]; }; + stack.last = function() { return stack[stack.length - 1]; }; while (html) { text = ''; chars = true; // Make sure we're not in a script or style element - if (!stack.last() || !specialElements[ stack.last() ]) { + if (!stack.last() || !specialElements[stack.last()]) { // Comment if (html.indexOf("; link; LOG; LOG; HIGH'); expect(element.text()).toEqual('1-2;1-3;'); @@ -6065,7 +6056,7 @@ describe('$compile', function() { link: function(scope, element, attrs, ctrl, transclude) { // We use timeout here to simulate how ng-if works - $timeout(function() { + $timeout(function() { transclude(function(child) { element.append(child); }); }); } diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index 73d995079421..8141e9a7da81 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -1641,9 +1641,9 @@ describe('input', function() { }); }); - describe('max', function() { + describe('max', function() { - it('should invalidate', function() { + it('should invalidate', function() { var inputElm = helper.compileInput(''); helper.changeInputValueTo('2019-12-31'); expect(inputElm).toBeInvalid(); diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index 7b9cb76f5585..b09cbedab81b 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -957,7 +957,7 @@ describe('$location', function() { initService({html5Mode:true,hashPrefix: '!!',supportHistory: false}); inject( initBrowser({url:'http://domain.com/base/index.html#!!/a/b',basePath: '/base/index.html'}), - function($rootScope, $location, $browser) { + function($rootScope, $location, $browser) { expect($browser.url()).toBe('http://domain.com/base/index.html#!!/a/b'); $location.path('/new'); $location.search({a: true}); @@ -1323,7 +1323,7 @@ describe('$location', function() { }); - it ('should not rewrite links when rewriting links is disabled', function() { + it('should not rewrite links when rewriting links is disabled', function() { configureService({linkHref: 'link?a#b', html5Mode: {enabled: true, rewriteLinks:false}, supportHist: true}); inject( initBrowser(), @@ -1847,7 +1847,7 @@ describe('$location', function() { }) ); - it ('should fire $locationChangeSuccess event when change from browser location bar', + it('should fire $locationChangeSuccess event when change from browser location bar', inject(function($log, $location, $browser, $rootScope) { $rootScope.$apply(); // clear initial $locationChangeStart diff --git a/test/ng/snifferSpec.js b/test/ng/snifferSpec.js index 382952607686..cd4728e3bb1d 100644 --- a/test/ng/snifferSpec.js +++ b/test/ng/snifferSpec.js @@ -87,11 +87,9 @@ describe('$sniffer', function() { var ua = $window.navigator.userAgent.toLowerCase(); if (/chrome/i.test(ua) || /safari/i.test(ua) || /webkit/i.test(ua)) { expectedPrefix = 'Webkit'; - } - else if (/firefox/i.test(ua)) { + } else if (/firefox/i.test(ua)) { expectedPrefix = 'Moz'; - } - else if (/ie/i.test(ua) || /trident/i.test(ua)) { + } else if (/ie/i.test(ua) || /trident/i.test(ua)) { expectedPrefix = 'Ms'; } expect($sniffer.vendorPrefix).toBe(expectedPrefix); diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index 54ea6f340d0f..3d3185a97f42 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -1193,7 +1193,7 @@ describe('ngMock', function() { }); - it ('should throw exception when only headers differs from expectation', function() { + it('should throw exception when only headers differs from expectation', function() { hb.when('GET').respond(200, '', {}); hb.expect('GET', '/match', undefined, {'Content-Type': 'application/json'}); @@ -1204,7 +1204,7 @@ describe('ngMock', function() { }); - it ('should throw exception when only data differs from expectation', function() { + it('should throw exception when only data differs from expectation', function() { hb.when('GET').respond(200, '', {}); hb.expect('GET', '/match', 'some-data'); @@ -1215,7 +1215,7 @@ describe('ngMock', function() { }); - it ('should not throw an exception when parsed body is equal to expected body object', function() { + it('should not throw an exception when parsed body is equal to expected body object', function() { hb.when('GET').respond(200, '', {}); hb.expect('GET', '/match', {a: 1, b: 2}); @@ -1230,7 +1230,7 @@ describe('ngMock', function() { }); - it ('should throw exception when only parsed body differs from expected body object', function() { + it('should throw exception when only parsed body differs from expected body object', function() { hb.when('GET').respond(200, '', {}); hb.expect('GET', '/match', {a: 1, b: 2});