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 8bb8ce3
Show file tree
Hide file tree
Showing 6 changed files with 807 additions and 1 deletion.
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
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
19 changes: 19 additions & 0 deletions lib/tasks/eslint.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
task "eslint" => "eslint:check"

namespace "eslint" do
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(Rails.root.join("bin", "yarn").to_s, "exec", "eslint", "-c", "config/eslint.json", *js_files)
end

task :fix do
system(Rails.root.join("bin", "yarn").to_s, "exec", "eslint", "-c", "config/eslint.json", "--fix", *js_files)
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 8bb8ce3

Please sign in to comment.