Skip to content

Commit

Permalink
Merge pull request #2 from remarkablemark/lint
Browse files Browse the repository at this point in the history
Add ESLint and fix linting errors
  • Loading branch information
remarkablemark authored Aug 23, 2016
2 parents 9970b64 + d62961a commit 572f1f5
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json
34 changes: 34 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"env": {
"node": true,
"browser": true,
"mocha": true,
"commonjs": true
},

"extends": "eslint:recommended",

"rules": {
"indent": [
"error",
4,
{ SwitchCase: 1 }
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"strict": 2,
"no-unused-vars": 2,
"no-cond-assign": 2,
"camelcase": 1
}
}
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test
.eslint*
3 changes: 2 additions & 1 deletion lib/html-to-dom-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function formatDOM(nodes, parentNode) {
};

// set the next node for the previous node (if applicable)
if (prevNode = result[i - 1]) {
prevNode = result[i - 1];
if (prevNode) {
prevNode.next = nodeObj;
}

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"author": "Mark <mark@remarkablemark.org>",
"main": "index.js",
"scripts": {
"test": "mocha"
"test": "mocha",
"lint": "eslint index.js \"lib/**\" \"test/**\""
},
"repository": {
"type": "git",
Expand All @@ -26,6 +27,7 @@
"htmlparser2": "^3.9.1"
},
"devDependencies": {
"eslint": "^3.3.1",
"jsdomify": "^2.1.0",
"mocha": "^3.0.2",
"react": "^15.3.0",
Expand Down
4 changes: 2 additions & 2 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ describe('test helper', function() {
var obj1;
var obj2;

var obj1 = { foo: 'bar', baz: ['qux', 42, null], obj: {} };
obj1 = { foo: 'bar', baz: ['qux', 42, null], obj: {} };
obj1.ref = obj1.obj;
var obj2 = { obj: {}, baz: ['qux', 42, null], foo: 'bar' };
obj2 = { obj: {}, baz: ['qux', 42, null], foo: 'bar' };
obj2.ref = obj2.obj;
deepEqualCircular(obj1, obj2);
});
Expand Down
1 change: 1 addition & 0 deletions test/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Module dependencies.
*/
var assert = require('assert');
var util = require('util');

/**
* Test for deep equality between objects that have circular references.
Expand Down
8 changes: 4 additions & 4 deletions test/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('utilties', function() {
[undefined, null, 1337, {}, []].forEach(function(parameter) {
assert.throws(function() { camelCase(parameter); });
});
})
});
});

describe('`invertObject` helper', function() {
Expand All @@ -40,7 +40,7 @@ describe('utilties', function() {
[undefined, null, 'foo', 1337].forEach(function(parameter) {
assert.throws(function() { invertObject(parameter); });
});
})
});

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

it('uses override if valid', function() {
assert.deepEqual(
invertObject({ foo: 'bar', baz: 'qux' }, function(key, value) {
invertObject({ foo: 'bar', baz: 'qux' }, function(key) {
if (key === 'foo') {
return ['key', 'value'];
}
Expand All @@ -78,7 +78,7 @@ describe('utilties', function() {

it('does not use override if invalid', function() {
assert.deepEqual(
invertObject({ foo: 'bar', baz: 'qux' }, function(key, value) {
invertObject({ foo: 'bar', baz: 'qux' }, function(key) {
if (key === 'foo') {
return ['key'];
} else if (key === 'baz') {
Expand Down

0 comments on commit 572f1f5

Please sign in to comment.