Skip to content

Commit 572f1f5

Browse files
Merge pull request #2 from remarkablemark/lint
Add ESLint and fix linting errors
2 parents 9970b64 + d62961a commit 572f1f5

File tree

8 files changed

+48
-8
lines changed

8 files changed

+48
-8
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.json

.eslintrc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"browser": true,
5+
"mocha": true,
6+
"commonjs": true
7+
},
8+
9+
"extends": "eslint:recommended",
10+
11+
"rules": {
12+
"indent": [
13+
"error",
14+
4,
15+
{ SwitchCase: 1 }
16+
],
17+
"linebreak-style": [
18+
"error",
19+
"unix"
20+
],
21+
"quotes": [
22+
"error",
23+
"single"
24+
],
25+
"semi": [
26+
"error",
27+
"always"
28+
],
29+
"strict": 2,
30+
"no-unused-vars": 2,
31+
"no-cond-assign": 2,
32+
"camelcase": 1
33+
}
34+
}

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
test
2+
.eslint*

lib/html-to-dom-client.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ function formatDOM(nodes, parentNode) {
4343
};
4444

4545
// set the next node for the previous node (if applicable)
46-
if (prevNode = result[i - 1]) {
46+
prevNode = result[i - 1];
47+
if (prevNode) {
4748
prevNode.next = nodeObj;
4849
}
4950

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"author": "Mark <mark@remarkablemark.org>",
66
"main": "index.js",
77
"scripts": {
8-
"test": "mocha"
8+
"test": "mocha",
9+
"lint": "eslint index.js \"lib/**\" \"test/**\""
910
},
1011
"repository": {
1112
"type": "git",
@@ -26,6 +27,7 @@
2627
"htmlparser2": "^3.9.1"
2728
},
2829
"devDependencies": {
30+
"eslint": "^3.3.1",
2931
"jsdomify": "^2.1.0",
3032
"mocha": "^3.0.2",
3133
"react": "^15.3.0",

test/helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ describe('test helper', function() {
3030
var obj1;
3131
var obj2;
3232

33-
var obj1 = { foo: 'bar', baz: ['qux', 42, null], obj: {} };
33+
obj1 = { foo: 'bar', baz: ['qux', 42, null], obj: {} };
3434
obj1.ref = obj1.obj;
35-
var obj2 = { obj: {}, baz: ['qux', 42, null], foo: 'bar' };
35+
obj2 = { obj: {}, baz: ['qux', 42, null], foo: 'bar' };
3636
obj2.ref = obj2.obj;
3737
deepEqualCircular(obj1, obj2);
3838
});

test/helpers/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Module dependencies.
55
*/
66
var assert = require('assert');
7+
var util = require('util');
78

89
/**
910
* Test for deep equality between objects that have circular references.

test/utilities.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('utilties', function() {
3030
[undefined, null, 1337, {}, []].forEach(function(parameter) {
3131
assert.throws(function() { camelCase(parameter); });
3232
});
33-
})
33+
});
3434
});
3535

3636
describe('`invertObject` helper', function() {
@@ -40,7 +40,7 @@ describe('utilties', function() {
4040
[undefined, null, 'foo', 1337].forEach(function(parameter) {
4141
assert.throws(function() { invertObject(parameter); });
4242
});
43-
})
43+
});
4444

4545
it('swaps key with value for object', function() {
4646
assert.deepEqual(
@@ -67,7 +67,7 @@ describe('utilties', function() {
6767

6868
it('uses override if valid', function() {
6969
assert.deepEqual(
70-
invertObject({ foo: 'bar', baz: 'qux' }, function(key, value) {
70+
invertObject({ foo: 'bar', baz: 'qux' }, function(key) {
7171
if (key === 'foo') {
7272
return ['key', 'value'];
7373
}
@@ -78,7 +78,7 @@ describe('utilties', function() {
7878

7979
it('does not use override if invalid', function() {
8080
assert.deepEqual(
81-
invertObject({ foo: 'bar', baz: 'qux' }, function(key, value) {
81+
invertObject({ foo: 'bar', baz: 'qux' }, function(key) {
8282
if (key === 'foo') {
8383
return ['key'];
8484
} else if (key === 'baz') {

0 commit comments

Comments
 (0)