Class: Danger::DangerEslint
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerEslint
- Defined in:
- lib/eslint/plugin.rb
Overview
Lint javascript files using [eslint](eslint.org/). Results are send as inline commen.
Constant Summary collapse
- DEFAULT_BIN_PATH =
'./node_modules/.bin/eslint'
Instance Attribute Summary collapse
- #bin_path ⇒ Object
-
#config_file ⇒ String
An path to eslint’s config file.
-
#filtering ⇒ Boolean
Enable filtering Only show messages within changed files.
-
#ignore_file ⇒ String
An path to eslint’s ignore file.
- #target_extensions ⇒ Object
Instance Method Summary collapse
-
#lint ⇒ void
Lints javascript files.
Instance Attribute Details
#bin_path ⇒ Object
33 34 35 |
# File 'lib/eslint/plugin.rb', line 33 def bin_path @bin_path ||= DEFAULT_BIN_PATH end |
#config_file ⇒ String
An path to eslint’s config file
20 21 22 |
# File 'lib/eslint/plugin.rb', line 20 def config_file @config_file end |
#filtering ⇒ Boolean
Enable filtering Only show messages within changed files.
29 30 31 |
# File 'lib/eslint/plugin.rb', line 29 def filtering @filtering end |
#ignore_file ⇒ String
An path to eslint’s ignore file
24 25 26 |
# File 'lib/eslint/plugin.rb', line 24 def ignore_file @ignore_file end |
#target_extensions ⇒ Object
41 42 43 |
# File 'lib/eslint/plugin.rb', line 41 def target_extensions @target_extensions ||= %W(.js) end |
Instance Method Details
#lint ⇒ void
This method returns an undefined value.
Lints javascript files. Generates ‘errors` and `warnings` due to eslint’s config. Will try to send inline comment if supported(Github)
51 52 53 54 55 56 |
# File 'lib/eslint/plugin.rb', line 51 def lint lint_results .reject { |r| r.nil? || r['messages'].length.zero? } .reject { |r| r['messages'].first['message'].include? 'matching ignore pattern' } .map { |r| send_comment r } end |