Skip to content

Commit fbf66a6

Browse files
linting
1 parent fae3158 commit fbf66a6

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

lib/react_on_rails/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def validate_generated_component_packs_loading_strategy
173173
raise ReactOnRails::Error, msg
174174
end
175175

176-
return if [:async, :defer, :sync].include?(generated_component_packs_loading_strategy)
176+
return if %i[async defer sync].include?(generated_component_packs_loading_strategy)
177177

178178
raise ReactOnRails::Error, "generated_component_packs_loading_strategy must be either :async, :defer, or :sync"
179179
end

lib/react_on_rails/helper.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,7 @@ def load_pack_for_generated_component(react_component_name, render_options)
427427
# Old versions of Shakapacker don't support async script tags.
428428
# ReactOnRails.configure already validates if async loading is supported by the installed Shakapacker version.
429429
# Therefore, we only need to pass the async option if the loading strategy is explicitly set to :async
430-
if ReactOnRails.configuration.generated_component_packs_loading_strategy == :async
431-
options[:async] = true
432-
end
430+
options[:async] = true if ReactOnRails.configuration.generated_component_packs_loading_strategy == :async
433431
append_javascript_pack_tag("generated/#{react_component_name}", **options)
434432
append_stylesheet_pack_tag("generated/#{react_component_name}")
435433
end

spec/dummy/spec/helpers/react_on_rails_helper_spec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,19 @@ class PlainReactOnRailsHelper
6363
original_append_javascript_pack_tag = helper.method(:append_javascript_pack_tag)
6464
begin
6565
# Temporarily redefine append_javascript_pack_tag to handle the async keyword argument.
66-
# This is needed because older versions of Shakapacker (which may be used during testing) don't support async loading,
67-
# but we still want to test that the async option is passed correctly when enabled.
66+
# This is needed because older versions of Shakapacker (which may be used during testing)
67+
# don't support async loading, but we still want to test that the async option is passed
68+
# correctly when enabled.
6869
def helper.append_javascript_pack_tag(name, **options)
6970
original_append_javascript_pack_tag.call(name, **options)
7071
end
7172
allow(helper).to receive(:append_javascript_pack_tag)
7273
allow(helper).to receive(:append_stylesheet_pack_tag)
7374
expect { helper.load_pack_for_generated_component("component_name", render_options) }.not_to raise_error
74-
expect(helper).to have_received(:append_javascript_pack_tag).with("generated/component_name", { defer: false, async: true })
75+
expect(helper).to have_received(:append_javascript_pack_tag).with(
76+
"generated/component_name",
77+
{ defer: false, async: true }
78+
)
7579
expect(helper).to have_received(:append_stylesheet_pack_tag).with("generated/component_name")
7680
ensure
7781
helper.define_singleton_method(:append_javascript_pack_tag, original_append_javascript_pack_tag)

0 commit comments

Comments
 (0)