Skip to content

Commit

Permalink
FIX linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Apr 18, 2017
1 parent 0a7163b commit c241677
Show file tree
Hide file tree
Showing 86 changed files with 257 additions and 230 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ dist
build
coverage
node_modules
**/example/**
**/demo/**
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ module.exports = {
singleQuote: true,
}],
quotes: ['warn', 'single'],
'class-methods-use-this': ignore,
'arrow-parens': ['warn', 'as-needed'],
'space-before-function-paren': ignore,
'import/no-extraneous-dependencies': [error, { devDependencies: true }],
'import/no-extraneous-dependencies': [error, { devDependencies: true, peerDependencies: true }],
'import/prefer-default-export': ignore,
'react/jsx-uses-react': error,
'react/jsx-uses-vars': error,
Expand Down
2 changes: 1 addition & 1 deletion packages/addon-info/src/components/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function getData(element) {
children: null,
};

if (typeof element == 'string') {
if (typeof element === 'string') {
data.text = element;
return data;
}
Expand Down
2 changes: 0 additions & 2 deletions packages/addon-info/src/components/Story.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,6 @@ export default class Story extends React.Component {
{propTables}
</div>
);

return;
}

render() {
Expand Down
5 changes: 4 additions & 1 deletion packages/addon-knobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"devDependencies": {
"@kadira/storybook": "*",
"@kadira/storybook-addons": "*",
"@types/node": "^7.0.12",
"@types/react": "^15.0.21",
"babel-cli": "^6.24.1",
Expand All @@ -26,6 +27,7 @@
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"enzyme": "^2.8.2",
"git-url-parse": "^6.2.2",
"raw-loader": "^0.5.1",
"react": "^15.5.4",
Expand All @@ -35,13 +37,14 @@
"typescript-definition-tester": "^0.0.5"
},
"peerDependencies": {
"@kadira/storybook-addons": "*",
"react": "*",
"react-dom": "*"
},
"dependencies": {
"@kadira/storybook-addons": "*",
"babel-runtime": "^6.23.0",
"deep-equal": "^1.0.1",
"global": "^4.3.1",
"insert-css": "^1.0.0",
"moment": "^2.18.1",
"prop-types": "^15.5.8",
Expand Down
6 changes: 4 additions & 2 deletions packages/addon-knobs/src/KnobManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint no-underscore-dangle: 0 */

import React from 'react';
import deepEqual from 'deep-equal';
import WrapStory from './components/WrapStory';
import KnobStore from './KnobStore';
import deepEqual from 'deep-equal';

// This is used by _mayCallChannel to determine how long to wait to before triggering a panel update
const PANEL_UPDATE_INTERVAL = 400;
Expand Down Expand Up @@ -41,7 +43,7 @@ export default class KnobManager {
let knobStore = this.knobStoreMap[key];

if (!knobStore) {
knobStore = this.knobStoreMap[key] = new KnobStore();
knobStore = this.knobStoreMap[key] = new KnobStore(); // eslint-disable-line
}

this.knobStore = knobStore;
Expand Down
2 changes: 2 additions & 0 deletions packages/addon-knobs/src/components/WrapStory.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint no-underscore-dangle: 0 */

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

Expand Down
9 changes: 2 additions & 7 deletions packages/addon-knobs/src/components/types/Array.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ ArrayType.propTypes = {
onChange: PropTypes.func,
};

ArrayType.serialize = function(value) {
return value;
};

ArrayType.deserialize = function(value) {
return value;
};
ArrayType.serialize = value => value;
ArrayType.deserialize = value => value;

export default ArrayType;
10 changes: 2 additions & 8 deletions packages/addon-knobs/src/components/types/Boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ BooleanType.propTypes = {
onChange: PropTypes.func,
};

BooleanType.serialize = function(value) {
return String(value);
};

BooleanType.deserialize = function(value) {
if (!value) return false;
return value.trim() === 'true';
};
BooleanType.serialize = value => String(value);
BooleanType.deserialize = value => (typeof value === 'string' ? value.match('true') : false);

export default BooleanType;
10 changes: 3 additions & 7 deletions packages/addon-knobs/src/components/types/Color.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { document } from 'global';
import PropTypes from 'prop-types';
import React from 'react';
import { SketchPicker } from 'react-color';
Expand Down Expand Up @@ -90,12 +91,7 @@ ColorType.propTypes = {
onChange: PropTypes.func,
};

ColorType.serialize = function(value) {
return value;
};

ColorType.deserialize = function(value) {
return value;
};
ColorType.serialize = value => value;
ColorType.deserialize = value => value;

export default ColorType;
9 changes: 2 additions & 7 deletions packages/addon-knobs/src/components/types/Date/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ DateType.propTypes = {
onChange: PropTypes.func,
};

DateType.serialize = function(value) {
return String(value);
};

DateType.deserialize = function(value) {
return parseFloat(value);
};
DateType.serialize = value => String(value);
DateType.deserialize = value => parseFloat(value);

export default DateType;
9 changes: 2 additions & 7 deletions packages/addon-knobs/src/components/types/Number.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ NumberType.propTypes = {
onChange: PropTypes.func,
};

NumberType.serialize = function(value) {
return String(value);
};

NumberType.deserialize = function(value) {
return parseFloat(value);
};
NumberType.serialize = value => String(value);
NumberType.deserialize = value => parseFloat(value);

export default NumberType;
10 changes: 2 additions & 8 deletions packages/addon-knobs/src/components/types/Object.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,7 @@ ObjectType.propTypes = {
onChange: PropTypes.func,
};

ObjectType.serialize = function(object) {
return JSON.stringify(object);
};

ObjectType.deserialize = function(value) {
if (!value) return {};
return JSON.parse(value);
};
ObjectType.serialize = object => JSON.stringify(object);
ObjectType.deserialize = value => (value ? JSON.parse(value) : {});

export default ObjectType;
11 changes: 4 additions & 7 deletions packages/addon-knobs/src/components/types/Select.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint no-underscore-dangle: 0 */

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

Expand Down Expand Up @@ -56,12 +58,7 @@ SelectType.propTypes = {
onChange: PropTypes.func,
};

SelectType.serialize = function(value) {
return value;
};

SelectType.deserialize = function(value) {
return value;
};
SelectType.serialize = value => value;
SelectType.deserialize = value => value;

export default SelectType;
9 changes: 2 additions & 7 deletions packages/addon-knobs/src/components/types/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ TextType.propTypes = {
onChange: PropTypes.func,
};

TextType.serialize = function(value) {
return value;
};

TextType.deserialize = function(value) {
return value;
};
TextType.serialize = value => value;
TextType.deserialize = value => value;

export default TextType;
1 change: 1 addition & 0 deletions packages/addon-notes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"devDependencies": {
"@kadira/storybook": "*",
"@kadira/storybook-addons": "*",
"babel-cli": "^6.5.0",
"babel-core": "^6.5.0",
"babel-loader": "^6.2.4",
Expand Down
1 change: 1 addition & 0 deletions packages/addon-options/manager.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
const manager = require('./dist/manager');

manager.init();
1 change: 1 addition & 0 deletions packages/addon-options/preview.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const preview = require('./dist/preview');

exports.setOptions = preview.setOptions;
preview.init();
1 change: 0 additions & 1 deletion packages/addon-options/src/manager/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import addons from '@kadira/storybook-addons';
import { ADDON_ID, EVENT_ID } from '../shared';

Expand Down
2 changes: 2 additions & 0 deletions packages/addons/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint no-underscore-dangle: 0 */

export class AddonStore {
constructor() {
this._loaders = {};
Expand Down
1 change: 1 addition & 0 deletions packages/channel-postmessage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"dependencies": {
"@kadira/storybook-channel": "*",
"global": "^4.3.1",
"json-stringify-safe": "^5.0.1"
}
}
28 changes: 15 additions & 13 deletions packages/channel-postmessage/src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/* eslint no-underscore-dangle: 0 */

import { window, document } from 'global';
import Channel from '@kadira/storybook-channel';
import stringify from 'json-stringify-safe';

export const KEY = 'storybook-channel';

export default function createChannel({ page }) {
const transport = new PostmsgTransport({ page });
return new Channel({ transport });
}

export class PostmsgTransport {
constructor(config) {
this._config = config;
Expand Down Expand Up @@ -58,22 +56,26 @@ export class PostmsgTransport {
return window.parent;
}

_handleEvent(e) {
if (!e.data || typeof e.data !== 'string') {
_handleEvent(event) {
if (!event.data || typeof event.data !== 'string') {
return;
}
let data;
try {
data = JSON.parse(e.data);
} catch (e) {
return null;
data = JSON.parse(event.data);
} catch (error) {
data = null;
}
if (!data || typeof data !== 'object') {
return null;
return;
}
const { key, event } = data;
const { key, event: eventData } = data;
if (key === KEY) {
this._handler(event);
this._handler(eventData);
}
}
}
export default function createChannel({ page }) {
const transport = new PostmsgTransport({ page });
return new Channel({ transport });
}
3 changes: 2 additions & 1 deletion packages/channel-websocket/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"shelljs": "^0.7.3"
},
"dependencies": {
"@kadira/storybook-channel": "^1.0.1"
"@kadira/storybook-channel": "^1.0.1",
"global": "^4.3.1"
}
}
13 changes: 8 additions & 5 deletions packages/channel-websocket/src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Channel from '@kadira/storybook-channel';
/* eslint no-underscore-dangle: 0 */

export default function createChannel({ url }) {
const transport = new WebsocketTransport({ url });
return new Channel({ transport });
}
import { WebSocket } from 'global';
import Channel from '@kadira/storybook-channel';

export class WebsocketTransport {
constructor({ url }) {
Expand Down Expand Up @@ -59,3 +57,8 @@ export class WebsocketTransport {
};
}
}

export default function createChannel({ url }) {
const transport = new WebsocketTransport({ url });
return new Channel({ transport });
}
2 changes: 2 additions & 0 deletions packages/channel/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint no-underscore-dangle: 0 */

export default class Channel {
constructor({ transport }) {
this._sender = this._randomId();
Expand Down
2 changes: 2 additions & 0 deletions packages/channel/src/index.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint no-underscore-dangle: 0 */

import Channel from './';

describe('Channel', () => {
Expand Down
8 changes: 7 additions & 1 deletion packages/decorator-centered/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@
"babelify"
]
},
"peerDependencies": {
"react": "*",
"react-dom": "*"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1"
"babel-preset-stage-0": "^6.24.1",
"react": "^15.5.4",
"react-dom": "^15.5.4"
}
}
Loading

0 comments on commit c241677

Please sign in to comment.