Class: RogerEslint::Lint
- Inherits:
-
Object
- Object
- RogerEslint::Lint
- Defined in:
- lib/roger_eslint/lint.rb
Overview
JS linter plugin for Roger
Constant Summary collapse
- ESLINT_SEVERITIES =
ESLint severities translated into a human readable format
{ 1 => "Warning", 2 => "Error" }.freeze
Instance Method Summary collapse
- #call(test, options) ⇒ Object
-
#initialize(options = {}) ⇒ Lint
constructor
A new instance of Lint.
-
#lint(test, file_paths) ⇒ Array
Failed files.
Constructor Details
#initialize(options = {}) ⇒ Lint
Returns a new instance of Lint.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/roger_eslint/lint.rb', line 23 def initialize( = {}) @options = { match: ["html/**/*.js"], skip: [%r{vendor\/.*\.js\Z}], fail_on_warning: false, eslint: nil, eslint_options: [] } @options.update() if end |
Instance Method Details
#call(test, options) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/roger_eslint/lint.rb', line 46 def call(test, ) @_call_options = {}.update(@options).update() detect_eslint(test) test.log(self, "ESLinting files") files = test.get_files(@_call_options[:match], @_call_options[:skip]) lint(test, files).empty? ensure @_call_options = {} end |
#lint(test, file_paths) ⇒ Array
Returns failed files.
36 37 38 39 40 41 |
# File 'lib/roger_eslint/lint.rb', line 36 def lint(test, file_paths) output = `#{eslint_command(file_paths)}` file_lints = JSON.parse(output) process_lint_results(test, file_lints) end |