Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Properly run JSHint
Browse files Browse the repository at this point in the history
  • Loading branch information
amoshaviv committed Dec 25, 2013
1 parent d35cd02 commit 822d7ca
Show file tree
Hide file tree
Showing 37 changed files with 125 additions and 114 deletions.
10 changes: 5 additions & 5 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
"browser": true, // Standard browser globals e.g. `window`, `document`.
"es5": true, // Allow EcmaScript 5 syntax.
"esnext": true, // Allow ES.next specific features such as `const` and `let`.
"bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
"camelcase": false, // Permit only camelcase for `var` and `object indexes`.
Expand All @@ -15,7 +14,7 @@
"regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
"undef": true, // Require all non-global variables be declared before they are used.
"unused": true, // Warn unused variables.
"strict": false, // Require `use strict` pragma in every file.
"strict": true, // Require `use strict` pragma in every file.
"trailing": true, // Prohibit trailing whitespaces.
"smarttabs": false, // Suppresses warnings about mixed tabs and spaces
"globals": { // Globals variables.
Expand All @@ -31,10 +30,11 @@
"beforeEach",
"after",
"afterEach",
"it"
"it",
"inject",
"expect"
],
"indent": 4, // Specify indentation spacing
"maxlen": 120, // Max line lenght
"devel": false, // Allow development statements e.g. `console.log();`.
"devel": true, // Allow development statements e.g. `console.log();`.
"noempty": true // Prohibit use of empty blocks.
}
16 changes: 13 additions & 3 deletions app/controllers/articles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* Module dependencies.
*/
Expand Down Expand Up @@ -46,7 +48,14 @@ exports.update = function(req, res) {
article = _.extend(article, req.body);

article.save(function(err) {
res.jsonp(article);
if (err) {
return res.send('users/signup', {
errors: err.errors,
article: article
});
} else {
res.jsonp(article);
}
});
};

Expand All @@ -58,8 +67,9 @@ exports.destroy = function(req, res) {

article.remove(function(err) {
if (err) {
res.render('error', {
status: 500
return res.send('users/signup', {
errors: err.errors,
article: article
});
} else {
res.jsonp(article);
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/**
* Module dependencies.
*/
var mongoose = require('mongoose');

'use strict';

exports.render = function(req, res) {
res.render('index', {
user: req.user ? JSON.stringify(req.user) : "null"
user: req.user ? JSON.stringify(req.user) : 'null'
});
};
12 changes: 7 additions & 5 deletions app/controllers/users.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* Module dependencies.
*/
Expand All @@ -7,7 +9,7 @@ var mongoose = require('mongoose'),
/**
* Auth callback
*/
exports.authCallback = function(req, res, next) {
exports.authCallback = function(req, res) {
res.redirect('/');
};

Expand Down Expand Up @@ -49,19 +51,19 @@ exports.session = function(req, res) {
/**
* Create user
*/
exports.create = function(req, res) {
exports.create = function(req, res, next) {
var user = new User(req.body);
var message = null;

user.provider = 'local';
user.save(function(err) {
if (err) {
switch(err.code){
switch (err.code) {
case 11000:
case 11001:
message = 'Username already exists';
break;
default:
default:
message = 'Please fill all the required fields';
}

Expand Down Expand Up @@ -98,4 +100,4 @@ exports.user = function(req, res, next, id) {
req.profile = user;
next();
});
};
};
3 changes: 2 additions & 1 deletion app/models/article.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict';

/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
config = require('../../config/config'),
Schema = mongoose.Schema;


Expand Down
8 changes: 5 additions & 3 deletions app/models/user.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* Module dependencies.
*/
Expand Down Expand Up @@ -104,7 +106,7 @@ UserSchema.methods = {
* @api public
*/
makeSalt: function() {
return crypto.randomBytes(16).toString('base64');
return crypto.randomBytes(16).toString('base64');
},

/**
Expand All @@ -116,9 +118,9 @@ UserSchema.methods = {
*/
encryptPassword: function(password) {
if (!password || !this.salt) return '';
salt = new Buffer(this.salt, 'base64');
var salt = new Buffer(this.salt, 'base64');
return crypto.pbkdf2Sync(password, salt, 10000, 64).toString('base64');
}
};

mongoose.model('User', UserSchema);
mongoose.model('User', UserSchema);
2 changes: 1 addition & 1 deletion app/views/includes/foot.jade
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ script(type='text/javascript', src='/js/init.js')

if (process.env.NODE_ENV == 'development')
//Livereload script rendered
script(type='text/javascript', src='http://localhost:35729/livereload.js')
script(type='text/javascript', src='http://' + req.host + ':35729/livereload.js')
29 changes: 13 additions & 16 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
{
"name": "mean",
"version": "0.1.0",
"dependencies": {
"angular": "latest",
"angular-resource": "latest",
"angular-cookies": "latest",
"angular-mocks": "latest",
"angular-route": "latest",
"bootstrap": "2.3.2",
"angular-bootstrap": "0.7.0",
"angular-ui-utils": "0.0.4"
},
"resolutions": {
"angular": "1.2.6"
}
}
"name": "mean",
"version": "0.1.0",
"dependencies": {
"angular": "latest",
"angular-resource": "latest",
"angular-cookies": "latest",
"angular-mocks": "latest",
"angular-route": "latest",
"bootstrap": "2.3.2",
"angular-bootstrap": "0.7.0",
"angular-ui-utils": "0.0.4"
}
}
2 changes: 2 additions & 0 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var _ = require('lodash');

// Load app configuration
Expand Down
2 changes: 2 additions & 0 deletions config/env/all.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var path = require('path'),
rootPath = path.normalize(__dirname + '/../..');

Expand Down
2 changes: 2 additions & 0 deletions config/env/development.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = {
db: "mongodb://localhost/mean-dev",
app: {
Expand Down
2 changes: 2 additions & 0 deletions config/env/production.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = {
db: "mongodb://localhost/mean",
app: {
Expand Down
2 changes: 2 additions & 0 deletions config/env/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = {
db: "mongodb://localhost/mean-test",
port: 3001,
Expand Down
27 changes: 0 additions & 27 deletions config/env/travis.json

This file was deleted.

2 changes: 2 additions & 0 deletions config/express.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* Module dependencies.
*/
Expand Down
2 changes: 2 additions & 0 deletions config/middlewares/authorization.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* Generic require login routing middleware
*/
Expand Down
2 changes: 2 additions & 0 deletions config/passport.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var mongoose = require('mongoose'),
LocalStrategy = require('passport-local').Strategy,
TwitterStrategy = require('passport-twitter').Strategy,
Expand Down
2 changes: 2 additions & 0 deletions config/routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = function(app, passport, auth) {
//User Routes
var users = require('../app/controllers/users');
Expand Down
14 changes: 9 additions & 5 deletions gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = function(grunt) {
// Project Configuration
grunt.initConfig({
Expand All @@ -10,7 +12,7 @@ module.exports = function(grunt) {
},
},
js: {
files: ['public/js/**', 'app/**/*.js'],
files: ['gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js'],
tasks: ['jshint'],
options: {
livereload: true,
Expand All @@ -31,17 +33,19 @@ module.exports = function(grunt) {
},
jshint: {
all: {
src: ['gruntfile.js', 'public/js/**/*.js', 'test/mocha/**/*.js', 'test/karma/**/*.js', 'app/**/*.js']
src: ['gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js'],
options: {
jshintrc: true
}
}
},
nodemon: {
dev: {
options: {
file: 'server.js',
args: [],
ignoredFiles: ['README.md', 'node_modules/**', '.DS_Store'],
ignoredFiles: ['public/**'],
watchedExtensions: ['js'],
watchedFolders: ['app', 'config'],
debug: true,
delayTime: 1,
env: {
Expand Down Expand Up @@ -92,4 +96,4 @@ module.exports = function(grunt) {

//Test task.
grunt.registerTask('test', ['env:test', 'mochaTest', 'karma:unit']);
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"engines": {
"node": "0.10.x",
"npm": "1.2.x"
"npm": "1.3.x"
},
"scripts": {
"start": "node node_modules/grunt-cli/bin/grunt",
Expand Down
2 changes: 2 additions & 0 deletions public/js/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

angular.module('mean', ['ngCookies', 'ngResource', 'ngRoute', 'ui.bootstrap', 'ui.route', 'mean.system', 'mean.articles']);

angular.module('mean.system', []);
Expand Down
4 changes: 3 additions & 1 deletion public/js/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

//Setting up route
angular.module('mean').config(['$routeProvider',
function($routeProvider) {
Expand Down Expand Up @@ -26,6 +28,6 @@ angular.module('mean').config(['$routeProvider',
//Setting HTML5 Location Mode
angular.module('mean').config(['$locationProvider',
function($locationProvider) {
$locationProvider.hashPrefix("!");
$locationProvider.hashPrefix('!');
}
]);
12 changes: 7 additions & 5 deletions public/js/controllers/articles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

angular.module('mean.articles').controller('ArticlesController', ['$scope', '$routeParams', '$location', 'Global', 'Articles', function ($scope, $routeParams, $location, Global, Articles) {
$scope.global = Global;

Expand All @@ -7,19 +9,19 @@ angular.module('mean.articles').controller('ArticlesController', ['$scope', '$ro
content: this.content
});
article.$save(function(response) {
$location.path("articles/" + response._id);
$location.path('articles/' + response._id);
});

this.title = "";
this.content = "";
this.title = '';
this.content = '';
};

$scope.remove = function(article) {
if (article) {
article.$remove();
article.$remove();

for (var i in $scope.articles) {
if ($scope.articles[i] == article) {
if ($scope.articles[i] === article) {
$scope.articles.splice(i, 1);
}
}
Expand Down
Loading

0 comments on commit 822d7ca

Please sign in to comment.