Skip to content

Commit

Permalink
Use eslint
Browse files Browse the repository at this point in the history
Enforce my style :)
  • Loading branch information
kentor authored and Kenneth Chung committed Oct 15, 2015
1 parent 6695ee9 commit fe70791
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
env:
mocha: true
extends:
- kentor
- kentor/browser
- kentor/es6
- kentor/react
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function enhanceWithClickOutside(WrappedComponent) {
},

handleClickOutside(e) {
var domNode = React.findDOMNode(this);
const domNode = React.findDOMNode(this);
if (!domNode || !domNode.contains(e.target)) {
this.refs.wrappedComponent.handleClickOutside(e);
}
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"build": "babel -d dist index.js",
"prepublish": "npm test && npm run build",
"test": "mocha --compilers js:babel/register --reporter nyan --require test-setup"
"lint": "eslint .",
"test": "npm run lint && mocha --compilers js:babel/register --reporter nyan --require test-setup"
},
"repository": {
"type": "git",
Expand All @@ -26,6 +27,9 @@
"homepage": "https://github.com/kentor/react-click-outside",
"devDependencies": {
"babel": "^5.8.23",
"eslint": "^1.6.0",
"eslint-config-kentor": "^1.0.0",
"eslint-plugin-react": "^3.5.1",
"expect": "^1.11.1",
"jsdom": "^6.5.1",
"mocha": "^2.3.3",
Expand Down
20 changes: 10 additions & 10 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('enhanceWithClickOutside', () => {
}).toThrow('UncoolComponent must implement handleClickOutside().');
});

it('calls the handleClickOutside when clicked outside of component', () => {
it('calls handleClickOutside when clicked outside of component', () => {
const clickInsideSpy = expect.createSpy();
const clickOutsideSpy = expect.createSpy();

Expand Down Expand Up @@ -69,7 +69,6 @@ describe('enhanceWithClickOutside', () => {
});

const rootComponent = React.render(<Root />, document.body);
const rootNode = React.findDOMNode(rootComponent);

const enhancedComponent = rootComponent.refs.enhancedComponent;
const enhancedNode = React.findDOMNode(enhancedComponent);
Expand Down Expand Up @@ -99,10 +98,10 @@ describe('enhanceWithClickOutside', () => {
React.unmountComponentAtNode(document.body);
expect(document.removeEventListener).toHaveBeenCalledWith(
'click', enhancedComponent.handleClickOutside, true
)
);
});

it('should always call the handleClickOutside if wrapped components render returns null', () => {
it('calls handleClickOutside even if wrapped component renders null', () => {
const clickOutsideSpy = expect.createSpy();

const WrappedComponent = React.createClass({
Expand All @@ -114,19 +113,20 @@ describe('enhanceWithClickOutside', () => {

render() {
return null;
}
},
});

const EnhancedComponent = enhanceWithClickOutside(WrappedComponent);

const RootComponent = React.createClass({
render() {
return (
<div>
<EnhancedComponent ref="enhancedComponent" />
</div>
<div>
<EnhancedComponent ref="enhancedComponent" />
</div>
);
}
})
},
});

const rootComponent = React.render(<RootComponent />, document.body);

Expand Down

0 comments on commit fe70791

Please sign in to comment.