Skip to content

Commit

Permalink
Add ESLint to webpacker config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodacious committed Sep 10, 2018
1 parent 36ba718 commit 27561a5
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ gem 'dragonfly'
gem 'bootstrap-sass', '~> 3.3.7'

# This is required for Font-Awesome, but not used as the main sass compiler

gem "sass-rails", require: false

gem "sassc-rails"

gem 'font-awesome-sass', '~> 4.2.0'

gem 'webpacker'
Expand Down
11 changes: 11 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,16 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sassc (1.12.1)
ffi (~> 1.9.6)
sass (>= 3.3.0)
sassc-rails (1.3.0)
railties (>= 4.0.0)
sass
sassc (~> 1.9)
sprockets (> 2.11)
sprockets-rails
tilt
sax-machine (1.3.2)
selenium-webdriver (3.14.0)
childprocess (~> 0.5)
Expand Down Expand Up @@ -474,6 +484,7 @@ DEPENDENCIES
rubocop-dmp_roadmap (>= 1.1.0)
ruby_dig
sass-rails
sassc-rails
selenium-webdriver (>= 3.13.1)
shoulda
simplecov
Expand Down
16 changes: 7 additions & 9 deletions app/assets/javascripts/views/org_admin/phases/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,21 @@ $(() => {
// How many modifiable sections are there?
const modifiableSections = draggableSections.has('[data-modifiable=true]').length;
// If all sections are modifiable, return false;
if (numberOfSections == modifiableSections) {
if (numberOfSections === modifiableSections) {
return false;
}
////
// Assuming all sections are NOT modifiable...

// A boolean to check if there a modifible prefix Section
const firS = draggableSections.has('[data-modifiable=true]:nth-child(1)').length == 1;
const prefix1 = draggableSections
.has('[data-modifiable=true]:nth-child(1)').length === 1;

// A boolean to check if there's a second prefix Section (this is invalid!)
const secS = draggableSections.has('[data-modifiable=true]:nth-child(2)').length == 1;
const prefix2 = draggableSections
.has('[data-modifiable=true]:nth-child(2)').length === 1;

if (firS && secS) {
return true;
} else {
return false;
}
// Return whether there are two prefixes or not?
return prefix1 && prefix2;
}

// Initialize the draggable-sections element as a jQuery sortable.
Expand Down
13 changes: 4 additions & 9 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Rails.application.config.assets.precompile += %w[
# *.ico *.png *.jpg *.jpeg *.gif
# ]

if Rails.env.staging? or Rails.env.production?

# Compress JavaScripts and CSS.
# Rails.application.config.assets.js_compressor = Uglifier.new(harmony: true)
# Rails.application.config.assets.js_compressor = nil

Rails.application.config.assets.css_compressor = :sass

Rails.application.config.sass.inline_source_maps = false

# Do not fallback to assets pipeline if a precompiled asset is missed.
Rails.application.config.assets.compile = false

Expand All @@ -19,11 +16,9 @@
# yet still be able to expire them through the digest params.
Rails.application.config.assets.digest = true

Rails.logger.debug("Digest: #{Rails.application.config.assets.digest}")

elsif Rails.env.development?

Rails.application.config.sass.inline_source_maps = false
Rails.application.config.sass.inline_source_maps = true

Rails.application.config.assets.compile = true

Expand Down
4 changes: 3 additions & 1 deletion config/webpack/environment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { environment } = require('@rails/webpacker')

const eslint = require('./loaders/eslint')
const webpack = require('webpack')

environment.plugins.append('Provide', new webpack.ProvidePlugin({
Expand All @@ -9,4 +9,6 @@ environment.plugins.append('Provide', new webpack.ProvidePlugin({
Popper: ['popper.js', 'default'],
}));

environment.loaders.prepend('ESLint', eslint)

module.exports = environment
5 changes: 0 additions & 5 deletions config/webpack/loaders/eslint.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// config/webpack/loaders/eslint.js
const { env } = require('../environment.js')

module.exports = {
enforce: 'pre',
test: /\.(js|jsx)$/i,
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
failOnError: env.NODE_ENV !== 'production'
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"@rails/webpacker": "3.5",
"bootstrap-sass": "3.3.7",
"chart.js": "^2.7.2",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-loader": "^2.1.0",
"jquery": "^3.3.1",
"jquery-accessible-autocomplete-list-aria": "^1.6.1",
"jquery-ui": "^1.12.1",
Expand All @@ -38,8 +40,6 @@
"babel-core": "^6.26.3",
"babel-loader": "7",
"eslint": "^5.5.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-loader": "^2.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-react": "^7.11.1",
"fixture": "^0.1.2",
Expand Down

0 comments on commit 27561a5

Please sign in to comment.