diff --git a/CHANGELOG.md b/CHANGELOG.md index 89924738..ed669138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## main / unreleased * [ENHANCEMENT] Update QUnit to 2.22.0 +* [ENHANCEMENT] Prefer `require_relative` for internal requires ## 22.2.0 / 2026-06-01 diff --git a/lib/client_side_validations.rb b/lib/client_side_validations.rb index 4241790a..6ac6ead2 100644 --- a/lib/client_side_validations.rb +++ b/lib/client_side_validations.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'client_side_validations/config' -require 'client_side_validations/active_model' if defined?(ActiveModel) -require 'client_side_validations/active_record' if defined?(ActiveRecord) -require 'client_side_validations/action_view' if defined?(ActionView) +require_relative 'client_side_validations/config' +require_relative 'client_side_validations/active_model' if defined?(ActiveModel) +require_relative 'client_side_validations/active_record' if defined?(ActiveRecord) +require_relative 'client_side_validations/action_view' if defined?(ActionView) if defined?(Rails) - require 'client_side_validations/engine' - require 'client_side_validations/generators' + require_relative 'client_side_validations/engine' + require_relative 'client_side_validations/generators' end diff --git a/lib/client_side_validations/action_view.rb b/lib/client_side_validations/action_view.rb index 1d808cf7..71a805ca 100644 --- a/lib/client_side_validations/action_view.rb +++ b/lib/client_side_validations/action_view.rb @@ -7,14 +7,14 @@ module Helpers end end -require 'client_side_validations/core_ext' -require 'client_side_validations/action_view/form_helper' +require_relative 'core_ext' +require_relative 'action_view/form_helper' if ActionView::Helpers::FormHelper.method_defined?(:form_with) - require 'client_side_validations/action_view/form_with_helper' + require_relative 'action_view/form_with_helper' end -require 'client_side_validations/action_view/form_builder' +require_relative 'action_view/form_builder' ActiveSupport.on_load(:action_view) { include ClientSideValidations::ActionView::Helpers::FormHelper } ActionView::Helpers::FormBuilder.prepend ClientSideValidations::ActionView::Helpers::FormBuilder diff --git a/lib/client_side_validations/active_model.rb b/lib/client_side_validations/active_model.rb index a492f6db..d9a1bf07 100644 --- a/lib/client_side_validations/active_model.rb +++ b/lib/client_side_validations/active_model.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require 'client_side_validations/core_ext' -require 'client_side_validations/extender' -require 'client_side_validations/active_model/conditionals' +require_relative 'core_ext' +require_relative 'extender' +require_relative 'active_model/conditionals' module ClientSideValidations module ActiveModel diff --git a/lib/client_side_validations/active_record.rb b/lib/client_side_validations/active_record.rb index a5afffd9..98160fe3 100644 --- a/lib/client_side_validations/active_record.rb +++ b/lib/client_side_validations/active_record.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true -require 'client_side_validations/active_model' -require 'client_side_validations/extender' +require_relative 'active_model' ActiveSupport.on_load(:active_record) { include ClientSideValidations::ActiveModel::Validations } diff --git a/lib/client_side_validations/core_ext.rb b/lib/client_side_validations/core_ext.rb index 21166651..9cadab94 100644 --- a/lib/client_side_validations/core_ext.rb +++ b/lib/client_side_validations/core_ext.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true require 'active_support/json' -require 'client_side_validations/core_ext/range' -require 'client_side_validations/core_ext/regexp' + +require_relative 'core_ext/range' +require_relative 'core_ext/regexp' diff --git a/lib/client_side_validations/generators.rb b/lib/client_side_validations/generators.rb index 9a8d376e..76070741 100644 --- a/lib/client_side_validations/generators.rb +++ b/lib/client_side_validations/generators.rb @@ -14,4 +14,4 @@ def self.assets end end -require 'client_side_validations/generators/rails_validations' +require_relative 'generators/rails_validations'