Skip to content

Commit 6547688

Browse files
JudahmeekAbanoubGhadban
authored andcommitted
rubocop linting
1 parent 2fd5c35 commit 6547688

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

lib/react_on_rails/helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def internal_rsc_react_component(react_component_name, options = {})
436436
render_options = create_render_options(react_component_name, options)
437437
json_stream = server_rendered_react_component(render_options)
438438
json_stream.transform do |chunk|
439-
(chunk.to_json + "\n").html_safe
439+
"#{chunk.to_json}\n".html_safe
440440
end
441441
end
442442

lib/react_on_rails/packs_generator.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def create_pack(file_path)
4444
puts(Rainbow("Generated Packs: #{output_path}").yellow)
4545
end
4646

47+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
4748
def first_js_statement_in_code(content)
49+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
4850
return "" if content.nil? || content.empty?
4951

5052
start_index = 0
@@ -89,7 +91,8 @@ def client_entrypoint?(file_path)
8991

9092
def pack_file_contents(file_path)
9193
registered_component_name = component_name(file_path)
92-
load_server_components = ReactOnRails::Utils.react_on_rails_pro? && ReactOnRailsPro.configuration.enable_rsc_support
94+
load_server_components = ReactOnRails::Utils.react_on_rails_pro? &&
95+
ReactOnRailsPro.configuration.enable_rsc_support
9396

9497
if load_server_components && !client_entrypoint?(file_path)
9598
rsc_rendering_url_path = ReactOnRailsPro.configuration.rsc_rendering_url_path

spec/dummy/spec/packs_generator_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module ReactOnRails
8282
it "generated pack for ComponentWithCommonOnly uses common file for pack" do
8383
pack_content = File.read(component_pack)
8484

85-
expect(pack_content).to include("#{component_namspec / dummy / spec / packs_generator_spec.rbe}.jsx")
85+
expect(pack_content).to include("#{component_name / dummy / spec / packs_generator_spec.rbe}.jsx")
8686
expect(pack_content).not_to include("#{component_name}.client.jsx")
8787
expect(pack_content).not_to include("#{component_name}.server.jsx")
8888
end
@@ -434,7 +434,7 @@ def stub_packer_source_path(packer_source_path:, component_name:)
434434
end
435435

436436
context "with string directive" do
437-
context "on top of the file" do
437+
context "when on top of the file" do
438438
let(:content) do
439439
<<~JS
440440
"use client";
@@ -446,13 +446,13 @@ def stub_packer_source_path(packer_source_path:, component_name:)
446446
it { is_expected.to eq '"use client";' }
447447
end
448448

449-
context "on top of the file and one line comment" do
449+
context "when on top of the file and one line comment" do
450450
let(:content) { '"use client"; // const x = 1' }
451451

452452
it { is_expected.to eq '"use client"; // const x = 1' }
453453
end
454454

455-
context "after some one-line comments" do
455+
context "when after some one-line comments" do
456456
let(:content) do
457457
<<~JS
458458
// First comment
@@ -464,7 +464,7 @@ def stub_packer_source_path(packer_source_path:, component_name:)
464464
it { is_expected.to eq '"use client";' }
465465
end
466466

467-
context "after some multi-line comments" do
467+
context "when after some multi-line comments" do
468468
let(:content) do
469469
<<~JS
470470
/* First comment */
@@ -478,7 +478,7 @@ def stub_packer_source_path(packer_source_path:, component_name:)
478478
it { is_expected.to eq '"use client";' }
479479
end
480480

481-
context "after some mixed comments" do
481+
context "when after some mixed comments" do
482482
let(:content) do
483483
<<~JS
484484
// First comment
@@ -492,7 +492,7 @@ def stub_packer_source_path(packer_source_path:, component_name:)
492492
it { is_expected.to eq '"use client";' }
493493
end
494494

495-
context "after any non-comment code" do
495+
context "when after any non-comment code" do
496496
let(:content) do
497497
<<~JS
498498
// First comment

0 commit comments

Comments
 (0)