Skip to content

Commit 5e90c93

Browse files
author
Walden Raines
committed
Use eslint to enforce coding standards.
Enforce a series of checks in order to maintain readability of code. Now before opening a pull request one can run `grunt check` and all linting and testing will be executed.
1 parent 21e21c6 commit 5e90c93

18 files changed

+429
-375
lines changed

.editorconfig

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ end_of_line = lf
88
charset = utf-8
99
trim_trailing_whitespace = true
1010
insert_final_newline = true
11-
12-
# Tabs in JS unless otherwise specified
13-
[**.js]
1411
indent_style = space
1512
indent_size = 2
1613

1714
[*.md]
18-
trim_trailing_whitespace = false
15+
trim_trailing_whitespace = false

.jshintrc

-27
This file was deleted.

Gruntfile.js

+16-22
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
'use strict';
2-
3-
module.exports = function(grunt) {
1+
module.exports = function (grunt) {
2+
'use strict';
43

54
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
65

7-
function init() {
6+
function init () {
87

98
grunt.initConfig({
109
availabletasks: {
@@ -16,7 +15,7 @@ module.exports = function(grunt) {
1615
'build': 'Builds the project (including documentation) into the dist directory. You can specify modules to be built as arguments (' +
1716
'grunt build:buttons:notification) otherwise all available modules are built.',
1817
'test': 'Executes the karma testsuite.',
19-
'watch': 'Whenever js source files (from the src directory) change, the tasks executes jshint and documentation build.',
18+
'watch': 'Whenever js source files (from the src directory) change, the tasks executes jslint and documentation build.',
2019
'ngdocs': 'Builds documentation into dist/docs.',
2120
'ngdocs:view': 'Builds documentation into dist/docs and runs a web server. The docs can be accessed on http://localhost:8000/'
2221
},
@@ -87,20 +86,14 @@ module.exports = function(grunt) {
8786
}
8887
}
8988
},
90-
jshint: {
91-
files: ['Gruntfile.js', 'src/**/*.js'],
89+
eslint: {
9290
options: {
93-
jshintrc: '.jshintrc'
91+
configFile: 'eslint.yaml'
9492
},
95-
beforeconcat: {
96-
options: {
97-
force: true,
98-
ignores: ['**.min.js']
99-
},
100-
files: {
101-
src: 'src/**/*.js'
102-
}
103-
}
93+
target: [
94+
'Gruntfile.js',
95+
'src/**/*.js'
96+
]
10497
},
10598
karma: {
10699
unit: {
@@ -177,7 +170,7 @@ module.exports = function(grunt) {
177170
watch: {
178171
main: {
179172
files: ['Gruntfile.js'],
180-
tasks: ['jshint']
173+
tasks: ['eslint']
181174
},
182175
js: {
183176
files: ['Gruntfile.js', 'src/**/*.js'],
@@ -187,11 +180,11 @@ module.exports = function(grunt) {
187180
});
188181

189182
// You can specify which modules to build as arguments of the build task.
190-
grunt.registerTask('build', 'Create bootstrap build files', function() {
183+
grunt.registerTask('build', 'Create bootstrap build files', function () {
191184
var concatSrc = [];
192185

193186
if (this.args.length) {
194-
this.args.forEach(function(file) {
187+
this.args.forEach(function (file) {
195188
if (grunt.file.exists('./src/' + file)) {
196189
grunt.log.ok('Adding ' + file + ' to the build queue.');
197190
concatSrc.push('src/' + file + '/*.js');
@@ -204,13 +197,14 @@ module.exports = function(grunt) {
204197
concatSrc = 'src/**/*.js';
205198
}
206199

207-
grunt.task.run(['clean', 'jshint:beforeconcat', 'lint', 'test', 'ngtemplates', 'concat', 'uglify:build', 'cssmin', 'copy', 'ngdocs', 'clean:templates']);
200+
grunt.task.run(['clean', 'lint', 'test', 'ngtemplates', 'concat', 'uglify:build', 'cssmin', 'copy', 'ngdocs', 'clean:templates']);
208201
});
209202

210203
grunt.registerTask('default', ['build']);
211204
grunt.registerTask('ngdocs:view', ['build', 'connect:docs', 'watch']);
212-
grunt.registerTask('lint', ['jshint', 'htmlhint']);
205+
grunt.registerTask('lint', ['eslint', 'htmlhint']);
213206
grunt.registerTask('test', ['karma']);
207+
grunt.registerTask('check', ['lint', 'test']);
214208
grunt.registerTask('help', ['availabletasks']);
215209

216210
}

0 commit comments

Comments
 (0)