Skip to content

Commit 4b89157

Browse files
committed
lint: use standard style
1 parent c350d7d commit 4b89157

File tree

8 files changed

+230
-213
lines changed

8 files changed

+230
-213
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage
2+
node_modules

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "standard"
3+
}

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cache:
1414
- node_modules
1515
before_install:
1616
# Setup Node.js version-specific dependencies
17-
- "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev istanbul"
17+
- "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev eslint eslint-config-standard eslint-plugin-promise eslint-plugin-standard istanbul"
1818

1919
# Update Node.js modules
2020
- "test ! -d node_modules || npm prune"
@@ -23,5 +23,6 @@ script:
2323
# Run test script, depending on istanbul install
2424
- "test ! -z $(npm -ps ls istanbul) || npm test"
2525
- "test -z $(npm -ps ls istanbul) || npm run-script test-ci"
26+
- "test -z $(npm -ps ls eslint ) || npm run-script lint"
2627
after_script:
2728
- "test -e ./coverage/lcov.info && npm install [email protected] && cat ./coverage/lcov.info | coveralls"

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ cache:
1313
install:
1414
- ps: Install-Product node $env:nodejs_version
1515
- if "%nodejs_version%" equ "0.8" npm rm --save-dev istanbul
16+
- npm rm --save-dev eslint eslint-config-standard eslint-plugin-promise eslint-plugin-standard
1617
- if exist node_modules npm prune
1718
- if exist node_modules npm rebuild
1819
- npm install

index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports.mime = send.mime
3434
* @public
3535
*/
3636

37-
function serveStatic(root, options) {
37+
function serveStatic (root, options) {
3838
if (!root) {
3939
throw new TypeError('root path required')
4040
}
@@ -68,7 +68,7 @@ function serveStatic(root, options) {
6868
? createRedirectDirectoryListener()
6969
: createNotFoundDirectoryListener()
7070

71-
return function serveStatic(req, res, next) {
71+
return function serveStatic (req, res, next) {
7272
if (req.method !== 'GET' && req.method !== 'HEAD') {
7373
if (fallthrough) {
7474
return next()
@@ -104,14 +104,14 @@ function serveStatic(root, options) {
104104

105105
// add file listener for fallthrough
106106
if (fallthrough) {
107-
stream.on('file', function onFile() {
107+
stream.on('file', function onFile () {
108108
// once file is determined, always forward error
109109
forwardError = true
110110
})
111111
}
112112

113113
// forward errors
114-
stream.on('error', function error(err) {
114+
stream.on('error', function error (err) {
115115
if (forwardError || !(err.statusCode < 500)) {
116116
next(err)
117117
return
@@ -129,7 +129,7 @@ function serveStatic(root, options) {
129129
* Collapse all leading slashes into a single slash
130130
* @private
131131
*/
132-
function collapseLeadingSlashes(str) {
132+
function collapseLeadingSlashes (str) {
133133
for (var i = 0; i < str.length; i++) {
134134
if (str[i] !== '/') {
135135
break
@@ -146,8 +146,8 @@ function collapseLeadingSlashes(str) {
146146
* @private
147147
*/
148148

149-
function createNotFoundDirectoryListener() {
150-
return function notFound() {
149+
function createNotFoundDirectoryListener () {
150+
return function notFound () {
151151
this.error(404)
152152
}
153153
}
@@ -157,8 +157,8 @@ function createNotFoundDirectoryListener() {
157157
* @private
158158
*/
159159

160-
function createRedirectDirectoryListener() {
161-
return function redirect() {
160+
function createRedirectDirectoryListener () {
161+
return function redirect () {
162162
if (this.hasTrailingSlash()) {
163163
this.error(404)
164164
return

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"send": "0.13.2"
1212
},
1313
"devDependencies": {
14+
"eslint": "2.11.1",
15+
"eslint-config-standard": "5.3.1",
16+
"eslint-plugin-promise": "1.3.1",
17+
"eslint-plugin-standard": "1.3.2",
1418
"istanbul": "0.4.2",
1519
"mocha": "2.4.5",
1620
"supertest": "1.1.0"
@@ -24,6 +28,7 @@
2428
"node": ">= 0.8.0"
2529
},
2630
"scripts": {
31+
"lint": "eslint **/*.js",
2732
"test": "mocha --reporter spec --bail --check-leaks test/",
2833
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
2934
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"

test/.eslintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"mocha": true
4+
}
5+
}

0 commit comments

Comments
 (0)