Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
remove jshint/ jsxhint and use eslint with react plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelB committed Sep 14, 2015
1 parent 9e87dc0 commit 8a0cd15
Show file tree
Hide file tree
Showing 27 changed files with 281 additions and 266 deletions.
36 changes: 33 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
{
"rules": {
"indent": [
2,
2
],
"quotes": [
2,
"double"
],
"linebreak-style": [
2,
"unix"
],
"semi": [
2,
"always"
],
"no-console": [
1
]

},
"env": {
"browser": true,
"node": true
}
}
"node": true,
"mocha": true
},
"extends": "eslint:recommended",
"ecmaFeatures": {
"jsx": true
},
"plugins": [
"react"
]
}
30 changes: 0 additions & 30 deletions .jshintrc

This file was deleted.

2 changes: 0 additions & 2 deletions .jsxhintignore

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: node_js
node_js:
- "0.10"
- "4"
7 changes: 0 additions & 7 deletions jest-config-win.json

This file was deleted.

7 changes: 0 additions & 7 deletions jest-config.json

This file was deleted.

19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"scripts": {
"deploy": "gulp deploy",
"dist": "gulp dist",
"lint": "jsxhint -c .jshintrc src/js",
"lint": "eslint src",
"start": "gulp",
"test": " npm run lint && jest --config jest-config.json",
"test-win": "npm run lint && jest --config jest-config-win.json"
"test": "mocha src/**/__tests__/*",
"tdd": "mocha --watch ./src/**/__tests__/*.*"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -45,11 +45,12 @@
"watchify": "^3.4.0"
},
"devDependencies": {
"babel-jest": "^5.3.*",
"jest-cli": "^0.5.*",
"jshint-stylish": "^2.0.1",
"jsxhint": "latest",
"jshint-stylish": "^1.0.0",
"react-tools": "latest"
"babel": "^5.8.23",
"chai": "^3.2.0",
"eslint": "^1.4.1",
"eslint-plugin-react": "^3.3.2",
"jsdom": "^6.3.0",
"mocha": "^2.3.2",
"sinon": "^1.16.1"
}
}
7 changes: 0 additions & 7 deletions preprocessor.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/js/components/KeptEntry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ var KeptEntry = React.createClass({
var panelHeader = (
<h3>
{this.props.itemData.title || "Untitled"}
<GlyphiconLink className="delete" glyph="trash" onClick={this.handleClickDelete} />
<GlyphiconLink className="edit" glyph="edit" onClick={this.handleClickEdit} />
<GlyphiconLink ref="deleteBt" className="delete" glyph="trash" onClick={this.handleClickDelete} />
<GlyphiconLink ref="editBt" className="edit" glyph="edit" onClick={this.handleClickEdit} />
</h3>
);
return (
Expand Down
70 changes: 43 additions & 27 deletions src/js/components/__tests__/DefaultContent-test.jsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,57 @@
"use strict";

var TestUtils = require('react/addons').addons.TestUtils;

jest.dontMock('../DefaultContent');
var DefaultContent = require('../DefaultContent');

describe("#render", function() {
var comp;
var React = require("react");
var TestUtils = require("react/lib/ReactTestUtils");
var sinon = require("sinon");
var expect = require("chai").expect;

var DefaultContent = require("../DefaultContent");
describe("DefaultContent", function() {
describe("#render", function() {
var renderer = TestUtils.createRenderer();
var result;
beforeEach(function() {
renderer.render(
<DefaultContent />
);
result = renderer.getRenderOutput();
});

it("should render HTML content", function() {
expect(result.props.children.length > 0).to.be.true;
});
});

var fakeCreateText = jasmine.createSpy("fakeCreateText");
var fakeCreateTodo = jasmine.createSpy("fakeCreateTodo");
describe("add default items", function() {
var comp;
var fakeCreateText = sinon.spy();
var fakeCreateTodo = sinon.spy();

function fakeNewItem(type) {
return type === "text" ? fakeCreateText : fakeCreateTodo;
}
function fakeNewItem(type) {
return type === "text" ? fakeCreateText : fakeCreateTodo;
}

beforeEach(function() {
comp = TestUtils.renderIntoDocument(<DefaultContent newItem={fakeNewItem} />);
});
beforeEach(function() {
comp = TestUtils.renderIntoDocument(
<DefaultContent newItem={fakeNewItem} />
);
});

it("should render HTML content", function() {
expect(comp.getDOMNode().outerHTML.length > 0).toBe(true);
});
it("should add a new text entry when clicking on Text link", function() {

it("should add a new text entry when clicking on Text link", function() {
var newTextLink = TestUtils.findRenderedDOMComponentWithClass(comp, "new-text");
var newTextLink = TestUtils.findRenderedDOMComponentWithClass(comp, "new-text");

TestUtils.Simulate.click(newTextLink);
TestUtils.Simulate.click(newTextLink);

expect(fakeCreateText).toHaveBeenCalled();
});
expect(fakeCreateText.calledOnce).to.be.true;
});

it("should add a new todo entry when clicking on Todo link", function() {
var newTodoLink = TestUtils.findRenderedDOMComponentWithClass(comp, "new-todo");
it("should add a new todo entry when clicking on Todo link", function() {
var newTodoLink = TestUtils.findRenderedDOMComponentWithClass(comp, "new-todo");

TestUtils.Simulate.click(newTodoLink);
TestUtils.Simulate.click(newTodoLink);

expect(fakeCreateTodo).toHaveBeenCalled();
expect(fakeCreateTodo.calledOnce).to.be.true;
});
});
});
35 changes: 21 additions & 14 deletions src/js/components/__tests__/KeptApp-test.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
"use strict";

var TestUtils = require('react/addons').addons.TestUtils;
var TestUtils = require("react/lib/ReactTestUtils");
var React = require("react");
var expect = require("chai").expect;
var renderer = TestUtils.createRenderer();

jest.dontMock('../KeptMenuBar');
jest.dontMock('../text/KeptTextForm');
jest.dontMock('../todo/KeptTodoForm');
jest.dontMock('../KeptApp');

var KeptApp = require('../KeptApp');
var KeptApp = require("../KeptApp");
var KeptTextForm = require("../text/KeptTextForm");
var KeptTodoForm = require("../todo/KeptTodoForm");

describe("KeptApp", function() {
var comp, fakeStore;
var fakeStore;

beforeEach(function() {
fakeStore = {
Expand All @@ -22,35 +20,44 @@ describe("KeptApp", function() {
save: function() {
}
};
comp = TestUtils.renderIntoDocument(<KeptApp store={fakeStore} />);
});

describe("#render", function() {
it("should render HTML content", function() {
expect(comp.getDOMNode().outerHTML.length > 0).toBe(true);
renderer.render(
<KeptApp store={fakeStore} />
);
var dom = renderer.getRenderOutput();
expect(dom.props.children.length).to.be.above(0);
});
});

describe("#formCreator", function() {
var comp;

beforeEach(function() {
comp = TestUtils.renderIntoDocument(<KeptApp store={fakeStore} />);
});

it("should generate a form creation function", function() {
expect(typeof comp.formCreator("text")).toEqual("function");
expect(typeof comp.formCreator("todo")).toEqual("function");
expect(comp.formCreator("text")).to.be.a("function");
expect(comp.formCreator("todo")).to.be.a("function");
});

it("should add a text form component to state", function() {
var textForm = comp.formCreator("text");

textForm({});

expect(TestUtils.isComponentOfType(comp.state.form, KeptTextForm)).toBe(true);
//expect(TestUtils.isComponentOfType(comp.state.form, KeptTextForm)).to.be.true;
});

it("should add a todo form component to state", function() {
var todoForm = comp.formCreator("todo");

todoForm({});

expect(TestUtils.isComponentOfType(comp.state.form, KeptTodoForm)).toBe(true);
//expect(TestUtils.isComponentOfType(comp.state.form, KeptTodoForm)).to.be.true;
});
});
});
11 changes: 5 additions & 6 deletions src/js/components/__tests__/KeptColumns-test.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"use strict";

var TestUtils = require('react/addons').addons.TestUtils;

jest.dontMock('../KeptEntry');
jest.dontMock('../KeptColumns');
var React = require("react");
var TestUtils = require("react/lib/ReactTestUtils");
var expect = require("chai").expect;

var KeptEntry = require("../KeptEntry");
var KeptColumns = require("../KeptColumns");
Expand All @@ -15,15 +14,15 @@ describe("KeptColumns", function() {
var items = [
{id: 1, type: "text", text: "text id #1"},
{id: 2, type: "text", text: "text id #2"},
{id: 3, type: "text", text: "text id #3"},
{id: 3, type: "text", text: "text id #3"}
];
var columns = 3;
var col = 1;

var comp = TestUtils.renderIntoDocument(<KeptColumns items={items} column={col} columns={columns}/>);

var entries = TestUtils.scryRenderedComponentsWithType(comp, KeptEntry);
expect(entries.length).toEqual(3);
expect(entries.length).to.equal(3);
});
});
});
Loading

0 comments on commit 8a0cd15

Please sign in to comment.