Permalink
Browse files

Add jshint

  • Loading branch information...
1 parent e3c2c46 commit c0256ac03036a8507f404261f9f1d4324193c57b @mrako committed Jun 24, 2014
Showing with 85 additions and 28 deletions.
  1. +24 −0 .jshintrc
  2. +13 −0 Gruntfile.js
  3. +35 −22 app/routes.js
  4. +1 −0 package.json
  5. +2 −0 public/js/app.js
  6. +7 −5 public/js/controllers/todo_controller.js
  7. +3 −1 public/js/services/todo_factory.js
View
@@ -0,0 +1,24 @@
+{
+ "node": true,
+ "browser": true,
+ "esnext": true,
+ "bitwise": true,
+ "camelcase": true,
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "indent": 2,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "quotmark": "single",
+ "regexp": true,
+ "undef": true,
+ "unused": true,
+ "strict": true,
+ "trailing": true,
+ "smarttabs": true,
+ "globals": {
+ "angular": false
+ }
+}
View
@@ -1,3 +1,5 @@
+'use strict';
+
module.exports = function(grunt) {
grunt.initConfig({
express: {
@@ -20,6 +22,16 @@ module.exports = function(grunt) {
}
}
},
+ jshint: {
+ options: {
+ jshintrc: '.jshintrc'
+ },
+ all: [
+ 'Gruntfile.js',
+ 'app/**/*.js',
+ 'public/js/**/*.js'
+ ]
+ },
open: {
server: {
url: 'http://localhost:<%= express.options.port %>'
@@ -32,5 +44,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks('grunt-contrib-watch');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-open');
};
View
@@ -1,22 +1,26 @@
+'use strict';
+
var Todo = require('./models/todo');
module.exports = function(app) {
// GET ALL ====================================================================
app.get('/api/todos', function(req, res) {
Todo.find(function(err, todos) {
- if (err)
- res.send(err)
+ if (err) {
+ res.send(err);
+ }
res.json(todos);
});
});
// FIND BY ID =================================================================
- app.get('/api/todos/:todo_id', function(req, res) {
- Todo.findById(req.params.todo_id ,function(err, todo) {
- if (err)
- res.send(err)
+ app.get('/api/todos/:todoId', function(req, res) {
+ Todo.findById(req.params.todoId ,function(err, todo) {
+ if (err) {
+ res.send(err);
+ }
res.json(todo);
});
@@ -27,49 +31,58 @@ module.exports = function(app) {
Todo.create({
text : req.body.text,
done : false
- }, function(err, todo) {
- if (err)
+ }, function(err) {
+ if (err) {
res.send(err);
+ }
Todo.find(function(err, todos) {
- if (err)
- res.send(err)
+ if (err) {
+ res.send(err);
+ }
+
res.json(todos);
});
});
});
// UPDATE =====================================================================
- app.put('/api/todos/:todo_id', function(req, res) {
+ app.put('/api/todos/:todoId', function(req, res) {
Todo.update({
- _id: req.params.todo_id
+ _id: req.params.todoId
},{
text : req.body.text,
done : req.body.done
- }, function(err, todo) {
- if (err)
+ }, function(err) {
+ if (err) {
res.send(err);
+ }
Todo.find(function(err, todos) {
- if (err)
- res.send(err)
+ if (err) {
+ res.send(err);
+ }
+
res.json(todos);
});
});
});
// DELETE =====================================================================
- app.delete('/api/todos/:todo_id', function(req, res) {
+ app.delete('/api/todos/:todoId', function(req, res) {
Todo.remove({
- _id : req.params.todo_id
- }, function(err, todo) {
- if (err)
+ _id : req.params.todoId
+ }, function(err) {
+ if (err) {
res.send(err);
+ }
Todo.find(function(err, todos) {
- if (err)
- res.send(err)
+ if (err) {
+ res.send(err);
+ }
+
res.json(todos);
});
});
View
@@ -22,6 +22,7 @@
"grunt": "latest",
"grunt-express-server": "latest",
"grunt-contrib-watch": "latest",
+ "grunt-contrib-jshint": "latest",
"grunt-open": "latest"
}
}
View
@@ -1,3 +1,5 @@
+'use strict';
+
var todoApp = angular.module('todoApp', ['TodoController', 'TodoFactory', 'xeditable']);
todoApp.run(function(editableOptions) {
@@ -1,7 +1,9 @@
+'use strict';
+
angular.module('TodoController', [])
.controller('todoController', function($scope, $http, Todo) {
$scope.formData = {};
- $scope.submit = "Create";
+ $scope.submit = 'Create';
$scope.loading = true;
// GET =====================================================================
@@ -15,7 +17,7 @@ angular.module('TodoController', [])
$scope.save = function() {
$scope.loading = true;
- if ($scope.formData._id == undefined) {
+ if ($scope.formData._id === undefined) {
Todo.create($scope.formData)
.success(function(data) {
$scope.todos = data;
@@ -29,22 +31,22 @@ angular.module('TodoController', [])
$scope.loading = false;
$scope.formData = {};
- $scope.submit = "Create";
+ $scope.submit = 'Create';
};
// CREATE ==================================================================
$scope.edit = function (id) {
Todo.get(id)
.success(function(data) {
$scope.formData = data;
- $scope.submit = "Save";
+ $scope.submit = 'Save';
$scope.loading = false;
});
};
// UPDATE ==================================================================
$scope.update = function(todo) {
- $scope.updateData(todo, todo.text)
+ $scope.updateData(todo, todo.text);
};
$scope.updateData = function(todo, data) {
@@ -1,3 +1,5 @@
+'use strict';
+
// SERVICE FOR API CALLS =======================================================
angular.module('TodoFactory', [])
.factory('Todo', function ($http) {
@@ -17,5 +19,5 @@ angular.module('TodoFactory', [])
delete : function(id) {
return $http.delete('/api/todos/' + id);
}
- }
+ };
});

0 comments on commit c0256ac

Please sign in to comment.