Skip to content

Commit

Permalink
Update all gems with bundle update (#657)
Browse files Browse the repository at this point in the history
* Update all gems with bundle update
* update node dependencies to run on sierra 10.12.2
* remove jscs
* Fix JS linting, using ShakaCode 13.2.1
* Updated rubocop linting
* Fix flow errors
  • Loading branch information
justin808 authored Dec 25, 2016
1 parent 501d593 commit 8bcaa34
Show file tree
Hide file tree
Showing 40 changed files with 289 additions and 1,159 deletions.
13 changes: 9 additions & 4 deletions docs/contributor-info/linters.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@ These linters support the [ShakaCode Style Guidelines](./style.md)

## Autofix!

If you haven't tried the autofix options for `jscs` and `rubocop`, you're seriously missing out!
If you haven't tried the autofix options for `eslint` and `rubocop`, you're seriously missing out!

1. Be **SURE** you have a clean git status, as you'll want to review what the autofix does to your code!
2. **Rubocop:** Be sure to be in the right directory where you have Ruby files, probably the top level of your Rails project.
```
rubocop -a
```

3. **JSCS:**: Be sure to be in the right directory where you have JS files.
3. **eslint:**: Be sure to be in the right directory where you have JS files.
```
jscs -x .
eslint --fix .
```

or

```
npm run lint -- --fix
```

Autofixing is a **HUGE** time saver!
Expand Down Expand Up @@ -60,5 +66,4 @@ You can disable all rules for a line or block, or only specific rules, as shown
* [ESLint quick start](http://untilfalse.com/eslint-quick-start/)
* [RuboCop](https://github.com/bbatsov/rubocop)
* [ESLint](http://eslint.org/)
* [JSCS](https://github.com/jscs-dev/node-jscs)

2 changes: 1 addition & 1 deletion docs/misc/doctrine.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Here's the chef's selection from the React on Rails community:

### JavaScript Tooling
* [Babel](https://babeljs.io/): Transpiler for ES6 into ES5 and much more.
* [EsLint](http://eslint.org/) and [Jsrc](http://jscs.info/): JavaScript linters.
* [EsLint](http://eslint.org/)
* [Webpack](http://webpack.github.io/): Generator of deployment assets and provider of hot module reloading.

By having a common set of tools, we can discuss what we should or shouldn't be using. Thus, this takes out the "JavaScript Fatigue" from having too many unclear choices in the JavaScript world.
Expand Down
3 changes: 2 additions & 1 deletion lib/react_on_rails/assets_precompile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def symlink_non_digested_assets
manifest_path = manifest_glob.first
manifest_file = File.new(manifest_path)
manifest_data = if File.extname(manifest_file) == ".json"
JSON.load(manifest_file)["assets"]
manifest_file_data = File.read(manifest_path)
JSON.parse(manifest_file_data)["assets"]
else
YAML.load(manifest_file)
end
Expand Down
55 changes: 34 additions & 21 deletions lib/react_on_rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,48 @@ def self.configure
DEFAULT_GENERATED_ASSETS_DIR = File.join(%w(app assets webpack)).freeze

def self.setup_config_values
if @configuration.webpack_generated_files.empty?
files = ["webpack-bundle.js"]
if @configuration.server_bundle_js_file.present?
files << @configuration.server_bundle_js_file
end
@configuration.webpack_generated_files = files
end
ensure_webpack_generated_files_exists
configure_generated_assets_dirs_deprecation
ensure_generated_assets_dir_present
ensure_server_bundle_js_file_has_no_path
end

if @configuration.generated_assets_dirs.present?
puts "[DEPRECATION] ReactOnRails: Use config.generated_assets_dir rather than "\
def self.ensure_generated_assets_dir_present
return unless @configuration.generated_assets_dir.blank?

@configuration.generated_assets_dir = DEFAULT_GENERATED_ASSETS_DIR
puts "ReactOnRails: Set generated_assets_dir to default: #{DEFAULT_GENERATED_ASSETS_DIR}"
end

def self.configure_generated_assets_dirs_deprecation
return unless @configuration.generated_assets_dirs.present?

puts "[DEPRECATION] ReactOnRails: Use config.generated_assets_dir rather than "\
"generated_assets_dirs"
if @configuration.generated_assets_dir.blank?
@configuration.generated_assets_dir = @configuration.generated_assets_dirs
else
puts "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and "\
if @configuration.generated_assets_dir.blank?
@configuration.generated_assets_dir = @configuration.generated_assets_dirs
else
puts "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and "\
"generated_assets_dir defined. Define ONLY generated_assets_dir"
end
end
end

if @configuration.generated_assets_dir.blank?
@configuration.generated_assets_dir = DEFAULT_GENERATED_ASSETS_DIR
puts "ReactOnRails: Set generated_assets_dir to default: #{DEFAULT_GENERATED_ASSETS_DIR}"
def self.ensure_webpack_generated_files_exists
return unless @configuration.webpack_generated_files.empty?

files = ["webpack-bundle.js"]
if @configuration.server_bundle_js_file.present?
files << @configuration.server_bundle_js_file
end
@configuration.webpack_generated_files = files
end

def self.ensure_server_bundle_js_file_has_no_path
return unless @configuration.server_bundle_js_file.include?(File::SEPARATOR)

if @configuration.server_bundle_js_file.include?(File::SEPARATOR)
puts "[DEPRECATION] ReactOnRails: remove path from server_bundle_js_file in configuration. "\
puts "[DEPRECATION] ReactOnRails: remove path from server_bundle_js_file in configuration. "\
"All generated files must go in #{@configuration.generated_assets_dir}"
@configuration.server_bundle_js_file = File.basename(@configuration.server_bundle_js_file)
end
@configuration.server_bundle_js_file = File.basename(@configuration.server_bundle_js_file)
end

def self.configuration
Expand Down
12 changes: 6 additions & 6 deletions lib/react_on_rails/test_helper/node_process_launcher.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module ReactOnRails
module TestHelper
def self.launch_node
if ReactOnRails.configuration.server_render_method == "NodeJS"
path = "#{::Rails.root}/client/node"
puts "Launching NodeJS server at #{path}"
system("cd #{path} && npm start &")
sleep(1)
end
return unless ReactOnRails.configuration.server_render_method == "NodeJS"

path = "#{::Rails.root}/client/node"
puts "Launching NodeJS server at #{path}"
system("cd #{path} && npm start &")
sleep(1)
end
end
end
7 changes: 5 additions & 2 deletions node_package/src/Authenticity.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
export default {

authenticityToken() {
const token: {content?: string} = document.querySelector('meta[name="csrf-token"]');
return token ? token.content : null;
const token: ?HTMLElement = document.querySelector('meta[name="csrf-token"]');
if (token && (token instanceof window.HTMLMetaElement)) {
return token.content;
}
return null;
},

authenticityHeaders(otherHeaders: {[id:string]: string} = {}) {
Expand Down
1 change: 1 addition & 0 deletions node_package/tests/ComponentRegistry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable react/prefer-stateless-function */
/* eslint-disable react/jsx-filename-extension */
/* eslint-disable no-unused-vars */
/* eslint-disable import/extensions */

import test from 'tape';
import React from 'react';
Expand Down
3 changes: 0 additions & 3 deletions node_package/tests/buildConsoleReplay.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,11 @@ test('buildConsoleReplay wraps console replay in a script tag', (assert) => {
];
const actual = buildConsoleReplay();

// https://github.com/jscs-dev/node-jscs/issues/2137
// jscs:disable disallowSpacesInsideTemplateStringPlaceholders
const expected = `
<script>
console.log.apply(console, ["some message","{\\"a\\":1,\\"b\\":2}"]);
console.warn.apply(console, ["other message","{\\"c\\":3,\\"d\\":4}"]);
</script>`;

// jscs:enable disallowSpacesInsideTemplateStringPlaceholders
assert.equals(actual, expected, 'Unexpected value for console replay history');
});
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@
"doc": "docs"
},
"devDependencies": {
"babel-cli": "^6.16.0",
"babel-core": "^6.17.0",
"babel-loader": "^6.2.5",
"babel-cli": "^6.18.0",
"babel-core": "^6.21.0",
"babel-loader": "^6.2.10",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-flow-strip-types": "^6.14.0",
"babel-plugin-transform-flow-strip-types": "^6.21.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"babel-runtime": "^6.11.6",
"babel-runtime": "^6.20.0",
"babel-tape-runner": "^2.0.1",
"babel-types": "^6.16.0",
"babel-types": "^6.21.0",
"babelify": "^7.3.0",
"blue-tape": "^1.0.0",
"eslint": "^3.8.1",
"eslint-config-shakacode": "^13.2.0-beta.1",
"eslint-plugin-import": "^2.0.1",
"eslint": "^3.12.2",
"eslint-config-shakacode": "^13.2.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.4.1",
"flow-bin": "^0.36.0",
"jsdom": "^9.8.0",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"eslint-plugin-react": "^6.8.0",
"flow-bin": "^0.37.4",
"jsdom": "^9.9.1",
"react": "^15.4.1",
"react-dom": "^15.4.1",
"react-transform-hmr": "^1.0.4",
"redux": "^3.6.0",
"release-it": "^2.4.3",
"release-it": "^2.5.2",
"tap-spec": "^4.1.1",
"tape": "^4.6.2",
"webpack": "^1.13.2"
"tape": "^4.6.3",
"webpack": "^1.14.0"
},
"peerDependencies": {
"react": ">= 0.14",
Expand Down
4 changes: 0 additions & 4 deletions rakelib/docker.rake
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ namespace :docker do
sh "docker-compose run lint rake lint:eslint"
end

desc "Run jscs linter from docker"
task :jscs do
sh "docker-compose run lint rake lint:jscs"
end
desc "Run all linting from docker"
task :lint do
sh "docker-compose run lint rake lint"
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ gem 'coffee-rails', '~> 4.1.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'

gem 'puma'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
if ENV["DISABLE_TURBOLINKS"].nil? || ENV["DISABLE_TURBOLINKS"].strip.empty?
if ENV["ENABLE_TURBOLINKS_5"].nil? || ENV["ENABLE_TURBOLINKS_5"].strip.empty?
Expand Down
Loading

0 comments on commit 8bcaa34

Please sign in to comment.