Skip to content

Commit bb6ac5b

Browse files
committed
Chore: Rework tests, linting and publishing (#100)
* Add eslint to package * Fix linting warnings * Add jest as test runner * move lib/ to src/ * add webpack config for building dist and dev * Add release script back * Add babel-core dev dependency * Add cross-env for windows support * Chore: add building of bundle to preversion
1 parent a603a06 commit bb6ac5b

32 files changed

+697
-568
lines changed

.babelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"react"
5+
]
6+
}

.eslintignore

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

.eslintrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "airbnb",
3+
"env": {
4+
"browser": true,
5+
"node": true
6+
},
7+
"rules": {
8+
"react/prefer-es6-class": 0,
9+
"react/prefer-stateless-function": 0
10+
}
11+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
build/
44
node_modules/
55
npm-debug.log
6+
lib/

.npmignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

.travis.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@ node_js:
44
- "4"
55
- "5"
66
- stable
7-
8-
before_script:
9-
- export DISPLAY=:99.0
10-
- sh -e /etc/init.d/xvfb start
117
branches:
128
only:
139
- master
14-
email:
15-
on_failure: change
16-
on_success: never
10+
script:
11+
- npm run lint
12+
- npm test

bower.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
"build",
1818
"examples",
1919
"lib",
20+
"src",
2021
"node_modules",
2122
"specs",
22-
"package.json"
23+
"package.json",
24+
"webpack.*"
2325
]
24-
}
26+
}

examples/basic/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import { Tab, Tabs, TabList, TabPanel } from '../../lib/main';
3+
import { Tab, Tabs, TabList, TabPanel } from '../../src/main';
44

55
const App = React.createClass({
66
render() {
@@ -83,7 +83,7 @@ const App = React.createClass({
8383
</Tabs>
8484
</div>
8585
);
86-
}
86+
},
8787
});
8888

89-
ReactDOM.render(<App/>, document.getElementById('example'));
89+
ReactDOM.render(<App />, document.getElementById('example'));

examples/conditional/app.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import { Tab, Tabs, TabList, TabPanel } from '../../lib/main';
3+
import { Tab, Tabs, TabList, TabPanel } from '../../src/main';
44

55
const App = React.createClass({
66
getInitialState() {
77
return {
88
showA: true,
99
showB: true,
10-
showC: true
10+
showC: true,
1111
};
1212
},
1313

@@ -19,35 +19,35 @@ const App = React.createClass({
1919

2020
render() {
2121
return (
22-
<div style={{padding: 50}}>
22+
<div style={{ padding: 50 }}>
2323
<p>
2424
<label>
25-
<input type="checkbox" checked={this.state.showA} name="showA" onChange={this.handleCheckClicked}/>
25+
<input type="checkbox" checked={this.state.showA} name="showA" onChange={this.handleCheckClicked} />
2626
Show A
27-
</label><br/>
27+
</label><br />
2828
<label>
29-
<input type="checkbox" checked={this.state.showB} name="showB" onChange={this.handleCheckClicked}/>
29+
<input type="checkbox" checked={this.state.showB} name="showB" onChange={this.handleCheckClicked} />
3030
Show B
31-
</label><br/>
31+
</label><br />
3232
<label>
33-
<input type="checkbox" checked={this.state.showC} name="showC" onChange={this.handleCheckClicked}/>
33+
<input type="checkbox" checked={this.state.showC} name="showC" onChange={this.handleCheckClicked} />
3434
Show C
35-
</label><br/>
35+
</label><br />
3636
</p>
3737
<Tabs>
3838
<TabList>
39-
{ this.state.showA && <Tab>Tab A</Tab> }
40-
{ this.state.showB && <Tab>Tab B</Tab> }
41-
{ this.state.showC && <Tab>Tab C</Tab> }
39+
{this.state.showA && <Tab>Tab A</Tab>}
40+
{this.state.showB && <Tab>Tab B</Tab>}
41+
{this.state.showC && <Tab>Tab C</Tab>}
4242
</TabList>
43-
{ this.state.showA && <TabPanel>This is tab A</TabPanel> }
44-
{ this.state.showB && <TabPanel>This is tab B</TabPanel> }
45-
{ this.state.showC && <TabPanel>This is tab C</TabPanel> }
43+
{this.state.showA && <TabPanel>This is tab A</TabPanel>}
44+
{this.state.showB && <TabPanel>This is tab B</TabPanel>}
45+
{this.state.showC && <TabPanel>This is tab C</TabPanel>}
4646
</Tabs>
4747
</div>
4848
);
49-
}
49+
},
5050
});
5151

52-
ReactDOM.render(<App/>, document.getElementById('example'));
52+
ReactDOM.render(<App />, document.getElementById('example'));
5353

examples/dyno/app.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
import Modal from 'react-modal';
4-
import { Tab, Tabs, TabList, TabPanel } from '../../lib/main';
4+
import { Tab, Tabs, TabList, TabPanel } from '../../src/main';
55

66
Modal.setAppElement(document.getElementById('example'));
77
Modal.injectCSS();
@@ -12,17 +12,17 @@ const App = React.createClass({
1212
isModalOpen: false,
1313
selectedIndex: -1,
1414
tabs: [
15-
{label: 'Foo', content: 'This is foo'},
16-
{label: 'Bar', content: 'This is bar'},
17-
{label: 'Baz', content: 'This is baz'},
18-
{label: 'Zap', content: 'This is zap'}
19-
]
15+
{ label: 'Foo', content: 'This is foo' },
16+
{ label: 'Bar', content: 'This is bar' },
17+
{ label: 'Baz', content: 'This is baz' },
18+
{ label: 'Zap', content: 'This is zap' },
19+
],
2020
};
2121
},
2222

2323
render() {
2424
return (
25-
<div style={{padding: 50}}>
25+
<div style={{ padding: 50 }}>
2626
<p>
2727
<button onClick={this.openModal}>+ Add</button>
2828
</p>
@@ -43,13 +43,13 @@ const App = React.createClass({
4343
<Modal
4444
isOpen={this.state.isModalOpen}
4545
onRequestClose={this.closeModal}
46-
style={{width: 400, height: 350, margin: '0 auto'}}
46+
style={{ width: 400, height: 350, margin: '0 auto' }}
4747
>
4848
<h2>Add a Tab</h2>
49-
<label htmlFor="label">Label:</label><br/>
50-
<input id="label" type="text" ref="label"/><br/><br/>
51-
<label htmlFor="content">Content:</label><br/>
52-
<textarea id="content" ref="content" rows="10" cols="50"></textarea><br/><br/>
49+
<label htmlFor="label">Label:</label><br />
50+
<input id="label" type="text" ref="label" /><br /><br />
51+
<label htmlFor="content">Content:</label><br />
52+
<textarea id="content" ref="content" rows="10" cols="50"></textarea><br /><br />
5353
<button onClick={this.addTab}>OK</button>{' '}
5454
<button onClick={this.closeModal}>Cancel</button>
5555
</Modal>
@@ -59,13 +59,13 @@ const App = React.createClass({
5959

6060
openModal() {
6161
this.setState({
62-
isModalOpen: true
62+
isModalOpen: true,
6363
});
6464
},
6565

6666
closeModal() {
6767
this.setState({
68-
isModalOpen: false
68+
isModalOpen: false,
6969
});
7070
},
7171

@@ -75,18 +75,18 @@ const App = React.createClass({
7575

7676
this.state.tabs.push({
7777
label: label,
78-
content: content
78+
content: content,
7979
});
8080
this.setState({
81-
selectedIndex: this.state.tabs.length - 1
81+
selectedIndex: this.state.tabs.length - 1,
8282
});
8383
this.closeModal();
8484
},
8585

8686
removeTab(index) {
8787
this.state.tabs.splice(index, 1);
8888
this.forceUpdate();
89-
}
89+
},
9090
});
9191

92-
ReactDOM.render(<App/>, document.getElementById('example'));
92+
ReactDOM.render(<App />, document.getElementById('example'));

0 commit comments

Comments
 (0)