lint: add editorconfig and eslint to enforce

This commit is contained in:
Douglas Christopher Wilson
2017-08-27 22:08:20 -04:00
parent 917b03d0db
commit 8b4f668dba
7 changed files with 39 additions and 15 deletions
+11
View File
@@ -0,0 +1,11 @@
# http://editorconfig.org
root = true
[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
[{*.js,*.json,*.yml}]
indent_size = 2
indent_style = space
+2
View File
@@ -0,0 +1,2 @@
coverage
node_modules
+7
View File
@@ -0,0 +1,7 @@
{
"rules": {
"eol-last": "error",
"indent": ["error", 2, { "SwitchCase": 1 }],
"no-trailing-spaces": "error"
}
}
+2
View File
@@ -20,6 +20,7 @@ before_install:
- "npm config set shrinkwrap false"
# Setup Node.js version-specific dependencies
- "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev istanbul"
- "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 4 || npm rm --save-dev eslint"
# Update Node.js modules
- "test ! -d node_modules || npm prune"
- "test ! -d node_modules || npm rebuild"
@@ -27,5 +28,6 @@ script:
# Run test script, depending on istanbul install
- "test ! -z $(npm -ps ls istanbul) || npm test"
- "test -z $(npm -ps ls istanbul) || npm run-script test-travis"
- "test -z $(npm -ps ls eslint) || npm run-script lint"
after_script:
- "test -e ./coverage/lcov.info && npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
+2
View File
@@ -23,6 +23,7 @@
"devDependencies": {
"after": "0.8.2",
"cookie-parser": "1.4.3",
"eslint": "3.19.0",
"express": "4.15.4",
"istanbul": "0.4.5",
"mocha": "2.5.3",
@@ -38,6 +39,7 @@
"node": ">= 0.8.0"
},
"scripts": {
"lint": "eslint .",
"test": "mocha --check-leaks --bail --no-exit --reporter spec test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --no-exit --reporter dot test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --no-exit --reporter spec test/"
+1 -1
View File
@@ -96,7 +96,7 @@ Cookie.prototype = {
get data() {
return {
originalMaxAge: this.originalMaxAge
originalMaxAge: this.originalMaxAge
, expires: this._expires
, secure: this.secure
, httpOnly: this.httpOnly
+14 -14
View File
@@ -652,17 +652,17 @@ describe('session()', function(){
describe('when disabled', function(){
before(function () {
function setup (req) {
req.secure = req.headers['x-secure']
function setup (req) {
req.secure = req.headers['x-secure']
? JSON.parse(req.headers['x-secure'])
: undefined
}
}
function respond (req, res) {
res.end(String(req.secure))
}
function respond (req, res) {
res.end(String(req.secure))
}
this.server = createServer(setup, { proxy: false, cookie: { secure: true }}, respond)
this.server = createServer(setup, { proxy: false, cookie: { secure: true }}, respond)
})
it('should not trust X-Forwarded-Proto', function(done){
@@ -685,17 +685,17 @@ describe('session()', function(){
describe('when unspecified', function(){
before(function () {
function setup (req) {
req.secure = req.headers['x-secure']
function setup (req) {
req.secure = req.headers['x-secure']
? JSON.parse(req.headers['x-secure'])
: undefined
}
}
function respond (req, res) {
res.end(String(req.secure))
}
function respond (req, res) {
res.end(String(req.secure))
}
this.server = createServer(setup, { cookie: { secure: true }}, respond)
this.server = createServer(setup, { cookie: { secure: true }}, respond)
})
it('should not trust X-Forwarded-Proto', function(done){