mirror of
https://github.com/hanzoai/session.git
synced 2026-09-24 17:02:35 +00:00
lint: add editorconfig and eslint to enforce
This commit is contained in:
@@ -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
|
||||
@@ -0,0 +1,2 @@
|
||||
coverage
|
||||
node_modules
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"rules": {
|
||||
"eol-last": "error",
|
||||
"indent": ["error", 2, { "SwitchCase": 1 }],
|
||||
"no-trailing-spaces": "error"
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
|
||||
@@ -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
@@ -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
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user