Coding style cleanup (Gruntfile, lib)

- Gruntfile: add `jshint` and `jscs` as deps of `grunt test`
 - Gruntfile: temporarily disable checks of `test` scripts
 - .jscsrc: relax jsdoc validation
 - .jshintrc: relax the rule for property access via dot notation
 - lib: fix remaining style issues
This commit is contained in:
Miroslav Bajtoš 2014-11-04 08:13:21 +01:00
parent 33096dafa7
commit 48d4ed28d3
7 changed files with 39 additions and 23 deletions

View File

@ -13,5 +13,10 @@
"value": 150, "value": 150,
"allowComments": true, "allowComments": true,
"allowRegex": true "allowRegex": true
},
"validateJSDoc": {
"checkParamNames": false,
"checkRedundantParams": true,
"requireParamTypes": true
} }
} }

View File

@ -9,6 +9,7 @@
"trailing": true, "trailing": true,
"newcap": true, "newcap": true,
"nonew": true, "nonew": true,
"sub": true,
"laxcomma": true, "laxcomma": true,
"laxbreak": true "laxbreak": true
} }

View File

@ -33,12 +33,16 @@ module.exports = function(grunt) {
lib: { lib: {
src: ['lib/**/*.js'] src: ['lib/**/*.js']
}, },
test: { // TODO(bajtos) - common/**/*.js
src: ['test/**/*.js'] // TODO tests don't pass yet
} // test: {
// src: ['test/**/*.js']
// }
}, },
jscs: { jscs: {
src: ['lib/**/*.js', 'test/**/*.js'] gruntfile: 'Gruntfile.js',
lib: ['lib/**/*.js']
// TODO(bajtos) - common/**/*.js
}, },
watch: { watch: {
gruntfile: { gruntfile: {
@ -83,7 +87,7 @@ module.exports = function(grunt) {
karma: { karma: {
'unit-once': { 'unit-once': {
configFile: 'test/karma.conf.js', configFile: 'test/karma.conf.js',
browsers: [ 'PhantomJS' ], browsers: ['PhantomJS'],
singleRun: true, singleRun: true,
reporters: ['dots', 'junit'], reporters: ['dots', 'junit'],
@ -185,7 +189,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks("grunt-jscs"); grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-karma'); grunt.loadNpmTasks('grunt-karma');
grunt.registerTask('e2e-server', function() { grunt.registerTask('e2e-server', function() {
@ -200,6 +204,8 @@ module.exports = function(grunt) {
grunt.registerTask('default', ['browserify']); grunt.registerTask('default', ['browserify']);
grunt.registerTask('test', [ grunt.registerTask('test', [
'jscs',
'jshint',
process.env.JENKINS_HOME ? 'mochaTest:unit-xml' : 'mochaTest:unit', process.env.JENKINS_HOME ? 'mochaTest:unit-xml' : 'mochaTest:unit',
'karma:unit-once']); 'karma:unit-once']);

View File

@ -41,7 +41,7 @@ function App() {
* Export the app prototype. * Export the app prototype.
*/ */
var app = exports = module.exports = {}; var app = module.exports = {};
/** /**
* Lazily load a set of [remote objects](http://apidocs.strongloop.com/strong-remoting/#remoteobjectsoptions). * Lazily load a set of [remote objects](http://apidocs.strongloop.com/strong-remoting/#remoteobjectsoptions).

View File

@ -28,7 +28,7 @@ var assert = require('assert');
* @header loopback * @header loopback
*/ */
var loopback = exports = module.exports = createApplication; var loopback = module.exports = createApplication;
/*! /*!
* Framework version. * Framework version.

View File

@ -593,10 +593,12 @@ Model.nestRemoting = function(relationName, options, cb) {
var paramName = options.paramName || 'nk'; var paramName = options.paramName || 'nk';
var http = [].concat(sharedToClass.http || [])[0]; var http = [].concat(sharedToClass.http || [])[0];
var httpPath;
var acceptArgs;
if (relation.multiple) { if (relation.multiple) {
var httpPath = pathName + '/:' + paramName; httpPath = pathName + '/:' + paramName;
var acceptArgs = [ acceptArgs = [
{ {
arg: paramName, type: 'any', http: { source: 'path' }, arg: paramName, type: 'any', http: { source: 'path' },
description: 'Foreign key for ' + relation.name, description: 'Foreign key for ' + relation.name,
@ -604,8 +606,8 @@ Model.nestRemoting = function(relationName, options, cb) {
} }
]; ];
} else { } else {
var httpPath = pathName; httpPath = pathName;
var acceptArgs = []; acceptArgs = [];
} }
// A method should return the method name to use, if it is to be // A method should return the method name to use, if it is to be

View File

@ -850,7 +850,7 @@ PersistedModel.replicate = function(since, targetModel, options, callback) {
sourceModel.emit('conflicts', conflicts); sourceModel.emit('conflicts', conflicts);
} }
callback && callback(null, conflicts); if (callback) callback(null, conflicts);
} }
}; };
@ -869,7 +869,7 @@ PersistedModel.createUpdates = function(deltas, cb) {
var tasks = []; var tasks = [];
deltas.forEach(function(change) { deltas.forEach(function(change) {
var change = new Change(change); change = new Change(change);
var type = change.type(); var type = change.type();
var update = {type: type, change: change}; var update = {type: type, change: change};
switch (type) { switch (type) {
@ -1011,15 +1011,15 @@ PersistedModel.enableChangeTracking = function() {
// cleanup // cleanup
setInterval(cleanup, cleanupInterval); setInterval(cleanup, cleanupInterval);
}
function cleanup() { function cleanup() {
Model.rectifyAllChanges(function(err) { Model.rectifyAllChanges(function(err) {
if (err) { if (err) {
console.error(Model.modelName + ' Change Cleanup Error:'); console.error(Model.modelName + ' Change Cleanup Error:');
console.error(err); console.error(err);
} }
}); });
}
} }
}; };
@ -1028,12 +1028,14 @@ PersistedModel._defineChangeModel = function() {
assert(BaseChangeModel, assert(BaseChangeModel,
'Change model must be defined before enabling change replication'); 'Change model must be defined before enabling change replication');
return this.Change = BaseChangeModel.extend(this.modelName + '-change', this.Change = BaseChangeModel.extend(this.modelName + '-change',
{}, {},
{ {
trackModel: this trackModel: this
} }
); );
return this.Change;
}; };
PersistedModel.rectifyAllChanges = function(callback) { PersistedModel.rectifyAllChanges = function(callback) {