Class: Standard::Sorbet::Plugin

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Plugin

Returns a new instance of Plugin.



3
4
5
6
# File 'lib/standard/sorbet/plugin.rb', line 3

def initialize(config)
  @config = config
  @merges_upstream_metadata = LintRoller::Support::MergesUpstreamMetadata.new
end

Instance Method Details

#aboutObject



8
9
10
11
12
13
14
15
# File 'lib/standard/sorbet/plugin.rb', line 8

def about
  LintRoller::About.new(
    name: "standard-sorbet",
    version: VERSION,
    homepage: "https://github.com/standardrb/standard-sorbet",
    description: "Configuration for rubocop-sorbet's rules"
  )
end

#rules(context) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/standard/sorbet/plugin.rb', line 21

def rules(context)
  trick_rubocop_into_thinking_we_required_rubocop_sorbet!

  rules = @merges_upstream_metadata.merge(
    YAML.load_file(Pathname.new(__dir__).join("../../../config/base.yml")),
    YAML.load_file(Pathname.new(Gem.loaded_specs["rubocop-sorbet"].full_gem_path).join("config/default.yml"))
  )

  LintRoller::Rules.new(
    type: :object,
    config_format: :rubocop,
    value: rules
  )
end

#supported?(context) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/standard/sorbet/plugin.rb', line 17

def supported?(context)
  true
end