Skip to content

Commit

Permalink
lint: add eslint rules that cover editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Aug 6, 2017
1 parent 713d2ae commit 56e90e3
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage
node_modules
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"rules": {
"eol-last": "error",
"indent": ["error", 2, { "SwitchCase": 1 }],
"no-trailing-spaces": "error"
}
}
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ test_script:
- node --version
- npm --version
- npm run test-ci
- npm run lint
version: "{build}"
2 changes: 1 addition & 1 deletion examples/content-negotiation/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ users.push({ name: 'Tobi' });
users.push({ name: 'Loki' });
users.push({ name: 'Jane' });

module.exports = users;
module.exports = users;
2 changes: 1 addition & 1 deletion examples/mvc/controllers/main/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
exports.index = function(req, res){
res.redirect('/users');
};
};
2 changes: 1 addition & 1 deletion examples/mvc/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
users.push({ name: 'Nathan', pets: [], id: 2 });
2 changes: 1 addition & 1 deletion examples/resource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ app.resource('/users', User);

app.get('/', function(req, res){
res.send([
'<h1>Examples:</h1> <ul>'
'<h1>Examples:</h1> <ul>'
, '<li>GET /users</li>'
, '<li>GET /users/1</li>'
, '<li>GET /users/3</li>'
Expand Down
2 changes: 1 addition & 1 deletion examples/route-separation/site.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
exports.index = function(req, res){
res.render('index', { title: 'Route Separation Example' });
};
};
2 changes: 1 addition & 1 deletion examples/search/public/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ search.addEventListener('keyup', function(){
}
};
xhr.send();
}, false);
}, false);
2 changes: 1 addition & 1 deletion examples/static-files/public/js/app.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
foo
foo
2 changes: 1 addition & 1 deletion examples/web-service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var users = [
];

var userRepos = {
tobi: [repos[0], repos[1]]
tobi: [repos[0], repos[1]]
, loki: [repos[1]]
, jane: [repos[2]]
};
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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/",
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/error-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ describe('error-pages', function(){
})
})
})
})
})
2 changes: 1 addition & 1 deletion test/acceptance/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ describe('error', function(){
.expect(404,done)
})
})
})
})
2 changes: 1 addition & 1 deletion test/acceptance/route-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ describe('route-map', function(){
.expect('delete 12\'s pet 2', done);
})
})
})
})
4 changes: 2 additions & 2 deletions test/app.engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('app', function(){
done();
})
})

it('should work "view engine" setting', function(done){
var app = express();

Expand All @@ -62,7 +62,7 @@ describe('app', function(){
done();
})
})

it('should work "view engine" with leading "."', function(done){
var app = express();

Expand Down
12 changes: 6 additions & 6 deletions test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -125,34 +125,34 @@ describe('config', function () {
assert.strictEqual(app.get('tobi'), true);
})
})

describe('.disable()', function(){
it('should set the value to false', function(){
var app = express();
assert.equal(app.disable('tobi'), app);
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');
Expand Down

0 comments on commit 56e90e3

Please sign in to comment.