Skip to content

Commit b2a855d

Browse files
justin808claude
andcommitted
Polish configuration and improve code clarity
## Changes ### RuboCop Configuration - Exclude bin/* shell scripts from RuboCop checks ### Configuration Improvements - Fix error message wording in configuration.rb (prefer :defer over :sync) - Add explanatory comment in context.ts about TypeScript var requirement - Improve ESLint config formatting (export at top, add deprecation disable) - Add clarifying comment in helper spec about defer default strategy These are small polish changes that improve code clarity and fix minor inconsistencies. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 28405e3 commit b2a855d

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ AllCops:
2525
- '**/node_modules/**/*'
2626
- '**/public/**/*'
2727
- '**/tmp/**/*'
28+
- 'bin/*' # Shell scripts
2829
- 'coverage/**/*'
2930
- 'gen-examples/examples/**/*'
3031
- 'node_modules/**/*'

eslint.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const compat = new FlatCompat({
1616
allConfig: js.configs.all,
1717
});
1818

19-
const config = tsEslint.config([
19+
// eslint-disable-next-line @typescript-eslint/no-deprecated
20+
export default tsEslint.config([
2021
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2122
includeIgnoreFile(path.resolve(__dirname, '.gitignore')),
2223
globalIgnores([
@@ -266,5 +267,3 @@ const config = tsEslint.config([
266267
// https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#configuration-new-eslintconfigjs
267268
prettierRecommended,
268269
]);
269-
270-
export default config;

lib/react_on_rails/configuration.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ def validate_generated_component_packs_loading_strategy
172172

173173
msg = <<~MSG
174174
ReactOnRails: Your current version of shakapacker \
175-
does not support async script loading, which may cause performance issues. Please either:
176-
1. Use :sync or :defer loading strategy instead of :async
175+
does not support async script loading. Please either:
176+
1. Use :defer or :sync loading strategy instead of :async
177177
2. Upgrade to Shakapacker v8.2.0 or above to enable async script loading
178178
MSG
179179
if generated_component_packs_loading_strategy.nil?

packages/react-on-rails/src/context.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type { ReactOnRailsInternal, RailsContext } from './types/index.ts';
22

33
declare global {
4-
/* eslint-disable no-var,vars-on-top,no-underscore-dangle */
4+
// TypeScript requires 'var' (not 'let') in 'declare global' for proper global scope augmentation across modules
5+
/* eslint-disable no-underscore-dangle, vars-on-top */
56
var ReactOnRails: ReactOnRailsInternal | undefined;
67
var __REACT_ON_RAILS_EVENT_HANDLERS_RAN_ONCE__: boolean;
7-
/* eslint-enable no-var,vars-on-top,no-underscore-dangle */
8+
/* eslint-enable no-underscore-dangle, vars-on-top */
89
}
910

1011
let currentRailsContext: RailsContext | null = null;

spec/dummy/spec/helpers/react_on_rails_helper_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def self.pro_attribution_comment
7777
allow(helper).to receive(:append_stylesheet_pack_tag)
7878
expect { helper.load_pack_for_generated_component("component_name", render_options) }.not_to raise_error
7979

80+
# Default loading strategy is now always :defer to prevent race conditions
81+
# between component registration and hydration, regardless of async support
8082
expect(helper).to have_received(:append_javascript_pack_tag).with("generated/component_name", { defer: true })
8183
expect(helper).to have_received(:append_stylesheet_pack_tag).with("generated/component_name")
8284
end

0 commit comments

Comments
 (0)