Class: Danger::DangerTextlint

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

Overview

[Danger](danger.systems/ruby/) plugin for [textlint](textlint.github.io/).

Examples:

Run textlint and send violations as inline comment.


# Lint added and modified files only
textlint.lint

Keep severity until warning. It allows merging pull request if there are violations remaining.


textlint.max_severity = "warn"
textlint.lint

Max inline comment number. If you want disable this feature, please set nil. Default: nil


textlint.max_comment_num = 5
textlint.lint

See Also:

  • Kesin11/danger-textlint

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#config_fileString

.textlintrc path

Returns:

  • (String)


28
29
30
# File 'lib/textlint/plugin.rb', line 28

def config_file
  @config_file
end

#max_comment_numString

Set max danger reporting comment number choice: nil or integer

Returns:

  • (String)


38
39
40
# File 'lib/textlint/plugin.rb', line 38

def max_comment_num
  @max_comment_num
end

#max_severityString

Set max danger reporting severity choice: nil or “warn”

Returns:

  • (String)


33
34
35
# File 'lib/textlint/plugin.rb', line 33

def max_severity
  @max_severity
end

Instance Method Details

#lintvoid

This method returns an undefined value.

Execute textlint and send comment



42
43
44
45
46
47
48
49
# File 'lib/textlint/plugin.rb', line 42

def lint
  return if target_files.empty?

  bin = textlint_path
  result_json = run_textlint(bin, target_files)
  errors = parse(result_json)
  send_comment(errors)
end