Class: Pronto::ESLintNpm
- Inherits:
-
Runner
- Object
- Runner
- Pronto::ESLintNpm
- Defined in:
- lib/pronto/eslint_npm.rb
Constant Summary collapse
- CONFIG_FILE =
'.pronto_eslint_npm.yml'.freeze
- CONFIG_KEYS =
%w[eslint_executable files_to_lint cmd_line_opts].freeze
- SEVERITY_LEVELS =
[nil, :warning, :error].freeze
Instance Attribute Summary collapse
Instance Method Summary collapse
- #config_options ⇒ Object
- #files_to_lint ⇒ Object
- #files_to_lint=(regexp) ⇒ Object
- #read_config ⇒ Object
- #run ⇒ Object
Instance Attribute Details
#cmd_line_opts ⇒ Object
22 23 24 |
# File 'lib/pronto/eslint_npm.rb', line 22 def cmd_line_opts @cmd_line_opts || '' end |
#eslint_executable ⇒ Object
14 15 16 |
# File 'lib/pronto/eslint_npm.rb', line 14 def eslint_executable @eslint_executable || 'eslint' end |
Instance Method Details
#config_options ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/pronto/eslint_npm.rb', line 30 def @config_options ||= begin config_file = File.join(repo_path, CONFIG_FILE) File.exist?(config_file) && YAML.load_file(config_file) || {} end end |
#files_to_lint ⇒ Object
18 19 20 |
# File 'lib/pronto/eslint_npm.rb', line 18 def files_to_lint @files_to_lint || /(\.js|\.es6)$/ end |
#files_to_lint=(regexp) ⇒ Object
26 27 28 |
# File 'lib/pronto/eslint_npm.rb', line 26 def files_to_lint=(regexp) @files_to_lint = regexp.is_a?(Regexp) && regexp || Regexp.new(regexp) end |
#read_config ⇒ Object
38 39 40 41 42 43 |
# File 'lib/pronto/eslint_npm.rb', line 38 def read_config .each do |key, val| next unless CONFIG_KEYS.include?(key.to_s) send("#{key}=", val) end end |
#run ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pronto/eslint_npm.rb', line 45 def run return [] if !@patches || @patches.count.zero? read_config @patches .select { |patch| patch.additions > 0 } .select { |patch| js_file?(patch.new_file_full_path) } .map { |patch| inspect(patch) } .flatten.compact end |