Sha256: 401b5ed5f7f0af85df890a683998343f43f981561fe9bdcdc26f1d772ca04db3
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
require 'slim_lint' module Danger # Lints Slim files via [slim-lint](https://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 class DangerSlimLint < Plugin # Runs Slim files through slim-lint. # @return [Array<SlimLint::Lint, nil>] def lint files_to_lint = fetch_files_to_lint lint_errors = run_linter(files_to_lint) warn_each_line(lint_errors) end private def run_linter(files_to_lint) runner = ::SlimLint::Runner.new runner.run(files: files_to_lint).lints end 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 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 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
danger-slim_lint-0.1.2 | lib/slim_lint/plugin.rb |
danger-slim_lint-0.1.1 | lib/slim_lint/plugin.rb |
danger-slim_lint-0.1.0 | lib/slim_lint/plugin.rb |