Skip to content

Commit

Permalink
Updated packages and handle some new eslint/airbnb rule changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoda committed Sep 4, 2016
2 parents abad12c + befed8a commit e435c31
Show file tree
Hide file tree
Showing 31 changed files with 135 additions and 81 deletions.
15 changes: 12 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
{
"extends": "airbnb",
"rules": {
"react/jsx-no-bind": 0,
"react/prefer-stateless-function": 0,
# We use _ to define private variables and methods in clases
"no-underscore-dangle": 0,
# This seems to be buggy we don't want eslint to check this
"import/no-extraneous-dependencies": 0,
# This is a depricated rule. So we turned off it.
"react/require-extension": 0,
# We can write JSX in anyfile we want.
"react/jsx-filename-extension": 0,
# We don't like this rule.
"arrow-body-style": 0,
# We don't like this rule. We write arrow functions only when we needed.
"prefer-arrow-callback": 0,
# We don't need to write function names always.
"func-names": 0
},
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
}
},
}
2 changes: 2 additions & 0 deletions dist/client/manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ var _provider2 = _interopRequireDefault(_provider);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/* global document */

var rootEl = document.getElementById('root');
(0, _storybookUi2.default)(rootEl, new _provider2.default());
4 changes: 3 additions & 1 deletion dist/client/manager/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ var _preview2 = _interopRequireDefault(_preview);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/* global location */

var ReactProvider = function (_Provider) {
(0, _inherits3.default)(ReactProvider, _Provider);

function ReactProvider() {
(0, _classCallCheck3.default)(this, ReactProvider);

var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(ReactProvider).call(this));
var _this = (0, _possibleConstructorReturn3.default)(this, (ReactProvider.__proto__ || (0, _getPrototypeOf2.default)(ReactProvider)).call(this));

_this.dataId = _uuid2.default.v4();
_this.channel = (0, _storybookChannelPagebus2.default)({ key: _this.dataId });
Expand Down
30 changes: 15 additions & 15 deletions dist/client/preview/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ var _toConsumableArray2 = require("babel-runtime/helpers/toConsumableArray");

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

var _keys = require("babel-runtime/core-js/object/keys");

var _keys2 = _interopRequireDefault(_keys);

var _extends2 = require("babel-runtime/helpers/extends");

var _extends3 = _interopRequireDefault(_extends2);
Expand Down Expand Up @@ -68,21 +72,17 @@ var ClientApi = function () {
};

// apply addons
for (var name in this._addons) {
if (this._addons.hasOwnProperty(name)) {
(function () {
var addon = _this._addons[name];
api[name] = function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

addon.apply(api, args);
return api;
};
})();
}
}
(0, _keys2.default)(this._addons).forEach(function (name) {
var addon = _this._addons[name];
api[name] = function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

addon.apply(api, args);
return api;
};
});

api.add = function (storyName, getStory) {
// Wrap the getStory function with each decorator. The first
Expand Down
5 changes: 4 additions & 1 deletion dist/client/preview/error_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de

var mainStyle = {
position: 'fixed',
top: 0, bottom: 0, left: 0, right: 0,
top: 0,
bottom: 0,
left: 0,
right: 0,
padding: 20,
backgroundColor: 'rgb(187, 49, 49)',
color: '#FFF',
Expand Down
30 changes: 15 additions & 15 deletions dist/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ var _assign = require('babel-runtime/core-js/object/assign');

var _assign2 = _interopRequireDefault(_assign);

var _redux = require('redux');

var _storybookAddons = require('@kadira/storybook-addons');

var _storybookAddons2 = _interopRequireDefault(_storybookAddons);

var _storybookChannelPagebus = require('@kadira/storybook-channel-pagebus');

var _storybookChannelPagebus2 = _interopRequireDefault(_storybookChannelPagebus);

var _qs = require('qs');

var _qs2 = _interopRequireDefault(_qs);

var _story_store = require('./story_store');

var _story_store2 = _interopRequireDefault(_story_store);
Expand All @@ -25,34 +39,20 @@ var _render = require('./render');

var _render2 = _interopRequireDefault(_render);

var _qs = require('qs');

var _qs2 = _interopRequireDefault(_qs);

var _init = require('./init');

var _init2 = _interopRequireDefault(_init);

var _storybookChannelPagebus = require('@kadira/storybook-channel-pagebus');

var _storybookChannelPagebus2 = _interopRequireDefault(_storybookChannelPagebus);

var _actions = require('./actions');

var _storybookAddons = require('@kadira/storybook-addons');

var _storybookAddons2 = _interopRequireDefault(_storybookAddons);

var _redux = require('redux');

var _reducer = require('./reducer');

var _reducer2 = _interopRequireDefault(_reducer);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// check whether we're running on node/browser
var isBrowser = typeof window !== 'undefined';
var isBrowser = typeof window !== 'undefined'; /* global window */

var storyStore = new _story_store2.default();
var reduxStore = (0, _redux.createStore)(_reducer2.default);
Expand Down
4 changes: 2 additions & 2 deletions dist/client/preview/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ exports.default = function (context) {
};
};

var _actions = require('./actions');

var _key_events = require('@kadira/storybook-ui/dist/libs/key_events');

var _key_events2 = _interopRequireDefault(_key_events);

var _actions = require('./actions');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8 changes: 5 additions & 3 deletions dist/client/preview/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _error_display2 = _interopRequireDefault(_error_display);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// check whether we're running on node/browser
var isBrowser = typeof window !== 'undefined';
var isBrowser = typeof window !== 'undefined'; /* global document */

var rootEl = null;
var previousKind = '';
Expand Down Expand Up @@ -58,7 +58,8 @@ function renderMain(data, storyStore) {

var story = storyStore.getStory(selectedKind, selectedStory);
if (!story) {
return _reactDom2.default.render(noPreview, rootEl);
_reactDom2.default.render(noPreview, rootEl);
return null;
}

// Unmount the previous story only if selectedKind or selectedStory has changed.
Expand All @@ -81,7 +82,8 @@ function renderMain(data, storyStore) {
};

try {
return _reactDom2.default.render(story(context), rootEl);
_reactDom2.default.render(story(context), rootEl);
return null;
} catch (ex) {
return renderError(ex);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var _json2 = _interopRequireDefault(_json);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// avoid ESLint errors
var logger = console;
var logger = console; /* eslint global-require: 0 */

function removeReactHmre(presets) {
var index = presets.indexOf('react-hmre');
Expand Down
3 changes: 3 additions & 0 deletions dist/server/config/error_enhancements.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';

/* eslint global-require: 0 */
/* global navigator */

var isChrome = function isChrome() {
return navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
};
Expand Down
6 changes: 5 additions & 1 deletion dist/server/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ var _caseSensitivePathsWebpackPlugin2 = _interopRequireDefault(_caseSensitivePat

var _utils = require('./utils');

var _babel = require('./babel.js');

var _babel2 = _interopRequireDefault(_babel);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var config = {
Expand All @@ -36,7 +40,7 @@ var config = {
loaders: [{
test: /\.jsx?$/,
loader: require.resolve('babel-loader'),
query: require('./babel.js'),
query: _babel2.default,
include: _utils.includePaths,
exclude: _utils.excludePaths
}]
Expand Down
6 changes: 5 additions & 1 deletion dist/server/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ var _webpack2 = _interopRequireDefault(_webpack);

var _utils = require('./utils');

var _babelProd = require('./babel.prod.js');

var _babelProd2 = _interopRequireDefault(_babelProd);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var entries = {
Expand Down Expand Up @@ -51,7 +55,7 @@ var config = {
loaders: [{
test: /\.jsx?$/,
loader: require.resolve('babel-loader'),
query: require('./babel.prod.js'),
query: _babelProd2.default,
include: _utils.includePaths,
exclude: _utils.excludePaths
}]
Expand Down
14 changes: 7 additions & 7 deletions dist/server/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env node
'use strict';

var _middleware = require('@kadira/storybook-database-local/dist/server/middleware');

var _middleware2 = _interopRequireDefault(_middleware);

var _express = require('express');

var _express2 = _interopRequireDefault(_express);
Expand All @@ -17,11 +21,7 @@ var _fs = require('fs');

var _fs2 = _interopRequireDefault(_fs);

var _middleware = require('./middleware');

var _middleware2 = _interopRequireDefault(_middleware);

var _middleware3 = require('@kadira/storybook-database-local/dist/server/middleware');
var _middleware3 = require('./middleware');

var _middleware4 = _interopRequireDefault(_middleware3);

Expand Down Expand Up @@ -83,13 +83,13 @@ if (_commander2.default.staticDir) {
// Build the webpack configuration using the `baseConfig`
// custom `.babelrc` file and `webpack.config.js` files
var configDir = _commander2.default.configDir || './.storybook';
app.use((0, _middleware2.default)(configDir));
app.use((0, _middleware4.default)(configDir));

// The addon database service is disabled by default for now
// It should be enabled with the --enable-db for dev server
if (_commander2.default.enableDb) {
var dbPath = _commander2.default.dbPath || _path2.default.resolve(configDir, 'addon-db.json');
app.use('/db', (0, _middleware4.default)(dbPath));
app.use('/db', (0, _middleware2.default)(dbPath));
}

app.listen.apply(app, listenAddr.concat([function (error) {
Expand Down
4 changes: 3 additions & 1 deletion dist/server/track_usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ var _request2 = _interopRequireDefault(_request);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var logger = console; // ### WHAT?
var logger = console; /* eslint global-require: 0 */

// ### WHAT?
//
// We will track anonymous usage of how you use storybook.
// We don't want any personal information.
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"testonly": "mocha $npm_package_options_mocha",
"test": "npm run lint && npm run testonly",
"test-watch": "npm run testonly -- --watch --watch-extensions js",
"dev": "DEV_BUILD=1 nodemon --watch src --exec 'npm run prepublish'"
"dev": "DEV_BUILD=1 nodemon --watch src --exec 'npm run prepublish'",
"postpublish": "greenkeeper-postpublish"
},
"dependencies": {
"@kadira/react-split-pane": "^1.4.0",
Expand All @@ -39,7 +40,6 @@
"babel-plugin-transform-react-constant-elements": "^6.9.1",
"babel-plugin-transform-regenerator": "^6.11.4",
"babel-plugin-transform-runtime": "^6.12.0",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-es2016": "^6.11.3",
"babel-preset-react": "^6.11.1",
Expand Down Expand Up @@ -82,9 +82,11 @@
"enzyme": "^2.2.0",
"eslint": "^3.4.0",
"eslint-config-airbnb": "^10.0.1",
"eslint-plugin-babel": "^3.1.0",
"eslint-plugin-react": "^6.2.0",
"eslint-plugin-import": "^1.13.0",
"eslint-plugin-jsx-a11y": "^2.1.0",
"eslint-plugin-react": "^6.1.2",
"expect": "^1.6.0",
"greenkeeper-postpublish": "^1.0.1",
"jsdom": "^9.5.0",
"mocha": "^3.0.2",
"mock-fs": "^3.8.0",
Expand Down
2 changes: 2 additions & 0 deletions src/client/manager/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global document */

import renderStorybookUI from '@kadira/storybook-ui';
import Provider from './provider';

Expand Down
2 changes: 2 additions & 0 deletions src/client/manager/provider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global location */

import UUID from 'uuid';
import qs from 'qs';
import React from 'react';
Expand Down
3 changes: 2 additions & 1 deletion src/client/preview/__tests__/client_api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai';
import ClientAPI from '../client_api';

const { describe, it } = global;
import { expect } from 'chai';

class StoryStore {
constructor() {
Expand Down
16 changes: 7 additions & 9 deletions src/client/preview/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ export default class ClientApi {
};

// apply addons
for (const name in this._addons) {
if (this._addons.hasOwnProperty(name)) {
const addon = this._addons[name];
api[name] = (...args) => {
addon.apply(api, args);
return api;
};
}
}
Object.keys(this._addons).forEach((name) => {
const addon = this._addons[name];
api[name] = (...args) => {
addon.apply(api, args);
return api;
};
});

api.add = (storyName, getStory) => {
// Wrap the getStory function with each decorator. The first
Expand Down
Loading

0 comments on commit e435c31

Please sign in to comment.