Skip to content

Commit 3632f18

Browse files
committed
add .eslintrc, fix issues
1 parent 81d4a96 commit 3632f18

File tree

4 files changed

+248
-9
lines changed

4 files changed

+248
-9
lines changed

.eslintrc

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
root: true
2+
3+
rules:
4+
accessor-pairs: [2]
5+
array-bracket-newline: [0]
6+
array-bracket-spacing: [2, never]
7+
array-callback-return: [0]
8+
array-element-newline: [0]
9+
arrow-body-style: [0]
10+
arrow-parens: [2, as-needed]
11+
arrow-spacing: [2, {before: true, after: true}]
12+
block-scoped-var: [2]
13+
brace-style: [2, 1tbs, {allowSingleLine: true}]
14+
camelcase: [2, {properties: never}]
15+
capitalized-comments: [0]
16+
class-methods-use-this: [2]
17+
comma-dangle: [0]
18+
comma-spacing: [2, {before: false, after: true}]
19+
comma-style: [2, last]
20+
complexity: [0]
21+
computed-property-spacing: [2, never]
22+
consistent-return: [0]
23+
constructor-super: [2]
24+
curly: [0]
25+
default-case: [0]
26+
dot-location: [2, property]
27+
dot-notation: [0]
28+
eol-last: [2]
29+
eqeqeq: [2]
30+
for-direction: [2]
31+
func-call-spacing: [2, never]
32+
func-name-matching: [2]
33+
func-names: [0]
34+
function-paren-newline: [0]
35+
generator-star-spacing: [2, before]
36+
global-require: [0]
37+
guard-for-in: [0]
38+
handle-callback-err: [2, ^(err|error)$]
39+
id-blacklist: [0]
40+
id-length: [0]
41+
id-match: [0]
42+
indent: [2, 2, {VariableDeclarator: 0, SwitchCase: 1}]
43+
jsx-quotes: [0]
44+
key-spacing: [0]
45+
keyword-spacing: [2]
46+
linebreak-style: [2, unix]
47+
lines-around-comment: [0]
48+
lines-around-directive: [0]
49+
lines-between-class-members: [2, never]
50+
max-len: [0]
51+
max-lines: [0]
52+
max-nested-callbacks: [0]
53+
max-params: [0]
54+
max-statements-per-line: [0]
55+
max-statements: [0]
56+
multiline-comment-style: [0]
57+
multiline-ternary: [0]
58+
new-cap: [0]
59+
new-parens: [2]
60+
newline-before-return: [0]
61+
newline-per-chained-call: [0]
62+
no-alert: [0]
63+
no-array-constructor: [0]
64+
no-await-in-loop: [2]
65+
no-bitwise: [0]
66+
no-buffer-constructor: [0]
67+
no-caller: [2]
68+
no-case-declarations: [2]
69+
no-class-assign: [2]
70+
no-compare-neg-zero: [2]
71+
no-cond-assign: [2, except-parens]
72+
no-confusing-arrow: [0]
73+
no-const-assign: [2]
74+
no-constant-condition: [0]
75+
no-continue: [2]
76+
no-control-regex: [2]
77+
no-debugger: [2]
78+
no-delete-var: [2]
79+
no-div-regex: [0]
80+
no-dupe-args: [2]
81+
no-dupe-class-members: [2]
82+
no-dupe-keys: [2]
83+
no-duplicate-case: [2]
84+
no-duplicate-imports: [2]
85+
no-else-return: [0]
86+
no-empty-character-class: [2]
87+
no-empty-function: [0]
88+
no-empty-pattern: [2]
89+
no-empty: [2, {allowEmptyCatch: true}]
90+
no-eq-null: [2]
91+
no-eval: [2]
92+
no-ex-assign: [2]
93+
no-extend-native: [2]
94+
no-extra-bind: [2]
95+
no-extra-boolean-cast: [2]
96+
no-extra-label: [0]
97+
no-extra-parens: [0]
98+
no-extra-semi: [2]
99+
no-fallthrough: [2]
100+
no-floating-decimal: [0]
101+
no-func-assign: [2]
102+
no-global-assign: [2]
103+
no-implicit-coercion: [0]
104+
no-implicit-globals: [0]
105+
no-implied-eval: [2]
106+
no-inline-comments: [0]
107+
no-inner-declarations: [2]
108+
no-invalid-regexp: [2]
109+
no-invalid-this: [0]
110+
no-irregular-whitespace: [2]
111+
no-iterator: [2]
112+
no-label-var: [2]
113+
no-labels: [2]
114+
no-lone-blocks: [2]
115+
no-lonely-if: [0]
116+
no-loop-func: [0]
117+
no-magic-numbers: [0]
118+
no-mixed-operators: [0]
119+
no-mixed-requires: [2, true]
120+
no-mixed-spaces-and-tabs: [2]
121+
no-multi-spaces:
122+
- 2
123+
- ignoreEOLComments: true
124+
exceptions:
125+
VariableDeclarator: true
126+
ImportDeclaration: true
127+
Property: true
128+
no-multi-str: [2]
129+
no-multiple-empty-lines: [2, {max: 1, maxEOF: 0, maxBOF: 0}]
130+
no-native-reassign: [2]
131+
no-negated-condition: [0]
132+
no-negated-in-lhs: [2]
133+
no-nested-ternary: [0]
134+
no-new-func: [2]
135+
no-new-object: [2]
136+
no-new-require: [2]
137+
no-new-symbol: [2]
138+
no-new-wrappers: [2]
139+
no-new: [0]
140+
no-obj-calls: [2]
141+
no-octal-escape: [2]
142+
no-octal: [2]
143+
no-path-concat: [2]
144+
no-process-exit: [0]
145+
no-proto: [2]
146+
no-redeclare: [2]
147+
no-regex-spaces: [2]
148+
no-restricted-imports: [0]
149+
no-restricted-modules: [2, domain, freelist, smalloc, sys]
150+
no-restricted-syntax: [2, WithStatement]
151+
no-return-assign: [0]
152+
no-return-await: [2]
153+
no-script-url: [2]
154+
no-self-assign: [2, {props: true}]
155+
no-self-compare: [2]
156+
no-sequences: [2]
157+
no-shadow-restricted-names: [2]
158+
no-shadow: [0]
159+
no-spaced-func: [2]
160+
no-sparse-arrays: [2]
161+
no-tabs: [2]
162+
no-template-curly-in-string: [2]
163+
no-this-before-super: [2]
164+
no-throw-literal: [2]
165+
no-trailing-spaces: [2]
166+
no-undef-init: [2]
167+
no-undef: [2]
168+
no-undefined: [0]
169+
no-underscore-dangle: [0]
170+
no-unexpected-multiline: [2]
171+
no-unmodified-loop-condition: [2]
172+
no-unneeded-ternary: [2]
173+
no-unreachable: [2]
174+
no-unsafe-finally: [2]
175+
no-unsafe-negation: [2]
176+
no-unused-expressions: [2]
177+
no-unused-labels: [0]
178+
no-unused-vars: [2, {args: all, argsIgnorePattern: ^_, varsIgnorePattern: ^_}]
179+
no-use-before-define: [2, nofunc]
180+
no-useless-call: [2]
181+
no-useless-computed-key: [2]
182+
no-useless-concat: [2]
183+
no-useless-constructor: [2]
184+
no-useless-escape: [2]
185+
no-var: [0]
186+
no-warning-comments: [0]
187+
no-whitespace-before-property: [2]
188+
no-with: [2]
189+
nonblock-statement-body-position: [2]
190+
object-curly-newline: [0]
191+
object-curly-spacing: [2, never]
192+
object-shorthand: [0]
193+
one-var-declaration-per-line: [0]
194+
one-var: [0]
195+
operator-assignment: [2, always]
196+
operator-linebreak: [2, after]
197+
padded-blocks: [2, never]
198+
prefer-arrow-callback: [0]
199+
prefer-const: [2]
200+
prefer-destructuring: [0]
201+
prefer-numeric-literals: [2]
202+
prefer-promise-reject-errors: [2, {allowEmptyReject: false}]
203+
prefer-reflect: [0]
204+
prefer-rest-params: [0]
205+
prefer-spread: [0]
206+
prefer-template: [0]
207+
quote-props: [0]
208+
quotes: [2, single, avoid-escape]
209+
radix: [2, as-needed]
210+
require-await: [2]
211+
require-jsdoc: [0]
212+
require-yield: [2]
213+
semi-spacing: [2, {before: false, after: true}]
214+
semi-style: [2, last]
215+
semi: [0]
216+
sort-imports: [0]
217+
sort-keys: [0]
218+
space-before-blocks: [2, always]
219+
space-before-function-paren: [2, always]
220+
space-in-parens: [2, never]
221+
space-infix-ops: [2]
222+
space-unary-ops: [2]
223+
spaced-comment: [2, always, {markers: ["!"]}]
224+
strict: [0]
225+
switch-colon-spacing: [2]
226+
symbol-description: [2]
227+
template-curly-spacing: [2, never]
228+
template-tag-spacing: [2, never]
229+
unicode-bom: [2, never]
230+
use-isnan: [2]
231+
valid-typeof: [2]
232+
wrap-iife: [2, inside]
233+
wrap-regex: [0]
234+
yield-star-spacing: [2, {before: true, after: false}]
235+
yoda: [2, never]
236+
237+
env:
238+
node: true

index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ var NOT_QU_MASK = ~QU_MASK
1414
var name = exports.txt = exports.name = {}
1515

1616
name.encode = function (str, buf, offset) {
17-
if (!buf) buf = Buffer.allocUnsafe(name.encodingLength(n))
17+
if (!buf) buf = Buffer.allocUnsafe(name.encodingLength(str))
1818
if (!offset) offset = 0
1919
var oldOffset = offset
2020

2121
// strip leading and trailing .
22-
const n = str.replace(/^\.|\.$/gm, '')
22+
var n = str.replace(/^\.|\.$/gm, '')
2323
if (n.length) {
24-
const list = n.split('.')
24+
var list = n.split('.')
2525

2626
for (var i = 0; i < list.length; i++) {
2727
var len = buf.write(list[i], offset + 1)
@@ -155,7 +155,7 @@ header.decode = function (buf, offset) {
155155

156156
header.decode.bytes = 12
157157

158-
header.encodingLength = function (h) {
158+
header.encodingLength = function () {
159159
return 12
160160
}
161161

@@ -519,7 +519,7 @@ ra.decode = function (buf, offset) {
519519

520520
ra.decode.bytes = 0
521521

522-
ra.encodingLength = function (host) {
522+
ra.encodingLength = function () {
523523
return 6
524524
}
525525

@@ -549,7 +549,7 @@ raaaa.decode = function (buf, offset) {
549549

550550
raaaa.decode.bytes = 0
551551

552-
raaaa.encodingLength = function (host) {
552+
raaaa.encodingLength = function () {
553553
return 18
554554
}
555555

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
"safe-buffer": "^5.0.1"
1212
},
1313
"devDependencies": {
14+
"eslint": "^4.15.0",
1415
"standard": "^6.0.5",
1516
"tape": "^4.4.0"
1617
},
1718
"scripts": {
18-
"test": "standard && tape test.js"
19+
"test": "standard && eslint --color *.js && tape test.js"
1920
},
2021
"bugs": {
2122
"url": "https://github.com/mafintosh/dns-packet/issues"

test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ tape('response', function (t) {
176176
})
177177

178178
tape('rcode', function (t) {
179-
const errors = ['NOERROR', 'FORMERR', 'SERVFAIL', 'NXDOMAIN', 'NOTIMP', 'REFUSED', 'YXDOMAIN', 'YXRRSET', 'NXRRSET', 'NOTAUTH', 'NOTZONE', 'RCODE_11', 'RCODE_12', 'RCODE_13', 'RCODE_14', 'RCODE_15']
179+
var errors = ['NOERROR', 'FORMERR', 'SERVFAIL', 'NXDOMAIN', 'NOTIMP', 'REFUSED', 'YXDOMAIN', 'YXRRSET', 'NXRRSET', 'NOTAUTH', 'NOTZONE', 'RCODE_11', 'RCODE_12', 'RCODE_13', 'RCODE_14', 'RCODE_15']
180180
for (var i in errors) {
181181
var code = rcodes.toRcode(errors[i])
182182
t.ok(errors[i] === rcodes.toString(code), 'rcode conversion from/to string matches: ' + rcodes.toString(code))
183183
}
184184

185-
const ops = ['QUERY', 'IQUERY', 'STATUS', 'OPCODE_3', 'NOTIFY', 'UPDATE', 'OPCODE_6', 'OPCODE_7', 'OPCODE_8', 'OPCODE_9', 'OPCODE_10', 'OPCODE_11', 'OPCODE_12', 'OPCODE_13', 'OPCODE_14', 'OPCODE_15']
185+
var ops = ['QUERY', 'IQUERY', 'STATUS', 'OPCODE_3', 'NOTIFY', 'UPDATE', 'OPCODE_6', 'OPCODE_7', 'OPCODE_8', 'OPCODE_9', 'OPCODE_10', 'OPCODE_11', 'OPCODE_12', 'OPCODE_13', 'OPCODE_14', 'OPCODE_15']
186186
for (var j in ops) {
187187
var ocode = opcodes.toOpcode(ops[j])
188188
t.ok(ops[j] === opcodes.toString(ocode), 'opcode conversion from/to string matches: ' + opcodes.toString(ocode))

0 commit comments

Comments
 (0)