Class: Danger::DangerEslint

Inherits:
Plugin
  • Object
show all
Defined in:
lib/eslint/plugin.rb

Overview

Lint javascript files using [eslint](eslint.org/). Results are send as inline commen.

Examples:

Run eslint with changed files only


eslint.filtering = true
eslint.lint

See Also:

  • leonhartX/danger-eslint

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#config_fileString

An path to eslint’s config file

Returns:

  • (String)


18
19
20
# File 'lib/eslint/plugin.rb', line 18

def config_file
  @config_file
end

#filteringBoolean

Enable filtering Only show messages within changed files.

Returns:

  • (Boolean)


27
28
29
# File 'lib/eslint/plugin.rb', line 27

def filtering
  @filtering
end

#ignore_fileString

An path to eslint’s ignore file

Returns:

  • (String)


22
23
24
# File 'lib/eslint/plugin.rb', line 22

def ignore_file
  @ignore_file
end

Instance Method Details

#lintvoid

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)



35
36
37
38
39
40
# File 'lib/eslint/plugin.rb', line 35

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