react_on_rails 2.0.0.beta.1 → 2.0.0.beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.dockerignore +2 -0
- data/.eslintignore +7 -0
- data/.eslintrc +19 -0
- data/.gitignore +28 -0
- data/.jscsrc +27 -0
- data/.npmignore +20 -0
- data/.rspec +2 -0
- data/.rubocop.yml +70 -0
- data/.scss-lint.yml +205 -0
- data/.travis.yml +43 -0
- data/CHANGELOG.md +34 -0
- data/Dockerfile_tests +12 -0
- data/Gemfile +40 -0
- data/README.md +365 -0
- data/Rakefile +5 -0
- data/app/helpers/react_on_rails_helper.rb +215 -0
- data/docker-compose.yml +11 -0
- data/docs/LICENSE +21 -0
- data/docs/additional_reading/heroku_deployment.md +23 -0
- data/docs/additional_reading/manual_installation.md +118 -0
- data/docs/additional_reading/node_dependencies_and_npm.md +29 -0
- data/docs/additional_reading/optional_configuration.md +33 -0
- data/docs/additional_reading/react-and-redux.md +36 -0
- data/docs/additional_reading/react_router.md +45 -0
- data/docs/additional_reading/server_rendering_tips.md +11 -0
- data/docs/additional_reading/tips.md +10 -0
- data/docs/additional_reading/webpack.md +46 -0
- data/docs/code_of_conduct.md +13 -0
- data/docs/coding-style/linters.md +64 -0
- data/docs/coding-style/style.md +42 -0
- data/docs/contributing.md +157 -0
- data/docs/generator_testing.md +20 -0
- data/docs/releasing.md +29 -0
- data/lib/generators/USAGE +99 -0
- data/lib/generators/react_on_rails/base_generator.rb +191 -0
- data/lib/generators/react_on_rails/bootstrap_generator.rb +89 -0
- data/lib/generators/react_on_rails/dev_tests_generator.rb +39 -0
- data/lib/generators/react_on_rails/generator_helper.rb +50 -0
- data/lib/generators/react_on_rails/heroku_deployment_generator.rb +30 -0
- data/lib/generators/react_on_rails/install_generator.rb +99 -0
- data/lib/generators/react_on_rails/js_linters_generator.rb +19 -0
- data/lib/generators/react_on_rails/react_no_redux_generator.rb +40 -0
- data/lib/generators/react_on_rails/react_with_redux_generator.rb +51 -0
- data/lib/generators/react_on_rails/ruby_linters_generator.rb +33 -0
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +4 -0
- data/lib/generators/react_on_rails/templates/base/base/REACT_ON_RAILS.md +16 -0
- data/lib/generators/react_on_rails/templates/base/base/app/controllers/hello_world_controller.rb +5 -0
- data/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt +4 -0
- data/lib/generators/react_on_rails/templates/base/base/client/.babelrc +3 -0
- data/lib/generators/react_on_rails/templates/base/base/client/REACT_ON_RAILS_CLIENT_README.md +3 -0
- data/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/startup/clientRegistration.jsx.tt +5 -0
- data/lib/generators/react_on_rails/templates/base/base/client/index.jade +15 -0
- data/lib/generators/react_on_rails/templates/base/base/client/package.json.tt +104 -0
- data/lib/generators/react_on_rails/templates/base/base/client/server.js +64 -0
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.base.config.js.tt +62 -0
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.hot.config.js.tt +69 -0
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.rails.config.js +42 -0
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +26 -0
- data/lib/generators/react_on_rails/templates/base/base/lib/tasks/assets.rake.tt +26 -0
- data/lib/generators/react_on_rails/templates/base/base/lib/tasks/linters.rake.tt +88 -0
- data/lib/generators/react_on_rails/templates/base/base/package.json +31 -0
- data/lib/generators/react_on_rails/templates/base/server_rendering/client/app/bundles/HelloWorld/startup/serverRegistration.jsx +4 -0
- data/lib/generators/react_on_rails/templates/base/server_rendering/client/webpack.server.rails.config.js +39 -0
- data/lib/generators/react_on_rails/templates/bootstrap/app/assets/stylesheets/_bootstrap-custom.scss +63 -0
- data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_post-bootstrap.scss +10 -0
- data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_pre-bootstrap.scss +8 -0
- data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_react-on-rails-sass-helper.scss +19 -0
- data/lib/generators/react_on_rails/templates/bootstrap/client/bootstrap-sass.config.js +89 -0
- data/lib/generators/react_on_rails/templates/dev_tests/.rspec +2 -0
- data/lib/generators/react_on_rails/templates/dev_tests/spec/features/hello_world_spec.rb +25 -0
- data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +57 -0
- data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +21 -0
- data/lib/generators/react_on_rails/templates/dev_tests/spec/spec_helper.rb +95 -0
- data/lib/generators/react_on_rails/templates/heroku_deployment/.buildpacks +2 -0
- data/lib/generators/react_on_rails/templates/heroku_deployment/Procfile +1 -0
- data/lib/generators/react_on_rails/templates/heroku_deployment/config/puma.rb +15 -0
- data/lib/generators/react_on_rails/templates/js_linters/client/.eslintignore +1 -0
- data/lib/generators/react_on_rails/templates/js_linters/client/.eslintrc +48 -0
- data/lib/generators/react_on_rails/templates/js_linters/client/.jscsrc +18 -0
- data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx +39 -0
- data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx +33 -0
- data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/startup/HelloWorldAppClient.jsx.tt +8 -0
- data/lib/generators/react_on_rails/templates/no_redux/server_rendering/client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx +8 -0
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx +8 -0
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx +48 -0
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx +8 -0
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx +43 -0
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx +19 -0
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/reducers/index.jsx +14 -0
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/HelloWorldAppClient.jsx.tt +19 -0
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/store/helloWorldStore.jsx +35 -0
- data/lib/generators/react_on_rails/templates/redux/base/client/app/lib/middlewares/loggerMiddleware.js +20 -0
- data/lib/generators/react_on_rails/templates/redux/server_rendering/client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx +19 -0
- data/lib/generators/react_on_rails/templates/ruby_linters/.rubocop.yml +26 -0
- data/lib/generators/react_on_rails/templates/ruby_linters/.scss-lint.yml +205 -0
- data/lib/generators/react_on_rails/templates/ruby_linters/lib/tasks/brakeman.rake +17 -0
- data/lib/generators/react_on_rails/templates/ruby_linters/lib/tasks/ci.rake +33 -0
- data/lib/generators/react_on_rails/templates/ruby_linters/ruby-lint.yml +20 -0
- data/lib/react_on_rails.rb +6 -0
- data/lib/react_on_rails/configuration.rb +60 -0
- data/lib/react_on_rails/engine.rb +7 -0
- data/lib/react_on_rails/prerender_error.rb +31 -0
- data/lib/react_on_rails/server_rendering_pool.rb +110 -0
- data/lib/react_on_rails/version.rb +3 -0
- data/package.json +76 -0
- data/rakelib/docker.rake +33 -0
- data/rakelib/dummy_apps.rake +20 -0
- data/rakelib/example_type.rb +160 -0
- data/rakelib/examples.rake +103 -0
- data/rakelib/examples_config.yml +19 -0
- data/rakelib/lint.rake +37 -0
- data/rakelib/node_package.rake +11 -0
- data/rakelib/run_rspec.rake +65 -0
- data/rakelib/task_helpers.rb +44 -0
- data/react_on_rails.gemspec +31 -0
- data/ruby-lint.yml +24 -0
- metadata +119 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"preset": "airbnb",
|
|
3
|
+
"fileExtensions": [
|
|
4
|
+
".js",
|
|
5
|
+
".jsx"
|
|
6
|
+
],
|
|
7
|
+
"excludeFiles": [
|
|
8
|
+
"assets/**",
|
|
9
|
+
"build/**",
|
|
10
|
+
"node_modules/**"
|
|
11
|
+
],
|
|
12
|
+
"esprima": "babel-jscs",
|
|
13
|
+
"validateQuoteMarks": {
|
|
14
|
+
"mark": "'",
|
|
15
|
+
"escape": true,
|
|
16
|
+
"ignoreJSX": true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { PropTypes } from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
|
|
4
|
+
// Simple example of a React "dumb" component
|
|
5
|
+
export default class HelloWorldWidget extends React.Component {
|
|
6
|
+
static propTypes = {
|
|
7
|
+
name: PropTypes.string.isRequired,
|
|
8
|
+
_updateName: PropTypes.func.isRequired,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
constructor(props, context) {
|
|
12
|
+
super(props, context);
|
|
13
|
+
|
|
14
|
+
// Uses lodash to bind all methods to the context of the object instance, otherwise
|
|
15
|
+
// the methods defined here would not refer to the component's class, not the component
|
|
16
|
+
// instance itself.
|
|
17
|
+
_.bindAll(this, '_handleChange');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// React will automatically provide us with the event `e`
|
|
21
|
+
_handleChange(e) {
|
|
22
|
+
const name = e.target.value;
|
|
23
|
+
this.props._updateName(name);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
render() {
|
|
27
|
+
return (
|
|
28
|
+
<div>
|
|
29
|
+
<h3>
|
|
30
|
+
Hello, {this.props.name}!
|
|
31
|
+
</h3>
|
|
32
|
+
<p>
|
|
33
|
+
Say hello to:
|
|
34
|
+
<input type="text" value={this.props.name} onChange={this._handleChange} />
|
|
35
|
+
</p>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { PropTypes } from 'react';
|
|
2
|
+
import HelloWorldWidget from '../components/HelloWorldWidget';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
|
|
5
|
+
// Simple example of a React "smart" component
|
|
6
|
+
export default class HelloWorld extends React.Component {
|
|
7
|
+
static propTypes = {
|
|
8
|
+
name: PropTypes.string.isRequired, // this is passed from the Rails view
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
constructor(props, context) {
|
|
12
|
+
super(props, context);
|
|
13
|
+
|
|
14
|
+
// Uses lodash to bind all methods to the context of the object instance, otherwise
|
|
15
|
+
// the methods defined here would not refer to the component's class, not the component
|
|
16
|
+
// instance itself.
|
|
17
|
+
_.bindAll(this, '_updateName');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
state = {name: this.props.name} // how to set initial state in es2015 class syntax
|
|
21
|
+
|
|
22
|
+
_updateName(name) {
|
|
23
|
+
this.setState({name: name});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
render() {
|
|
27
|
+
return (
|
|
28
|
+
<div>
|
|
29
|
+
<HelloWorldWidget name={this.state.name} _updateName={this._updateName} />
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// HelloWorldWidget is an arbitrary name for any "dumb" component. We do not recommend suffixing all your
|
|
2
|
+
// dump component names with Widget.
|
|
3
|
+
|
|
4
|
+
import React, { PropTypes } from 'react';
|
|
5
|
+
import Immutable from 'immutable';
|
|
6
|
+
import _ from 'lodash';
|
|
7
|
+
|
|
8
|
+
// Simple example of a React "dumb" component
|
|
9
|
+
export default class HelloWorldWidget extends React.Component {
|
|
10
|
+
static propTypes = {
|
|
11
|
+
// We prefix all property and variable names pointing to Immutable.js objects with '$$'.
|
|
12
|
+
// This allows us to immediately know we don't call $$helloWorldStore['someProperty'], but instead use
|
|
13
|
+
// the Immutable.js `get` API for Immutable.Map
|
|
14
|
+
actions: PropTypes.object.isRequired,
|
|
15
|
+
$$helloWorldStore: PropTypes.instanceOf(Immutable.Map).isRequired,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
constructor(props, context) {
|
|
19
|
+
super(props, context);
|
|
20
|
+
|
|
21
|
+
// Uses lodash to bind all methods to the context of the object instance, otherwise
|
|
22
|
+
// the methods defined here would not refer to the component's class, not the component
|
|
23
|
+
// instance itself.
|
|
24
|
+
_.bindAll(this, '_handleChange');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// React will automatically provide us with the event `e`
|
|
28
|
+
_handleChange(e) {
|
|
29
|
+
const name = e.target.value;
|
|
30
|
+
this.props.actions.updateName(name);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
render() {
|
|
34
|
+
const $$helloWorldStore = this.props.$$helloWorldStore;
|
|
35
|
+
const name = $$helloWorldStore.get('name');
|
|
36
|
+
return (
|
|
37
|
+
<div>
|
|
38
|
+
<h3>
|
|
39
|
+
Hello, {name}!
|
|
40
|
+
</h3>
|
|
41
|
+
<p>
|
|
42
|
+
Say hello to:
|
|
43
|
+
<input type="text" value={name} onChange={this._handleChange} />
|
|
44
|
+
</p>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// See https://www.npmjs.com/package/mirror-creator
|
|
2
|
+
// Allows us to easily setup constants inside of
|
|
3
|
+
// client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx
|
|
4
|
+
import mirrorCreator from 'mirror-creator';
|
|
5
|
+
|
|
6
|
+
export default mirrorCreator([
|
|
7
|
+
'HELLO_WORLD_NAME_UPDATE',
|
|
8
|
+
]);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { PropTypes } from 'react';
|
|
2
|
+
import HelloWorldWidget from '../components/HelloWorldWidget';
|
|
3
|
+
import { connect } from 'react-redux';
|
|
4
|
+
import { bindActionCreators } from 'redux';
|
|
5
|
+
import Immutable from 'immutable';
|
|
6
|
+
import * as helloWorldActionCreators from '../actions/helloWorldActionCreators';
|
|
7
|
+
|
|
8
|
+
function select(state) {
|
|
9
|
+
// Which part of the Redux global state does our component want to receive as props?
|
|
10
|
+
// Note the use of `$$` to prefix the property name because the value is of type Immutable.js
|
|
11
|
+
return { $$helloWorldStore: state.$$helloWorldStore };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Simple example of a React "smart" component
|
|
15
|
+
class HelloWorld extends React.Component {
|
|
16
|
+
static propTypes = {
|
|
17
|
+
dispatch: PropTypes.func.isRequired,
|
|
18
|
+
|
|
19
|
+
// This corresponds to the value used in function select above.
|
|
20
|
+
$$helloWorldStore: PropTypes.instanceOf(Immutable.Map).isRequired,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
constructor(props, context) {
|
|
24
|
+
super(props, context);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
render() {
|
|
28
|
+
const { dispatch, $$helloWorldStore } = this.props;
|
|
29
|
+
const actions = bindActionCreators(helloWorldActionCreators, dispatch);
|
|
30
|
+
|
|
31
|
+
// This uses the ES2015 spread operator to pass properties as it is more DRY
|
|
32
|
+
// This is equivalent to:
|
|
33
|
+
// <HelloWorldWidget $$helloWorldStore={$$helloWorldStore} actions={actions} />
|
|
34
|
+
return (
|
|
35
|
+
<HelloWorldWidget {...{$$helloWorldStore, actions}} />
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Don't forget to actually use connect!
|
|
41
|
+
// Note that we don't export HelloWorld, but the redux "connected" version of it.
|
|
42
|
+
// See https://github.com/rackt/react-redux/blob/master/docs/api.md#examples
|
|
43
|
+
export default connect(select)(HelloWorld);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Immutable from 'immutable';
|
|
2
|
+
|
|
3
|
+
import * as actionTypes from '../constants/helloWorldConstants';
|
|
4
|
+
|
|
5
|
+
export const $$initialState = Immutable.fromJS({
|
|
6
|
+
name: '', // this is the default state that would be used if one were not passed into the store
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export default function helloWorldReducer($$state = $$initialState, action) {
|
|
10
|
+
const { type, name } = action;
|
|
11
|
+
|
|
12
|
+
switch (type) {
|
|
13
|
+
case actionTypes.HELLO_WORLD_NAME_UPDATE:
|
|
14
|
+
return $$state.set('name', name);
|
|
15
|
+
|
|
16
|
+
default:
|
|
17
|
+
return $$state;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// This file is our manifest of all reducers for the app.
|
|
2
|
+
// See also /client/app/bundles/HelloWorld/store/helloWorldStore.jsx
|
|
3
|
+
// A real world app will likely have many reducers and it helps to organize them in one file.
|
|
4
|
+
// `https://github.com/shakacode/react_on_rails/tree/master/docs/additional_reading/generated_client_code.md`
|
|
5
|
+
import helloWorldReducer from './helloWorldReducer';
|
|
6
|
+
import { $$initialState as $$helloWorldState } from './helloWorldReducer';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
$$helloWorldStore: helloWorldReducer,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const initalStates = {
|
|
13
|
+
$$helloWorldState,
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Provider } from 'react-redux';
|
|
3
|
+
|
|
4
|
+
import createStore from '../store/helloWorldStore';
|
|
5
|
+
import HelloWorld from '../containers/HelloWorld';
|
|
6
|
+
|
|
7
|
+
// See documentation for https://github.com/rackt/react-redux.
|
|
8
|
+
// This is how you get props from the Rails view into the redux store.
|
|
9
|
+
// This code here binds your smart component to the redux store.
|
|
10
|
+
export default (props) => {
|
|
11
|
+
const store = createStore(props);
|
|
12
|
+
const reactComponent = (
|
|
13
|
+
<Provider store={store}>
|
|
14
|
+
<HelloWorld />
|
|
15
|
+
</Provider>
|
|
16
|
+
);
|
|
17
|
+
return reactComponent;
|
|
18
|
+
};
|
|
19
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { compose, createStore, applyMiddleware, combineReducers } from 'redux';
|
|
2
|
+
|
|
3
|
+
// See https://github.com/gaearon/redux-thunk and http://redux.js.org/docs/advanced/AsyncActions.html
|
|
4
|
+
// This is not actually used for this simple example, but you'd probably want to use this once your app has
|
|
5
|
+
// asynchronous actions.
|
|
6
|
+
import thunkMiddleware from 'redux-thunk';
|
|
7
|
+
|
|
8
|
+
// This provides an example of logging redux actions to the console.
|
|
9
|
+
// You'd want to disable this for production.
|
|
10
|
+
import loggerMiddleware from 'lib/middlewares/loggerMiddleware';
|
|
11
|
+
|
|
12
|
+
import reducers from '../reducers';
|
|
13
|
+
import { initalStates } from '../reducers';
|
|
14
|
+
|
|
15
|
+
export default props => {
|
|
16
|
+
// This is how we get initial props Rails into redux.
|
|
17
|
+
const { name } = props;
|
|
18
|
+
const { $$helloWorldState } = initalStates;
|
|
19
|
+
|
|
20
|
+
// Redux expects to initialize the store using an Object, not an Immutable.Map
|
|
21
|
+
const initialState = {
|
|
22
|
+
$$helloWorldStore: $$helloWorldState.merge({
|
|
23
|
+
name: name,
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const reducer = combineReducers(reducers);
|
|
28
|
+
const composedStore = compose(
|
|
29
|
+
applyMiddleware(thunkMiddleware, loggerMiddleware)
|
|
30
|
+
);
|
|
31
|
+
const storeCreator = composedStore(createStore);
|
|
32
|
+
const store = storeCreator(reducer, initialState);
|
|
33
|
+
|
|
34
|
+
return store;
|
|
35
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* eslint no-console: 0 */
|
|
2
|
+
|
|
3
|
+
// This logger should be configured not to run in a production environment.
|
|
4
|
+
// See https://github.com/petehunt/webpack-howto#6-feature-flags for you might turn this off for production.
|
|
5
|
+
export default function logger({ getState }) {
|
|
6
|
+
return next => action => {
|
|
7
|
+
console.log('will dispatch', action);
|
|
8
|
+
|
|
9
|
+
// Call the next dispatch method in the middleware chain.
|
|
10
|
+
const result = next(action);
|
|
11
|
+
|
|
12
|
+
const immutableState = getState();
|
|
13
|
+
|
|
14
|
+
console.log('state after dispatch', JSON.stringify(immutableState));
|
|
15
|
+
|
|
16
|
+
// This will likely be the action itself, unless
|
|
17
|
+
// a middleware further in chain changed it.
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Provider } from 'react-redux';
|
|
3
|
+
|
|
4
|
+
import createStore from '../store/helloWorldStore';
|
|
5
|
+
import HelloWorld from '../containers/HelloWorld';
|
|
6
|
+
|
|
7
|
+
// See documentation for https://github.com/rackt/react-redux.
|
|
8
|
+
// This is how you get props from the Rails view into the redux store.
|
|
9
|
+
// This code here binds your smart component to the redux store.
|
|
10
|
+
// This is how the server redux gets hydrated with data.
|
|
11
|
+
export default (props) => {
|
|
12
|
+
const store = createStore(props);
|
|
13
|
+
const reactComponent = (
|
|
14
|
+
<Provider store={store}>
|
|
15
|
+
<HelloWorld />
|
|
16
|
+
</Provider>
|
|
17
|
+
);
|
|
18
|
+
return reactComponent;
|
|
19
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# This is the configuration used to check the rubocop source code.
|
|
2
|
+
# Check out: https://github.com/bbatsov/rubocop
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
Include:
|
|
6
|
+
- '**/Rakefile'
|
|
7
|
+
- '**/config.ru'
|
|
8
|
+
Exclude:
|
|
9
|
+
- 'vendor/**/*'
|
|
10
|
+
- 'spec/fixtures/**/*'
|
|
11
|
+
- 'node_modules/**/*'
|
|
12
|
+
- 'db/**/*'
|
|
13
|
+
- 'db/schema.rb'
|
|
14
|
+
- 'db/seeds.rb'
|
|
15
|
+
- 'client/node_modules/**/*'
|
|
16
|
+
- 'bin/**/*'
|
|
17
|
+
- !ruby/regexp /old_and_unused\.rb$/
|
|
18
|
+
|
|
19
|
+
Metrics/LineLength:
|
|
20
|
+
Max: 120
|
|
21
|
+
|
|
22
|
+
Style/StringLiterals:
|
|
23
|
+
EnforcedStyle: double_quotes
|
|
24
|
+
|
|
25
|
+
Style/Documentation:
|
|
26
|
+
Enabled: false
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# See http://sass-guidelin.es/#zeros
|
|
2
|
+
|
|
3
|
+
scss_files:
|
|
4
|
+
- 'app/assets/stylesheets/**/*.scss'
|
|
5
|
+
- 'client/assets/stylesheets/**/*.scss'
|
|
6
|
+
|
|
7
|
+
linters:
|
|
8
|
+
# BangFormat:
|
|
9
|
+
# enabled: true
|
|
10
|
+
# space_before_bang: true
|
|
11
|
+
# space_after_bang: false
|
|
12
|
+
#
|
|
13
|
+
# BorderZero:
|
|
14
|
+
# enabled: true
|
|
15
|
+
# convention: zero # or `none`
|
|
16
|
+
#
|
|
17
|
+
ColorKeyword:
|
|
18
|
+
enabled: false
|
|
19
|
+
ColorVariable:
|
|
20
|
+
enabled: false
|
|
21
|
+
#
|
|
22
|
+
# Comment:
|
|
23
|
+
# enabled: true
|
|
24
|
+
#
|
|
25
|
+
# DebugStatement:
|
|
26
|
+
# enabled: true
|
|
27
|
+
#
|
|
28
|
+
# DeclarationOrder:
|
|
29
|
+
# enabled: true
|
|
30
|
+
#
|
|
31
|
+
# DuplicateProperty:
|
|
32
|
+
# enabled: true
|
|
33
|
+
#
|
|
34
|
+
# ElsePlacement:
|
|
35
|
+
# enabled: true
|
|
36
|
+
# style: same_line # or 'new_line'
|
|
37
|
+
#
|
|
38
|
+
# EmptyLineBetweenBlocks:
|
|
39
|
+
# enabled: true
|
|
40
|
+
# ignore_single_line_blocks: true
|
|
41
|
+
#
|
|
42
|
+
# EmptyRule:
|
|
43
|
+
# enabled: true
|
|
44
|
+
#
|
|
45
|
+
# FinalNewline:
|
|
46
|
+
# enabled: true
|
|
47
|
+
# present: true
|
|
48
|
+
#
|
|
49
|
+
HexLength:
|
|
50
|
+
enabled: true
|
|
51
|
+
style: long
|
|
52
|
+
|
|
53
|
+
HexNotation:
|
|
54
|
+
enabled: true
|
|
55
|
+
style: uppercase
|
|
56
|
+
#
|
|
57
|
+
# HexValidation:
|
|
58
|
+
# enabled: true
|
|
59
|
+
#
|
|
60
|
+
IdSelector:
|
|
61
|
+
enabled: true
|
|
62
|
+
#
|
|
63
|
+
# ImportantRule:
|
|
64
|
+
# enabled: true
|
|
65
|
+
#
|
|
66
|
+
# ImportPath:
|
|
67
|
+
# enabled: true
|
|
68
|
+
# leading_underscore: false
|
|
69
|
+
# filename_extension: false
|
|
70
|
+
#
|
|
71
|
+
# Indentation:
|
|
72
|
+
# enabled: true
|
|
73
|
+
# allow_non_nested_indentation: false
|
|
74
|
+
# character: space # or 'tab'
|
|
75
|
+
# width: 2
|
|
76
|
+
#
|
|
77
|
+
LeadingZero:
|
|
78
|
+
enabled: true
|
|
79
|
+
style: include_zero
|
|
80
|
+
#
|
|
81
|
+
# MergeableSelector:
|
|
82
|
+
# enabled: true
|
|
83
|
+
# force_nesting: true
|
|
84
|
+
#
|
|
85
|
+
# NameFormat:
|
|
86
|
+
# enabled: true
|
|
87
|
+
# allow_leading_underscore: true
|
|
88
|
+
# convention: hyphenated_lowercase # or 'camel_case', or 'snake_case', or a regex pattern
|
|
89
|
+
#
|
|
90
|
+
# NestingDepth:
|
|
91
|
+
# enabled: true
|
|
92
|
+
# max_depth: 3
|
|
93
|
+
#
|
|
94
|
+
# PlaceholderInExtend:
|
|
95
|
+
# enabled: true
|
|
96
|
+
#
|
|
97
|
+
# PropertyCount:
|
|
98
|
+
# enabled: false
|
|
99
|
+
# include_nested: false
|
|
100
|
+
# max_properties: 10
|
|
101
|
+
#
|
|
102
|
+
# PropertyUnits:
|
|
103
|
+
# enabled: true
|
|
104
|
+
# global: [
|
|
105
|
+
# 'ch', 'em', 'ex', 'rem', # Font-relative lengths
|
|
106
|
+
# 'cm', 'in', 'mm', 'pc', 'pt', 'px', 'q', # Absolute lengths
|
|
107
|
+
# 'vh', 'vw', 'vmin', 'vmax', # Viewport-percentage lengths
|
|
108
|
+
# 'deg', 'grad', 'rad', 'turn', # Angle
|
|
109
|
+
# 'ms', 's', # Duration
|
|
110
|
+
# 'Hz', 'kHz', # Frequency
|
|
111
|
+
# 'dpi', 'dpcm', 'dppx', # Resolution
|
|
112
|
+
# '%', # Other
|
|
113
|
+
# ]
|
|
114
|
+
# properties: {}
|
|
115
|
+
#
|
|
116
|
+
# PropertySortOrder:
|
|
117
|
+
# enabled: true
|
|
118
|
+
# ignore_unspecified: false
|
|
119
|
+
# separate_groups: false
|
|
120
|
+
#
|
|
121
|
+
# PropertySpelling:
|
|
122
|
+
# enabled: true
|
|
123
|
+
# extra_properties: []
|
|
124
|
+
#
|
|
125
|
+
# QualifyingElement:
|
|
126
|
+
# enabled: true
|
|
127
|
+
# allow_element_with_attribute: false
|
|
128
|
+
# allow_element_with_class: false
|
|
129
|
+
# allow_element_with_id: false
|
|
130
|
+
#
|
|
131
|
+
# SelectorDepth:
|
|
132
|
+
# enabled: true
|
|
133
|
+
# max_depth: 3
|
|
134
|
+
#
|
|
135
|
+
# SelectorFormat:
|
|
136
|
+
# enabled: true
|
|
137
|
+
# convention: hyphenated_lowercase # or 'strict_BEM', or 'hyphenated_BEM', or 'snake_case', or 'camel_case', or a regex pattern
|
|
138
|
+
#
|
|
139
|
+
# Shorthand:
|
|
140
|
+
# enabled: true
|
|
141
|
+
# allowed_shorthands: [1, 2, 3]
|
|
142
|
+
#
|
|
143
|
+
# SingleLinePerProperty:
|
|
144
|
+
# enabled: true
|
|
145
|
+
# allow_single_line_rule_sets: true
|
|
146
|
+
#
|
|
147
|
+
# SingleLinePerSelector:
|
|
148
|
+
# enabled: true
|
|
149
|
+
#
|
|
150
|
+
# SpaceAfterComma:
|
|
151
|
+
# enabled: true
|
|
152
|
+
#
|
|
153
|
+
# SpaceAfterPropertyColon:
|
|
154
|
+
# enabled: true
|
|
155
|
+
# style: one_space # or 'no_space', or 'at_least_one_space', or 'aligned'
|
|
156
|
+
#
|
|
157
|
+
# SpaceAfterPropertyName:
|
|
158
|
+
# enabled: true
|
|
159
|
+
#
|
|
160
|
+
# SpaceBeforeBrace:
|
|
161
|
+
# enabled: true
|
|
162
|
+
# style: space # or 'new_line'
|
|
163
|
+
# allow_single_line_padding: false
|
|
164
|
+
#
|
|
165
|
+
# SpaceBetweenParens:
|
|
166
|
+
# enabled: true
|
|
167
|
+
# spaces: 0
|
|
168
|
+
#
|
|
169
|
+
# StringQuotes:
|
|
170
|
+
# enabled: true
|
|
171
|
+
# style: single_quotes # or double_quotes
|
|
172
|
+
#
|
|
173
|
+
# TrailingSemicolon:
|
|
174
|
+
# enabled: true
|
|
175
|
+
#
|
|
176
|
+
# TrailingZero:
|
|
177
|
+
# enabled: false
|
|
178
|
+
#
|
|
179
|
+
# UnnecessaryMantissa:
|
|
180
|
+
# enabled: true
|
|
181
|
+
#
|
|
182
|
+
# UnnecessaryParentReference:
|
|
183
|
+
# enabled: true
|
|
184
|
+
#
|
|
185
|
+
# UrlFormat:
|
|
186
|
+
# enabled: true
|
|
187
|
+
#
|
|
188
|
+
# UrlQuotes:
|
|
189
|
+
# enabled: true
|
|
190
|
+
#
|
|
191
|
+
# VariableForProperty:
|
|
192
|
+
# enabled: false
|
|
193
|
+
# properties: []
|
|
194
|
+
#
|
|
195
|
+
# VendorPrefix:
|
|
196
|
+
# enabled: true
|
|
197
|
+
# identifier_list: base
|
|
198
|
+
# additional_identifiers: []
|
|
199
|
+
# excluded_identifiers: []
|
|
200
|
+
#
|
|
201
|
+
# ZeroUnit:
|
|
202
|
+
# enabled: true
|
|
203
|
+
#
|
|
204
|
+
# Compass::*:
|
|
205
|
+
# enabled: false
|