Skip to content

Commit f9702b0

Browse files
committed
Use eslint with loopback config
Drop jshint and jscs in favour of eslint. Fix style violations. While we are at this, reduce the max line length from 150 to 100.
1 parent 2a86e95 commit f9702b0

Some content is hidden

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

74 files changed

+1398
-1439
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
coverage

.eslintrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "loopback",
3+
"rules": {
4+
"max-len": ["error", 100, 4, {
5+
"ignoreComments": true,
6+
"ignoreUrls": true,
7+
"ignorePattern": "^\\s*var\\s.+=\\s*(require\\s*\\()|(/)"
8+
}]
9+
}
10+
}

.jshintignore

-1
This file was deleted.

.jshintrc

-34
This file was deleted.

Gruntfile.js

+51-53
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*global module:false*/
22
module.exports = function(grunt) {
3-
43
// Do not report warnings from unit-tests exercising deprecated paths
54
process.env.NO_DEPRECATION = 'loopback';
65

@@ -18,58 +17,59 @@ module.exports = function(grunt) {
1817
// Task configuration.
1918
uglify: {
2019
options: {
21-
banner: '<%= banner %>'
20+
banner: '<%= banner %>',
2221
},
2322
dist: {
2423
files: {
25-
'dist/loopback.min.js': ['dist/loopback.js']
26-
}
27-
}
28-
},
29-
jshint: {
30-
options: {
31-
jshintrc: true
24+
'dist/loopback.min.js': ['dist/loopback.js'],
25+
},
3226
},
27+
},
28+
eslint: {
3329
gruntfile: {
34-
src: 'Gruntfile.js'
30+
src: 'Gruntfile.js',
3531
},
3632
lib: {
37-
src: ['lib/**/*.js']
33+
src: ['lib/**/*.js'],
3834
},
3935
common: {
40-
src: ['common/**/*.js']
36+
src: ['common/**/*.js'],
4137
},
4238
browser: {
43-
src: ['browser/**/*.js']
39+
src: ['browser/**/*.js'],
4440
},
4541
server: {
46-
src: ['server/**/*.js']
42+
src: ['server/**/*.js'],
4743
},
4844
test: {
49-
src: ['test/**/*.js']
50-
}
51-
},
52-
jscs: {
53-
gruntfile: 'Gruntfile.js',
54-
lib: ['lib/**/*.js'],
55-
common: ['common/**/*.js'],
56-
server: ['server/**/*.js'],
57-
browser: ['browser/**/*.js'],
58-
test: ['test/**/*.js']
45+
src: ['test/**/*.js'],
46+
},
5947
},
6048
watch: {
6149
gruntfile: {
62-
files: '<%= jshint.gruntfile.src %>',
63-
tasks: ['jshint:gruntfile']
50+
files: '<%= eslint.gruntfile.src %>',
51+
tasks: ['eslint:gruntfile'],
52+
},
53+
browser: {
54+
files: ['<%= eslint.browser.src %>'],
55+
tasks: ['eslint:browser'],
56+
},
57+
common: {
58+
files: ['<%= eslint.common.src %>'],
59+
tasks: ['eslint:common'],
6460
},
6561
lib: {
66-
files: ['<%= jshint.lib.src %>'],
67-
tasks: ['jshint:lib']
62+
files: ['<%= eslint.lib.src %>'],
63+
tasks: ['eslint:lib'],
64+
},
65+
server: {
66+
files: ['<%= eslint.server.src %>'],
67+
tasks: ['eslint:server'],
6868
},
6969
test: {
70-
files: ['<%= jshint.test.src %>'],
71-
tasks: ['jshint:test']
72-
}
70+
files: ['<%= eslint.test.src %>'],
71+
tasks: ['eslint:test'],
72+
},
7373
},
7474
browserify: {
7575
dist: {
@@ -78,24 +78,24 @@ module.exports = function(grunt) {
7878
},
7979
options: {
8080
ignore: ['nodemailer', 'passport', 'bcrypt'],
81-
standalone: 'loopback'
82-
}
83-
}
81+
standalone: 'loopback',
82+
},
83+
},
8484
},
8585
mochaTest: {
8686
'unit': {
8787
src: 'test/*.js',
8888
options: {
8989
reporter: 'dot',
90-
}
90+
},
9191
},
9292
'unit-xml': {
9393
src: 'test/*.js',
9494
options: {
9595
reporter: 'xunit',
96-
captureFile: 'xunit.xml'
97-
}
98-
}
96+
captureFile: 'xunit.xml',
97+
},
98+
},
9999
},
100100
karma: {
101101
'unit-once': {
@@ -109,16 +109,16 @@ module.exports = function(grunt) {
109109

110110
// CI friendly test output
111111
junitReporter: {
112-
outputFile: 'karma-xunit.xml'
112+
outputFile: 'karma-xunit.xml',
113113
},
114114

115115
browserify: {
116116
// Disable sourcemaps to prevent
117117
// Fatal error: Maximum call stack size exceeded
118118
debug: false,
119119
// Disable watcher, grunt will exit after the first run
120-
watch: false
121-
}
120+
watch: false,
121+
},
122122
},
123123
unit: {
124124
configFile: 'test/karma.conf.js',
@@ -134,7 +134,7 @@ module.exports = function(grunt) {
134134
// list of files / patterns to load in the browser
135135
files: [
136136
'test/e2e/remote-connector.e2e.js',
137-
'test/e2e/replication.e2e.js'
137+
'test/e2e/replication.e2e.js',
138138
],
139139

140140
// list of files to exclude
@@ -171,7 +171,7 @@ module.exports = function(grunt) {
171171
// - PhantomJS
172172
// - IE (only Windows)
173173
browsers: [
174-
'Chrome'
174+
'Chrome',
175175
],
176176

177177
// If browser does not capture in given timeout [ms], kill it
@@ -190,7 +190,7 @@ module.exports = function(grunt) {
190190
'passport-local',
191191
'superagent',
192192
'supertest',
193-
'bcrypt'
193+
'bcrypt',
194194
],
195195
// transform: ['coffeeify'],
196196
// debug: true,
@@ -199,19 +199,18 @@ module.exports = function(grunt) {
199199
},
200200

201201
// Add browserify to preprocessors
202-
preprocessors: {'test/e2e/*': ['browserify']}
203-
}
204-
}
205-
}
202+
preprocessors: { 'test/e2e/*': ['browserify'] },
203+
},
204+
},
205+
},
206206

207207
});
208208

209209
// These plugins provide necessary tasks.
210210
grunt.loadNpmTasks('grunt-browserify');
211211
grunt.loadNpmTasks('grunt-contrib-uglify');
212-
grunt.loadNpmTasks('grunt-contrib-jshint');
212+
grunt.loadNpmTasks('grunt-eslint');
213213
grunt.loadNpmTasks('grunt-contrib-watch');
214-
grunt.loadNpmTasks('grunt-jscs');
215214
grunt.loadNpmTasks('grunt-karma');
216215

217216
grunt.registerTask('e2e-server', function() {
@@ -229,10 +228,9 @@ module.exports = function(grunt) {
229228
grunt.registerTask('default', ['browserify']);
230229

231230
grunt.registerTask('test', [
232-
'jscs',
233-
'jshint',
231+
'eslint',
234232
process.env.JENKINS_HOME ? 'mochaTest:unit-xml' : 'mochaTest:unit',
235-
'karma:unit-once']);
233+
'karma:unit-once']);
236234

237235
// alias for sl-ci-run and `npm test`
238236
grunt.registerTask('mocha-and-karma', ['test']);

common/models/access-token.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ var DEFAULT_TOKEN_LEN = 64;
2727
*/
2828

2929
module.exports = function(AccessToken) {
30-
3130
// Workaround for https://github.com/strongloop/loopback/issues/292
3231
AccessToken.definition.rawProperties.created.default =
3332
AccessToken.definition.properties.created.default = function() {
@@ -42,7 +41,7 @@ module.exports = function(AccessToken) {
4241
* ```
4342
*/
4443

45-
AccessToken.ANONYMOUS = new AccessToken({id: '$anonymous'});
44+
AccessToken.ANONYMOUS = new AccessToken({ id: '$anonymous' });
4645

4746
/**
4847
* Create a cryptographically random access token id.
@@ -165,8 +164,7 @@ module.exports = function(AccessToken) {
165164
var headers = options.headers || [];
166165
var cookies = options.cookies || [];
167166
var i = 0;
168-
var length;
169-
var id;
167+
var length, id;
170168

171169
// https://github.com/strongloop/loopback/issues/1326
172170
if (options.searchDefaultTokenKeys !== false) {

0 commit comments

Comments
 (0)