diff --git a/.jshintignore b/.jshintignore new file mode 120000 index 00000000000..e650afb0573 --- /dev/null +++ b/.jshintignore @@ -0,0 +1 @@ +config/.jshint_ignore \ No newline at end of file diff --git a/.jshintrc b/.jshintrc new file mode 120000 index 00000000000..2c12c8897ed --- /dev/null +++ b/.jshintrc @@ -0,0 +1 @@ +config/.jshint.json \ No newline at end of file diff --git a/Gemfile b/Gemfile index 44bb174cc4a..4e9f2368cd7 100644 --- a/Gemfile +++ b/Gemfile @@ -213,6 +213,7 @@ end group :development do # Automatic test runs gem "guard-cucumber", "1.5.3" + gem "guard-jshintrb", "1.1.1" gem "guard-rspec", "4.5.0" gem "guard-rubocop", "1.2.0" gem "guard", "2.12.4", require: false @@ -220,8 +221,8 @@ group :development do gem "rb-inotify", "0.9.5", require: false # Linters - gem "jshint", "1.3.1" - gem "rubocop", "0.29.1" + gem "jshintrb", "0.3.0" + gem "rubocop", "0.29.1" # Preloading environment diff --git a/Gemfile.lock b/Gemfile.lock index 209f386806f..613ff7dec39 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -317,6 +317,9 @@ GEM guard (>= 2.0.0) guard-compat (~> 1.0) nenv (~> 0.1) + guard-jshintrb (1.1.1) + guard (~> 2.0) + jshintrb guard-rspec (4.5.0) guard (~> 2.1) guard-compat (~> 1.1) @@ -366,17 +369,16 @@ GEM sprockets-rails js_image_paths (0.0.2) rails (~> 4.0) - jshint (1.3.1) - execjs (>= 1.4.0) - multi_json (~> 1.0) - therubyracer (~> 0.12.1) + jshintrb (0.3.0) + execjs + multi_json (>= 1.3) + rake json (1.8.2) jwt (1.3.0) kaminari (0.16.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) kgio (2.9.3) - libv8 (3.16.14.7) listen (2.8.5) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) @@ -566,7 +568,6 @@ GEM redis (3.2.1) redis-namespace (1.5.1) redis (~> 3.0, >= 3.0.4) - ref (1.0.5) remotipart (1.2.1) request_store (1.1.0) responders (2.1.0) @@ -656,9 +657,6 @@ GEM systemu (2.6.4) test_after_commit (0.4.0) activerecord (>= 3.2) - therubyracer (0.12.1) - libv8 (~> 3.16.14.0) - ref thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) @@ -736,6 +734,7 @@ DEPENDENCIES gon (= 5.2.3) guard (= 2.12.4) guard-cucumber (= 1.5.3) + guard-jshintrb (= 1.1.1) guard-rspec (= 4.5.0) guard-rubocop (= 1.2.0) haml (= 4.0.6) @@ -747,7 +746,7 @@ DEPENDENCIES jquery-rails (= 3.1.2) js-routes (= 1.0.0) js_image_paths (= 0.0.2) - jshint (= 1.3.1) + jshintrb (= 0.3.0) json (= 1.8.2) markerb (= 1.0.2) messagebus_ruby_api (= 1.0.3) diff --git a/Guardfile b/Guardfile index df294bb7fc8..ec3eade0c65 100644 --- a/Guardfile +++ b/Guardfile @@ -37,3 +37,9 @@ guard :rubocop, all_on_start: false, keep_failed: false do watch(/(?:app|config|db|lib|features|spec)\/.+\.rb$/) watch(/(config.ru|Gemfile|Guardfile|Rakefile)$/) end + +guard :jshintrb do + watch(/^app\/assets\/javascripts\/.+\.js$/) + watch(/^lib\/assets\/javascripts\/.+\.js$/) + watch(/^spec\/javascripts\/.+\.js$/) +end diff --git a/config/.jshint_ignore b/config/.jshint_ignore index 9ff1b592649..59dc22151bc 100644 --- a/config/.jshint_ignore +++ b/config/.jshint_ignore @@ -2,4 +2,3 @@ vendor/assets/javascripts/**.js lib/assets/javascripts/fileuploader-custom.js lib/assets/javascripts/jquery.autoresize.js lib/assets/javascripts/jquery.mentionsInput.js -lib/assets/javascripts/markdown-it-diaspora-linkify.js diff --git a/config/jshint.yml b/config/jshint.yml deleted file mode 100644 index 599914bb454..00000000000 --- a/config/jshint.yml +++ /dev/null @@ -1,74 +0,0 @@ -files: ['**/*.js'] - -exclude_paths: [ - 'vendor/assets/javascripts', - 'lib/assets/javascripts' -] - -options: - # enforcing options - bitwise: true - camelcase: false - curly: true - eqeqeq: true - forin: true - freeze: true - immed: true - indent: 2 - latedef: true - maxlen: false - newcap: true - noarg: true - noempty: true - nonbsp: true - nonew: false - quotmark: false - undef: true - unused: true - - # relaxing options - asi: false - boss: false - browser: true - devel: true - eqnull: true - evil: false - expr: false - jasmine: true - jquery: true - lastsemic: true - laxbreak: false - laxcomma: false - loopfunc: false - notypeof: false - scripturl: false - sub: false - supernew: true - - globals: - "_": true - "Backbone": true - "gon": true - "Handlebars": true - "HandlebarsTemplates": true - "ImagePaths": true - "jsxc": true - "MBP": true - "Routes": true - "OSM": true - "parse_url": true - "punycode": true - "qq": true - - "loginAs": true - "logout": true - "spec": true - "context": true - "factory": true - "stubView": true - "exports": true - - "app": true - "Diaspora": true - "Mentions": true - "PosixBracketExpressions": true diff --git a/lib/tasks/linter.rake b/lib/tasks/linter.rake new file mode 100644 index 00000000000..c533ad8206c --- /dev/null +++ b/lib/tasks/linter.rake @@ -0,0 +1,12 @@ +begin + require "jshintrb/jshinttask" + Jshintrb::JshintTask.new :jshint do |t| + t.pattern = "{app/assets,lib/assets,spec}/javascripts/**/*.js" + t.options = :jshintrc + end +rescue LoadError + desc "jshint rake task not available (jshintrb not installed)" + task :jshint do + abort "JSHint rake task is not available. Be sure to install jshintrb." + end +end