Class: Appium::Lint::LineBreakInvalid

Inherits:
Base
  • Object
show all
Defined in:
lib/appium_doc_lint/lint/line_break_invalid.rb

Overview

line breaks such as ‘–` and `—` shouldn’t be used on Slate. They will cause problems such as null divs

Constant Summary collapse

FAIL =
'`--` and `---` line breaks must not be used. Delete them.'

Instance Attribute Summary

Attributes inherited from Base

#input, #warnings

Instance Method Summary collapse

Methods inherited from Base

#initialize, #warn

Constructor Details

This class inherits a constructor from Appium::Lint::Base

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/appium_doc_lint/lint/line_break_invalid.rb', line 7

def call
  previous_line = ''
  input.lines.each_with_index do |line, index|
    # If the previous line isn't empty then --- createa a h2 not a line break.
    previous_line_empty = previous_line.match(/^\s*$/)
    line_break_invalid  = previous_line_empty && line.match(/^--+\s*$/)
    warn index if line_break_invalid

    previous_line = line
  end

  warnings
end

#failObject



23
24
25
# File 'lib/appium_doc_lint/lint/line_break_invalid.rb', line 23

def fail
  FAIL
end