Skip to content

Commit

Permalink
eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Apr 14, 2019
1 parent 5e42165 commit 60b1ac7
Show file tree
Hide file tree
Showing 8 changed files with 815 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ config/settings/*.local.yml
coverage
doc
log
node_modules
public/assets
public/attachments
public/export
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ before_script:
- touch config/settings.local.yml
- bundle exec rake db:migrate
- bundle exec rake i18n:js:export
- bundle exec rake yarn:install
script:
- bundle exec rubocop -f fuubar
- bundle exec rake eslint:run_all
- bundle exec rake eslint
- bundle exec erblint .
- bundle exec rake test:db
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ group :development, :test do
gem "capybara", "~> 2.13"
gem "coveralls", :require => false
gem "erb_lint", :require => false
gem "eslint-rails-ee"
gem "execjs"
gem "factory_bot_rails"
gem "poltergeist"
gem "puma", "~> 3.7"
gem "therubyracer", :platforms => :ruby
end
13 changes: 0 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
colorize (0.8.1)
composite_primary_keys (11.1.0)
activerecord (~> 5.2.1)
concurrent-ruby (1.1.5)
Expand Down Expand Up @@ -162,10 +161,6 @@ GEM
rubocop (~> 0.51)
smart_properties
erubi (1.8.0)
eslint-rails-ee (1.0.2)
colorize
execjs
railties (>= 3.2)
execjs (2.7.0)
exifr (1.3.6)
factory_bot (5.0.2)
Expand Down Expand Up @@ -218,7 +213,6 @@ GEM
jwt (2.1.0)
kgio (2.11.2)
kramdown (2.1.0)
libv8 (3.16.14.19)
libxml-ruby (3.1.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand Down Expand Up @@ -359,7 +353,6 @@ GEM
ffi (~> 1.0)
record_tag_helper (1.0.0)
actionview (~> 5.x)
ref (2.0.0)
request_store (1.4.1)
rack (>= 1.4)
rinku (2.0.4)
Expand Down Expand Up @@ -408,9 +401,6 @@ GEM
tins (~> 1.0)
terrapin (0.6.0)
climate_control (>= 0.0.3, < 1.0)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.9)
Expand Down Expand Up @@ -460,8 +450,6 @@ DEPENDENCIES
delayed_job_active_record
dynamic_form
erb_lint
eslint-rails-ee
execjs
factory_bot_rails
fakefs
faraday
Expand Down Expand Up @@ -508,7 +496,6 @@ DEPENDENCIES
sanitize
sassc-rails
secure_headers
therubyracer
uglifier (>= 1.3.0)
validates_email_format_of (>= 1.5.1)
vendorer
Expand Down
7 changes: 7 additions & 0 deletions config/eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
"eol-last": "error",
"eqeqeq": ["error", "smart"],
"func-call-spacing": "error",
"indent": ["error", 2, {
"SwitchCase": 1,
"VariableDeclarator": "first",
"FunctionDeclaration": { "parameters": "first" },
"FunctionExpression": { "parameters": "first" },
"CallExpression": { "arguments": "first" }
}],
"key-spacing": "error",
"keyword-spacing": "error",
"no-alert": "warn",
Expand Down
27 changes: 27 additions & 0 deletions lib/tasks/eslint.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
task "eslint" => "eslint:check"

namespace "eslint" do
def yarn_path
Rails.root.join("bin", "yarn").to_s
end

def config_file
Rails.root.join("config", "eslint.json").to_s
end

def js_files
require File.dirname(__FILE__) + "/../../config/environment"

Rails.application.assets.each_file.select do |file|
file.ends_with?(".js") && !file.match?(%r{/(gems|vendor|i18n)/})
end
end

task :check do
system(yarn_path, "run", "eslint", "-c", config_file, *js_files) || abort
end

task :fix do
system(yarn_path, "run", "eslint", "-c", config_file, "--fix", *js_files) || abort
end
end
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "openstreetmap",
"private": true,
"dependencies": {
},
"devDependencies": {
"eslint": "*"
}
}
Loading

0 comments on commit 60b1ac7

Please sign in to comment.