class Danger::DangerSlimLint
Lints Slim files via [slim-lint](rubygems.org/gems/slim_lint). Results are sent as inline comments.
@example Running slim-lint
# Runs slim-lint on modified and added files in the PR slim_lint.lint
@see blooper05/danger-slim_lint @tags slim, ruby, slim-lint, lint
Public Instance Methods
lint()
click to toggle source
Runs Slim files through slim-lint. @return [Array<SlimLint::Lint, nil>]
# File lib/slim_lint/plugin.rb, line 17 def lint files_to_lint = fetch_files_to_lint lint_errors = run_linter(files_to_lint) warn_each_line(lint_errors) end
Private Instance Methods
fetch_files_to_lint()
click to toggle source
# File lib/slim_lint/plugin.rb, line 30 def fetch_files_to_lint files = git.modified_files + git.added_files files.select do |file| ::SlimLint::FileFinder::VALID_EXTENSIONS.include?(File.extname(file)) end end
run_linter(files_to_lint)
click to toggle source
# File lib/slim_lint/plugin.rb, line 25 def run_linter(files_to_lint) runner = ::SlimLint::Runner.new runner.run(files: files_to_lint).lints end
warn_each_line(lint_errors)
click to toggle source
# File lib/slim_lint/plugin.rb, line 37 def warn_each_line(lint_errors) current_dir = "#{Dir.pwd}/" lint_errors.each do |error| message = error.message file = error.filename.sub(current_dir, '') line = error.line warn(message, file: file, line: line) end end