react_on_rails 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintignore +2 -0
- data/.eslintrc +33 -2
- data/.jscsrc +23 -4
- data/.rubocop.yml +1 -1
- data/README.md +8 -2
- data/app/assets/javascripts/react_on_rails.js +114 -70
- data/app/helpers/react_on_rails_helper.rb +79 -34
- data/docs/additional_reading/{generated_client_code.md → react-and-redux.md} +2 -1
- data/docs/additional_reading/react_router.md +35 -0
- data/docs/coding-style/linters.md +64 -0
- data/docs/coding-style/style.md +42 -0
- data/docs/contributing.md +12 -40
- data/docs/generator_testing_script.md +0 -1
- data/docs/install_and_releasing.md +24 -0
- data/docs/sample_generated_js/README.md +4 -0
- data/docs/sample_generated_js/server-generated.js +23 -9
- data/lib/generators/react_on_rails/base_generator.rb +12 -7
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.base.config.js.tt +9 -0
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.rails.config.js +0 -7
- data/lib/generators/react_on_rails/templates/base/base/lib/tasks/linters.rake.tt +2 -2
- data/lib/generators/react_on_rails/templates/base/server_rendering/client/webpack.server.rails.config.js +4 -1
- data/lib/generators/react_on_rails/templates/js_linters/client/.eslintrc +34 -3
- data/lib/generators/react_on_rails/templates/js_linters/client/.jscsrc +15 -4
- data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx +1 -1
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/reducers/index.jsx +1 -1
- data/lib/generators/react_on_rails/templates/redux/base/client/app/lib/middlewares/loggerMiddleware.js +0 -1
- data/lib/react_on_rails/configuration.rb +4 -2
- data/lib/react_on_rails/prerender_error.rb +31 -0
- data/lib/react_on_rails/server_rendering_pool.rb +9 -18
- data/lib/react_on_rails/version.rb +1 -1
- metadata +9 -3
@@ -0,0 +1,35 @@
|
|
1
|
+
# Using React Router
|
2
|
+
React on Rails supports the use of React Router. Client-side code doesn't need any special configuration for the React on Rails gem. Implement React Router how you normally would.
|
3
|
+
|
4
|
+
However, when attempting to use server-rendering, it is necessary to take steps that prevent rendering when there is a router error or redirect. In these cases, the client code should return an object containing the `error` and a `redirectLocation` instead of the React component. The `react_component` helper method in your Rails view will automatically detect that there was an error/redirect and handle it accordingly.
|
5
|
+
|
6
|
+
```js
|
7
|
+
const RouterApp = (props, location) => {
|
8
|
+
const store = createStore(props);
|
9
|
+
|
10
|
+
let error;
|
11
|
+
let redirectLocation;
|
12
|
+
let routeProps;
|
13
|
+
|
14
|
+
// See https://github.com/rackt/react-router/blob/master/docs/guides/advanced/ServerRendering.md
|
15
|
+
match({ routes, location }, (_error, _redirectLocation, _routeProps) => {
|
16
|
+
error = _error;
|
17
|
+
redirectLocation = _redirectLocation;
|
18
|
+
routeProps = _routeProps;
|
19
|
+
});
|
20
|
+
|
21
|
+
// This tell react_on_rails to skip server rendering any HTML. Note, client rendering
|
22
|
+
// will handle the redirect. What's key is that we don't try to render.
|
23
|
+
// Critical to return the Object properties to match this { error, redirectLocation }
|
24
|
+
if (error || redirectLocation) {
|
25
|
+
return { error, redirectLocation };
|
26
|
+
}
|
27
|
+
|
28
|
+
// Important that you don't do this if you are redirecting or have an error.
|
29
|
+
return (
|
30
|
+
<Provider store={store}>
|
31
|
+
<RoutingContext {...routeProps} />
|
32
|
+
</Provider>
|
33
|
+
);
|
34
|
+
};
|
35
|
+
```
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Linters
|
2
|
+
These linters support the [ShakaCode Style Guidelines](./style.md)
|
3
|
+
|
4
|
+
## Autofix!
|
5
|
+
|
6
|
+
If you haven't tried the autofix options for `jscs` and `rubocop`, you're seriously missing out!
|
7
|
+
|
8
|
+
1. Be **SURE** you have a clean git status, as you'll want to review what the autofix does to your code!
|
9
|
+
2. **Rubocop:** Be sure to be in the right directory where you have Ruby files, probably the top level of your Rails project.
|
10
|
+
```
|
11
|
+
rubocop -a
|
12
|
+
```
|
13
|
+
|
14
|
+
3. **JSCS:**: Be sure to be in the right directory where you have JS files.
|
15
|
+
```
|
16
|
+
jscs -x .
|
17
|
+
```
|
18
|
+
|
19
|
+
Autofixing is a **HUGE** time saver!
|
20
|
+
|
21
|
+
## ESLint
|
22
|
+
|
23
|
+
### Configuring Rules
|
24
|
+
|
25
|
+
Rules are configured with a 0, 1 or 2. Setting a rule to 0 is turning it off, setting it to 1 triggers a warning if that rule is violated, and setting it to 2 triggers an error.
|
26
|
+
|
27
|
+
Rules can also take a few additional options. In this case, the rule can be set to an array, the first item of which is the 0/1/2 flag and the rest are options.
|
28
|
+
|
29
|
+
See file [.eslintrc](../../client/.eslintrc) for examples of configuration
|
30
|
+
|
31
|
+
### Specify/Override rules in code
|
32
|
+
|
33
|
+
Rules can also be specified in the code file to be linted, as JavaScript comments. This can be useful when the rule is a one-off or is a override to a project-wide rule.
|
34
|
+
|
35
|
+
For example, if your file assumes a few globals and you have the no-undef rule set in the .eslintrc file, you might want to relax the rule in the current file.
|
36
|
+
|
37
|
+
```
|
38
|
+
/* global $, window, angular */
|
39
|
+
// rest of code
|
40
|
+
```
|
41
|
+
|
42
|
+
It's also useful to disable ESLint for particular lines or blocks of lines.
|
43
|
+
|
44
|
+
```
|
45
|
+
console.log('console.log not allowed'); // eslint-disable-line
|
46
|
+
|
47
|
+
alert('alert not allowed'); // eslint-disable-line no-alert
|
48
|
+
|
49
|
+
/* eslint-disable no-console, no-alert */
|
50
|
+
console.log('more console.log');
|
51
|
+
alert('more alert');
|
52
|
+
/* eslint-enable no-console, no-alert */
|
53
|
+
```
|
54
|
+
|
55
|
+
You can disable all rules for a line or block, or only specific rules, as shown above.
|
56
|
+
|
57
|
+
### Useful Reference Links
|
58
|
+
|
59
|
+
* [Configuring ESLint](http://eslint.org/docs/user-guide/configuring.html#configuring-rules)
|
60
|
+
* [ESLint quick start](http://untilfalse.com/eslint-quick-start/)
|
61
|
+
* [RuboCop][https://github.com/bbatsov/rubocop]
|
62
|
+
* [ESLint][http://eslint.org/]
|
63
|
+
* [JSCS][https://github.com/jscs-dev/node-jscs]
|
64
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Code Style
|
2
|
+
This document describes the coding style of [ShakaCode](http://www.shakacode.com). Yes, it's opinionated, as all style guidelines should be. We shall put as little as possible into this guide and instead rely on:
|
3
|
+
|
4
|
+
* Use of linters with our standard linter configuration.
|
5
|
+
* References to existing style guidelines that support the linter configuration.
|
6
|
+
* Anything additional goes next.
|
7
|
+
|
8
|
+
## Client Side JavaScript and React
|
9
|
+
* Use [Redux](https://github.com/rackt/redux) for your flux store.
|
10
|
+
* Use [Lodash](https://lodash.com/) rather than Underscore.
|
11
|
+
* Place all JavaScript for the client app in `/client`
|
12
|
+
* Organize your app into high level domains which map to JavaScript bundles. These are like mini-apps that live within your entire app. Create directories named like `/client/app/<bundle>` and configure Webpack to generate different corresponding bundles.
|
13
|
+
* Carefully organize your React components into [Smart and Dumb Components](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0#.ygdkh1l7b):
|
14
|
+
1. "dumb" components that live in the `/client/app/<bundle>/components/` directories. These components should take props, including values and callbacks, and should not talk directly to Redux or any AJAX endpoints.
|
15
|
+
2. "smart" components that live in the `/client/app/<bundle>/containers/` directory. These components will talk to the Redux store and AJAX endpoints.
|
16
|
+
* Place common code shared across bundles in `/client/app/libs` and configure Webpack to generate a common bundle for this one.
|
17
|
+
* Prefix Immutable.js variable names and properties with `$$`. By doing this, you will clearly know that you are dealing with an Immutable.js object and not a standard JavaScript Object or Array.
|
18
|
+
* Use ES6 classes rather than `React.createClass`.
|
19
|
+
* Bind callbacks passed to react components with `_.bindAll` in the constructor unless you need to bind additional parameters. In that case, you can call `_.bind` within the rendering.
|
20
|
+
|
21
|
+
## Style Guides to Follow
|
22
|
+
Follow these style guidelines per the linter configuration. Basically, lint your code and if you have questions about the suggested fixes, look here:
|
23
|
+
|
24
|
+
### Ruby Coding Standards
|
25
|
+
* [RailsOnMaui Ruby Coding Standards](https://github.com/justin808/ruby)
|
26
|
+
* [Ruby Documentation](http://guides.rubyonrails.org/api_documentation_guidelines.html)
|
27
|
+
|
28
|
+
### JavaScript Coding Standards
|
29
|
+
* [AirBnb Javascript](https://github.com/airbnb/javascript)
|
30
|
+
* [JSDoc](http://usejsdoc.org/)
|
31
|
+
|
32
|
+
### Git coding Standards
|
33
|
+
* [Git Coding Standards](http://chlg.co/1GV2m9p)
|
34
|
+
|
35
|
+
### Sass Coding Standards
|
36
|
+
* [Sass Guidelines](http://sass-guidelin.es/) by [Hugo Giraudel](http://hugogiraudel.com/)
|
37
|
+
* [Github Front End Guidelines](http://primercss.io/guidelines/)
|
38
|
+
|
39
|
+
# Git Usage
|
40
|
+
* Follow a github-flow model where you branch off of master for features.
|
41
|
+
* Before merging a branch to master, rebase it on top of master, by using command like `git fetch; git checkout my-branch; git rebase -i origin/master`. Clean up your commit message at this point. Be super careful to communicate with anybody else working on this branch and do not do this when others have uncommitted changes. Ideally, your merge of your feature back to master should be one nice commit.
|
42
|
+
* Run hosted CI and code coverage.
|
data/docs/contributing.md
CHANGED
@@ -8,19 +8,10 @@
|
|
8
8
|
3. Did you document your change? Update the README.md?
|
9
9
|
|
10
10
|
### Initial Setup
|
11
|
-
After checking out the repo, making sure you have rvm and nvm setup (setup ruby and node),
|
12
|
-
cd to `spec/dummy` and run `bin/setup` to install dependencies.
|
13
|
-
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
11
|
+
After checking out the repo, making sure you have rvm and nvm setup (setup ruby and node), cd to `spec/dummy` and run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
14
12
|
|
15
13
|
### Starting the Dummy App
|
16
|
-
To run the test app, it's **CRITICAL** to not just run `rails s`. You have to run `foreman start`.
|
17
|
-
If you don't do this, then `webpack` will not generate a new bundle,
|
18
|
-
and you will be seriously confused when you change JavaScript and the app does not change.
|
19
|
-
|
20
|
-
### Install and Release
|
21
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version,
|
22
|
-
update the version number in `version.rb`, and then run `bundle exec rake release`,
|
23
|
-
which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
14
|
+
To run the test app, it's **CRITICAL** to not just run `rails s`. You have to run `foreman start`. If you don't do this, then `webpack` will not generate a new bundle, and you will be seriously confused when you change JavaScript and the app does not change.
|
24
15
|
|
25
16
|
### RSpec Testing
|
26
17
|
Run `rake` for testing the gem and `spec/dummy` and `spec/dummy-react-013`. Otherwise, the `rspec` command only works for testing within the sample apps, like `spec/dummy`.
|
@@ -31,6 +22,7 @@ After running a test, you can view the coverage results SimpleCov reports by ope
|
|
31
22
|
|
32
23
|
### Debugging
|
33
24
|
Start the sample app like this for some debug printing:
|
25
|
+
|
34
26
|
```bash
|
35
27
|
TRACE_REACT_ON_RAILS=true && foreman start
|
36
28
|
```
|
@@ -40,7 +32,6 @@ In your Rails app add this gem with a path to your fork.
|
|
40
32
|
|
41
33
|
```
|
42
34
|
gem 'react_on_rails', path: '/your_fork'
|
43
|
-
gem 'therubyracer'
|
44
35
|
```
|
45
36
|
|
46
37
|
The main installer can be run with ```rails generate react_on_rails:install```
|
@@ -48,43 +39,24 @@ The main installer can be run with ```rails generate react_on_rails:install```
|
|
48
39
|
### Testing the Generator
|
49
40
|
The generators are covered by generator tests using Rails's generator testing helpers, but it never hurts to do a sanity check and explore the API. See [generator_testing_script.md](generator_testing_script.md) for a script on how to run the generator on a fresh project.
|
50
41
|
|
51
|
-
## Updating New Versions of the Gem
|
52
|
-
|
53
|
-
See https://github.com/svenfuchs/gem-release
|
54
|
-
|
55
|
-
```bash
|
56
|
-
gem bump
|
57
|
-
cd spec/dummy
|
58
|
-
bundle
|
59
|
-
git commit -am "Updated Gemfile.lock"
|
60
|
-
cd ../..
|
61
|
-
gem tag
|
62
|
-
gem release
|
63
|
-
```
|
64
|
-
|
65
42
|
### Linting
|
66
|
-
All linting is performed from the docker container. You will need docker and docker-compose installed
|
67
|
-
locally to lint code changes via the lint container.
|
43
|
+
All linting is performed from the docker container. You will need docker and docker-compose installed locally to lint code changes via the lint container.
|
68
44
|
|
69
45
|
* [Install Docker Toolbox for Mac](https://www.docker.com/toolbox)
|
70
46
|
* [Install Docker Compose for Linux](https://docs.docker.com/compose/install/)
|
71
47
|
|
72
|
-
Once you have docker and docker-compose running locally, run `docker-compose build lint`. This will build
|
73
|
-
the `reactonrails_lint` docker image and docker-compose `lint` container. The inital build is slow,
|
74
|
-
but after the install, startup is very quick.
|
48
|
+
Once you have docker and docker-compose running locally, run `docker-compose build lint`. This will build the `reactonrails_lint` docker image and docker-compose `lint` container. The initial build is slow, but after the install, startup is very quick.
|
75
49
|
|
76
50
|
### Linting Commands
|
77
|
-
Run `rake -D docker` to see all docker linting commands for rake. `rake docker:lint` will run all linters.
|
78
|
-
|
79
|
-
You can run
|
51
|
+
Run `rake -D docker` to see all docker linting commands for rake. `rake docker:lint` will run all linters. For individual rake linting commands please refer to `rake -D docker` for the list.
|
52
|
+
|
53
|
+
You can run specific linting for directories or files by using `docker-compose run lint rubocop (file path or directory)`, etc.
|
54
|
+
|
80
55
|
`docker-compose run lint bash` sets you up to run from the container command line.
|
81
56
|
|
82
57
|
### Docker CI - Test and Linting
|
83
|
-
Docker CI and Tests containers have a xvfd server automatically started for headless browser testing with selenium and
|
58
|
+
Docker CI and Tests containers have a xvfd server automatically started for headless browser testing with selenium and Firefox.
|
84
59
|
|
85
|
-
Run `docker-compose build ci` to build the
|
86
|
-
rspec test and linting. `docker-compose run --entrypoint=/bin/bash` will override the default ci action and place
|
87
|
-
you inside the ci container in a bash session. This is what is run on Travis-ci.
|
60
|
+
Run `docker-compose build ci` to build the CI container. Run `docker-compose run ci` to start all rspec tests and linting. `docker-compose run --entrypoint=/bin/bash` will override the default CI action and place you inside the CI container in a bash session. This is what is run on Travis-CI.
|
88
61
|
|
89
|
-
Run `docker-compose build tests` to build the tests container. Run `docker-compose run tests` to start all
|
90
|
-
rspec tests.
|
62
|
+
Run `docker-compose build tests` to build the tests container. Run `docker-compose run tests` to start all rspec tests.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
### Install and Release
|
2
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
3
|
+
|
4
|
+
## Updating New Versions of the Gem
|
5
|
+
See https://github.com/svenfuchs/gem-release
|
6
|
+
|
7
|
+
```bash
|
8
|
+
gem bump
|
9
|
+
cd spec/dummy
|
10
|
+
bundle
|
11
|
+
git commit -am "Updated Gemfile.lock"
|
12
|
+
cd ../..
|
13
|
+
gem tag
|
14
|
+
gem release
|
15
|
+
```
|
16
|
+
|
17
|
+
## Testing the Gem before Release from a Rails App
|
18
|
+
If you want to test the gem with an application before you release a new version of the gem, you can specify the path to your local version via your test app's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem "react_on_rails", path: "../path-to-react-on-rails"
|
22
|
+
```
|
23
|
+
|
24
|
+
Note that you will need to bundle install after making this change, but also that **you will need to restart your Rails application if you make any changes to the gem**.
|
@@ -1,11 +1,25 @@
|
|
1
1
|
(function() {
|
2
|
-
var
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
var htmlResult = '';
|
3
|
+
var consoleReplayScript = '';
|
4
|
+
var hasErrors = false;
|
5
|
+
|
6
|
+
try {
|
7
|
+
htmlResult =
|
8
|
+
(function() {
|
9
|
+
return this.HelloString.world();
|
10
|
+
})();
|
11
|
+
} catch(e) {
|
12
|
+
htmlResult = ReactOnRails.handleError({e: e, componentName: null,
|
13
|
+
jsCode: 'this.HelloString.world()', serverSide: true});
|
14
|
+
hasErrors = true;
|
15
|
+
}
|
16
|
+
|
17
|
+
consoleReplayScript = ReactOnRails.buildConsoleReplay();
|
18
|
+
|
19
|
+
return JSON.stringify({
|
20
|
+
html: htmlResult,
|
21
|
+
consoleReplayScript: consoleReplayScript,
|
22
|
+
hasErrors: hasErrors
|
10
23
|
});
|
11
|
-
|
24
|
+
|
25
|
+
})()
|
@@ -4,7 +4,7 @@ include GeneratorHelper
|
|
4
4
|
|
5
5
|
module ReactOnRails
|
6
6
|
module Generators
|
7
|
-
class BaseGenerator < Rails::Generators::Base
|
7
|
+
class BaseGenerator < Rails::Generators::Base # rubocop:disable Metrics/ClassLength
|
8
8
|
hide!
|
9
9
|
source_root(File.expand_path("../templates", __FILE__))
|
10
10
|
|
@@ -71,21 +71,22 @@ module ReactOnRails
|
|
71
71
|
|
72
72
|
// bootstrap-sprockets depends on generated/vendor-bundle for jQuery.
|
73
73
|
//= require bootstrap-sprockets
|
74
|
+
|
74
75
|
DATA
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
if
|
79
|
-
prepend_to_file(
|
77
|
+
app_js_path = "app/assets/javascripts/application.js"
|
78
|
+
found_app_js = dest_file_exists?(app_js_path) || dest_file_exists?(app_js_path + ".coffee")
|
79
|
+
if found_app_js
|
80
|
+
prepend_to_file(found_app_js, data)
|
80
81
|
else
|
81
|
-
|
82
|
+
create_file(app_js_path, data)
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
85
86
|
def strip_application_js_of_incompatible_sprockets_statements
|
86
87
|
application_js = File.join(destination_root, "app/assets/javascripts/application.js")
|
87
88
|
gsub_file(application_js, "//= require jquery_ujs", "")
|
88
|
-
gsub_file(application_js,
|
89
|
+
gsub_file(application_js, %r{//= require jquery$}, "")
|
89
90
|
gsub_file(application_js, "//= require_tree .", "")
|
90
91
|
end
|
91
92
|
|
@@ -123,6 +124,10 @@ module ReactOnRails
|
|
123
124
|
client/package.json).each { |file| template(base_path + file + ".tt", file) }
|
124
125
|
end
|
125
126
|
|
127
|
+
def add_base_gems_to_gemfile
|
128
|
+
append_to_file("Gemfile", "\ngem 'therubyracer', platforms: :ruby\n")
|
129
|
+
end
|
130
|
+
|
126
131
|
def template_client_globals_file
|
127
132
|
filename = options.server_rendering? ? "clientGlobals.jsx" : "globals.jsx"
|
128
133
|
location = "client/app/bundles/HelloWorld/startup"
|
data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.base.config.js.tt
CHANGED
@@ -4,6 +4,9 @@
|
|
4
4
|
const webpack = require('webpack');
|
5
5
|
const path = require('path');
|
6
6
|
|
7
|
+
const devBuild = process.env.NODE_ENV !== 'production';
|
8
|
+
const nodeEnv = devBuild ? 'development' : 'production';
|
9
|
+
|
7
10
|
module.exports = {
|
8
11
|
|
9
12
|
// the project dir
|
@@ -32,6 +35,12 @@ module.exports = {
|
|
32
35
|
},
|
33
36
|
plugins: [
|
34
37
|
|
38
|
+
new webpack.DefinePlugin({
|
39
|
+
'process.env': {
|
40
|
+
NODE_ENV: JSON.stringify(NODE_ENV),
|
41
|
+
},
|
42
|
+
}),
|
43
|
+
|
35
44
|
// https://webpack.github.io/docs/list-of-plugins.html#2-explicit-vendor-chunk
|
36
45
|
new webpack.optimize.CommonsChunkPlugin({
|
37
46
|
|
data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.rails.config.js
CHANGED
@@ -7,8 +7,6 @@
|
|
7
7
|
const webpack = require('webpack');
|
8
8
|
const config = require('./webpack.client.base.config');
|
9
9
|
|
10
|
-
const devBuild = process.env.NODE_ENV !== 'production';
|
11
|
-
|
12
10
|
config.output = {
|
13
11
|
filename: '[name]-bundle.js',
|
14
12
|
path: '../app/assets/javascripts/generated',
|
@@ -34,11 +32,6 @@ if (devBuild) {
|
|
34
32
|
module.exports.devtool = 'eval-source-map';
|
35
33
|
} else {
|
36
34
|
config.plugins.push(
|
37
|
-
new webpack.DefinePlugin({
|
38
|
-
'process.env': {
|
39
|
-
NODE_ENV: JSON.stringify('production'),
|
40
|
-
},
|
41
|
-
}),
|
42
35
|
new webpack.optimize.DedupePlugin()
|
43
36
|
);
|
44
37
|
console.log('Webpack production build for Rails'); // eslint-disable-line no-console
|
@@ -76,8 +76,8 @@ if %w(development test).include? Rails.env
|
|
76
76
|
<%- end -%>
|
77
77
|
|
78
78
|
<%- enabled_linters = [] -%>
|
79
|
-
<%- enabled_linters << %i(rubocop ruby) if options.ruby_linters? -%>
|
80
|
-
<%- enabled_linters << %i(js
|
79
|
+
<%- enabled_linters << %i(rubocop ruby scss) if options.ruby_linters? -%>
|
80
|
+
<%- enabled_linters << %i(js) unless options.skip_js_linters? -%>
|
81
81
|
task lint: <%= enabled_linters.flatten %> do
|
82
82
|
puts "Completed all linting"
|
83
83
|
end
|
@@ -1,8 +1,11 @@
|
|
1
|
-
//
|
1
|
+
// Webpack configuration for server bundle
|
2
2
|
|
3
3
|
const webpack = require('webpack');
|
4
4
|
const path = require('path');
|
5
5
|
|
6
|
+
const devBuild = process.env.NODE_ENV !== 'production';
|
7
|
+
const nodeEnv = devBuild ? 'development' : 'production';
|
8
|
+
|
6
9
|
module.exports = {
|
7
10
|
|
8
11
|
// the project dir
|
@@ -6,12 +6,43 @@ extends: eslint-config-airbnb
|
|
6
6
|
plugins:
|
7
7
|
- react
|
8
8
|
|
9
|
+
globals:
|
10
|
+
__DEBUG_SERVER_ERRORS__: true
|
11
|
+
__SERVER_ERRORS__: true
|
12
|
+
|
9
13
|
env:
|
10
14
|
browser: true
|
11
15
|
node: true
|
16
|
+
mocha: true
|
12
17
|
|
13
18
|
rules:
|
19
|
+
### Variables
|
20
|
+
no-undef: 2
|
21
|
+
no-unused-vars: [2, { vars: all, args: none }]
|
22
|
+
|
23
|
+
### Stylistic issues
|
14
24
|
indent: [1, 2, { SwitchCase: 1, VariableDeclarator: 2 }]
|
15
|
-
|
16
|
-
|
17
|
-
|
25
|
+
id-length: [1, { min: 2, exceptions: [_, e, i, k, v] }]
|
26
|
+
|
27
|
+
### React
|
28
|
+
jsx-quotes: [1, prefer-double]
|
29
|
+
react/display-name: 0
|
30
|
+
react/jsx-boolean-value: [1, always]
|
31
|
+
react/jsx-curly-spacing: [1, never]
|
32
|
+
react/jsx-no-duplicate-props: [2, { ignoreCase: true }]
|
33
|
+
react/jsx-no-undef: 2
|
34
|
+
react/jsx-sort-prop-types: 0
|
35
|
+
react/jsx-sort-props: 0
|
36
|
+
react/jsx-uses-react: 2
|
37
|
+
react/jsx-uses-vars: 2
|
38
|
+
react/no-danger: 0
|
39
|
+
react/no-did-mount-set-state: 1
|
40
|
+
react/no-did-update-set-state: 0
|
41
|
+
react/no-multi-comp: 2
|
42
|
+
react/no-unknown-property: 2
|
43
|
+
react/prop-types: 1
|
44
|
+
react/react-in-jsx-scope: 2
|
45
|
+
react/require-extension: [1, { extensions: [.js, .jsx] }]
|
46
|
+
react/self-closing-comp: 2
|
47
|
+
react/sort-comp: 0 # Should be 1. `statics` should be on top.
|
48
|
+
react/wrap-multilines: 2
|