react_on_rails 15.0.0.alpha.2 → 15.0.0.rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +443 -78
- data/CONTRIBUTING.md +53 -35
- data/Gemfile.development_dependencies +1 -1
- data/Gemfile.lock +4 -4
- data/KUDOS.md +22 -1
- data/NEWS.md +48 -48
- data/PROJECTS.md +45 -40
- data/README.md +24 -16
- data/SUMMARY.md +62 -52
- data/eslint.config.ts +213 -0
- data/knip.ts +19 -10
- data/lib/generators/USAGE +1 -1
- data/lib/generators/react_on_rails/dev_tests_generator.rb +4 -8
- data/lib/generators/react_on_rails/templates/.eslintrc +1 -1
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +2 -2
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorldServer.js +1 -1
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/packs/registration.js.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml +1 -1
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/reducers/helloWorldReducer.js +1 -1
- data/lib/react_on_rails/configuration.rb +52 -8
- data/lib/react_on_rails/controller.rb +4 -2
- data/lib/react_on_rails/helper.rb +16 -4
- data/lib/react_on_rails/packs_generator.rb +4 -10
- data/lib/react_on_rails/react_component/render_options.rb +13 -1
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +2 -0
- data/lib/react_on_rails/utils.rb +23 -0
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/tasks/assets.rake +1 -1
- data/tsconfig.eslint.json +6 -0
- data/tsconfig.json +3 -2
- metadata +5 -5
data/README.md
CHANGED
@@ -17,21 +17,24 @@
|
|
17
17
|
[](https://github.com/shakacode/react_on_rails/actions/workflows/lint-js-and-ruby.yml)
|
18
18
|
|
19
19
|
# News
|
20
|
-
* [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro/) supports the latest features of React 18, including [React Server Components](https://react.dev/reference/rsc/server-components) and [streaming](https://react.dev/reference/react-dom/server/renderToPipeableStream). Contact [Justin Gordon](mailto:justin@shakacode.com) for more information.
|
21
|
-
* ShakaCode now maintains the official successor to `rails/webpacker`, [`shakapacker`](https://github.com/shakacode/shakapacker).
|
22
|
-
* Project is updated to support Rails 7 and Shakapacker v6+!
|
23
20
|
|
24
|
-
|
21
|
+
- [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro/) supports the latest features of React 18, including [React Server Components](https://react.dev/reference/rsc/server-components) and [streaming](https://react.dev/reference/react-dom/server/renderToPipeableStream). Contact [Justin Gordon](mailto:justin@shakacode.com) for more information.
|
22
|
+
- ShakaCode now maintains the official successor to `rails/webpacker`, [`shakapacker`](https://github.com/shakacode/shakapacker).
|
23
|
+
- Project is updated to support Rails 7 and Shakapacker v6+!
|
25
24
|
|
26
|
-
|
25
|
+
---
|
26
|
+
|
27
|
+
_These are the docs for React on Rails 14. To see the older docs and code: [v13](https://github.com/shakacode/react_on_rails/tree/13.4.0), [v12](https://github.com/shakacode/react_on_rails/tree/12.6.0), and [v11](https://github.com/shakacode/react_on_rails/tree/11.3.0)._
|
27
28
|
|
28
29
|
# About
|
30
|
+
|
29
31
|
React on Rails integrates Rails with (server rendering of) [React](https://github.com/facebook/react).
|
30
32
|
|
31
|
-
This project is maintained by [ShakaCode](https://www.shakacode.com).
|
33
|
+
This project is maintained by [ShakaCode](https://www.shakacode.com).
|
32
34
|
|
33
35
|
## ShakaCode Upgrade Support
|
34
|
-
|
36
|
+
|
37
|
+
ShakaCode focuses on helping Ruby on Rails teams better use React and Webpack. We can upgrade your project and improve your development and customer experiences, allowing you to focus on building new features or fixing bugs instead.
|
35
38
|
|
36
39
|
For an overview of working with us, see our [Client Engagement Model](https://www.shakacode.com/blog/client-engagement-model/) article and [how we bill for time](https://www.shakacode.com/blog/shortcut-jira-trello-github-toggl-time-and-task-tracking/).
|
37
40
|
|
@@ -40,7 +43,8 @@ We also specialize in helping development teams lower infrastructure and CI cost
|
|
40
43
|
If you think ShakaCode can help your project, [click here](https://meetings.hubspot.com/justingordon/30-minute-consultation) to book a call with [Justin Gordon](mailto:justin@shakacode.com), the creator of React on Rails.
|
41
44
|
|
42
45
|
## React on Rails Pro
|
43
|
-
|
46
|
+
|
47
|
+
Are you interested in optimizing your Webpack setup for React on Rails, including code splitting with [React Router](https://reactrouter.com/) and [loadable-components](https://loadable-components.com/) with server-side rendering for SEO and hot-reloading for developers?
|
44
48
|
We did this for Popmenu, [lowering Heroku costs 20-25% while getting a 73% decrease in average response times](https://www.shakacode.com/recent-work/popmenu/). Several years later, Popmenu serves tens of millions of SSR requests daily with React on Rails Pro.
|
45
49
|
|
46
50
|
If you're interested, read more about [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro/) and [book a call](https://meetings.hubspot.com/justingordon/30-minute-consultation).
|
@@ -60,10 +64,10 @@ Given that `shakacode/shakapacker` gem already provides basic React integration,
|
|
60
64
|
1. Automatic configuration of what bundles are added to the page based on what React components are on the page. This results in faster browser loading time via smaller bundle sizes.
|
61
65
|
1. Keep up with the latest changes in different versions of React. React 18 is supported.
|
62
66
|
1. Easy passing of props directly from your Rails view to your React components rather than having your Rails view load and then make a separate request to your API.
|
63
|
-
Tight integration with [shakapacker](https://github.com/shakacode/shakapacker) (or its predecessor [rails/webpacker](https://github.com/rails/webpacker)).
|
67
|
+
Tight integration with [shakapacker](https://github.com/shakacode/shakapacker) (or its predecessor [rails/webpacker](https://github.com/rails/webpacker)).
|
64
68
|
1. Server-Side Rendering (SSR), often used for SEO crawler indexing and UX performance.
|
65
69
|
1. [Automated optimized entry-point creation and bundle inclusion when placing a component on a page. With this feature, you no longer need to configure `javascript_pack_tags` and `stylesheet_pack_tags` on your layouts based on what’s shown. “It just works!”](https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation/)
|
66
|
-
1. [Redux](https://
|
70
|
+
1. [Redux](https://redux.js.org/) and [React Router](https://reactrouter.com/) integration with server-side-rendering.
|
67
71
|
1. [Internationalization (I18n) and (localization)](https://www.shakacode.com/react-on-rails/docs/guides/i18n)
|
68
72
|
1. A supportive community. This [web search shows how live public sites are using React on Rails](https://publicwww.com/websites/%22react-on-rails%22++-undeveloped.com+depth%3Aall/).
|
69
73
|
1. [ReScript Support](https://github.com/shakacode/rescript-react-on-rails-example).
|
@@ -71,14 +75,16 @@ Tight integration with [shakapacker](https://github.com/shakacode/shakapacker) (
|
|
71
75
|
See [Rails/Webpacker React Integration Options](https://www.shakacode.com/react-on-rails/docs/guides/rails-webpacker-react-integration-options) for comparisons to other gems.
|
72
76
|
|
73
77
|
## Online demo
|
74
|
-
|
75
|
-
|
78
|
+
|
79
|
+
- See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
|
80
|
+
- A deployed version of the project `spec/dummy`, which demonstrates several uses of `react_on_rails`, will soon be available on [Control Plane through this link](https://ror-spec-dummy.reactrails.com/)
|
76
81
|
|
77
82
|
## ShakaCode Forum Premium Content
|
83
|
+
|
78
84
|
_Requires creating a free account._
|
79
85
|
|
80
|
-
|
81
|
-
|
86
|
+
- [How to use different versions of a file for client and server rendering](https://forum.shakacode.com/t/how-to-use-different-versions-of-a-file-for-client-and-server-rendering/1352)
|
87
|
+
- [How to conditionally render server side based on the device type](https://forum.shakacode.com/t/how-to-conditionally-render-server-side-based-on-the-device-type/1473)
|
82
88
|
|
83
89
|
## Prerequisites
|
84
90
|
|
@@ -86,12 +92,13 @@ Ruby on Rails >=5, rails/webpacker >= 4.2 or shakapacker > 6, Ruby >= 3.0.0
|
|
86
92
|
|
87
93
|
# Support
|
88
94
|
|
89
|
-
|
95
|
+
- [Click to join **React + Rails Slack**](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE).
|
96
|
+
|
90
97
|
- [**Subscribe**](https://app.mailerlite.com/webforms/landing/l1d9x5) for announcements of new releases of React on Rails and of our latest [blog articles](https://blog.shakacode.com) and tutorials.
|
91
98
|
- [Discussions](https://github.com/shakacode/react_on_rails/discussions): Post your questions regarding React on Rails
|
92
99
|
- **[forum.shakacode.com](https://forum.shakacode.com)**: Other discussions
|
93
100
|
- **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)**
|
94
|
-
-
|
101
|
+
- _See [NEWS.md](https://github.com/shakacode/react_on_rails/tree/master/NEWS.md) for more notes over time._
|
95
102
|
- See [Projects](https://github.com/shakacode/react_on_rails/tree/master/PROJECTS.md) using and [KUDOS](https://github.com/shakacode/react_on_rails/tree/master/KUDOS.md) for React on Rails. Please submit yours! Please edit either page or [email us](mailto:contact@shakacode.com) and we'll add your info. We also **love stars** as it helps us attract new users and contributors.
|
96
103
|
|
97
104
|
## Contributing
|
@@ -99,6 +106,7 @@ Ruby on Rails >=5, rails/webpacker >= 4.2 or shakapacker > 6, Ruby >= 3.0.0
|
|
99
106
|
Bug reports and pull requests are welcome. To get started, see [Contributing](https://github.com/shakacode/react_on_rails/tree/master/CONTRIBUTING.md) and the [list of help wanted issues](https://github.com/shakacode/react_on_rails/labels/contributions%3A%20up%20for%20grabs%21).
|
100
107
|
|
101
108
|
# Work with Us
|
109
|
+
|
102
110
|
ShakaCode is **[hiring passionate software engineers](http://www.shakacode.com/career)** to work on our projects, including [HiChee](https://hichee.com)!
|
103
111
|
|
104
112
|
# License
|
data/SUMMARY.md
CHANGED
@@ -6,73 +6,83 @@ Here is the new link:
|
|
6
6
|
|
7
7
|
**[React on Rails Documentation Link](https://www.shakacode.com/react-on-rails/docs/)**
|
8
8
|
|
9
|
-
|
9
|
+
---
|
10
10
|
|
11
11
|
## **OLD DOCS BELOW**
|
12
|
-
|
12
|
+
|
13
|
+
- [Home](./README.md)
|
13
14
|
|
14
15
|
## **Basics**
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
16
|
+
|
17
|
+
- [React on Rails Basic Installation Tutorial](./docs/tutorial.md)
|
18
|
+
- [Webpack Configuration](./docs/guides/webpack-configuration.md)
|
19
|
+
- [How React on Rails Works](docs/outdated/how-react-on-rails-works.md)
|
20
|
+
- [Client vs. Server Rendering](./docs/guides/client-vs-server-rendering.md)
|
21
|
+
- [React Server Rendering](./docs/guides/react-server-rendering.md)
|
22
|
+
- [🚀 Next-Gen Server Rendering: Streaming with React 18's Latest APIs](./docs/guides/streaming-server-rendering.md)
|
23
|
+
- [Render-Functions and the RailsContext](docs/guides/render-functions-and-railscontext.md)
|
24
|
+
- [Caching and Performance: React on Rails Pro](https://github.com/shakacode/react_on_rails/wiki).
|
25
|
+
- [Deployment](docs/guides/deployment.md).
|
26
|
+
- [React on Rails Internationalization (I18n, localization)](docs/guides/i18n.md)
|
27
|
+
- [RSpec Test Helpers Configuration](docs/guides/rspec-configuration.md)
|
28
|
+
- [Minitest Configuration](docs/guides/minitest-configuration.md)
|
29
|
+
- [Upgrading React on Rails](docs/guides/upgrading-react-on-rails.md)
|
30
|
+
|
29
31
|
## **API**
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
|
33
|
+
- [View Helpers API](./docs/api/view-helpers-api.md)
|
34
|
+
- [JavaScript API](./docs/api/javascript-api.md)
|
35
|
+
- [Redux Store API](./docs/api/redux-store-api.md)
|
33
36
|
|
34
37
|
## **Additional Details**
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
|
39
|
+
- [Migration from `react-rails`](./docs/guides/migrating-from-react-rails.md)
|
40
|
+
- [Generator Details](docs/guides/generator-details.md)
|
41
|
+
- [Updating Dependencies](./docs/additional-reading/updating-dependencies.md)
|
42
|
+
- [Manual Installation Overview](docs/outdated/manual-installation-overview.md)
|
43
|
+
- [Upgrading from rails/webpacker v3 to v4](docs/additional-reading/upgrade-webpacker-v3-to-v4.md)
|
44
|
+
- [Recommended Project Structure](docs/additional-reading/recommended-project-structure.md)
|
45
|
+
|
42
46
|
## **Rails**
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
|
48
|
+
- [Rails Engine Integration](./docs/additional-reading/rails-engine-integration.md)
|
49
|
+
- [Rails View Rendering from Inline JavaScript](./docs/additional-reading/rails_view_rendering_from_inline_javascript.md)
|
50
|
+
- [Turbolinks](./docs/additional-reading/turbolinks.md)
|
51
|
+
- [Converting a Rails 5 API only app to a Rails app](./docs/additional-reading/convert-rails-5-api-only-app.md)
|
47
52
|
|
48
53
|
## **Javascript**
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
|
55
|
+
- [Node Dependencies, NPM, and Yarn](./docs/additional-reading/node-dependencies-and-npm.md)
|
56
|
+
- [React Router](./docs/additional-reading/react-router.md)
|
57
|
+
- [React & Redux](./docs/additional-reading/react-and-redux.md)
|
58
|
+
- [Webpack Tips](./docs/additional-reading/webpack.md)
|
59
|
+
- [Server Rendering Tips](./docs/additional-reading/server-rendering-tips.md)
|
60
|
+
- [Code Splitting](docs/outdated/code-splitting.md)
|
61
|
+
- [AngularJS Integration and Migration to React on Rails](./docs/additional-reading/angular-js-integration-migration.md)
|
56
62
|
|
57
63
|
## **Deployment**
|
58
|
-
|
59
|
-
|
64
|
+
|
65
|
+
- [Heroku Deployment](docs/guides/heroku-deployment.md)
|
66
|
+
- [Elastic Beanstalk Deployment](./docs/additional-reading/elastic-beanstalk.md)
|
60
67
|
|
61
68
|
## Outdated Non-Webpack Docs
|
62
|
-
|
63
|
-
|
69
|
+
|
70
|
+
- [Developing with the Webpack Dev Server](./docs/additional-reading/webpack-dev-server.md)
|
71
|
+
- [Webpack, the Asset Pipeline, and Using Assets w/ React](./docs/outdated/rails-assets-relative-paths.md)
|
64
72
|
|
65
73
|
## **[CONTRIBUTING](CONTRIBUTING.md)**
|
66
|
-
|
67
|
-
|
68
|
-
|
74
|
+
|
75
|
+
- [Generator Testing](./docs/contributor-info/generator-testing.md)
|
76
|
+
- [Linting](./docs/contributor-info/linters.md)
|
77
|
+
- [Releasing](./docs/contributor-info/releasing.md)
|
69
78
|
|
70
79
|
## **Misc**
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
80
|
+
|
81
|
+
- [Tips](./docs/additional-reading/tips.md)
|
82
|
+
- [Changelog](./CHANGELOG.md)
|
83
|
+
- [Projects](./PROJECTS.md)
|
84
|
+
- [Shaka Code Style](./docs/coding-style/style.md)
|
85
|
+
- [React on Rails, Slides](http://www.slideshare.net/justingordon/react-on-rails-v61)
|
86
|
+
- [Code of Conduct](./docs/misc/code_of_conduct.md)
|
87
|
+
- [The React on Rails Doctrine](https://medium.com/@railsonmaui/the-react-on-rails-doctrine-3c59a778c724)
|
88
|
+
- [React on Rails, 2000+ 🌟 Stars](https://medium.com/shakacode/react-on-rails-2000-stars-32ff5cfacfbf#.6gmfb2gpy)
|
data/eslint.config.ts
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
import path from 'node:path';
|
2
|
+
import { globalIgnores } from 'eslint/config';
|
3
|
+
import jest from 'eslint-plugin-jest';
|
4
|
+
import prettierRecommended from 'eslint-plugin-prettier/recommended';
|
5
|
+
import globals from 'globals';
|
6
|
+
import tsEslint from 'typescript-eslint';
|
7
|
+
import { includeIgnoreFile } from '@eslint/compat';
|
8
|
+
import js from '@eslint/js';
|
9
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
10
|
+
|
11
|
+
const compat = new FlatCompat({
|
12
|
+
baseDirectory: __dirname,
|
13
|
+
recommendedConfig: js.configs.recommended,
|
14
|
+
allConfig: js.configs.all,
|
15
|
+
});
|
16
|
+
|
17
|
+
const config = tsEslint.config([
|
18
|
+
includeIgnoreFile(path.resolve(__dirname, '.gitignore')),
|
19
|
+
globalIgnores([
|
20
|
+
// compiled code
|
21
|
+
'node_package/lib/',
|
22
|
+
// used for tests only
|
23
|
+
'spec/react_on_rails/dummy-for-generators',
|
24
|
+
// temporary and generated files
|
25
|
+
'spec/dummy/.yalc',
|
26
|
+
'spec/dummy/public',
|
27
|
+
'spec/dummy/vendor',
|
28
|
+
'spec/dummy/tmp',
|
29
|
+
'spec/dummy/app/assets/config/manifest.js',
|
30
|
+
'spec/dummy/client/app/packs/server-bundle.js',
|
31
|
+
'**/*.res.js',
|
32
|
+
'**/coverage',
|
33
|
+
'**/assets/webpack/',
|
34
|
+
'**/public/webpack/',
|
35
|
+
'**/generated/',
|
36
|
+
'**/app/assets/javascripts/application.js',
|
37
|
+
'**/cable.js',
|
38
|
+
'**/public/packs*/',
|
39
|
+
'**/gen-examples/',
|
40
|
+
'**/bundle/',
|
41
|
+
// dependencies
|
42
|
+
'**/node_modules/',
|
43
|
+
// fixtures
|
44
|
+
'**/fixtures/',
|
45
|
+
'**/.yalc/**/*',
|
46
|
+
]),
|
47
|
+
{
|
48
|
+
files: ['**/*.[jt]s', '**/*.[jt]sx', '**/*.[cm][jt]s'],
|
49
|
+
},
|
50
|
+
js.configs.recommended,
|
51
|
+
compat.extends('eslint-config-shakacode'),
|
52
|
+
{
|
53
|
+
languageOptions: {
|
54
|
+
globals: {
|
55
|
+
...globals.browser,
|
56
|
+
...globals.node,
|
57
|
+
},
|
58
|
+
|
59
|
+
parserOptions: {
|
60
|
+
requireConfigFile: false,
|
61
|
+
|
62
|
+
babelOptions: {
|
63
|
+
presets: ['@babel/preset-env', '@babel/preset-react'],
|
64
|
+
},
|
65
|
+
},
|
66
|
+
},
|
67
|
+
|
68
|
+
settings: {
|
69
|
+
'import/core-modules': ['react-redux'],
|
70
|
+
|
71
|
+
'import/resolver': {
|
72
|
+
alias: [['Assets', './spec/dummy/client/app/assets']],
|
73
|
+
|
74
|
+
node: {
|
75
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'],
|
76
|
+
},
|
77
|
+
},
|
78
|
+
},
|
79
|
+
|
80
|
+
rules: {
|
81
|
+
'no-shadow': 'off',
|
82
|
+
'no-console': 'off',
|
83
|
+
'function-paren-newline': 'off',
|
84
|
+
'object-curly-newline': 'off',
|
85
|
+
'no-restricted-syntax': ['error', 'SequenceExpression'],
|
86
|
+
'no-void': [
|
87
|
+
'error',
|
88
|
+
{
|
89
|
+
allowAsStatement: true,
|
90
|
+
},
|
91
|
+
],
|
92
|
+
|
93
|
+
'import/extensions': [
|
94
|
+
'error',
|
95
|
+
'ignorePackages',
|
96
|
+
{
|
97
|
+
js: 'never',
|
98
|
+
jsx: 'never',
|
99
|
+
ts: 'never',
|
100
|
+
tsx: 'never',
|
101
|
+
},
|
102
|
+
],
|
103
|
+
|
104
|
+
'import/first': 'off',
|
105
|
+
'import/no-extraneous-dependencies': 'off',
|
106
|
+
// The rule seems broken: it's reporting errors on imports in files using `export` too,
|
107
|
+
// not just `module.exports`.
|
108
|
+
'import/no-import-module-exports': 'off',
|
109
|
+
'import/no-unresolved': [
|
110
|
+
'error',
|
111
|
+
{
|
112
|
+
ignore: ['\\.res\\.js$'],
|
113
|
+
},
|
114
|
+
],
|
115
|
+
'react/destructuring-assignment': [
|
116
|
+
'error',
|
117
|
+
'always',
|
118
|
+
{
|
119
|
+
ignoreClassFields: true,
|
120
|
+
},
|
121
|
+
],
|
122
|
+
'react/forbid-prop-types': 'off',
|
123
|
+
'react/function-component-definition': [
|
124
|
+
'error',
|
125
|
+
{
|
126
|
+
namedComponents: ['arrow-function', 'function-declaration'],
|
127
|
+
unnamedComponents: 'arrow-function',
|
128
|
+
},
|
129
|
+
],
|
130
|
+
'react/jsx-props-no-spreading': 'off',
|
131
|
+
'react/static-property-placement': 'off',
|
132
|
+
'jsx-a11y/anchor-is-valid': 'off',
|
133
|
+
'react/jsx-filename-extension': [
|
134
|
+
'error',
|
135
|
+
{
|
136
|
+
extensions: ['.jsx', '.tsx'],
|
137
|
+
},
|
138
|
+
],
|
139
|
+
},
|
140
|
+
},
|
141
|
+
{
|
142
|
+
files: ['node_package/**/*'],
|
143
|
+
rules: {
|
144
|
+
'import/extensions': ['error', 'ignorePackages'],
|
145
|
+
},
|
146
|
+
},
|
147
|
+
{
|
148
|
+
files: ['lib/generators/react_on_rails/templates/**/*'],
|
149
|
+
rules: {
|
150
|
+
// It doesn't use package.json from the template
|
151
|
+
'import/no-unresolved': 'off',
|
152
|
+
// We have `const [name, setName] = useState(props.name)` so can't just destructure props
|
153
|
+
'react/destructuring-assignment': 'off',
|
154
|
+
},
|
155
|
+
},
|
156
|
+
{
|
157
|
+
files: ['**/*.ts{x,}', '**/*.[cm]ts'],
|
158
|
+
|
159
|
+
extends: tsEslint.configs.strictTypeChecked,
|
160
|
+
|
161
|
+
languageOptions: {
|
162
|
+
parserOptions: {
|
163
|
+
projectService: {
|
164
|
+
allowDefaultProject: ['eslint.config.ts', 'knip.ts', 'node_package/tests/*.test.{ts,tsx}'],
|
165
|
+
// Needed because `import * as ... from` instead of `import ... from` doesn't work in this file
|
166
|
+
// for some imports.
|
167
|
+
defaultProject: 'tsconfig.eslint.json',
|
168
|
+
},
|
169
|
+
},
|
170
|
+
},
|
171
|
+
|
172
|
+
rules: {
|
173
|
+
'@typescript-eslint/no-namespace': 'off',
|
174
|
+
'@typescript-eslint/no-shadow': 'error',
|
175
|
+
'@typescript-eslint/no-confusing-void-expression': [
|
176
|
+
'error',
|
177
|
+
{
|
178
|
+
ignoreArrowShorthand: true,
|
179
|
+
},
|
180
|
+
],
|
181
|
+
// Too many false positives
|
182
|
+
'@typescript-eslint/no-unnecessary-condition': 'off',
|
183
|
+
'@typescript-eslint/no-unused-vars': [
|
184
|
+
'error',
|
185
|
+
{
|
186
|
+
caughtErrorsIgnorePattern: '^_',
|
187
|
+
},
|
188
|
+
],
|
189
|
+
'@typescript-eslint/restrict-template-expressions': 'off',
|
190
|
+
},
|
191
|
+
},
|
192
|
+
{
|
193
|
+
files: ['**/app-react16/**/*'],
|
194
|
+
rules: {
|
195
|
+
'react/no-deprecated': 'off',
|
196
|
+
},
|
197
|
+
},
|
198
|
+
{
|
199
|
+
files: ['node_package/tests/**', '**/*.test.{js,jsx,ts,tsx}'],
|
200
|
+
|
201
|
+
extends: [jest.configs['flat/recommended'], jest.configs['flat/style']],
|
202
|
+
|
203
|
+
rules: {
|
204
|
+
// Allows Jest mocks before import
|
205
|
+
'import/first': 'off',
|
206
|
+
},
|
207
|
+
},
|
208
|
+
// must be the last config in the array
|
209
|
+
// https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#configuration-new-eslintconfigjs
|
210
|
+
prettierRecommended,
|
211
|
+
]);
|
212
|
+
|
213
|
+
export default config;
|
data/knip.ts
CHANGED
@@ -7,17 +7,20 @@ const config: KnipConfig = {
|
|
7
7
|
entry: [
|
8
8
|
'node_package/src/ReactOnRails.node.ts!',
|
9
9
|
'node_package/src/ReactOnRailsRSC.ts!',
|
10
|
-
'node_package/src/registerServerComponent/client.
|
11
|
-
'node_package/src/registerServerComponent/server.
|
12
|
-
'node_package/src/
|
10
|
+
'node_package/src/registerServerComponent/client.tsx!',
|
11
|
+
'node_package/src/registerServerComponent/server.tsx!',
|
12
|
+
'node_package/src/registerServerComponent/server.rsc.ts!',
|
13
|
+
'node_package/src/wrapServerComponentRenderer/server.tsx!',
|
14
|
+
'node_package/src/wrapServerComponentRenderer/server.rsc.tsx!',
|
15
|
+
'node_package/src/RSCRoute.tsx!',
|
16
|
+
'node_package/src/ServerComponentFetchError.ts!',
|
17
|
+
'eslint.config.ts',
|
13
18
|
],
|
14
19
|
project: ['node_package/src/**/*.[jt]s{x,}!', 'node_package/tests/**/*.[jt]s{x,}'],
|
15
20
|
babel: {
|
16
21
|
config: ['node_package/babel.config.js'],
|
17
22
|
},
|
18
|
-
ignore: [
|
19
|
-
'node_package/tests/emptyForTesting.js',
|
20
|
-
],
|
23
|
+
ignore: ['node_package/tests/emptyForTesting.js'],
|
21
24
|
ignoreBinaries: [
|
22
25
|
// Knip fails to detect it's declared in devDependencies
|
23
26
|
'nps',
|
@@ -27,14 +30,19 @@ const config: KnipConfig = {
|
|
27
30
|
ignoreDependencies: [
|
28
31
|
// Required for TypeScript compilation, but we don't depend on Turbolinks itself.
|
29
32
|
'@types/turbolinks',
|
30
|
-
// used in package-scripts.yml
|
31
|
-
'concurrently',
|
32
33
|
// The Knip ESLint plugin fails to detect these are transitively required by a config,
|
33
34
|
// though we don't actually use its rules anywhere.
|
35
|
+
'@babel/eslint-parser',
|
36
|
+
'@babel/preset-react',
|
37
|
+
'eslint-config-shakacode',
|
38
|
+
'eslint-import-resolver-alias',
|
39
|
+
'eslint-plugin-import',
|
34
40
|
'eslint-plugin-jsx-a11y',
|
35
41
|
'eslint-plugin-react',
|
36
|
-
|
37
|
-
|
42
|
+
'eslint-plugin-react-hooks',
|
43
|
+
// These are used as transitive dependencies and missing from package.json
|
44
|
+
'@eslint/eslintrc',
|
45
|
+
'@eslint/js',
|
38
46
|
// used by Jest
|
39
47
|
'jsdom',
|
40
48
|
],
|
@@ -50,6 +58,7 @@ const config: KnipConfig = {
|
|
50
58
|
// Declaring this as webpack.config instead doesn't work correctly
|
51
59
|
'config/webpack/webpack.config.js',
|
52
60
|
],
|
61
|
+
ignore: ['**/app-react16/**/*'],
|
53
62
|
project: ['**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!', 'config/webpack/*.js'],
|
54
63
|
paths: {
|
55
64
|
'Assets/*': ['client/app/assets/*'],
|
data/lib/generators/USAGE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Description:
|
2
2
|
|
3
|
-
The react_on_rails:install generator integrates
|
3
|
+
The react_on_rails:install generator integrates Webpack with Rails with ease. You
|
4
4
|
can pass the redux option if you'd like to have redux setup for you automatically.
|
5
5
|
|
6
6
|
* Redux
|
@@ -47,14 +47,10 @@ module ReactOnRails
|
|
47
47
|
|
48
48
|
def add_yarn_relative_install_script_in_package_json
|
49
49
|
package_json = File.join(destination_root, "package.json")
|
50
|
-
contents = File.read(package_json)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
STRING
|
55
|
-
new_client_package_json_contents = contents.gsub(/ {2}"scripts": {/,
|
56
|
-
replacement_value)
|
57
|
-
File.open(package_json, "w+") { |f| f.puts new_client_package_json_contents }
|
50
|
+
contents = JSON.parse(File.read(package_json))
|
51
|
+
contents["scripts"] ||= {}
|
52
|
+
contents["scripts"]["postinstall"] = "yalc link react-on-rails"
|
53
|
+
File.open(package_json, "w+") { |f| f.puts JSON.pretty_generate(contents) }
|
58
54
|
end
|
59
55
|
end
|
60
56
|
end
|
@@ -37,7 +37,7 @@ development:
|
|
37
37
|
# port: 8080
|
38
38
|
compress: true
|
39
39
|
# Note that apps that do not check the host are vulnerable to DNS rebinding attacks
|
40
|
-
allowed_hosts: [
|
40
|
+
allowed_hosts: ['localhost']
|
41
41
|
pretty: true
|
42
42
|
headers:
|
43
43
|
'Access-Control-Allow-Origin': '*'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { combineReducers } from 'redux';
|
2
2
|
import { HELLO_WORLD_NAME_UPDATE } from '../constants/helloWorldConstants';
|
3
3
|
|
4
|
-
const name = (state = '', action) => {
|
4
|
+
const name = (state = '', action = {}) => {
|
5
5
|
switch (action.type) {
|
6
6
|
case HELLO_WORLD_NAME_UPDATE:
|
7
7
|
return action.text;
|