Skip to content

Commit

Permalink
lint: use standard style
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed May 30, 2016
1 parent c350d7d commit 4b89157
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 213 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
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "standard"
}
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cache:
- node_modules
before_install:
# Setup Node.js version-specific dependencies
- "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev istanbul"
- "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev eslint eslint-config-standard eslint-plugin-promise eslint-plugin-standard istanbul"

# Update Node.js modules
- "test ! -d node_modules || npm prune"
Expand All @@ -23,5 +23,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-ci"
- "test -z $(npm -ps ls eslint ) || npm run-script lint"
after_script:
- "test -e ./coverage/lcov.info && npm install [email protected] && 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 @@ -13,6 +13,7 @@ cache:
install:
- ps: Install-Product node $env:nodejs_version
- if "%nodejs_version%" equ "0.8" npm rm --save-dev istanbul
- npm rm --save-dev eslint eslint-config-standard eslint-plugin-promise eslint-plugin-standard
- if exist node_modules npm prune
- if exist node_modules npm rebuild
- npm install
Expand Down
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports.mime = send.mime
* @public
*/

function serveStatic(root, options) {
function serveStatic (root, options) {
if (!root) {
throw new TypeError('root path required')
}
Expand Down Expand Up @@ -68,7 +68,7 @@ function serveStatic(root, options) {
? createRedirectDirectoryListener()
: createNotFoundDirectoryListener()

return function serveStatic(req, res, next) {
return function serveStatic (req, res, next) {
if (req.method !== 'GET' && req.method !== 'HEAD') {
if (fallthrough) {
return next()
Expand Down Expand Up @@ -104,14 +104,14 @@ function serveStatic(root, options) {

// add file listener for fallthrough
if (fallthrough) {
stream.on('file', function onFile() {
stream.on('file', function onFile () {
// once file is determined, always forward error
forwardError = true
})
}

// forward errors
stream.on('error', function error(err) {
stream.on('error', function error (err) {
if (forwardError || !(err.statusCode < 500)) {
next(err)
return
Expand All @@ -129,7 +129,7 @@ function serveStatic(root, options) {
* Collapse all leading slashes into a single slash
* @private
*/
function collapseLeadingSlashes(str) {
function collapseLeadingSlashes (str) {
for (var i = 0; i < str.length; i++) {
if (str[i] !== '/') {
break
Expand All @@ -146,8 +146,8 @@ function collapseLeadingSlashes(str) {
* @private
*/

function createNotFoundDirectoryListener() {
return function notFound() {
function createNotFoundDirectoryListener () {
return function notFound () {
this.error(404)
}
}
Expand All @@ -157,8 +157,8 @@ function createNotFoundDirectoryListener() {
* @private
*/

function createRedirectDirectoryListener() {
return function redirect() {
function createRedirectDirectoryListener () {
return function redirect () {
if (this.hasTrailingSlash()) {
this.error(404)
return
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"send": "0.13.2"
},
"devDependencies": {
"eslint": "2.11.1",
"eslint-config-standard": "5.3.1",
"eslint-plugin-promise": "1.3.1",
"eslint-plugin-standard": "1.3.2",
"istanbul": "0.4.2",
"mocha": "2.4.5",
"supertest": "1.1.0"
Expand All @@ -24,6 +28,7 @@
"node": ">= 0.8.0"
},
"scripts": {
"lint": "eslint **/*.js",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
Expand Down
5 changes: 5 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"mocha": true
}
}
Loading

0 comments on commit 4b89157

Please sign in to comment.