Skip to content

Commit

Permalink
FIX linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Jun 3, 2017
1 parent 572d677 commit da961dc
Show file tree
Hide file tree
Showing 55 changed files with 618 additions and 646 deletions.
128 changes: 62 additions & 66 deletions addons/info/src/components/PropTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,91 +22,87 @@ const stylesheet = {
},
};

export default class PropTable extends React.Component {
render() {
const type = this.props.type;

if (!type) {
return null;
}
const PropTable = ({ type }) => {
if (!type) {
return null;
}

const props = {};
const props = {};

if (type.propTypes) {
if (type.propTypes) {
for (const property in type.propTypes) { // eslint-disable-line
if (!type.propTypes.hasOwnProperty(property)) { // eslint-disable-line
continue; // eslint-disable-line
}
const typeInfo = type.propTypes[property];
let propType = PropTypesMap.get(typeInfo) || 'other';
const required = typeInfo.isRequired === undefined ? 'yes' : 'no';
const description = type.__docgenInfo &&
}
const typeInfo = type.propTypes[property];
let propType = PropTypesMap.get(typeInfo) || 'other';
const required = typeInfo.isRequired === undefined ? 'yes' : 'no';
const description = type.__docgenInfo &&
type.__docgenInfo.props &&
type.__docgenInfo.props[property]
? type.__docgenInfo.props[property].description
: null;
if (propType === 'other') {
if (
type.__docgenInfo &&
type.__docgenInfo.props &&
type.__docgenInfo.props[property]
? type.__docgenInfo.props[property].description
: null;
if (propType === 'other') {
if (
type.__docgenInfo &&
type.__docgenInfo.props &&
type.__docgenInfo.props[property] &&
type.__docgenInfo.props[property].type
) {
propType = type.__docgenInfo.props[property].type.name;
}
type.__docgenInfo.props[property] &&
type.__docgenInfo.props[property].type
) {
propType = type.__docgenInfo.props[property].type.name;
}
props[property] = { property, propType, required, description };
}
props[property] = { property, propType, required, description };
}
}

if (type.defaultProps) {
if (type.defaultProps) {
for (const property in type.defaultProps) { // eslint-disable-line
if (!type.defaultProps.hasOwnProperty(property)) { // eslint-disable-line
continue; // eslint-disable-line
}
const value = type.defaultProps[property];
if (value === undefined) {
}
const value = type.defaultProps[property];
if (value === undefined) {
continue; // eslint-disable-line
}
if (!props[property]) {
props[property] = { property };
}
props[property].defaultValue = value;
}
if (!props[property]) {
props[property] = { property };
}
props[property].defaultValue = value;
}
}

const array = Object.values(props);
if (!array.length) {
return <small>No propTypes defined!</small>;
}
array.sort((a, b) => a.property > b.property);
const array = Object.values(props);
if (!array.length) {
return <small>No propTypes defined!</small>;
}
array.sort((a, b) => a.property > b.property);

return (
<table style={stylesheet.propTable}>
<thead>
<tr>
<th>property</th>
<th>propType</th>
<th>required</th>
<th>default</th>
<th>description</th>
return (
<table style={stylesheet.propTable}>
<thead>
<tr>
<th>property</th>
<th>propType</th>
<th>required</th>
<th>default</th>
<th>description</th>
</tr>
</thead>
<tbody>
{array.map(row => (
<tr key={row.property}>
<td>{row.property}</td>
<td>{row.propType}</td>
<td>{row.required}</td>
<td>{row.defaultValue === undefined ? '-' : <PropVal val={row.defaultValue} />}</td>
<td>{row.description}</td>
</tr>
</thead>
<tbody>
{array.map(row => (
<tr key={row.property}>
<td>{row.property}</td>
<td>{row.propType}</td>
<td>{row.required}</td>
<td>{row.defaultValue === undefined ? '-' : <PropVal val={row.defaultValue} />}</td>
<td>{row.description}</td>
</tr>
))}
</tbody>
</table>
);
}
}
))}
</tbody>
</table>
);
};

PropTable.displayName = 'PropTable';
PropTable.defaultProps = {
Expand Down
4 changes: 3 additions & 1 deletion addons/info/src/components/Props.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export default function Props(props) {

const names = Object.keys(props).filter(
name =>
name[0] !== '_' && name !== 'children' && (!defaultProps || props[name] != defaultProps[name])
name[0] !== '_' &&
name !== 'children' &&
(!defaultProps || props[name] !== defaultProps[name])
);

const breakIntoNewLines = names.length > 3;
Expand Down
9 changes: 7 additions & 2 deletions addons/info/src/components/Story.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/* eslint no-underscore-dangle: 0 */

import PropTypes from 'prop-types';
import React from 'react';
import PropTypes from 'prop-types';
import global from 'global';

import MTRC from 'markdown-to-react-components';
import PropTable from './PropTable';
import Node from './Node';
import { baseFonts } from './theme';
import { Pre } from './markdown';

global.STORYBOOK_REACT_CLASSES = global.STORYBOOK_REACT_CLASSES || [];
const STORYBOOK_REACT_CLASSES = global.STORYBOOK_REACT_CLASSES;

const stylesheet = {
link: {
base: {
Expand Down Expand Up @@ -222,7 +227,7 @@ export default class Story extends React.Component {
let retDiv = null;

if (Object.keys(STORYBOOK_REACT_CLASSES).length) {
Object.keys(STORYBOOK_REACT_CLASSES).forEach((key, index) => {
Object.keys(STORYBOOK_REACT_CLASSES).forEach(key => {
if (STORYBOOK_REACT_CLASSES[key].name === this.props.context.kind) {
retDiv = (
<div>
Expand Down
2 changes: 1 addition & 1 deletion addons/knobs/src/components/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Panel.propTypes = {
on: PropTypes.func,
removeListener: PropTypes.func,
}).isRequired,
onReset: PropTypes.object,
onReset: PropTypes.object, // eslint-disable-line
api: PropTypes.shape({
getQueryParam: PropTypes.func,
setQueryParams: PropTypes.func,
Expand Down
4 changes: 3 additions & 1 deletion addons/storyshots/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"read-pkg-up": "^2.0.0"
},
"peerDependencies": {
"@storybook/addons": "^3.0.0",
"react": "*",
"react-test-renderer": "*"
"react-test-renderer": "*",
"babel-core": "^6.24.1"
}
}
22 changes: 12 additions & 10 deletions addons/storyshots/src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import path from 'path';
import global from 'global';
import global, { describe, it } from 'global';
import readPkgUp from 'read-pkg-up';
import addons from '@storybook/addons';
import runWithRequireContext from './require_context';
import createChannel from './storybook-channel-mock';
import { snapshot } from './test-bodies';
const { describe, it, expect } = global;

export { snapshotWithOptions, snapshot, renderOnly } from './test-bodies';

Expand All @@ -17,12 +16,9 @@ const babel = require('babel-core');

const pkg = readPkgUp.sync().pkg;

const hasDependency = function(name) {
return (
(pkg.devDependencies && pkg.devDependencies[name]) ||
(pkg.dependencies && pkg.dependencies[name])
);
};
const hasDependency = name =>
(pkg.devDependencies && pkg.devDependencies[name]) ||
(pkg.dependencies && pkg.dependencies[name]);

export default function testStorySnapshots(options = {}) {
addons.setChannel(createChannel());
Expand All @@ -33,16 +29,17 @@ export default function testStorySnapshots(options = {}) {

if (isStorybook) {
storybook = require.requireActual('@storybook/react');
// eslint-disable-next-line
const loadBabelConfig = require('@storybook/react/dist/server/babel_config').default;
const configDirPath = path.resolve(options.configPath || '.storybook');
configPath = path.join(configDirPath, 'config.js');

const babelConfig = loadBabelConfig(configDirPath);
const content = babel.transformFileSync(configPath, babelConfig).code;
const contextOpts = {
filename: configPath,
dirname: configDirPath,
};
const babelConfig = loadBabelConfig(configDirPath);

runWithRequireContext(content, contextOpts);
} else if (isRNStorybook) {
Expand All @@ -61,19 +58,24 @@ export default function testStorySnapshots(options = {}) {
const stories = storybook.getStorybook();

// Added not to break existing storyshots configs (can be removed in a future major release)
// eslint-disable-next-line
options.storyNameRegex = options.storyNameRegex || options.storyRegex;

// eslint-disable-next-line
options.test = options.test || snapshot;

// eslint-disable-next-line
for (const group of stories) {
if (options.storyKindRegex && !group.kind.match(options.storyKindRegex)) {
// eslint-disable-next-line
continue;
}

describe(suit, () => {
describe(group.kind, () => {
// eslint-disable-next-line
for (const story of group.stories) {
if (options.storyNameRegex && !story.name.match(options.storyNameRegex)) {
// eslint-disable-next-line
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion addons/storyshots/src/test-bodies.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export const snapshot = snapshotWithOptions({});

export function renderOnly({ story, context }) {
const storyElement = story.render(context);
const tree = renderer.create(storyElement);
renderer.create(storyElement);
}
4 changes: 2 additions & 2 deletions addons/storyshots/stories/directly_required/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react'; // eslint-disable-line
import { action } from '@storybook/addon-actions'; // eslint-disable-line
import Button from './Button';

storiesOf('Another Button', module)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react'; // eslint-disable-line
import { action } from '@storybook/addon-actions'; // eslint-disable-line

import Button from './Button';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { storiesOf } from '@storybook/react';
import { linkTo } from '@storybook/addon-links';
import { storiesOf } from '@storybook/react'; // eslint-disable-line
import { linkTo } from '@storybook/addon-links'; // eslint-disable-line

import Welcome from './Welcome';

Expand Down
4 changes: 3 additions & 1 deletion app/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"events": "^1.1.1",
"express": "^4.15.2",
"file-loader": "^0.11.1",
"global": "^4.3.2",
"json-loader": "^0.5.4",
"json5": "^0.5.1",
"postcss-loader": "^2.0.3",
Expand All @@ -71,6 +72,7 @@
"uuid": "^3.0.1",
"webpack": "^2.4.1",
"webpack-dev-middleware": "^1.10.1",
"webpack-hot-middleware": "^2.18.0"
"webpack-hot-middleware": "^2.18.0",
"ws": "^3.0.0"
}
}
Loading

0 comments on commit da961dc

Please sign in to comment.