diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 7755d0a6cc..0000000000 --- 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 e066247f38..2abddb7850 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 1a9225a6ab..ff1a8c5b0d 100644 --- a/lib/generators/react_on_rails/base_generator.rb +++ b/lib/generators/react_on_rails/base_generator.rb @@ -58,7 +58,7 @@ def strip_application_js_of_double_blank_lines end def create_react_directories - dirs = %w(components containers startup) + dirs = %w(components startup) dirs.each { |name| empty_directory("client/app/bundles/HelloWorld/#{name}") } end @@ -77,7 +77,6 @@ def template_base_files 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) } end 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 6f498cab2d..2b95ed1b12 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,12 @@ class ReactNoReduxGenerator < Rails::Generators::Base Rails::Generators.hide_namespace(namespace) source_root(File.expand_path("../templates", __FILE__)) - def copy_base_files + def copy_react_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}") + %w(client/app/bundles/HelloWorld/components/HelloWorldApp.jsx + client/app/bundles/HelloWorld/startup/registration.jsx).each do |file| + copy_file(base_path + file, file) + end 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 b9f06842c2..6608f00f51 100644 --- a/lib/generators/react_on_rails/react_with_redux_generator.rb +++ b/lib/generators/react_on_rails/react_with_redux_generator.rb @@ -7,26 +7,23 @@ class ReactWithReduxGenerator < Rails::Generators::Base source_root(File.expand_path("../templates", __FILE__)) def create_redux_directories - dirs = %w(actions constants reducers store) + dirs = %w(actions constants containers reducers store) dirs.each { |name| empty_directory("client/app/bundles/HelloWorld/#{name}") } end def copy_base_redux_files base_path = "redux/base/" %w(client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx + client/app/bundles/HelloWorld/components/HelloWorld.jsx 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 + client/app/bundles/HelloWorld/startup/registration.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}") - end end end end 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 49e5fc5582..0000000000 --- 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}! -

-
-
- - updateName(e.target.value)} - /> -
-
-); - -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/webpack.config.js b/lib/generators/react_on_rails/templates/base/base/client/webpack.config.js index 9d7505150f..a051c0fe10 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/components/HelloWorldApp.jsx b/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldApp.jsx new file mode 100644 index 0000000000..8b14275b56 --- /dev/null +++ b/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldApp.jsx @@ -0,0 +1,45 @@ +import React, { PropTypes } from 'react'; + +export default class HelloWorldApp 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}! +

+
+
+ + this.updateName(e.target.value)} + /> +
+
+ ); + } +} 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 aacfb43bbb..0000000000 --- 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 9a49aeeb60..0000000000 --- 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/no_redux/base/client/app/bundles/HelloWorld/startup/registration.jsx b/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/startup/registration.jsx new file mode 100644 index 0000000000..c97655e97a --- /dev/null +++ b/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/startup/registration.jsx @@ -0,0 +1,8 @@ +import ReactOnRails from 'react-on-rails'; + +import HelloWorldApp from '../components/HelloWorldApp'; + +// This is how react_on_rails can see the HelloWorld 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 f60b99f802..fa6a37d1e2 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/components/HelloWorld.jsx b/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/components/HelloWorld.jsx new file mode 100644 index 0000000000..8ea8aae743 --- /dev/null +++ b/lib/generators/react_on_rails/templates/redux/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}! +

+
+
+ + this.updateName(e.target.value)} + /> +
+
+ ); + } +} 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 a9cbeba296..3d2622d53a 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/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/registration.jsx.tt b/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/registration.jsx.tt new file mode 100644 index 0000000000..3b2418cd56 --- /dev/null +++ b/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/registration.jsx.tt @@ -0,0 +1,6 @@ +import ReactOnRails from 'react-on-rails'; + +import HelloWorldApp from './HelloWorldApp'; + +// This is how react_on_rails can see the HelloWorldApp in the browser. +ReactOnRails.register({ HelloWorldApp }); \ No newline at end of file diff --git a/node_package/scripts/lint-fix b/node_package/scripts/lint-fix deleted file mode 100755 index 90cef38b77..0000000000 --- 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 fa4c423b0a..f14cc7b2eb 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 c2e3449dd2..4f72e2178b 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 7d60e315b1..7fd47b376e 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 9b15bdbb6e..8619559117 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 10063aa218..2eb725d0c3 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 61d654aa82..25aa5c5968 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 2a92162503..8f240fa93d 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 34f060ceb6..b41b04fb39 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,10 +53,8 @@ "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", + "lint": "npm run eslint && npm run flow", "check": "npm run lint && npm run test", "prerelease": "npm run check && npm run clean && npm run build", "release:patch": "node_package/scripts/release patch", diff --git a/rakelib/lint.rake b/rakelib/lint.rake index e7180c16ba..23857f8b6c 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 8b3db12002..ca6ab9053e 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 e876639be5..6acafec12f 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 4cb3e20bee..3e1a8b22dc 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 @@ -32,7 +32,7 @@ end it "creates react directories" do - dirs = %w(components containers startup) + dirs = %w(components startup) dirs.each { |dirname| assert_directory "client/app/bundles/HelloWorld/#{dirname}" } end @@ -42,7 +42,6 @@ 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 39f7b22a29..45ed2c5378 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,11 +1,15 @@ 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_file("client/app/bundles/HelloWorld/startup/registration.jsx") do |contents| assert_match("HelloWorld", contents) end end + it "copies react files" do + %w(client/app/bundles/HelloWorld/components/HelloWorldApp.jsx + client/app/bundles/HelloWorld/startup/registration.jsx).each { |file| assert_file(file) } + end + it "does not place react folders in root" do %w(reducers store middlewares constants actions).each do |dir| assert_no_directory(dir) 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 e627907b6a..1f274b9840 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 @@ -1,14 +1,22 @@ shared_examples "react_with_redux_generator" do it "creates redux directories" do - %w(actions constants reducers store).each { |dir| assert_directory("client/app/bundles/HelloWorld/#{dir}") } + %w(actions + constants + containers + reducers + store).each do |dir| + assert_directory("client/app/bundles/HelloWorld/#{dir}") + end end it "copies base redux files" do %w(client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx + client/app/bundles/HelloWorld/components/HelloWorld.jsx 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 - client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx).each { |file| assert_file(file) } + client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx + client/app/bundles/HelloWorld/startup/registration.jsx).each { |file| assert_file(file) } end end