Skip to content

Commit f8705a4

Browse files
committed
migrate to eslint
1 parent cc684a4 commit f8705a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+738
-498
lines changed

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# node_modules ignored by default
2+
node_modules/
3+
4+
# other ignored directories
5+
examples/
6+

.eslintrc

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"env": {
3+
"browser": false,
4+
"node": true,
5+
"es6": false
6+
},
7+
"rules": {
8+
// possible errors
9+
"comma-dangle": [ 2 ],
10+
"no-cond-assign": [ 2 ],
11+
"no-console": [ 0 ],
12+
"no-constant-condition": [ 2 ],
13+
"no-control-regex": [ 2 ],
14+
"no-debugger": [ 2 ],
15+
"no-dupe-args": [ 2 ],
16+
"no-dupe-keys": [ 2 ],
17+
"no-duplicate-case": [ 2 ],
18+
"no-empty": [ 2 ],
19+
"no-empty-class": [ 2 ],
20+
"no-ex-assign": [ 2 ],
21+
"no-extra-boolean-cast": [ 2 ],
22+
"no-extra-semi": [ 2 ],
23+
"no-func-assign": [ 2 ],
24+
// this is for variable hoisting, not necessary if we use block scoped declarations
25+
// "no-inner-declarations": [ 2, "both" ],
26+
"no-invalid-regexp": [ 2 ],
27+
"no-irregular-whitespace": [ 2 ],
28+
"no-negated-in-lhs": [ 2 ],
29+
"no-reserved-keys": [ 0 ],
30+
"no-regex-spaces": [ 2 ],
31+
"no-sparse-arrays": [ 2 ],
32+
"no-unreachable": [ 2 ],
33+
"use-isnan": [ 2 ],
34+
"valid-typeof": [ 2 ],
35+
36+
// best practices
37+
"block-scoped-var": [ 2 ],
38+
"consistent-return": [ 2 ],
39+
"curly": [ 2 ],
40+
"default-case": [ 2 ],
41+
"dot-notation": [ [ 2 ], { "allowKeywords": true } ],
42+
"eqeqeq": [ 2 ],
43+
"guard-for-in": [ 2 ],
44+
"no-alert": [ 2 ],
45+
"no-caller": [ 2 ],
46+
"no-div-regex": [ 2 ],
47+
"no-eq-null": [ 2 ],
48+
"no-eval": [ 2 ],
49+
"no-extend-native": [ 2 ],
50+
"no-extra-bind": [ 2 ],
51+
"no-fallthrough": [ 2 ],
52+
"no-floating-decimal": [ 2 ],
53+
"no-implied-eval": [ 2 ],
54+
"no-iterator": [ 2 ],
55+
"no-labels": [ 2 ],
56+
"no-lone-blocks": [ 2 ],
57+
"no-loop-func": [ 0 ],
58+
"no-multi-spaces": [ 0 ],
59+
"no-native-reassign": [ 2 ],
60+
"no-new": [ 0 ],
61+
"no-new-func": [ 2 ],
62+
"no-new-wrappers": [ 2 ],
63+
"no-octal": [ 2 ],
64+
"no-octal-escape": [ 2 ],
65+
"no-param-reassign": [ 0 ],
66+
"no-proto": [ 2 ],
67+
"no-process-env": [ 0 ],
68+
"no-redeclare": [ 2 ],
69+
"no-return-assign": [ 2 ],
70+
"no-script-url": [ 2 ],
71+
"no-self-compare": [ 2 ],
72+
"no-sequences": [ 2 ],
73+
"no-throw-literal": [ 2 ],
74+
"no-unused-expressions": [ 2 ],
75+
76+
"no-warning-comments": [ 1 ],
77+
"no-with": [ 2 ],
78+
"radix": [ 2 ],
79+
"wrap-iife": [ 2 ],
80+
"yoda": [ 0 ],
81+
82+
// strict mode
83+
"strict": [ 2, "global" ],
84+
85+
// variables
86+
"no-catch-shadow": [ 2 ],
87+
"no-delete-var": [ 2 ],
88+
"no-shadow": [ 2 ],
89+
"no-shadow-restricted-names": [ 2 ],
90+
"no-undef": [ 2 ],
91+
"no-undef-init": [ 2 ],
92+
"no-undefined": [ 0 ],
93+
"no-unused-vars": [ 2, { "vars": "all", "args": "none" } ],
94+
"no-use-before-define": [ 2, "nofunc" ],
95+
96+
// node.js
97+
"handle-callback-err": [ 2, "^.*(e|E)rr" ],
98+
"no-mixed-requires": [ 2 ],
99+
"no-new-require": [ 2 ],
100+
"no-path-concat": [ 0 ],
101+
"no-process-exit": [ 0 ],
102+
103+
// stylistic
104+
"camelcase": [ 0 ],
105+
"eol-last": [ 2 ],
106+
"key-spacing": [ 0 ],
107+
"new-cap": [ 0 ],
108+
"no-array-constructor": [ 0 ],
109+
"no-mixed-spaces-and-tabs": [ 0 ],
110+
"no-nested-ternary": [ 0 ],
111+
"no-new-object": [ 0 ],
112+
"no-underscore-dangle": [ 0 ],
113+
"no-trailing-spaces": [ 0 ],
114+
"no-wrap-func": [ 0 ],
115+
"semi": [ 0, "always" ],
116+
"space-after-keywords": [ 0 ],
117+
"space-before-blocks": [ 0 ],
118+
"space-before-function-paren": [ 0 ],
119+
"space-infix-ops": [ 0 ],
120+
"space-return-throw-case": [ 0 ],
121+
"space-unary-ops": [ 0 ],
122+
"spaced-line-comment": [ 0 ],
123+
"quotes": [ 0 ]
124+
}
125+
}

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
NODEUNIT := ./node_modules/.bin/nodeunit
2121
NODECOVER := ./node_modules/.bin/cover
2222
BUNYAN := ./node_modules/.bin/bunyan
23+
ESLINT := ./node_modules/.bin/eslint
2324
NPM := npm
2425

2526
#
2627
# Files
2728
#
2829
DOC_FILES = index.restdown
30+
ESLINT_JS_FILES = '.'
2931
JS_FILES := $(shell find lib test bin -name '*.js')
30-
JSL_CONF_NODE = tools/jsl.node.conf
31-
JSL_FILES_NODE = $(JS_FILES)
3232
JSSTYLE_FILES = $(JS_FILES)
3333
JSSTYLE_FLAGS = -f tools/jsstyle.conf
3434
SHRINKWRAP = npm-shrinkwrap.json

deps/javascriptlint

Submodule javascriptlint deleted from e1bd0ab

examples/jsonp/jsonp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ srv.get('/', function (req, res, next) {
1010

1111
srv.listen(8080, function () {
1212
console.log('ready on %s', srv.url);
13-
});
13+
});

lib/bunyan_helper.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright 2012 Mark Cavage, Inc. All rights reserved.
22

3+
'use strict';
4+
35
var Stream = require('stream').Stream;
46
var util = require('util');
57

@@ -80,11 +82,13 @@ function RequestCaptureStream(opts) {
8082

8183
this.streams = [];
8284

83-
if (opts.stream)
85+
if (opts.stream) {
8486
appendStream(this.streams, opts.stream);
87+
}
8588

86-
if (opts.streams)
89+
if (opts.streams) {
8790
opts.streams.forEach(appendStream.bind(null, this.streams));
91+
}
8892

8993
this.haveNonRawStreams = false;
9094
for (var i = 0; i < this.streams.length; i++) {
@@ -103,8 +107,9 @@ RequestCaptureStream.prototype.write = function write(record) {
103107
var self = this;
104108

105109
if (!(ring = this.requestMap.get(req_id))) {
106-
if (++this._offset > this.maxRequestIds)
110+
if (++this._offset > this.maxRequestIds) {
107111
this._offset = 0;
112+
}
108113

109114
if (this._rings.length <= this._offset) {
110115
this._rings.push(new bunyan.RingBuffer({
@@ -164,8 +169,9 @@ RequestCaptureStream.prototype.toString = function toString() {
164169
///--- Serializers
165170

166171
function clientReq(req) {
167-
if (!req)
172+
if (!req) {
168173
return (req);
174+
}
169175

170176
var host;
171177

@@ -186,8 +192,9 @@ function clientReq(req) {
186192

187193

188194
function clientRes(res) {
189-
if (!res || !res.statusCode)
195+
if (!res || !res.statusCode) {
190196
return (res);
197+
}
191198

192199
return ({
193200
statusCode: res.statusCode,

0 commit comments

Comments
 (0)