diff --git a/.jscsrc b/.jscsrc
deleted file mode 100644
index 7755d0a6c..000000000
--- a/.jscsrc
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "preset": "airbnb",
- "fileExtensions": [
- ".js",
- ".jsx"
- ],
- "excludeFiles": [
- "**/.c9/**",
- "**/build/**",
- "**/node_modules/**",
- "**/assets/webpack/**",
- "**/generated/**",
- "**/docs/**",
- "**/tmp/**",
- "**/sample_generated/**",
- "**/coverage/**",
- "**/vendor/**",
- "**/dummy-for-generators/**",
- "**/dummy/**",
- "**/node_package/lib/**",
- "**/app/assets/javascripts/application.js"
- ],
- "esprima": "babel-jscs",
- "validateQuoteMarks": {
- "mark": "'",
- "escape": true,
- "ignoreJSX": true
- },
- "requireTrailingComma": false
-}
diff --git a/Gemfile b/Gemfile
index e066247f3..2abddb785 100644
--- a/Gemfile
+++ b/Gemfile
@@ -32,6 +32,7 @@ gem "web-console", "~> 2.0", group: :development
# below are copied from spec/dummy/Gemfile
gem "rspec-rails"
+gem "rspec-retry"
gem "capybara"
gem "capybara-screenshot"
gem "capybara-webkit"
diff --git a/lib/generators/react_on_rails/base_generator.rb b/lib/generators/react_on_rails/base_generator.rb
index 1a9225a6a..c296fde4f 100644
--- a/lib/generators/react_on_rails/base_generator.rb
+++ b/lib/generators/react_on_rails/base_generator.rb
@@ -44,7 +44,7 @@ def update_application_js
DATA
app_js_path = "app/assets/javascripts/application.js"
- found_app_js = dest_file_exists?(app_js_path) || dest_file_exists?(app_js_path + ".coffee")
+ found_app_js = dest_file_exists?(app_js_path) || dest_file_exists?("#{app_js_path}.coffee")
if found_app_js
prepend_to_file(found_app_js, data)
else
@@ -65,20 +65,19 @@ def create_react_directories
def copy_base_files
base_path = "base/base/"
base_files = %w(app/controllers/hello_world_controller.rb
+ client/app/bundles/HelloWorld/components/HelloWorld.jsx
client/.babelrc
client/webpack.config.js
client/REACT_ON_RAILS_CLIENT_README.md)
- base_files.each { |file| copy_file(base_path + file, file) }
+ base_files.each { |file| copy_file("#{base_path}#{file}", file) }
end
def template_base_files
base_path = "base/base/"
%w(config/initializers/react_on_rails.rb
Procfile.dev
- app/views/hello_world/index.html.erb
package.json
- client/app/bundles/HelloWorld/components/HelloWorld.jsx
- client/package.json).each { |file| template(base_path + file + ".tt", file) }
+ client/package.json).each { |file| template("#{base_path}#{file}.tt", file) }
end
def add_base_gems_to_gemfile
diff --git a/lib/generators/react_on_rails/react_no_redux_generator.rb b/lib/generators/react_on_rails/react_no_redux_generator.rb
index 6f498cab2..1cbb5845c 100644
--- a/lib/generators/react_on_rails/react_no_redux_generator.rb
+++ b/lib/generators/react_on_rails/react_no_redux_generator.rb
@@ -8,16 +8,16 @@ class ReactNoReduxGenerator < Rails::Generators::Base
Rails::Generators.hide_namespace(namespace)
source_root(File.expand_path("../templates", __FILE__))
- def copy_base_files
- base_path = "no_redux/base/"
- file = "client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx"
- copy_file(base_path + file, file)
- end
-
- def template_appropriate_version_of_hello_world_app
- filename = "HelloWorldApp.jsx"
- location = "client/app/bundles/HelloWorld/startup"
- template("no_redux/base/#{location}/HelloWorldApp.jsx.tt", "#{location}/#{filename}")
+ def create_appropriate_templates
+ base_path = "base/base/"
+ location = "client/app/bundles/HelloWorld/"
+ source = base_path + location
+ config = {
+ component_name: "HelloWorld",
+ app_relative_path: "../components/HelloWorld"
+ }
+ template("#{source}/startup/registration.jsx.tt", "#{location}/startup/registration.jsx", config)
+ template("#{base_path}app/views/hello_world/index.html.erb.tt", "app/views/hello_world/index.html.erb", config)
end
end
end
diff --git a/lib/generators/react_on_rails/react_with_redux_generator.rb b/lib/generators/react_on_rails/react_with_redux_generator.rb
index b9f06842c..a1376f84f 100644
--- a/lib/generators/react_on_rails/react_with_redux_generator.rb
+++ b/lib/generators/react_on_rails/react_with_redux_generator.rb
@@ -17,15 +17,22 @@ def copy_base_redux_files
client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx
client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx
client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx
- client/app/bundles/HelloWorld/store/helloWorldStore.jsx).each do |file|
+ client/app/bundles/HelloWorld/store/helloWorldStore.jsx
+ client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx).each do |file|
copy_file(base_path + file, file)
end
end
- def template_appropriate_version_of_hello_world_app
- filename = "HelloWorldApp.jsx"
- location = "client/app/bundles/HelloWorld/startup"
- template("redux/base/#{location}/HelloWorldApp.jsx.tt", "#{location}/#{filename}")
+ def create_appropriate_templates
+ base_path = "base/base/"
+ location = "client/app/bundles/HelloWorld/"
+ source = base_path + location
+ config = {
+ component_name: "HelloWorldApp",
+ app_relative_path: "./HelloWorldApp"
+ }
+ template("#{source}/startup/registration.jsx.tt", "#{location}/startup/registration.jsx", config)
+ template("#{base_path}app/views/hello_world/index.html.erb.tt", "app/views/hello_world/index.html.erb", config)
end
end
end
diff --git a/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt b/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt
index a4d030dc8..98deed972 100644
--- a/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt
+++ b/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt
@@ -1,3 +1,3 @@
Hello World
-<%%= react_component("HelloWorldApp", props: @hello_world_props, prerender: false) %>
+<%%= react_component("<%= config[:component_name] %>", props: @hello_world_props, prerender: false) %>
diff --git a/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/components/HelloWorld.jsx b/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/components/HelloWorld.jsx
new file mode 100644
index 000000000..8ea8aae74
--- /dev/null
+++ b/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/components/HelloWorld.jsx
@@ -0,0 +1,45 @@
+import React, { PropTypes } from 'react';
+
+export default class HelloWorld extends React.Component {
+ static propTypes = {
+ name: PropTypes.string.isRequired, // this is passed from the Rails view
+ };
+
+ /**
+ * @param props - Comes from your rails view.
+ * @param _railsContext - Comes from React on Rails
+ */
+ constructor(props, _railsContext) {
+ super(props);
+
+ // How to set initial state in ES6 class syntax
+ // https://facebook.github.io/react/docs/reusable-components.html#es6-classes
+ this.state = { name: this.props.name };
+ }
+
+ updateName = (name) => {
+ this.setState({ name });
+ };
+
+ render() {
+ return (
+
+
+ Hello, {this.state.name}!
+
+
+
+
+ );
+ }
+}
diff --git a/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/components/HelloWorld.jsx.tt b/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/components/HelloWorld.jsx.tt
deleted file mode 100644
index 49e5fc558..000000000
--- a/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/components/HelloWorld.jsx.tt
+++ /dev/null
@@ -1,29 +0,0 @@
-import React, { PropTypes } from 'react';
-
-// Simple example of a React "dumb" component
-const HelloWorld = ({ name, updateName }) => (
-
-
- Hello, {name}!
-
-
-
-
-);
-
-HelloWorld.propTypes = {
- // If you have lots of data or action properties, you should consider grouping them by
- // passing two properties: "data" and "actions".
- updateName: PropTypes.func.isRequired,
- name: PropTypes.string.isRequired,
-};
-
-export default HelloWorld;
diff --git a/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/startup/registration.jsx.tt b/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/startup/registration.jsx.tt
new file mode 100644
index 000000000..379de1f4f
--- /dev/null
+++ b/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/startup/registration.jsx.tt
@@ -0,0 +1,8 @@
+import ReactOnRails from 'react-on-rails';
+
+import <%= config[:component_name] %> from '<%= config[:app_relative_path] %>';
+
+// This is how react_on_rails can see the HelloWorld in the browser.
+ReactOnRails.register({
+ <%= config[:component_name] %>,
+});
diff --git a/lib/generators/react_on_rails/templates/base/base/client/webpack.config.js b/lib/generators/react_on_rails/templates/base/base/client/webpack.config.js
index 9d7505150..a051c0fe1 100644
--- a/lib/generators/react_on_rails/templates/base/base/client/webpack.config.js
+++ b/lib/generators/react_on_rails/templates/base/base/client/webpack.config.js
@@ -1,3 +1,7 @@
+/* eslint comma-dangle: ["error",
+ {"functions": "never", "arrays": "only-multiline", "objects":
+"only-multiline"} ] */
+
const webpack = require('webpack');
const path = require('path');
@@ -9,7 +13,7 @@ const config = {
'es5-shim/es5-shim',
'es5-shim/es5-sham',
'babel-polyfill',
- './app/bundles/HelloWorld/startup/HelloWorldApp',
+ './app/bundles/HelloWorld/startup/registration',
],
output: {
diff --git a/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx b/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx
deleted file mode 100644
index aacfb43bb..000000000
--- a/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import React, { PropTypes } from 'react';
-import HelloWorld from '../components/HelloWorld';
-
-// Simple example of a React "smart" component
-export default class HelloWorldContainer extends React.Component {
- static propTypes = {
- name: PropTypes.string.isRequired, // this is passed from the Rails view
- };
-
- constructor(props) {
- super(props);
-
- // How to set initial state in ES6 class syntax
- // https://facebook.github.io/react/docs/reusable-components.html#es6-classes
- this.state = { name: this.props.name };
- }
-
- updateName = (name) => { this.setState({ name }); };
-
- render() {
- return (
-
- );
- }
-}
diff --git a/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx.tt b/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx.tt
deleted file mode 100644
index 9a49aeeb6..000000000
--- a/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx.tt
+++ /dev/null
@@ -1,12 +0,0 @@
-import React from 'react';
-import ReactOnRails from 'react-on-rails';
-
-import HelloWorldContainer from '../containers/HelloWorldContainer';
-
-// _railsContext is the Rails context, providing contextual information for rendering
-const HelloWorldApp = (props, _railsContext) => (
-
-);
-
-// This is how react_on_rails can see the HelloWorldApp in the browser.
-ReactOnRails.register({ HelloWorldApp });
diff --git a/lib/generators/react_on_rails/templates/node/base/client/node/server.js b/lib/generators/react_on_rails/templates/node/base/client/node/server.js
index f60b99f80..fa6a37d1e 100644
--- a/lib/generators/react_on_rails/templates/node/base/client/node/server.js
+++ b/lib/generators/react_on_rails/templates/node/base/client/node/server.js
@@ -68,7 +68,7 @@ fs.watchFile(bundlePath + bundleFileName, (curr) => {
return;
}
- // eslint-disable-next-line global-require
+ // eslint-disable-next-line global-require, import/no-dynamic-require
require(bundlePath + bundleFileName);
console.log(`Loaded server bundle: ${bundlePath + bundleFileName}`);
handler.initialize();
diff --git a/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx.tt b/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx.tt
index a9cbeba29..3d2622d53 100644
--- a/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx.tt
+++ b/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx.tt
@@ -16,5 +16,4 @@ const HelloWorldApp = (props, _railsContext) => (
);
-// This is how react_on_rails can see the HelloWorldApp in the browser.
-ReactOnRails.register({ HelloWorldApp });
+export default HelloWorldApp;
diff --git a/node_package/scripts/lint-fix b/node_package/scripts/lint-fix
deleted file mode 100755
index 90cef38b7..000000000
--- a/node_package/scripts/lint-fix
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-# COMMENTING OUT UNTIL BREAKING FIX IS HANDLED
-# https://github.com/jscs-dev/node-jscs/issues/2043
-echo "RUN MANUALLY"
-echo "$(npm bin)/jscs -x . && (cd spec/dummy/client && $(npm bin)/jscs -x .)"
-
-# $(npm bin)/jscs -x . && (cd spec/dummy/client && $(npm bin)/jscs -x .)
diff --git a/node_package/src/ReactOnRails.js b/node_package/src/ReactOnRails.js
index fa4c423b0..f14cc7b2e 100644
--- a/node_package/src/ReactOnRails.js
+++ b/node_package/src/ReactOnRails.js
@@ -62,12 +62,14 @@ ctx.ReactOnRails = {
setOptions(newOptions) {
if ('traceTurbolinks' in newOptions) {
this.options.traceTurbolinks = newOptions.traceTurbolinks;
+
+ // eslint-disable-next-line no-param-reassign
delete newOptions.traceTurbolinks;
}
if (Object.keys(newOptions).length > 0) {
throw new Error(
- 'Invalid options passed to ReactOnRails.options: ', JSON.stringify(newOptions)
+ 'Invalid options passed to ReactOnRails.options: ', JSON.stringify(newOptions),
);
}
},
diff --git a/node_package/src/clientStartup.js b/node_package/src/clientStartup.js
index c2e3449dd..4f72e2178 100644
--- a/node_package/src/clientStartup.js
+++ b/node_package/src/clientStartup.js
@@ -37,7 +37,7 @@ function turbolinksInstalled() {
function forEach(fn, className, railsContext) {
const els = document.getElementsByClassName(className);
- for (let i = 0; i < els.length; i++) {
+ for (let i = 0; i < els.length; i += 1) {
fn(els[i], railsContext);
}
}
@@ -141,7 +141,7 @@ export function clientStartup(context) {
return;
}
- // eslint-disable-next-line no-underscore-dangle
+ // eslint-disable-next-line no-underscore-dangle, no-param-reassign
context.__REACT_ON_RAILS_EVENT_HANDLERS_RAN_ONCE__ = true;
debugTurbolinks('Adding DOMContentLoaded event to install event listeners.');
@@ -153,13 +153,13 @@ export function clientStartup(context) {
if (!turbolinksInstalled()) {
debugTurbolinks(
- 'NOT USING TURBOLINKS: DOMContentLoaded event, calling reactOnRailsPageLoaded'
+ 'NOT USING TURBOLINKS: DOMContentLoaded event, calling reactOnRailsPageLoaded',
);
reactOnRailsPageLoaded();
} else if (turbolinksVersion5()) {
debugTurbolinks(
'USING TURBOLINKS 5: document added event listeners turbolinks:before-cache and ' +
- 'turbolinks:load.'
+ 'turbolinks:load.',
);
document.addEventListener('turbolinks:before-cache', reactOnRailsPageUnloaded);
document.addEventListener('turbolinks:load', reactOnRailsPageLoaded);
diff --git a/node_package/src/serverRenderReactComponent.js b/node_package/src/serverRenderReactComponent.js
index 7d60e315b..7fd47b376 100644
--- a/node_package/src/serverRenderReactComponent.js
+++ b/node_package/src/serverRenderReactComponent.js
@@ -20,13 +20,13 @@ export default function serverRenderReactComponent(options) {
hasErrors = !!reactElementOrRouterResult.routeError;
if (hasErrors) {
console.error(
- `React Router ERROR: ${JSON.stringify(reactElementOrRouterResult.routeError)}`
+ `React Router ERROR: ${JSON.stringify(reactElementOrRouterResult.routeError)}`,
);
} else if (trace) {
const redirectLocation = reactElementOrRouterResult.redirectLocation;
const redirectPath = redirectLocation.pathname + redirectLocation.search;
console.log(`\
-ROUTER REDIRECT: ${name} to dom node with id: ${domNodeId}, redirect to ${redirectPath}`
+ROUTER REDIRECT: ${name} to dom node with id: ${domNodeId}, redirect to ${redirectPath}`,
);
}
} else {
diff --git a/node_package/tests/Authenticity.test.js b/node_package/tests/Authenticity.test.js
index 9b15bdbb6..861955911 100644
--- a/node_package/tests/Authenticity.test.js
+++ b/node_package/tests/Authenticity.test.js
@@ -1,5 +1,5 @@
import test from 'tape';
-import ReactOnRails from '../src/ReactOnRails.js';
+import ReactOnRails from '../src/ReactOnRails';
test('authenticityToken and authenticityHeaders', (assert) => {
assert.plan(4);
@@ -25,6 +25,6 @@ test('authenticityToken and authenticityHeaders', (assert) => {
const realHeader = ReactOnRails.authenticityHeaders();
assert.deepEqual(realHeader, { 'X-CSRF-Token': testToken, 'X-Requested-With': 'XMLHttpRequest' },
- 'authenticityHeaders returns valid header with CFRS token'
+ 'authenticityHeaders returns valid header with CFRS token',
);
});
diff --git a/node_package/tests/ComponentRegistry.test.js b/node_package/tests/ComponentRegistry.test.js
index 10063aa21..2eb725d0c 100644
--- a/node_package/tests/ComponentRegistry.test.js
+++ b/node_package/tests/ComponentRegistry.test.js
@@ -70,7 +70,7 @@ test('ComponentRegistry throws error for retrieving unregistered component', (as
assert.plan(1);
assert.throws(() => ComponentRegistry.get('foobar'),
/Could not find component registered with name foobar/,
- 'Expected an exception for calling ComponentRegistry.get with an invalid name.'
+ 'Expected an exception for calling ComponentRegistry.get with an invalid name.',
);
});
@@ -79,6 +79,6 @@ test('ComponentRegistry throws error for setting null component', (assert) => {
const C6 = null;
assert.throws(() => ComponentRegistry.register({ C6 }),
/Called register with null component named C6/,
- 'Expected an exception for calling ComponentRegistry.set with a null component.'
+ 'Expected an exception for calling ComponentRegistry.set with a null component.',
);
});
diff --git a/node_package/tests/ReactOnRails.test.js b/node_package/tests/ReactOnRails.test.js
index 61d654aa8..25aa5c596 100644
--- a/node_package/tests/ReactOnRails.test.js
+++ b/node_package/tests/ReactOnRails.test.js
@@ -56,7 +56,7 @@ test('serverRenderReactComponent throws error for invalid options', (assert) =>
assert.throws(
() => ReactOnRails.setOptions({ foobar: true }),
/Invalid option/,
- 'setOptions should throw an error for invalid options'
+ 'setOptions should throw an error for invalid options',
);
});
@@ -66,19 +66,19 @@ test('registerStore throws if passed a falsey object (null, undefined, etc)', (a
assert.throws(
() => ReactOnRails.registerStore(null),
/null or undefined/,
- 'registerStore should throw an error if a falsey value is passed (null)'
+ 'registerStore should throw an error if a falsey value is passed (null)',
);
assert.throws(
() => ReactOnRails.registerStore(undefined),
/null or undefined/,
- 'registerStore should throw an error if a falsey value is passed (undefined)'
+ 'registerStore should throw an error if a falsey value is passed (undefined)',
);
assert.throws(
() => ReactOnRails.registerStore(false),
/null or undefined/,
- 'registerStore should throw an error if a falsey value is passed (false)'
+ 'registerStore should throw an error if a falsey value is passed (false)',
);
});
diff --git a/node_package/tests/StoreRegistry.test.js b/node_package/tests/StoreRegistry.test.js
index 2a9216250..8f240fa93 100644
--- a/node_package/tests/StoreRegistry.test.js
+++ b/node_package/tests/StoreRegistry.test.js
@@ -20,11 +20,11 @@ test('StoreRegistry throws error for registering null or undefined store', (asse
StoreRegistry.stores().clear();
assert.throws(() => StoreRegistry.register({ storeGenerator: null }),
/Called ReactOnRails.registerStores with a null or undefined as a value/,
- 'Expected an exception for calling StoreRegistry.register with an invalid store generator.'
+ 'Expected an exception for calling StoreRegistry.register with an invalid store generator.',
);
assert.throws(() => StoreRegistry.register({ storeGenerator: undefined }),
/Called ReactOnRails.registerStores with a null or undefined as a value/,
- 'Expected an exception for calling StoreRegistry.register with an invalid store generator.'
+ 'Expected an exception for calling StoreRegistry.register with an invalid store generator.',
);
});
@@ -33,7 +33,7 @@ test('StoreRegistry throws error for retrieving unregistered store', (assert) =>
StoreRegistry.stores().clear();
assert.throws(() => StoreRegistry.getStore('foobar'),
/There are no stores hydrated and you are requesting the store/,
- 'Expected an exception for calling StoreRegistry.getStore with no registered stores.'
+ 'Expected an exception for calling StoreRegistry.getStore with no registered stores.',
);
});
@@ -54,7 +54,7 @@ test('StoreRegistry throws error for retrieving unregistered store', (assert) =>
assert.plan(1);
assert.throws(() => StoreRegistry.getStoreGenerator('foobar'),
/Could not find store registered with name 'foobar'\. Registered store names include/,
- 'Expected an exception for calling StoreRegistry.getStoreGenerator with an invalid name.'
+ 'Expected an exception for calling StoreRegistry.getStoreGenerator with an invalid name.',
);
});
@@ -66,9 +66,9 @@ test('StoreRegistry returns undefined for retrieving unregistered store, ' +
const actual = StoreRegistry.getStore('foobar', false);
const expected = undefined;
assert.equals(actual, expected, 'StoreRegistry.get should return undefined for missing ' +
- 'store if throwIfMissing is passed as false'
+ 'store if throwIfMissing is passed as false',
);
- }
+ },
);
test('StoreRegistry getStore, setStore', (assert) => {
@@ -84,6 +84,6 @@ test('StoreRegistry throws error for retrieving unregistered hydrated store', (a
assert.plan(1);
assert.throws(() => StoreRegistry.getStore('foobar'),
/Could not find hydrated store with name 'foobar'\. Hydrated store names include/,
- 'Expected an exception for calling StoreRegistry.getStore with an invalid name.'
+ 'Expected an exception for calling StoreRegistry.getStore with an invalid name.',
);
});
diff --git a/package.json b/package.json
index 34f060ceb..f437e6a8b 100644
--- a/package.json
+++ b/package.json
@@ -22,12 +22,11 @@
"babelify": "^7.3.0",
"blue-tape": "^1.0.0",
"eslint": "^3.8.1",
- "eslint-config-shakacode": "^6.0.0",
+ "eslint-config-shakacode": "^13.2.0-beta.1",
"eslint-plugin-import": "^2.0.1",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.4.1",
- "flow-bin": "^0.33.0",
- "jscs": "^2.11.0",
+ "flow-bin": "^0.36.0",
"jsdom": "^9.8.0",
"react": "^15.3.2",
"react-dom": "^15.3.2",
@@ -54,11 +53,9 @@
"build": "npm run clean && npm run babel",
"build-watch": "babel --watch --out-dir node_package/lib node_package/src",
"eslint": "eslint .",
- "jscs": "jscs -e -v .",
"flow": "flow check node_package",
- "lint": "npm run eslint && npm run jscs && npm run flow",
- "lint:fix": "node_package/scripts/lint-fix",
- "check": "npm run lint && npm run test",
+ "lint": "npm run eslint",
+ "check": "npm run lint && npm run flow && npm run test",
"prerelease": "npm run check && npm run clean && npm run build",
"release:patch": "node_package/scripts/release patch",
"release:minor": "node_package/scripts/release minor",
diff --git a/rakelib/lint.rake b/rakelib/lint.rake
index e7180c16b..23857f8b6 100644
--- a/rakelib/lint.rake
+++ b/rakelib/lint.rake
@@ -23,18 +23,13 @@ namespace :lint do
sh_in_dir(gem_root, "npm run eslint")
end
- desc "Run jscs from shell"
- task :jscs do
- sh_in_dir(gem_root, "npm run jscs")
- end
-
desc "Run flow from shell"
task :flow do
sh_in_dir(gem_root, "npm run flow")
end
- desc "Run all eslint, jscs, flow, rubocop linters. Skip ruby-lint and scss"
- task lint: [:eslint, :jscs, :flow, :rubocop] do
+ desc "Run all eslint, flow, rubocop linters. Skip ruby-lint and scss"
+ task lint: [:eslint, :flow, :rubocop] do
puts "Completed all linting"
end
end
diff --git a/spec/dummy/Gemfile b/spec/dummy/Gemfile
index 8b3db1200..ca6ab9053 100644
--- a/spec/dummy/Gemfile
+++ b/spec/dummy/Gemfile
@@ -75,5 +75,6 @@ group :test do
gem "launchy"
gem "poltergeist"
gem "rspec-rails"
+ gem "rspec-retry"
gem "selenium-webdriver"
end
diff --git a/spec/react_on_rails/spec_helper.rb b/spec/react_on_rails/spec_helper.rb
index e876639be..6acafec12 100644
--- a/spec/react_on_rails/spec_helper.rb
+++ b/spec/react_on_rails/spec_helper.rb
@@ -13,6 +13,7 @@
require "binding_of_caller"
require "awesome_print"
+require "rspec/retry"
require_relative "./simplecov_helper"
@@ -50,6 +51,14 @@
# ...rather than:
# # => "be bigger than 2"
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
+
+ ### Fix Net::ReadTimeout error on first test
+ # Show retry status in spec process
+ config.verbose_retry = true
+ # Try twice (retry once)
+ config.default_retry_count = 3
+ # Only retry when Selenium raises Net::ReadTimeout
+ # config.exceptions_to_retry = [Net::ReadTimeout]
end
# rspec-mocks config goes here. You can use an alternate test double
diff --git a/spec/react_on_rails/support/shared_examples/base_generator_examples.rb b/spec/react_on_rails/support/shared_examples/base_generator_examples.rb
index 4cb3e20be..fa5ed45ad 100644
--- a/spec/react_on_rails/support/shared_examples/base_generator_examples.rb
+++ b/spec/react_on_rails/support/shared_examples/base_generator_examples.rb
@@ -38,11 +38,10 @@
it "copies react files" do
%w(app/controllers/hello_world_controller.rb
- app/views/hello_world/index.html.erb
+ client/app/bundles/HelloWorld/components/HelloWorld.jsx
client/REACT_ON_RAILS_CLIENT_README.md
client/webpack.config.js
client/.babelrc
- client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx
client/package.json
config/initializers/react_on_rails.rb
package.json
@@ -56,7 +55,7 @@
it "templates HelloWorldApp into webpack.config.js" do
assert_file("client/webpack.config.js") do |contents|
- assert_match("HelloWorldApp", contents)
+ assert_match("registration", contents)
end
end
end
diff --git a/spec/react_on_rails/support/shared_examples/react_no_redux_generator_examples.rb b/spec/react_on_rails/support/shared_examples/react_no_redux_generator_examples.rb
index 39f7b22a2..424e032eb 100644
--- a/spec/react_on_rails/support/shared_examples/react_no_redux_generator_examples.rb
+++ b/spec/react_on_rails/support/shared_examples/react_no_redux_generator_examples.rb
@@ -1,8 +1,10 @@
shared_examples "no_redux_generator" do
- it "copies non-redux base files" do
- assert_file("client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx")
- assert_file("client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx") do |contents|
- assert_match("HelloWorld", contents)
+ it "creates appropriate templates" do
+ assert_file("client/app/bundles/HelloWorld/startup/registration.jsx") do |contents|
+ assert_match("import HelloWorld from '../components/HelloWorld';", contents)
+ end
+ assert_file("app/views/hello_world/index.html.erb") do |contents|
+ assert_match(/"HelloWorld"/, contents)
end
end
diff --git a/spec/react_on_rails/support/shared_examples/react_with_redux_generator_examples.rb b/spec/react_on_rails/support/shared_examples/react_with_redux_generator_examples.rb
index e627907b6..6862160a6 100644
--- a/spec/react_on_rails/support/shared_examples/react_with_redux_generator_examples.rb
+++ b/spec/react_on_rails/support/shared_examples/react_with_redux_generator_examples.rb
@@ -3,6 +3,15 @@
%w(actions constants reducers store).each { |dir| assert_directory("client/app/bundles/HelloWorld/#{dir}") }
end
+ it "creates appropriate templates" do
+ assert_file("client/app/bundles/HelloWorld/startup/registration.jsx") do |contents|
+ assert_match("import HelloWorldApp from './HelloWorldApp';", contents)
+ end
+ assert_file("app/views/hello_world/index.html.erb") do |contents|
+ assert_match(/"HelloWorldApp"/, contents)
+ end
+ end
+
it "copies base redux files" do
%w(client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx
client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx