Skip to content

Commit 2bcaae9

Browse files
committed
FIX linting
1 parent 09747c6 commit 2bcaae9

File tree

29 files changed

+254
-273
lines changed

29 files changed

+254
-273
lines changed

addons/info/src/components/Node.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ function getData(element) {
1616
children: null,
1717
};
1818

19-
2019
if (typeof element === 'null') {
2120
return data;
2221
}

addons/info/src/components/PropTable.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ export default class PropTable extends React.Component {
3838
const typeInfo = type.propTypes[property];
3939
const propType = PropTypesMap.get(typeInfo) || 'other';
4040
const required = typeInfo.isRequired === undefined ? 'yes' : 'no';
41-
const description = type.__docgenInfo && type.__docgenInfo.props && type.__docgenInfo.props[property] ? type.__docgenInfo.props[property].description : null; // eslint-disable-line no-underscore-dangle
41+
const description = type.__docgenInfo &&
42+
type.__docgenInfo.props &&
43+
type.__docgenInfo.props[property]
44+
? type.__docgenInfo.props[property].description
45+
: null; // eslint-disable-line no-underscore-dangle
4246

4347
props[property] = { property, propType, required, description };
4448
}
@@ -96,7 +100,7 @@ export default class PropTable extends React.Component {
96100
PropTable.displayName = 'PropTable';
97101
PropTable.defaultProps = {
98102
type: null,
99-
}
103+
};
100104
PropTable.propTypes = {
101105
type: PropTypes.func,
102106
};

addons/knobs/src/components/types/Color.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ColorType extends React.Component {
7575
? <div
7676
style={styles.popover}
7777
ref={e => {
78-
this.popover = e;
78+
this.popover = e;
7979
}}
8080
>
8181
<SketchPicker color={knob.value} onChange={color => onChange(color.hex)} />

app/react/src/client/index.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import deprecate from 'util-deprecate';
2+
3+
// NOTE export these to keep backwards compatibility
4+
import { action as deprecatedAction } from '@storybook/addon-actions';
5+
import { linkTo as deprecatedLinkTo } from '@storybook/addon-links';
6+
27
import * as previewApi from './preview';
38

49
export const storiesOf = previewApi.storiesOf;
@@ -7,10 +12,6 @@ export const addDecorator = previewApi.addDecorator;
712
export const configure = previewApi.configure;
813
export const getStorybook = previewApi.getStorybook;
914

10-
// NOTE export these to keep backwards compatibility
11-
import { action as deprecatedAction } from '@storybook/addon-actions';
12-
import { linkTo as deprecatedLinkTo } from '@storybook/addon-links';
13-
1415
export const action = deprecate(
1516
deprecatedAction,
1617
'@storybook/react action is deprecated. See: https://github.com/storybooks/storybook/tree/master/packages/addon-actions',

lib/cli/generators/METEOR/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const mergeDirs = require('merge-dirs').default;
22
const helpers = require('../../lib/helpers');
33
const path = require('path');
44
const fs = require('fs');
5-
const sh = require('shelljs');
65
const JSON5 = require('json5');
76

87
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
@@ -40,7 +39,7 @@ fs.writeFileSync('.babelrc', JSON.stringify(babelrc, null, 2), 'utf8');
4039

4140
// write the new package.json.
4241
packageJson.devDependencies['@storybook/react'] = '^2.21.0';
43-
packageJson.scripts['storybook'] = 'start-storybook -p 6006';
42+
packageJson.scripts.storybook = 'start-storybook -p 6006';
4443
packageJson.scripts['build-storybook'] = 'build-storybook';
4544

4645
// add react packages.

lib/cli/generators/METEOR/template/.stories/Button.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ const buttonStyles = {
1212
};
1313

1414
const Button = ({ children, onClick }) => (
15-
<button
16-
style={buttonStyles}
17-
onClick={onClick}
18-
>
15+
<button style={buttonStyles} onClick={onClick}>
1916
{children}
2017
</button>
2118
);
@@ -24,5 +21,8 @@ Button.propTypes = {
2421
children: PropTypes.string.isRequired,
2522
onClick: PropTypes.func,
2623
};
24+
Button.defaultProps = {
25+
onClick: () => {},
26+
};
2727

2828
export default Button;

lib/cli/generators/METEOR/template/.stories/Welcome.js

+63-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23

34
const styles = {
45
main: {
@@ -22,18 +23,29 @@ const styles = {
2223
code: {
2324
fontSize: 15,
2425
fontWeight: 600,
25-
padding: "2px 5px",
26-
border: "1px solid #eae9e9",
26+
padding: '2px 5px',
27+
border: '1px solid #eae9e9',
2728
borderRadius: 4,
2829
backgroundColor: '#f3f2f2',
2930
color: '#3a3a3a',
3031
},
32+
33+
note: {
34+
opacity: 0.5,
35+
},
3136
};
3237

38+
const log = () => console.log('Welcome to storybook!');
39+
3340
export default class Welcome extends React.Component {
34-
showApp(e) {
35-
e.preventDefault();
36-
if(this.props.showApp) this.props.showApp();
41+
constructor(props) {
42+
super(props);
43+
this.clickHandler = event => {
44+
event.preventDefault();
45+
46+
const { showApp } = this.props;
47+
showApp();
48+
};
3749
}
3850

3951
render() {
@@ -44,29 +56,68 @@ export default class Welcome extends React.Component {
4456
This is a UI component dev environment for your app.
4557
</p>
4658
<p>
47-
We've added some basic stories inside the <code style={styles.code}>.stories</code> directory.
48-
<br/>
59+
We've added some basic stories inside the
60+
{' '}
61+
<code style={styles.code}>src/stories</code>
62+
{' '}
63+
directory.
64+
<br />
4965
A story is a single state of one or more UI components. You can have as many stories as you want.
50-
<br/>
66+
<br />
5167
(Basically a story is like a visual test case.)
5268
</p>
5369
<p>
54-
See these sample <a style={styles.link} href='#' onClick={this.showApp.bind(this)}>stories</a> for a component called <code style={styles.code}>Button</code>.
70+
See these sample
71+
{' '}
72+
<a style={styles.link} onClick={this.clickHandler} role="button" tabIndex="0">stories</a>
73+
{' '}
74+
for a component called
75+
{' '}
76+
<code style={styles.code}>Button</code>
77+
.
5578
</p>
5679
<p>
5780
Just like that, you can add your own components as stories.
5881
<br />
5982
You can also edit those components and see changes right away.
6083
<br />
6184
(Try editing the <code style={styles.code}>Button</code> component
62-
located at <code style={styles.code}>.stories/Button.js</code>.)
85+
located at <code style={styles.code}>src/stories/Button.js</code>.)
6386
</p>
6487
<p>
6588
This is just one thing you can do with Storybook.
66-
<br/>
67-
Have a look at the <a style={styles.link} href="https://github.com/storybooks/storybook" target="_blank">Storybook</a> repo for more information.
89+
<br />
90+
Have a look at the
91+
{' '}
92+
<a
93+
style={styles.link}
94+
href="https://github.com/storybooks/storybook"
95+
target="_blank"
96+
rel="noopener noreferrer"
97+
>
98+
Storybook
99+
</a>
100+
{' '}
101+
repo for more information.
102+
</p>
103+
<p style={styles.note}>
104+
<b>NOTE:</b>
105+
<br />
106+
Have a look at the
107+
{' '}
108+
<code style={styles.code}>.storybook/webpack.config.js</code>
109+
{' '}
110+
to add webpack
111+
loaders and plugins you are using in this project.
68112
</p>
69113
</div>
70114
);
71115
}
72116
}
117+
118+
Welcome.propTypes = {
119+
showApp: PropTypes.func,
120+
};
121+
Welcome.defaultProps = {
122+
showApp: log,
123+
};

lib/cli/generators/REACT/template/stories/Button.js

+3
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@ Button.propTypes = {
2121
children: PropTypes.string.isRequired,
2222
onClick: PropTypes.func,
2323
};
24+
Button.defaultProps = {
25+
onClick: () => {},
26+
};
2427

2528
export default Button;

lib/cli/generators/REACT/template/stories/Welcome.js

+40-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23

34
const styles = {
45
main: {
@@ -28,12 +29,23 @@ const styles = {
2829
backgroundColor: '#f3f2f2',
2930
color: '#3a3a3a',
3031
},
32+
33+
note: {
34+
opacity: 0.5,
35+
},
3136
};
3237

38+
const log = () => console.log('Welcome to storybook!');
39+
3340
export default class Welcome extends React.Component {
34-
showApp(e) {
35-
e.preventDefault();
36-
if (this.props.showApp) this.props.showApp();
41+
constructor(props) {
42+
super(props);
43+
this.clickHandler = event => {
44+
event.preventDefault();
45+
46+
const { showApp } = this.props;
47+
showApp();
48+
};
3749
}
3850

3951
render() {
@@ -57,7 +69,7 @@ export default class Welcome extends React.Component {
5769
<p>
5870
See these sample
5971
{' '}
60-
<a style={styles.link} href="#" onClick={this.showApp.bind(this)}>stories</a>
72+
<a style={styles.link} onClick={this.clickHandler} role="button" tabIndex="0">stories</a>
6173
{' '}
6274
for a component called
6375
{' '}
@@ -70,20 +82,42 @@ export default class Welcome extends React.Component {
7082
You can also edit those components and see changes right away.
7183
<br />
7284
(Try editing the <code style={styles.code}>Button</code> component
73-
located at <code style={styles.code}>stories/Button.js</code>.)
85+
located at <code style={styles.code}>src/stories/Button.js</code>.)
7486
</p>
7587
<p>
7688
This is just one thing you can do with Storybook.
7789
<br />
7890
Have a look at the
7991
{' '}
80-
<a style={styles.link} href="https://github.com/storybooks/storybook" target="_blank">
92+
<a
93+
style={styles.link}
94+
href="https://github.com/storybooks/storybook"
95+
target="_blank"
96+
rel="noopener noreferrer"
97+
>
8198
Storybook
8299
</a>
83100
{' '}
84101
repo for more information.
85102
</p>
103+
<p style={styles.note}>
104+
<b>NOTE:</b>
105+
<br />
106+
Have a look at the
107+
{' '}
108+
<code style={styles.code}>.storybook/webpack.config.js</code>
109+
{' '}
110+
to add webpack
111+
loaders and plugins you are using in this project.
112+
</p>
86113
</div>
87114
);
88115
}
89116
}
117+
118+
Welcome.propTypes = {
119+
showApp: PropTypes.function,
120+
};
121+
Welcome.defaultProps = {
122+
showApp: log,
123+
};

lib/cli/generators/REACT/template/stories/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
2+
13
import React from 'react';
2-
import { storiesOf, action, linkTo } from '@storybook/react';
4+
5+
import { storiesOf } from '@storybook/react';
6+
import { action } from '@storybook/addon-actions';
7+
import { linkTo } from '@storybook/addon-links';
8+
39
import Button from './Button';
410
import Welcome from './Welcome';
511

Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
2+
13
import '@storybook/addon-actions/register';
24
import '@storybook/addon-links/register';

lib/cli/generators/REACT_NATIVE/template/storybook/index.android.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions, global-require */
2+
13
import { AppRegistry } from 'react-native';
24
import { getStorybookUI, configure } from '@storybook/react-native';
35

lib/cli/generators/REACT_NATIVE/template/storybook/index.ios.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions, global-require */
2+
13
import { AppRegistry } from 'react-native';
24
import { getStorybookUI, configure } from '@storybook/react-native';
35

lib/cli/generators/REACT_NATIVE/template/storybook/stories/CenterView/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
2+
13
import React, { PropTypes } from 'react';
24
import { View } from 'react-native';
35
import style from './style';

lib/cli/generators/REACT_NATIVE/template/storybook/stories/Welcome/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint max-len: 0 */
1+
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
22

33
import React, { PropTypes } from 'react';
44
import { View, Text } from 'react-native';
@@ -21,8 +21,8 @@ export default class Welcome extends React.Component {
2121
},
2222
};
2323

24-
showApp(e) {
25-
e.preventDefault();
24+
showApp(event) {
25+
event.preventDefault();
2626
if (this.props.showApp) this.props.showApp();
2727
}
2828

lib/cli/generators/REACT_NATIVE/template/storybook/stories/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
2+
13
import React from 'react';
24
import { Text } from 'react-native';
35

lib/cli/generators/REACT_SCRIPTS/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ const packageJson = helpers.getPackageJson();
99

1010
// TODO: Get the latest version of storybook here.
1111
packageJson.devDependencies['@storybook/react'] = '^2.21.0';
12-
packageJson.scripts['storybook'] = 'start-storybook -p 9009';
12+
packageJson.scripts.storybook = 'start-storybook -p 9009';
1313
packageJson.scripts['build-storybook'] = 'build-storybook';
1414

1515
if (fs.existsSync(path.resolve('./public'))) {
1616
// has a public folder and add support to it.
17-
packageJson.scripts['storybook'] += ' -s public';
17+
packageJson.scripts.storybook += ' -s public';
1818
packageJson.scripts['build-storybook'] += ' -s public';
1919
}
2020

0 commit comments

Comments
 (0)