Class: Lintrunner::Parser::SCSSLint

Inherits:
Object
  • Object
show all
Defined in:
lib/lintrunner/parser/scss_lint.rb

Instance Method Summary collapse

Instance Method Details

#parse(output, exit_code, options = {}) ⇒ Object

Example output of scss-lint (using the json formatter): {

"app/styles/pages/delivery/_add_guests.scss": [
  {
    "line": 9,
    "column": 14,
    "length": 16,
    "severity": "warning",
    "reason": "Shorthand form for property `padding` should be written more concisely as `32px 70px 0` instead of `32px 70px 0 70px`",
    "linter": "Shorthand"
  }
]

}



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lintrunner/parser/scss_lint.rb', line 18

def parse(output, exit_code, options = {})
  return [] unless exit_code == 1

  messages = []
  JSON.parse(output).each do |filename, lints|
    lints.each do |lint|
      messages << Lintrunner::Message.new(
        filename: options[:filename] || filename,
        line: lint["line"],
        name: lint["linter"],
        description: lint["reason"])
    end
  end
  messages
end