diff --git a/.rubocop.yml b/.rubocop.yml index 262358bdc..9eb10ab14 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,3 +4,5 @@ Metrics/MethodLength: Max: 16 Style/BracesAroundHashParameters: EnforcedStyle: context_dependent +Style/RegexpLiteral: + EnforcedStyle: slashes diff --git a/CHANGELOG.md b/CHANGELOG.md index 980daafd9..1823ac370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Fix rake task fablab:es_build_projects_index for ElasticSearch > 1.7 - Fix Dockerfile: yarn was not setup correctly +- Updated Uglifier gem to support ES6 syntax # v2.7.2 2018 November 29 diff --git a/Gemfile b/Gemfile index af491f407..07dce838d 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem 'rails', '4.2.10' gem 'sass-rails', '5.0.1' # Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' +gem 'uglifier', '>= 4.1.20' # See https://github.com/sstephenson/execjs#readme for more supported runtimes gem 'therubyracer', '= 0.12.0', platforms: :ruby diff --git a/Gemfile.lock b/Gemfile.lock index 8ff2a8124..5539afb1a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -460,9 +460,8 @@ GEM tzinfo tzinfo (1.2.4) thread_safe (~> 0.1) - uglifier (2.7.1) - execjs (>= 0.3.0) - json (>= 1.8.0) + uglifier (4.1.20) + execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext unf_ext (0.0.6) @@ -564,7 +563,7 @@ DEPENDENCIES therubyracer (= 0.12.0) twitter twitter-text - uglifier (>= 1.3.0) + uglifier (>= 4.1.20) unicorn vcr web-console (~> 2.1.3) diff --git a/config/environments/production.rb b/config/environments/production.rb index 238ebcfd1..50161662a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -22,10 +22,8 @@ Rails.application.configure do # Disable Rails's static asset server (Apache or nginx will already do this). config.serve_static_files = false - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier - # if you want disable variable name mangling - config.assets.js_compressor = Uglifier.new(mangle: false) + # Compress JavaScripts and CSS. We disable variable name mangling and enable ES6 support + config.assets.js_compressor = Uglifier.new(mangle: false, harmony: true) # config.assets.css_compressor = :sass diff --git a/config/routes.rb b/config/routes.rb index 0b4596592..9816030d7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,7 +113,7 @@ Rails.application.routes.draw do resources :event_themes resources :age_ranges resources :statistics, only: [:index] - resources :custom_assets, only: [:show, :create, :update] + resources :custom_assets, only: %i[show create update] resources :tags resources :stylesheets, only: [:show] resources :auth_providers do @@ -122,14 +122,15 @@ Rails.application.routes.draw do post 'send_code', action: 'send_code', on: :collection end resources :abuses, only: [:create] - resources :open_api_clients, only: [:index, :create, :update, :destroy] do + resources :open_api_clients, only: %i[index create update destroy] do patch :reset_token, on: :member end resources :price_categories resources :spaces # i18n - get 'translations/:locale/:state' => 'translations#show', :constraints => { :state => /[^\/]+/ } # allow dots in URL for 'state' + # regex allows using dots in URL for 'state' + get 'translations/:locale/:state' => 'translations#show', :constraints => { state: /[^\/]+/ } # XLSX exports get 'exports/:id/download' => 'exports#download' @@ -166,12 +167,12 @@ Rails.application.routes.draw do end end - %w(account event machine project subscription training user space).each do |path| + %w[account event machine project subscription training user space].each do |path| post "/stats/#{path}/_search", to: "api/statistics##{path}" post "/stats/#{path}/export", to: "api/statistics#export_#{path}" end - post '/stats/global/export', to: "api/statistics#export_global" - post '_search/scroll', to: "api/statistics#scroll" + post '/stats/global/export', to: 'api/statistics#export_global' + post '_search/scroll', to: 'api/statistics#scroll' match '/project_collaborator/:valid_token', to: 'api/projects#collaborator_valid', via: :get