Skip to content

Commit bb2e6dd

Browse files
committed
Add JSCS and make necessary changes for build to pass
1 parent e4d79e9 commit bb2e6dd

30 files changed

+342
-355
lines changed

.jscsrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"preset": "crockford",
3+
"disallowDanglingUnderscores": { "allExcept": ["_$compile_", "_$rootScope_"] },
4+
"disallowMultipleVarDecl": "strict",
5+
"validateIndentation": 2,
6+
"requireMultipleVarDecl": null
7+
}

gulpfile.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
'use strict';
44

55
var gulp = require('gulp');
6+
var jscs = require('gulp-jscs');
67
var jshint = require('gulp-jshint');
78
var karma = require('karma').server;
8-
var lodash = require('lodash');
9-
var plato = require('gulp-plato');
109
var karmaConfig = __dirname + '/karma.conf.js';
10+
var lodash = require('lodash');
1111
var paths = require('./paths');
12+
var plato = require('gulp-plato');
1213

1314
gulp.task('complexity', function () {
1415
return gulp.src('src/**/*.js')
@@ -52,4 +53,10 @@ gulp.task('lint', function () {
5253
.pipe(jshint.reporter('fail'));
5354
});
5455

55-
gulp.task('default', ['lint', 'complexity', 'test']);
56+
gulp.task('jscs', function () {
57+
return gulp
58+
.src(paths.lint)
59+
.pipe(jscs('.jscsrc'));
60+
});
61+
62+
gulp.task('default', ['jscs', 'lint', 'complexity', 'test']);

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"grunt": "^0.4.4",
1919
"grunt-bump": "^0.3.0",
2020
"gulp": "^3.8.11",
21+
"gulp-jscs": "^1.4.0",
2122
"gulp-jshint": "^1.9.4",
2223
"gulp-plato": "^1.0.2",
2324
"jshint": "^2.6.0",

src/css/datetimepicker.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license angular-bootstrap-datetimepicker version: 0.3.12
3-
* (c) 2013-2014 Knight Rider Consulting, Inc. http://www.knightrider.com
3+
* Copyright 2013-2015 Knight Rider Consulting, Inc. http://www.knightrider.com
44
* License: MIT
55
*/
66

src/js/datetimepicker.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/**
55
* @license angular-bootstrap-datetimepicker version: 0.3.12
6-
* (c) 2013-2014 Knight Rider Consulting, Inc. http://www.knightrider.com
6+
* Copyright 2013-2015 Knight Rider Consulting, Inc. http://www.knightrider.com
77
* License: MIT
88
*/
99

test/commonjs/browserify.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
/*globals require */
2+
/**
3+
* @license angular-bootstrap-datetimepicker
4+
* Copyright 2015 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* License: MIT
6+
*/
27

38
/** This file is intentionally named browserify.test.js so that it is not picked up by the karma runner **/
49

test/configuration/beforeRender.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @license angular-bootstrap-datetimepicker
5-
* (c) 2013-2014 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* Copyright 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
66
* License: MIT
77
*/
88

@@ -13,7 +13,8 @@
1313
*/
1414
describe('beforeRender', function () {
1515
'use strict';
16-
var $rootScope, $compile;
16+
var $rootScope;
17+
var $compile;
1718
beforeEach(module('ui.bootstrap.datetimepicker'));
1819
beforeEach(inject(function (_$compile_, _$rootScope_) {
1920
moment.locale('en');

test/configuration/configurationValidation.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @license angular-bootstrap-datetimepicker
5-
* (c) 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* Copyright 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
66
* License: MIT
77
*/
88

@@ -13,7 +13,8 @@
1313
*/
1414
describe('configuration validation', function () {
1515
'use strict';
16-
var $rootScope, $compile;
16+
var $rootScope;
17+
var $compile;
1718
beforeEach(module('ui.bootstrap.datetimepicker'));
1819
beforeEach(inject(function (_$compile_, _$rootScope_) {
1920
$compile = _$compile_;

test/configuration/datetimepickerConfig.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @license angular-bootstrap-datetimepicker
5-
* (c) 2014 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* Copyright 2014 Knight Rider Consulting, Inc. http://www.knightrider.com
66
* License: MIT
77
*/
88

@@ -14,7 +14,8 @@
1414

1515
describe('dateimePickerConfig', function () {
1616
'use strict';
17-
var $rootScope, $compile;
17+
var $rootScope;
18+
var $compile;
1819

1920
beforeEach(module('ui.bootstrap.datetimepicker'));
2021

test/configuration/dropdownSelector.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @license angular-bootstrap-datetimepicker
5-
* (c) 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* Copyright 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
66
* License: MIT
77
*/
88

@@ -14,7 +14,8 @@
1414

1515
describe('dropdownSelector', function () {
1616
'use strict';
17-
var $rootScope, $compile;
17+
var $rootScope;
18+
var $compile;
1819
beforeEach(module('ui.bootstrap.datetimepicker'));
1920
beforeEach(inject(function (_$compile_, _$rootScope_) {
2021
$compile = _$compile_;

test/configuration/minView.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @license angular-bootstrap-datetimepicker
5-
* (c) 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* Copyright 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
66
* License: MIT
77
*/
88

@@ -14,7 +14,8 @@
1414

1515
describe('minView', function () {
1616
'use strict';
17-
var $rootScope, $compile;
17+
var $rootScope;
18+
var $compile;
1819
beforeEach(module('ui.bootstrap.datetimepicker'));
1920
beforeEach(inject(function (_$compile_, _$rootScope_) {
2021
$compile = _$compile_;

test/configuration/minuteStep.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @license angular-bootstrap-datetimepicker
5-
* (c) 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* Copyright 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
66
* License: MIT
77
*/
88

@@ -14,7 +14,8 @@
1414

1515
describe('minuteStep', function () {
1616
'use strict';
17-
var $rootScope, $compile;
17+
var $rootScope;
18+
var $compile;
1819
beforeEach(module('ui.bootstrap.datetimepicker'));
1920
beforeEach(inject(function (_$compile_, _$rootScope_) {
2021
$compile = _$compile_;

test/configuration/onSetTime.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @license angular-bootstrap-datetimepicker
5-
* (c) 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* Copyright 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
66
* License: MIT
77
*/
88

@@ -13,7 +13,8 @@
1313
*/
1414
describe('onSetTime', function () {
1515
'use strict';
16-
var $rootScope, $compile;
16+
var $rootScope;
17+
var $compile;
1718
beforeEach(module('ui.bootstrap.datetimepicker'));
1819
beforeEach(inject(function (_$compile_, _$rootScope_) {
1920
$compile = _$compile_;

test/configuration/startView.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @license angular-bootstrap-datetimepicker
5-
* (c) 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* Copyright 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
66
* License: MIT
77
*/
88

@@ -14,7 +14,8 @@
1414

1515
describe('startView', function () {
1616
'use strict';
17-
var $rootScope, $compile;
17+
var $rootScope;
18+
var $compile;
1819
beforeEach(module('ui.bootstrap.datetimepicker'));
1920
beforeEach(inject(function (_$compile_, _$rootScope_) {
2021
$compile = _$compile_;

test/model/ngModelController.spec.js

+9-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @license angular-bootstrap-datetimepicker
5-
* (c) 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* Copyright 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
66
* License: MIT
77
*/
88

@@ -14,39 +14,31 @@
1414

1515
describe('ngModelController', function () {
1616
'use strict';
17-
var $rootScope, $compile;
1817
beforeEach(module('ui.bootstrap.datetimepicker'));
19-
beforeEach(inject(function (_$compile_, _$rootScope_) {
20-
$compile = _$compile_;
21-
$rootScope = _$rootScope_;
22-
$rootScope.data = {};
23-
}));
2418

2519
describe('remove $pristine when date set', function () {
26-
it('if value is not a string', function () {
20+
it('if value is not a string', inject(function ($compile, $rootScope) {
2721

28-
$rootScope.setTimeFunction = function ()
29-
//noinspection JSLint
30-
{
22+
$rootScope.data = {};
23+
24+
$rootScope.setTimeFunction = function setTimeFunction() {
3125
// Nothing to validate here.
26+
return undefined;
3227
};
3328

3429
spyOn($rootScope, 'setTimeFunction');
3530

3631
var formElement = $compile('<form name="pickerform"><datetimepicker data-ng-model="data.dateValue" name="dateValue" data-on-set-time="setTimeFunction(newDate)" required data-datetimepicker-config="{ startView: \'day\', minView: \'day\' }" ></datetimepicker></form>')($rootScope);
3732
$rootScope.$digest();
3833

39-
var picker = jQuery(jQuery('.datetimepicker', formElement));
40-
4134
expect(formElement.hasClass('ng-pristine')).toBeTruthy();
4235

43-
// expect(picker.hasClass('ng-pristine')).toBeTruthy(); // This breaks in 1.3, not sure why.
36+
var picker = jQuery(jQuery('.datetimepicker', formElement));
4437
expect(picker.hasClass('ng-invalid')).toBeTruthy();
4538
expect(picker.hasClass('ng-dirty')).toBeFalsy();
4639
expect(picker.hasClass('ng-valid')).toBeFalsy();
4740

48-
var selectedElement = jQuery(jQuery('.day', picker)[2]);
49-
selectedElement.trigger('click');
41+
jQuery(jQuery('.day', picker)[2]).trigger('click');
5042

5143
expect($rootScope.setTimeFunction).toHaveBeenCalled();
5244

@@ -57,7 +49,7 @@ describe('ngModelController', function () {
5749

5850
expect(formElement.hasClass('ng-pristine')).toBeFalsy();
5951
expect(formElement.hasClass('ng-dirty')).toBeTruthy();
60-
});
52+
}));
6153
});
6254

6355
});

test/view/de/day.spec.js

+20-21
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @license angular-bootstrap-datetimepicker
5-
* (c) 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
5+
* Copyright 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
66
* License: MIT
77
*/
88

@@ -12,17 +12,16 @@
1212
* @since 7/21/13
1313
*/
1414

15-
describe('current view displayed on the markup', function(){
15+
describe('current view displayed on the markup', function () {
1616
'use strict';
1717

18-
var $rootScope, element;
18+
var element;
1919

2020
beforeEach(module('ui.bootstrap.datetimepicker'));
21-
beforeEach(inject(function (_$compile_, _$rootScope_) {
21+
beforeEach(inject(function ($compile, $rootScope) {
2222
moment.locale('de');
23-
$rootScope = _$rootScope_;
2423
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
25-
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'day\'}" data-ng-model="date"></datetimepicker>')($rootScope);
24+
element = $compile('<datetimepicker data-datetimepicker-config="{ startView: \'day\'}" data-ng-model="date"></datetimepicker>')($rootScope);
2625
$rootScope.$digest();
2726
}));
2827

@@ -33,13 +32,12 @@ describe('current view displayed on the markup', function(){
3332

3433
describe('German day view with initial date of 2013-01-22', function () {
3534
'use strict';
36-
var $rootScope, element;
35+
var element;
3736
beforeEach(module('ui.bootstrap.datetimepicker'));
38-
beforeEach(inject(function (_$compile_, _$rootScope_) {
37+
beforeEach(inject(function ($compile, $rootScope) {
3938
moment.locale('de');
40-
$rootScope = _$rootScope_;
4139
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
42-
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'day\'}" data-ng-model="date"></datetimepicker>')($rootScope);
40+
element = $compile('<datetimepicker data-datetimepicker-config="{ startView: \'day\'}" data-ng-model="date"></datetimepicker>')($rootScope);
4341
$rootScope.$digest();
4442
}));
4543
it('has `.switch` element with a value of 2013-1', function () {
@@ -62,12 +60,13 @@ describe('German day view with initial date of 2013-01-22', function () {
6260

6361
describe('day with initial date of "2020-01-01T00:00:00.000" and minView="day"', function () {
6462
'use strict';
65-
var $rootScope, element;
63+
var rootScope;
64+
var element;
6665
beforeEach(module('ui.bootstrap.datetimepicker'));
67-
beforeEach(inject(function (_$compile_, _$rootScope_) {
68-
$rootScope = _$rootScope_;
66+
beforeEach(inject(function ($compile, $rootScope) {
67+
rootScope = $rootScope;
6968
$rootScope.date = moment('2020-01-01T00:00:00.000').toDate();
70-
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'day\', minView: \'day\' }" data-ng-model="date"></datetimepicker>')($rootScope);
69+
element = $compile('<datetimepicker data-datetimepicker-config="{ startView: \'day\', minView: \'day\' }" data-ng-model="date"></datetimepicker>')($rootScope);
7170
$rootScope.$digest();
7271
}));
7372
it('clicking the 13th `.day` element will set the date value to 2020-01-11T00:00:00.000"', function () {
@@ -80,20 +79,20 @@ describe('day with initial date of "2020-01-01T00:00:00.000" and minView="day"',
8079
selectedElement.trigger('click');
8180

8281
expect(jQuery('.active', element).text()).toBe('12');
83-
expect($rootScope.date).toEqual(moment('2020-01-12T00:00:00.000').toDate());
82+
expect(rootScope.date).toEqual(moment('2020-01-12T00:00:00.000').toDate());
8483
});
8584
});
8685

8786

88-
8987
describe('day with initial date of "2008-02-01T00:00:00.000" (leap year) and minView="day"', function () {
9088
'use strict';
91-
var $rootScope, element;
89+
var rootScope;
90+
var element;
9291
beforeEach(module('ui.bootstrap.datetimepicker'));
93-
beforeEach(inject(function (_$compile_, _$rootScope_) {
94-
$rootScope = _$rootScope_;
92+
beforeEach(inject(function ($compile, $rootScope) {
93+
rootScope = $rootScope;
9594
$rootScope.date = moment('2008-02-01T00:00:00.000').toDate();
96-
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'day\', minView: \'day\' }" data-ng-model="date"></datetimepicker>')($rootScope);
95+
element = $compile('<datetimepicker data-datetimepicker-config="{ startView: \'day\', minView: \'day\' }" data-ng-model="date"></datetimepicker>')($rootScope);
9796
$rootScope.$digest();
9897
}));
9998
it('clicking the 33rd `.day` element will set the date value to 2008-29-11T00:00:00.000"', function () {
@@ -109,6 +108,6 @@ describe('day with initial date of "2008-02-01T00:00:00.000" (leap year) and min
109108

110109
selectedElement.trigger('click');
111110
expect(jQuery('.active', element).text()).toBe('29');
112-
expect($rootScope.date).toEqual(moment('2008-02-29T00:00:00.000').toDate());
111+
expect(rootScope.date).toEqual(moment('2008-02-29T00:00:00.000').toDate());
113112
});
114113
});

0 commit comments

Comments
 (0)