Skip to content

Instantly share code, notes, and snippets.

@kaspernj
Created August 18, 2019 11:41
Show Gist options
  • Save kaspernj/83a6082033d275e4779221311abd9579 to your computer and use it in GitHub Desktop.
Save kaspernj/83a6082033d275e4779221311abd9579 to your computer and use it in GitHub Desktop.
class ScssLintConfigGenerator < ApplicationService
def execute
output = %x[scss-lint]
todo_config = {
"linters" => {}
}
output.scan(/^(.+):(\d+):(\d+) \[(.)\] (.+?): (.+)$/) do |match|
file_path, line, column, offence_type, linter_name, description = match
file = "/#{file_path}"
# puts "file_path: #{file_path}"
# puts "line: #{line}"
# puts "offence_type: #{offence_type}"
puts "linter_name: #{linter_name}"
# puts "description: #{description}"
puts
todo_config.fetch("linters")[linter_name] ||= {"exclude" => []}
unless todo_config.fetch("linters").fetch(linter_name).fetch("exclude").include?(file_path)
todo_config.fetch("linters").fetch(linter_name).fetch("exclude") << file_path
end
end
todo_config.fetch("linters").each_value do |linter_config|
linter_config.fetch("exclude").sort!
end
todo_config["linters"] = todo_config.fetch("linters").sort.to_h
puts todo_config.to_yaml
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment