lint: add eslint rules that cover editorconfig

This commit is contained in:
Douglas Christopher Wilson 2017-08-05 23:37:39 -04:00
parent 713d2aed93
commit 56e90e3c72
18 changed files with 34 additions and 20 deletions

2
.eslintignore Normal file
View File

@ -0,0 +1,2 @@
coverage
node_modules

7
.eslintrc Normal file
View File

@ -0,0 +1,7 @@
{
"rules": {
"eol-last": "error",
"indent": ["error", 2, { "SwitchCase": 1 }],
"no-trailing-spaces": "error"
}
}

View File

@ -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"

View File

@ -22,4 +22,5 @@ test_script:
- node --version
- npm --version
- npm run test-ci
- npm run lint
version: "{build}"

View File

@ -4,4 +4,4 @@ users.push({ name: 'Tobi' });
users.push({ name: 'Loki' });
users.push({ name: 'Jane' });
module.exports = users;
module.exports = users;

View File

@ -1,3 +1,3 @@
exports.index = function(req, res){
res.redirect('/users');
};
};

View File

@ -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 });

View File

@ -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>'

View File

@ -1,3 +1,3 @@
exports.index = function(req, res){
res.render('index', { title: 'Route Separation Example' });
};
};

View File

@ -10,4 +10,4 @@ search.addEventListener('keyup', function(){
}
};
xhr.send();
}, false);
}, false);

View File

@ -1 +1 @@
foo
foo

View File

@ -61,7 +61,7 @@ var users = [
];
var userRepos = {
tobi: [repos[0], repos[1]]
tobi: [repos[0], repos[1]]
, loki: [repos[1]]
, jane: [repos[2]]
};

View File

@ -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/",

View File

@ -99,4 +99,4 @@ describe('error-pages', function(){
})
})
})
})
})

View File

@ -26,4 +26,4 @@ describe('error', function(){
.expect(404,done)
})
})
})
})

View File

@ -42,4 +42,4 @@ describe('route-map', function(){
.expect('delete 12\'s pet 2', done);
})
})
})
})

View File

@ -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();

View File

@ -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');