Skip to content

Commit 81ef83d

Browse files
committed
style(js,css): Use standard and stylelint for linting js and css
Use npm standard package to lint js - this is non-configurable and does not allow semicolons. stylelint lints the css. Also added link to gitter chat the readme file. Closes #280, #284, #313
1 parent 79050c3 commit 81ef83d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2494
-2570
lines changed

.jscsrc

-9
This file was deleted.

.jshintrc

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"maxlen" : false, // {int} Max number of characters per line
3636

3737
// Relaxing
38-
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
38+
"asi" : true, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
3939
"boss" : false, // true: Tolerate assignments where comparisons would be expected
4040
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
4141
"eqnull" : false, // true: Tolerate use of `== null`
@@ -48,7 +48,7 @@
4848
"funcscope" : false, // true: Tolerate defining variables inside control statements
4949
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
5050
"iterator" : false, // true: Tolerate using the `__iterator__` property
51-
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
51+
"lastsemic" : true, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
5252
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
5353
"laxcomma" : false, // true: Tolerate comma-first style coding
5454
"loopfunc" : false, // true: Tolerate functions being defined in loops
@@ -68,7 +68,7 @@
6868
"couch" : false, // CouchDB
6969
"devel" : true, // Development/debugging (alert, confirm, etc)
7070
"dojo" : false, // Dojo Toolkit
71-
"jasmine" : true, // Jasmine
71+
"jasmine" : true, // Jasmine
7272
"jquery" : false, // jQuery
7373
"mocha" : true, // Mocha
7474
"mootools" : false, // MooTools

.stylelintrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "stylelint-config-standard",
3+
4+
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The template used by this directive has been separated from the directive to all
2828
<script type="text/javascript" src="node_modules/angular-bootstrap-datetimepicker/src/js/datetimepicker.templates.js"></script>
2929
```
3030

31-
If you wan to override the template used by this directive, simply populate the ```$templateCache``` with your own template.
31+
If you want to override the template used by this directive, simply populate the ```$templateCache``` with your own template.
3232

3333
# Formatting the date in an input box
3434

demo/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<script type="text/javascript" src="demo/demo-controller.js"></script>
3030
<script type="text/javascript" src="src/js/datetimepicker.js"></script>
3131
<script type="text/javascript" src="src/js/datetimepicker.templates.js"></script>
32-
<script type="text/javascript" src="https://cdn.rawgit.com/dalelotts/angular-date-time-input/v1.0.0/src/dateTimeInput.js"></script>
32+
<script type="text/javascript" src="node_modules/angular-date-time-input/src/dateTimeInput.js"></script>
3333
<style>
3434
.datetimepicker {
3535
width: 400px;

gulpfile.js

+78-78
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,106 @@
1-
/*globals require, __dirname */
1+
/* globals require, __dirname */
22
/* jshint node:true */
3-
'use strict';
4-
5-
var csslint = require('gulp-csslint');
6-
var gulp = require('gulp');
7-
var jscs = require('gulp-jscs');
8-
var jshint = require('gulp-jshint');
9-
var karmaConfig = __dirname + '/karma.conf.js';
10-
var lodash = require('lodash');
11-
var paths = require('./paths');
12-
var plato = require('plato');
13-
var Server = require('karma').Server;
14-
var path = require('path');
3+
'use strict'
4+
5+
var gulp = require('gulp')
6+
var gulpStylelint = require('gulp-stylelint')
7+
var jshint = require('gulp-jshint')
8+
var lodash = require('lodash')
9+
var path = require('path')
10+
var paths = require('./paths')
11+
var plato = require('plato')
12+
var Server = require('karma').Server
13+
var standard = require('gulp-standard')
14+
15+
var karmaConfig = path.join(__dirname, 'karma.conf.js')
1516

1617
gulp.task('build-css', ['scss'], function () {
17-
var Comb = require('csscomb');
18-
var config = require('./.csscomb.json');
19-
var comb = new Comb(config);
20-
comb.processPath('./src/css/');
21-
});
18+
var Comb = require('csscomb')
19+
var config = require('./.csscomb.json')
20+
var comb = new Comb(config)
21+
comb.processPath('./src/css/')
22+
})
2223

2324
gulp.task('clean', function () {
24-
25-
var del = require('del');
25+
var del = require('del')
2626
return del([
2727
'build'
28-
]);
29-
});
28+
])
29+
})
3030

31-
gulp.task('default', ['clean:mobile']);
31+
gulp.task('default', ['clean:mobile'])
3232

3333
gulp.task('complexity', function (done) {
34-
35-
var callback = function () {
36-
done();
37-
};
38-
39-
plato.inspect(paths.lint, 'build/complexity', {title: 'prerender', recurse: true}, callback);
40-
});
41-
34+
function callback () {
35+
done()
36+
}
37+
plato.inspect(paths.lint, 'build/complexity', {title: 'prerender', recurse: true}, callback)
38+
})
4239

4340
gulp.task('csslint', function () {
4441
return gulp.src(paths.css)
45-
.pipe(csslint())
46-
.pipe(csslint.reporter())
47-
.pipe(csslint.failReporter());
48-
});
42+
.pipe(gulpStylelint({
43+
failAfterError: true,
44+
reporters: [
45+
{formatter: 'string', console: true}
46+
]
47+
}))
48+
})
4949

50-
gulp.task('jscs', function () {
50+
gulp.task('standard', function () {
5151
return gulp
5252
.src(paths.lint)
53-
.pipe(jscs('.jscsrc'));
54-
});
53+
.pipe(standard())
54+
.pipe(standard.reporter('default', {
55+
breakOnError: true,
56+
quiet: true
57+
}))
58+
})
5559

5660
gulp.task('lint', function () {
5761
return gulp
5862
.src(paths.lint)
5963
.pipe(jshint('.jshintrc'))
6064
.pipe(jshint.reporter('default', {verbose: true}))
6165
.pipe(jshint.reporter('jshint-stylish'))
62-
.pipe(jshint.reporter('fail'));
63-
});
64-
66+
.pipe(jshint.reporter('fail'))
67+
})
6568

6669
gulp.task('scss', ['scss-lint'], function () {
67-
var scss = require('gulp-sass');
68-
var postcss = require('gulp-postcss');
69-
var sourcemaps = require('gulp-sourcemaps');
70-
var autoprefixer = require('autoprefixer');
70+
var scss = require('gulp-sass')
71+
var postcss = require('gulp-postcss')
72+
var sourcemaps = require('gulp-sourcemaps')
73+
var autoprefixer = require('autoprefixer')
7174

7275
return gulp.src(paths.scss)
7376
.pipe(scss())
7477
.pipe(sourcemaps.init())
7578
.pipe(postcss([autoprefixer({browsers: ['last 2 versions']})]))
7679
.pipe(sourcemaps.write('.'))
77-
.pipe(gulp.dest('./src/css'));
78-
});
80+
.pipe(gulp.dest('./src/css'))
81+
})
7982

8083
gulp.task('scss-lint', function () {
81-
var scssLint = require('gulp-scss-lint');
82-
var scssLintStylish = require('gulp-scss-lint-stylish');
84+
var scssLint = require('gulp-scss-lint')
85+
var scssLintStylish = require('gulp-scss-lint-stylish')
8386
return gulp.src('./src/scss/*.scss')
84-
.pipe(scssLint({customReport: scssLintStylish}));
85-
});
87+
.pipe(scssLint({customReport: scssLintStylish}))
88+
})
8689

87-
var testConfig = function (options) {
88-
var travisOptions = process.env.TRAVIS &&
89-
{
90-
browsers: ['Firefox'],
91-
reporters: ['dots', 'coverage', 'threshold']
92-
};
90+
function testConfig (options) {
91+
var travisDefaultOptions = {
92+
browsers: ['Firefox'],
93+
reporters: ['dots', 'coverage', 'threshold']
94+
}
9395

94-
return lodash.assign(options, travisOptions);
95-
};
96+
var travisOptions = process.env.TRAVIS && travisDefaultOptions
97+
98+
return lodash.assign(options, travisOptions)
99+
}
96100

97101
gulp.task('templatecache', function () {
98-
var templateCache = require('gulp-angular-templatecache');
99-
var htmlMin = require('gulp-htmlmin');
102+
var templateCache = require('gulp-angular-templatecache')
103+
var htmlMin = require('gulp-htmlmin')
100104

101105
return gulp
102106
.src('src/templates/**/*.html')
@@ -105,12 +109,11 @@ gulp.task('templatecache', function () {
105109
base: path.join(__dirname, 'src'),
106110
module: 'ui.bootstrap.datetimepicker'
107111
}))
108-
.pipe(gulp.dest('src/js'));
109-
});
110-
112+
.pipe(gulp.dest('src/js'))
113+
})
111114

112115
gulp.task('tdd', function (done) {
113-
gulp.watch(paths.all.concat(paths.scss), ['jscs', 'lint', 'build-css']);
116+
gulp.watch(paths.all.concat(paths.scss), ['standard', 'lint', 'build-css'])
114117

115118
var config = testConfig(
116119
{
@@ -119,26 +122,23 @@ gulp.task('tdd', function (done) {
119122
configFile: karmaConfig,
120123
singleRun: false
121124
}
122-
);
125+
)
123126

124-
var server = new Server(config, done);
125-
server.start();
126-
});
127-
128-
129-
gulp.task('test', ['jscs', 'lint', 'csslint'], function (done) {
127+
var server = new Server(config, done)
128+
server.start()
129+
})
130130

131+
gulp.task('test', ['standard', 'lint', 'csslint'], function (done) {
131132
var config = testConfig(
132133
{
133134
configFile: karmaConfig,
134135
singleRun: true,
135136
reporters: ['progress', 'coverage', 'threshold']
136137
}
137-
);
138-
139-
var server = new Server(config, done);
140-
server.start();
141-
});
138+
)
142139

140+
var server = new Server(config, done)
141+
server.start()
142+
})
143143

144-
gulp.task('default', ['complexity', 'test']);
144+
gulp.task('default', ['complexity', 'test'])

karma.conf.js

+5-18
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
/*globals require */
1+
/* globals require */
22
/* jshint node:true */
33

44
/**
55
* @license angular-bootstrap-datetimepicker
66
* (c) 2013 Knight Rider Consulting, Inc. http://www.knightrider.com
77
* License: MIT
8-
*/
9-
10-
/**
11-
*
128
* @author Dale "Ducky" Lotts
139
* @since 7/21/13
1410
*/
1511

16-
17-
var paths = require('./paths');
12+
var paths = require('./paths')
1813

1914
module.exports = function (config) {
20-
'use strict';
15+
'use strict'
2116
config.set({
2217

2318
frameworks: ['jasmine'],
@@ -53,7 +48,6 @@ module.exports = function (config) {
5348
// possible values: 'dots', 'progress', 'junit'
5449
reporters: ['progress', 'coverage'],
5550

56-
5751
// the configure thresholds
5852
thresholdReporter: {
5953
statements: 100,
@@ -65,24 +59,19 @@ module.exports = function (config) {
6559
// web server port
6660
port: 9876,
6761

68-
6962
// cli runner port
7063
runnerPort: 9100,
7164

72-
7365
// enable / disable colors in the output (reporters and logs)
7466
colors: true,
7567

76-
7768
// level of logging
7869
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
7970
logLevel: config.LOG_INFO,
8071

81-
8272
// enable / disable watching file and executing tests whenever any file changes
8373
autoWatch: false,
8474

85-
8675
// Start these browsers, currently available:
8776
// - Chrome
8877
// - ChromeCanary
@@ -93,13 +82,11 @@ module.exports = function (config) {
9382
// - IE (only Windows)
9483
browsers: ['PhantomJS'],
9584

96-
9785
// If browser does not capture in given timeout [ms], kill it
9886
captureTimeout: 60000,
9987

100-
10188
// Continuous Integration mode
10289
// if true, it capture browsers, run tests and exit
10390
singleRun: false
104-
});
105-
};
91+
})
92+
}

0 commit comments

Comments
 (0)