From f54a4eca6713ecd41f26627d3e5616a8e4473f99 Mon Sep 17 00:00:00 2001 From: Alexander Momchilov Date: Tue, 3 Mar 2026 17:13:27 -0500 Subject: [PATCH 1/2] Migrate to RuboCop plugin system https://docs.rubocop.org/rubocop/latest/plugin_migration_guide.html --- Gemfile | 1 - Gemfile.lock | 3 +- lib/rubocop-type_toolkit.rb | 4 +- lib/rubocop/cop/type_toolkit/plugin.rb | 33 ++++ sorbet/rbi/gems/lint_roller@1.1.0.rbi | 204 +++++++++++++++++++++++++ sorbet/rbi/shims/lint_roller.rbi | 6 - type_toolkit.gemspec | 8 +- 7 files changed, 243 insertions(+), 16 deletions(-) create mode 100644 lib/rubocop/cop/type_toolkit/plugin.rb delete mode 100644 sorbet/rbi/shims/lint_roller.rbi diff --git a/Gemfile b/Gemfile index e8ab1c2..fc72a81 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,6 @@ gem "sorbet" gem "tapioca", ">= 0.17", require: false gem "minitest", "~> 5.16" -gem "rubocop", "~> 1.21" gem "rubocop-shopify", require: false gem "rubocop-minitest", require: false gem "rubocop-rake", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 2471da9..1ae54da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,6 +2,8 @@ PATH remote: . specs: type_toolkit (0.0.3) + lint_roller + rubocop (>= 1.72.0) GEM remote: https://rubygems.org/ @@ -124,7 +126,6 @@ DEPENDENCIES irb minitest (~> 5.16) rake (~> 13.0) - rubocop (~> 1.21) rubocop-minitest rubocop-rake rubocop-shopify diff --git a/lib/rubocop-type_toolkit.rb b/lib/rubocop-type_toolkit.rb index 8526e3e..d55e476 100644 --- a/lib/rubocop-type_toolkit.rb +++ b/lib/rubocop-type_toolkit.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true require "rubocop" - -RuboCop::ConfigLoader.inject_defaults!(File.join(__dir__, "..", "config", "default.yml")) - +require_relative "rubocop/cop/type_toolkit/plugin" require_relative "rubocop/cop/type_toolkit/dont_expect_unexpected_nil" diff --git a/lib/rubocop/cop/type_toolkit/plugin.rb b/lib/rubocop/cop/type_toolkit/plugin.rb new file mode 100644 index 0000000..9cbfa0e --- /dev/null +++ b/lib/rubocop/cop/type_toolkit/plugin.rb @@ -0,0 +1,33 @@ +# typed: false +# frozen_string_literal: true + +require "lint_roller" + +module RuboCop + module Cop + module TypeToolkit + class Plugin < LintRoller::Plugin + def about + LintRoller::About.new( + name: "rubocop-type_toolkit", + version: ::TypeToolkit::VERSION, + homepage: "https://github.com/Shopify/type_toolkit", + description: "Detects misuse of UnexpectedNilError.", + ) + end + + def supported?(context) + context.engine == :rubocop + end + + def rules(_context) + LintRoller::Rules.new( + type: :path, + config_format: :rubocop, + value: Pathname.new(__dir__).join("../../../../config/default.yml"), + ) + end + end + end + end +end diff --git a/sorbet/rbi/gems/lint_roller@1.1.0.rbi b/sorbet/rbi/gems/lint_roller@1.1.0.rbi index 789c5c9..db4caf6 100644 --- a/sorbet/rbi/gems/lint_roller@1.1.0.rbi +++ b/sorbet/rbi/gems/lint_roller@1.1.0.rbi @@ -8,6 +8,86 @@ # source://lint_roller//lib/lint_roller/context.rb#1 module LintRoller; end +# source://lint_roller//lib/lint_roller/about.rb#2 +class LintRoller::About < ::Struct + # Returns the value of attribute description + # + # @return [Object] the current value of description + # + # source://lint_roller//lib/lint_roller/about.rb#2 + def description; end + + # Sets the attribute description + # + # @param value [Object] the value to set the attribute description to. + # @return [Object] the newly set value + # + # source://lint_roller//lib/lint_roller/about.rb#2 + def description=(_); end + + # Returns the value of attribute homepage + # + # @return [Object] the current value of homepage + # + # source://lint_roller//lib/lint_roller/about.rb#2 + def homepage; end + + # Sets the attribute homepage + # + # @param value [Object] the value to set the attribute homepage to. + # @return [Object] the newly set value + # + # source://lint_roller//lib/lint_roller/about.rb#2 + def homepage=(_); end + + # Returns the value of attribute name + # + # @return [Object] the current value of name + # + # source://lint_roller//lib/lint_roller/about.rb#2 + def name; end + + # Sets the attribute name + # + # @param value [Object] the value to set the attribute name to. + # @return [Object] the newly set value + # + # source://lint_roller//lib/lint_roller/about.rb#2 + def name=(_); end + + # Returns the value of attribute version + # + # @return [Object] the current value of version + # + # source://lint_roller//lib/lint_roller/about.rb#2 + def version; end + + # Sets the attribute version + # + # @param value [Object] the value to set the attribute version to. + # @return [Object] the newly set value + # + # source://lint_roller//lib/lint_roller/about.rb#2 + def version=(_); end + + class << self + # source://lint_roller//lib/lint_roller/about.rb#2 + def [](*_arg0); end + + # source://lint_roller//lib/lint_roller/about.rb#2 + def inspect; end + + # source://lint_roller//lib/lint_roller/about.rb#2 + def keyword_init?; end + + # source://lint_roller//lib/lint_roller/about.rb#2 + def members; end + + # source://lint_roller//lib/lint_roller/about.rb#2 + def new(*_arg0); end + end +end + # source://lint_roller//lib/lint_roller/context.rb#2 class LintRoller::Context < ::Struct # Returns the value of attribute engine @@ -117,3 +197,127 @@ class LintRoller::Context < ::Struct def new(*_arg0); end end end + +# source://lint_roller//lib/lint_roller/error.rb#2 +class LintRoller::Error < ::StandardError; end + +# source://lint_roller//lib/lint_roller/plugin.rb#2 +class LintRoller::Plugin + # `config' is a Hash of options passed to the plugin by the user + # + # @return [Plugin] a new instance of Plugin + # + # source://lint_roller//lib/lint_roller/plugin.rb#4 + def initialize(config = T.unsafe(nil)); end + + # @raise [Error] + # + # source://lint_roller//lib/lint_roller/plugin.rb#8 + def about; end + + # `context' is an instance of LintRoller::Context provided by the runner + # + # @raise [Error] + # + # source://lint_roller//lib/lint_roller/plugin.rb#18 + def rules(context); end + + # `context' is an instance of LintRoller::Context provided by the runner + # + # @return [Boolean] + # + # source://lint_roller//lib/lint_roller/plugin.rb#13 + def supported?(context); end +end + +# source://lint_roller//lib/lint_roller/rules.rb#2 +class LintRoller::Rules < ::Struct + # Returns the value of attribute config_format + # + # @return [Object] the current value of config_format + # + # source://lint_roller//lib/lint_roller/rules.rb#2 + def config_format; end + + # Sets the attribute config_format + # + # @param value [Object] the value to set the attribute config_format to. + # @return [Object] the newly set value + # + # source://lint_roller//lib/lint_roller/rules.rb#2 + def config_format=(_); end + + # Returns the value of attribute error + # + # @return [Object] the current value of error + # + # source://lint_roller//lib/lint_roller/rules.rb#2 + def error; end + + # Sets the attribute error + # + # @param value [Object] the value to set the attribute error to. + # @return [Object] the newly set value + # + # source://lint_roller//lib/lint_roller/rules.rb#2 + def error=(_); end + + # Returns the value of attribute type + # + # @return [Object] the current value of type + # + # source://lint_roller//lib/lint_roller/rules.rb#2 + def type; end + + # Sets the attribute type + # + # @param value [Object] the value to set the attribute type to. + # @return [Object] the newly set value + # + # source://lint_roller//lib/lint_roller/rules.rb#2 + def type=(_); end + + # Returns the value of attribute value + # + # @return [Object] the current value of value + # + # source://lint_roller//lib/lint_roller/rules.rb#2 + def value; end + + # Sets the attribute value + # + # @param value [Object] the value to set the attribute value to. + # @return [Object] the newly set value + # + # source://lint_roller//lib/lint_roller/rules.rb#2 + def value=(_); end + + class << self + # source://lint_roller//lib/lint_roller/rules.rb#2 + def [](*_arg0); end + + # source://lint_roller//lib/lint_roller/rules.rb#2 + def inspect; end + + # source://lint_roller//lib/lint_roller/rules.rb#2 + def keyword_init?; end + + # source://lint_roller//lib/lint_roller/rules.rb#2 + def members; end + + # source://lint_roller//lib/lint_roller/rules.rb#2 + def new(*_arg0); end + end +end + +# source://lint_roller//lib/lint_roller/support/merges_upstream_metadata.rb#2 +module LintRoller::Support; end + +# source://lint_roller//lib/lint_roller/support/merges_upstream_metadata.rb#3 +class LintRoller::Support::MergesUpstreamMetadata + # source://lint_roller//lib/lint_roller/support/merges_upstream_metadata.rb#4 + def merge(plugin_yaml, upstream_yaml); end +end + +# source://lint_roller//lib/lint_roller/version.rb#2 +LintRoller::VERSION = T.let(T.unsafe(nil), String) diff --git a/sorbet/rbi/shims/lint_roller.rbi b/sorbet/rbi/shims/lint_roller.rbi deleted file mode 100644 index e7f750e..0000000 --- a/sorbet/rbi/shims/lint_roller.rbi +++ /dev/null @@ -1,6 +0,0 @@ -# typed: strict -# frozen_string_literal: true - -module LintRoller - class Plugin; end -end diff --git a/type_toolkit.gemspec b/type_toolkit.gemspec index 5f20457..bbe00b4 100644 --- a/type_toolkit.gemspec +++ b/type_toolkit.gemspec @@ -18,6 +18,7 @@ Gem::Specification.new do |spec| spec.metadata["allowed_push_host"] = "https://rubygems.org" spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = spec.homepage + spec.metadata["default_lint_roller_plugin"] = "RuboCop::Cop::TypeToolkit::Plugin" # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. @@ -32,9 +33,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - - # For more information and examples about making a new gem, check out our - # guide at: https://bundler.io/guides/creating_gem.html + spec.add_dependency("lint_roller") + spec.add_dependency("rubocop", ">= 1.72.0") end From 5659a13555e3ff198a9d591d23d5608015574642 Mon Sep 17 00:00:00 2001 From: Alexander Momchilov Date: Tue, 3 Mar 2026 17:31:37 -0500 Subject: [PATCH 2/2] Release `v0.0.4` --- Gemfile.lock | 4 ++-- lib/type_toolkit/version.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1ae54da..95a28e2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - type_toolkit (0.0.3) + type_toolkit (0.0.4) lint_roller rubocop (>= 1.72.0) @@ -179,7 +179,7 @@ CHECKSUMS tapioca (0.17.10) sha256=880a682ca8314f798dd09e9f104134fbf1a713c13be51f7dd4741dd434e6471b thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73 tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f - type_toolkit (0.0.3) + type_toolkit (0.0.4) unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42 unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f yard (0.9.38) sha256=721fb82afb10532aa49860655f6cc2eaa7130889df291b052e1e6b268283010f diff --git a/lib/type_toolkit/version.rb b/lib/type_toolkit/version.rb index 9a4c45e..28b7e5f 100644 --- a/lib/type_toolkit/version.rb +++ b/lib/type_toolkit/version.rb @@ -2,5 +2,5 @@ # frozen_string_literal: true module TypeToolkit - VERSION = "0.0.3" + VERSION = "0.0.4" end