Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add jshint

  • Loading branch information...
commit c0256ac03036a8507f404261f9f1d4324193c57b 1 parent e3c2c46
@mrako authored
View
24 .jshintrc
@@ -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
13 Gruntfile.js
@@ -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
57 app/routes.js
@@ -1,3 +1,5 @@
+'use strict';
+
var Todo = require('./models/todo');
module.exports = function(app) {
@@ -5,18 +7,20 @@ 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,13 +31,16 @@ 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);
});
});
@@ -41,35 +48,41 @@ module.exports = function(app) {
});
// 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
1  package.json
@@ -22,6 +22,7 @@
"grunt": "latest",
"grunt-express-server": "latest",
"grunt-contrib-watch": "latest",
+ "grunt-contrib-jshint": "latest",
"grunt-open": "latest"
}
}
View
2  public/js/app.js
@@ -1,3 +1,5 @@
+'use strict';
+
var todoApp = angular.module('todoApp', ['TodoController', 'TodoFactory', 'xeditable']);
todoApp.run(function(editableOptions) {
View
12 public/js/controllers/todo_controller.js
@@ -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,7 +31,7 @@ angular.module('TodoController', [])
$scope.loading = false;
$scope.formData = {};
- $scope.submit = "Create";
+ $scope.submit = 'Create';
};
// CREATE ==================================================================
@@ -37,14 +39,14 @@ angular.module('TodoController', [])
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) {
View
4 public/js/services/todo_factory.js
@@ -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.
Something went wrong with that request. Please try again.