diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 00000000..62562b74
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,2 @@
+coverage
+node_modules
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 00000000..8f51db36
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,7 @@
+{
+ "rules": {
+ "eol-last": "error",
+ "indent": ["error", 2, { "SwitchCase": 1 }],
+ "no-trailing-spaces": "error"
+ }
+}
diff --git a/.travis.yml b/.travis.yml
index 3e899dd2..5926ca56 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,5 +27,7 @@ before_install:
# Update Node.js modules
- "test ! -d node_modules || npm prune"
- "test ! -d node_modules || npm rebuild"
-script: "npm run-script test-ci"
+script:
+ - "npm run test-ci"
+ - "npm run lint"
after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls"
diff --git a/appveyor.yml b/appveyor.yml
index ed8d4aa9..9863c08e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -22,4 +22,5 @@ test_script:
- node --version
- npm --version
- npm run test-ci
+ - npm run lint
version: "{build}"
diff --git a/examples/content-negotiation/db.js b/examples/content-negotiation/db.js
index 8def2f5a..43fb04ba 100644
--- a/examples/content-negotiation/db.js
+++ b/examples/content-negotiation/db.js
@@ -4,4 +4,4 @@ users.push({ name: 'Tobi' });
users.push({ name: 'Loki' });
users.push({ name: 'Jane' });
-module.exports = users;
\ No newline at end of file
+module.exports = users;
diff --git a/examples/mvc/controllers/main/index.js b/examples/mvc/controllers/main/index.js
index 83db90f6..031862d3 100644
--- a/examples/mvc/controllers/main/index.js
+++ b/examples/mvc/controllers/main/index.js
@@ -1,3 +1,3 @@
exports.index = function(req, res){
res.redirect('/users');
-};
\ No newline at end of file
+};
diff --git a/examples/mvc/db.js b/examples/mvc/db.js
index 565fdfaa..c992afcf 100644
--- a/examples/mvc/db.js
+++ b/examples/mvc/db.js
@@ -11,4 +11,4 @@ var users = exports.users = [];
users.push({ name: 'TJ', pets: [pets[0], pets[1], pets[2]], id: 0 });
users.push({ name: 'Guillermo', pets: [pets[3]], id: 1 });
-users.push({ name: 'Nathan', pets: [], id: 2 });
\ No newline at end of file
+users.push({ name: 'Nathan', pets: [], id: 2 });
diff --git a/examples/resource/index.js b/examples/resource/index.js
index 9137167c..0c2a7a32 100644
--- a/examples/resource/index.js
+++ b/examples/resource/index.js
@@ -75,7 +75,7 @@ app.resource('/users', User);
app.get('/', function(req, res){
res.send([
- '
Examples:
'
+ 'Examples:
'
, '- GET /users
'
, '- GET /users/1
'
, '- GET /users/3
'
diff --git a/examples/route-separation/site.js b/examples/route-separation/site.js
index 698892cc..a3d20bc8 100644
--- a/examples/route-separation/site.js
+++ b/examples/route-separation/site.js
@@ -1,3 +1,3 @@
exports.index = function(req, res){
res.render('index', { title: 'Route Separation Example' });
-};
\ No newline at end of file
+};
diff --git a/examples/search/public/client.js b/examples/search/public/client.js
index 0c198cc3..a7eeb6a7 100644
--- a/examples/search/public/client.js
+++ b/examples/search/public/client.js
@@ -10,4 +10,4 @@ search.addEventListener('keyup', function(){
}
};
xhr.send();
-}, false);
\ No newline at end of file
+}, false);
diff --git a/examples/static-files/public/js/app.js b/examples/static-files/public/js/app.js
index 19102815..257cc564 100644
--- a/examples/static-files/public/js/app.js
+++ b/examples/static-files/public/js/app.js
@@ -1 +1 @@
-foo
\ No newline at end of file
+foo
diff --git a/examples/web-service/index.js b/examples/web-service/index.js
index 694e121d..41747cfd 100644
--- a/examples/web-service/index.js
+++ b/examples/web-service/index.js
@@ -61,7 +61,7 @@ var users = [
];
var userRepos = {
- tobi: [repos[0], repos[1]]
+ tobi: [repos[0], repos[1]]
, loki: [repos[1]]
, jane: [repos[2]]
};
diff --git a/package.json b/package.json
index 15e80f19..9f38f52b 100644
--- a/package.json
+++ b/package.json
@@ -61,6 +61,7 @@
"body-parser": "1.17.2",
"cookie-parser": "~1.4.3",
"ejs": "2.5.7",
+ "eslint": "2.13.1",
"express-session": "1.15.3",
"hbs": "4.0.1",
"istanbul": "0.4.5",
@@ -87,6 +88,7 @@
"lib/"
],
"scripts": {
+ "lint": "eslint .",
"test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/",
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/",
diff --git a/test/acceptance/error-pages.js b/test/acceptance/error-pages.js
index 886cedca..9af95017 100644
--- a/test/acceptance/error-pages.js
+++ b/test/acceptance/error-pages.js
@@ -99,4 +99,4 @@ describe('error-pages', function(){
})
})
})
-})
\ No newline at end of file
+})
diff --git a/test/acceptance/error.js b/test/acceptance/error.js
index 6010f2e2..6bdf099f 100644
--- a/test/acceptance/error.js
+++ b/test/acceptance/error.js
@@ -26,4 +26,4 @@ describe('error', function(){
.expect(404,done)
})
})
-})
\ No newline at end of file
+})
diff --git a/test/acceptance/route-map.js b/test/acceptance/route-map.js
index ae3eeea6..0bd2a6d3 100644
--- a/test/acceptance/route-map.js
+++ b/test/acceptance/route-map.js
@@ -42,4 +42,4 @@ describe('route-map', function(){
.expect('delete 12\'s pet 2', done);
})
})
-})
\ No newline at end of file
+})
diff --git a/test/app.engine.js b/test/app.engine.js
index 6d1ee1ca..b198292f 100644
--- a/test/app.engine.js
+++ b/test/app.engine.js
@@ -47,7 +47,7 @@ describe('app', function(){
done();
})
})
-
+
it('should work "view engine" setting', function(done){
var app = express();
@@ -62,7 +62,7 @@ describe('app', function(){
done();
})
})
-
+
it('should work "view engine" with leading "."', function(done){
var app = express();
diff --git a/test/config.js b/test/config.js
index e298e76a..17a02b7e 100644
--- a/test/config.js
+++ b/test/config.js
@@ -49,7 +49,7 @@ describe('config', function () {
var app = express();
assert.strictEqual(app.get('foo'), undefined);
})
-
+
it('should otherwise return the value', function(){
var app = express();
app.set('foo', 'bar');
@@ -125,7 +125,7 @@ describe('config', function () {
assert.strictEqual(app.get('tobi'), true);
})
})
-
+
describe('.disable()', function(){
it('should set the value to false', function(){
var app = express();
@@ -133,26 +133,26 @@ describe('config', function () {
assert.strictEqual(app.get('tobi'), false);
})
})
-
+
describe('.enabled()', function(){
it('should default to false', function(){
var app = express();
assert.strictEqual(app.enabled('foo'), false);
})
-
+
it('should return true when set', function(){
var app = express();
app.set('foo', 'bar');
assert.strictEqual(app.enabled('foo'), true);
})
})
-
+
describe('.disabled()', function(){
it('should default to true', function(){
var app = express();
assert.strictEqual(app.disabled('foo'), true);
})
-
+
it('should return false when set', function(){
var app = express();
app.set('foo', 'bar');