Skip to content

Commit

Permalink
Use eslint with loopback config
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bajtos committed Apr 6, 2016
1 parent 2a86e95 commit f9702b0
Show file tree
Hide file tree
Showing 74 changed files with 1,398 additions and 1,439 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
coverage
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "loopback",
"rules": {
"max-len": ["error", 100, 4, {
"ignoreComments": true,
"ignoreUrls": true,
"ignorePattern": "^\\s*var\\s.+=\\s*(require\\s*\\()|(/)"
}]
}
}
1 change: 0 additions & 1 deletion .jshintignore

This file was deleted.

34 changes: 0 additions & 34 deletions .jshintrc

This file was deleted.

104 changes: 51 additions & 53 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*global module:false*/
module.exports = function(grunt) {

// Do not report warnings from unit-tests exercising deprecated paths
process.env.NO_DEPRECATION = 'loopback';

Expand All @@ -18,58 +17,59 @@ module.exports = function(grunt) {
// Task configuration.
uglify: {
options: {
banner: '<%= banner %>'
banner: '<%= banner %>',
},
dist: {
files: {
'dist/loopback.min.js': ['dist/loopback.js']
}
}
},
jshint: {
options: {
jshintrc: true
'dist/loopback.min.js': ['dist/loopback.js'],
},
},
},
eslint: {
gruntfile: {
src: 'Gruntfile.js'
src: 'Gruntfile.js',
},
lib: {
src: ['lib/**/*.js']
src: ['lib/**/*.js'],
},
common: {
src: ['common/**/*.js']
src: ['common/**/*.js'],
},
browser: {
src: ['browser/**/*.js']
src: ['browser/**/*.js'],
},
server: {
src: ['server/**/*.js']
src: ['server/**/*.js'],
},
test: {
src: ['test/**/*.js']
}
},
jscs: {
gruntfile: 'Gruntfile.js',
lib: ['lib/**/*.js'],
common: ['common/**/*.js'],
server: ['server/**/*.js'],
browser: ['browser/**/*.js'],
test: ['test/**/*.js']
src: ['test/**/*.js'],
},
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
files: '<%= eslint.gruntfile.src %>',
tasks: ['eslint:gruntfile'],
},
browser: {
files: ['<%= eslint.browser.src %>'],
tasks: ['eslint:browser'],
},
common: {
files: ['<%= eslint.common.src %>'],
tasks: ['eslint:common'],
},
lib: {
files: ['<%= jshint.lib.src %>'],
tasks: ['jshint:lib']
files: ['<%= eslint.lib.src %>'],
tasks: ['eslint:lib'],
},
server: {
files: ['<%= eslint.server.src %>'],
tasks: ['eslint:server'],
},
test: {
files: ['<%= jshint.test.src %>'],
tasks: ['jshint:test']
}
files: ['<%= eslint.test.src %>'],
tasks: ['eslint:test'],
},
},
browserify: {
dist: {
Expand All @@ -78,24 +78,24 @@ module.exports = function(grunt) {
},
options: {
ignore: ['nodemailer', 'passport', 'bcrypt'],
standalone: 'loopback'
}
}
standalone: 'loopback',
},
},
},
mochaTest: {
'unit': {
src: 'test/*.js',
options: {
reporter: 'dot',
}
},
},
'unit-xml': {
src: 'test/*.js',
options: {
reporter: 'xunit',
captureFile: 'xunit.xml'
}
}
captureFile: 'xunit.xml',
},
},
},
karma: {
'unit-once': {
Expand All @@ -109,16 +109,16 @@ module.exports = function(grunt) {

// CI friendly test output
junitReporter: {
outputFile: 'karma-xunit.xml'
outputFile: 'karma-xunit.xml',
},

browserify: {
// Disable sourcemaps to prevent
// Fatal error: Maximum call stack size exceeded
debug: false,
// Disable watcher, grunt will exit after the first run
watch: false
}
watch: false,
},
},
unit: {
configFile: 'test/karma.conf.js',
Expand All @@ -134,7 +134,7 @@ module.exports = function(grunt) {
// list of files / patterns to load in the browser
files: [
'test/e2e/remote-connector.e2e.js',
'test/e2e/replication.e2e.js'
'test/e2e/replication.e2e.js',
],

// list of files to exclude
Expand Down Expand Up @@ -171,7 +171,7 @@ module.exports = function(grunt) {
// - PhantomJS
// - IE (only Windows)
browsers: [
'Chrome'
'Chrome',
],

// If browser does not capture in given timeout [ms], kill it
Expand All @@ -190,7 +190,7 @@ module.exports = function(grunt) {
'passport-local',
'superagent',
'supertest',
'bcrypt'
'bcrypt',
],
// transform: ['coffeeify'],
// debug: true,
Expand All @@ -199,19 +199,18 @@ module.exports = function(grunt) {
},

// Add browserify to preprocessors
preprocessors: {'test/e2e/*': ['browserify']}
}
}
}
preprocessors: { 'test/e2e/*': ['browserify'] },
},
},
},

});

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-karma');

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

grunt.registerTask('test', [
'jscs',
'jshint',
'eslint',
process.env.JENKINS_HOME ? 'mochaTest:unit-xml' : 'mochaTest:unit',
'karma:unit-once']);
'karma:unit-once']);

// alias for sl-ci-run and `npm test`
grunt.registerTask('mocha-and-karma', ['test']);
Expand Down
6 changes: 2 additions & 4 deletions common/models/access-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ var DEFAULT_TOKEN_LEN = 64;
*/

module.exports = function(AccessToken) {

// Workaround for https://github.com/strongloop/loopback/issues/292
AccessToken.definition.rawProperties.created.default =
AccessToken.definition.properties.created.default = function() {
Expand All @@ -42,7 +41,7 @@ module.exports = function(AccessToken) {
* ```
*/

AccessToken.ANONYMOUS = new AccessToken({id: '$anonymous'});
AccessToken.ANONYMOUS = new AccessToken({ id: '$anonymous' });

/**
* Create a cryptographically random access token id.
Expand Down Expand Up @@ -165,8 +164,7 @@ module.exports = function(AccessToken) {
var headers = options.headers || [];
var cookies = options.cookies || [];
var i = 0;
var length;
var id;
var length, id;

// https://github.com/strongloop/loopback/issues/1326
if (options.searchDefaultTokenKeys !== false) {
Expand Down
Loading

0 comments on commit f9702b0

Please sign in to comment.