Class: Standard::Erb::Plugin

Inherits:
LintRoller::Plugin
  • Object
show all
Defined in:
lib/standard/erb/plugin.rb

Constant Summary collapse

INVALID_UPSTREAM_ENTRIES =

Entries in rubocop-erb's config/default.yml that fail RuboCop's config validation. Plain RuboCop never validates plugin configs, but Standard does, so these are fatal under standardrb.

The goal state is for upstream's config to load clean and this list to be empty. Whenever rubocop-erb fixes one of these, delete it here and bump the minimum rubocop-erb version.

  • Layout/LeadingEmptyLine: dead cop name (the real cop is Layout/LeadingEmptyLines, which upstream also configures).
  • Lint/Syntax: RuboCop forbids configuring this cop at all under validation, so it can't be fixed upstream. The ignore block in the README restores upstream's intent (no syntax diagnostics on .erb).
["Layout/LeadingEmptyLine", "Lint/Syntax"].freeze

Instance Method Summary collapse

Instance Method Details

#aboutObject



26
27
28
29
30
31
32
33
# File 'lib/standard/erb/plugin.rb', line 26

def about
  LintRoller::About.new(
    name: "standard-erb",
    version: VERSION,
    homepage: "https://github.com/foca/standard-erb",
    description: "Lint ERB templates with rubocop-erb under Standard"
  )
end

#rules(_context) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/standard/erb/plugin.rb', line 39

def rules(_context)
  register_ruby_extractor

  LintRoller::Rules.new(
    config_format: :rubocop,
    type: :object,
    value: upstream_config.except(*INVALID_UPSTREAM_ENTRIES)
  )
end

#supported?(context) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/standard/erb/plugin.rb', line 35

def supported?(context)
  context.engine == :rubocop
end