Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
AbanoubGhadban committed Aug 25, 2024
1 parent ce37122 commit bcfddd6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions lib/react_on_rails/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def build_react_component_result_for_server_streamed_content(
render_options: required("render_options")
)
is_first_chunk = true
rendered_html_stream = rendered_html_stream.transform do |chunk_json_result|
rendered_html_stream.transform do |chunk_json_result|
if is_first_chunk
is_first_chunk = false
next build_react_component_result_for_server_rendered_string(
Expand All @@ -411,7 +411,8 @@ def build_react_component_result_for_server_streamed_content(
end

result_console_script = render_options.replay_console ? chunk_json_result["consoleReplayScript"] : ""
# No need to prepend component_specification_tag or add rails context again as they're already included in the first chunk
# No need to prepend component_specification_tag or add rails context again
# as they're already included in the first chunk
compose_react_component_html_with_spec_and_console(
"", chunk_json_result["html"], result_console_script
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def reset_pool_if_server_bundle_was_modified
# Note, js_code does not have to be based on React.
# js_code MUST RETURN json stringify Object
# Calling code will probably call 'html_safe' on return value before rendering to the view.
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
# rubocop:disable Metrics/CyclomaticComplexity
def exec_server_render_js(js_code, render_options, js_evaluator = nil)
js_evaluator ||= self
if render_options.trace
Expand All @@ -57,10 +57,10 @@ def exec_server_render_js(js_code, render_options, js_evaluator = nil)
end
begin
result = if render_options.stream?
js_evaluator.eval_streaming_js(js_code, render_options)
else
js_evaluator.eval_js(js_code, render_options)
end
js_evaluator.eval_streaming_js(js_code, render_options)
else
js_evaluator.eval_js(js_code, render_options)
end
rescue StandardError => err
msg = <<~MSG
Error evaluating server bundle. Check your webpack configuration.
Expand All @@ -75,14 +75,14 @@ def exec_server_render_js(js_code, render_options, js_evaluator = nil)
end
raise ReactOnRails::Error, msg, err.backtrace
end

return parse_result_and_replay_console_messages(result, render_options) unless render_options.stream?

# Streamed component is returned as stream of strings.
# We need to parse each chunk and replay the console messages.
result.transform { |chunk| parse_result_and_replay_console_messages(chunk, render_options) }
end
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
# rubocop:enable Metrics/CyclomaticComplexity

def trace_js_code_used(msg, js_code, file_name = "tmp/server-generated.js", force: false)
return unless ReactOnRails.configuration.trace || force
Expand Down

0 comments on commit bcfddd6

Please sign in to comment.