Skip to content

Commit 68bc17a

Browse files
committed
Migration to Biome
1 parent e854b2f commit 68bc17a

File tree

86 files changed

+1128
-2962
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1128
-2962
lines changed

.stylelintrc.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
2-
"extends": [
3-
"stylelint-config-standard-scss",
4-
"stylelint-config-clean-order"
5-
],
2+
"extends": ["stylelint-config-standard-scss", "stylelint-config-clean-order"],
63
"rules": {
74
"max-nesting-depth": 3,
85
"declaration-property-value-no-unknown": true,

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# React Proto - React TypeScript Boilerplate
22

3-
![node.js@22](https://img.shields.io/badge/node.js-22-339933?style=for-the-badge&logo=nodedotjs) ![typescript@5](https://img.shields.io/badge/typescript-5-3178C6?style=for-the-badge&logo=typescript) ![reactjs@18](https://img.shields.io/badge/Reactjs-18-61DAFB?style=for-the-badge&logo=react) ![rspack@1](https://img.shields.io/badge/rspack-1-f0965b?style=for-the-badge) ![webpack@5](https://img.shields.io/badge/webpack-5-8dd6f9?style=for-the-badge&logo=webpack) ![sass@1.7](https://img.shields.io/badge/sass-1.7-CC6699?style=for-the-badge&logo=sass) ![ts-standard](https://img.shields.io/badge/standard-ts-F3DF49?style=for-the-badge&logo=standardjs)
3+
![node.js@22](https://img.shields.io/badge/node.js-22-339933?style=for-the-badge&logo=nodedotjs) ![typescript@5](https://img.shields.io/badge/typescript-5-3178C6?style=for-the-badge&logo=typescript) ![reactjs@18](https://img.shields.io/badge/Reactjs-18-61DAFB?style=for-the-badge&logo=react) ![rspack@1](https://img.shields.io/badge/rspack-1-f0965b?style=for-the-badge) ![webpack@5](https://img.shields.io/badge/webpack-5-8dd6f9?style=for-the-badge&logo=webpack) ![sass@1.7](https://img.shields.io/badge/sass-1.7-CC6699?style=for-the-badge&logo=sass)
44

55
<img align="right" width="100" src="src/assets/images/logo.png">
66

@@ -23,7 +23,7 @@ Webpack is still available as an option ([rspack vs webpack](#rspack-vs-webpack)
2323
- [What's Inside](#whats-inside)
2424
- [The App](#the-app)
2525
- [How to Use](#how-to-use)
26-
- [Basic Project Configuration](#basic-project-Configuration)
26+
- [Basic Project Configuration](#basic-project-configuration)
2727
- [General Notices](#general-notices)
2828
- [Documentation](#documentation)
2929
- [Changes](#changes)
@@ -83,13 +83,12 @@ i18n (Internationalization):
8383

8484
Styles:
8585

86-
- **(S)CSS modules** (with TypeScript support)
86+
- **(S)CSS modules** (with TypeScript support; [important note for VSCode](#typescript-css-modules-for-vscode))
8787

8888
Linters:
8989

90-
- **TS Standard** (TypeScript Style Guide, with linter and automatic code fixer based on [StandardJS](https://standardjs.com/))
90+
- **Biome** ([modern replace for ESLinter and Prettier](https://github.com/biomejs/biome); [configuration Biome for VSCode](#configuration-biome-for-vscode))
9191
- **Stylelint** (including rules order)
92-
- **Prettier**
9392

9493
Tests:
9594

@@ -239,17 +238,17 @@ Here is a comparison between Rspack 1 with the built-in SWC loader and Webpack 5
239238

240239
| | Rspack | webpack |
241240
| ------- | --------- | -------- |
242-
| Server | 5.35 s | 6.83 s |
243-
| Client | 5.32 s | 7.50 s |
241+
| Server | 4.82 s | 6.14 s |
242+
| Client | 4.81 s | 6.56 s |
244243

245244
Of course, the larger the project, the greater the performance advantage. However, if you need more webpack compatibility or hot module reloading while developing with [Preact](#react-vs-preact), you can always [switch back to the webpack bundler](#switching-back-to-webpack).
246245

247246
Also, the optimization process of Rspack is currently slightly worse. Check the bundle size comparison for the non-SSR version of the sample application in this repository:
248247

249248
| | Rspack | webpack |
250249
| ------- | --------- | -------- |
251-
| Parsed | 284.47 KB | 262.9 KB |
252-
| Gzipped | 90.29 KB | 86.84 KB |
250+
| Parsed | 285.42 KB | 263.92 KB |
251+
| Gzipped | 90.55 KB | 87.16 KB |
253252
### React vs Preact
254253

255254
In `webpack\constants.ts` you can choose to use [Preact](https://preactjs.com/) library instead React itself (`IS_PREACT` boolean constant).
@@ -258,8 +257,8 @@ Preact is a fast and compact React-compatible Virtual DOM library. But because i
258257

259258
| | React | Preact |
260259
| ------- | --------- | -------- |
261-
| Parsed | 262.9 KB | 150.55 KB |
262-
| Gzipped | 86.84 KB | 52.09 KB |
260+
| Parsed | 285.42 KB | 173.3 KB |
261+
| Gzipped | 90.55 KB | 56.05 KB |
263262

264263
**Important Note**
265264
At the moment, the Rspack version of the project does not support hot module reloading during development with Preact. Compared to Webpack, it requires some additional tricky configuration, which I will probably add in the near future. However, if you need HMR (and you definitely do!), you can develop your project using React and then build it with Preact. Or just [switch your project back to the webpack](#switching-back-to-webpack).
@@ -269,6 +268,12 @@ You can freely integrate any React compatible i18n solution. But if React Proto
269268

270269
### Why not redux-persist package?
271270
As for me this solution is overcomplicated in most of cases. It definitely has a lot of "storage engines", state version control and etc., but smart using of Redux Middlewares and Listeners can cover all this functionality in a more precise way.
271+
272+
### Configuration Biome for VSCode
273+
Please check [this official documentation](https://biomejs.dev/reference/vscode/).
274+
275+
### Typescript CSS Modules for VSCode
276+
For proper CSS class hinting, please check this [note](https://github.com/mrmckeb/typescript-plugin-css-modules?tab=readme-ov-file#visual-studio-code).
272277
## Documentation
273278

274279
_Coming soon._

_webpack/package.json

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
{
22
"name": "react-proto",
3-
"version": "2.0.1",
3+
"version": "2.1.0",
44
"description": "React TypeScript Boilerplate",
55
"author": "Max L Stop&Go",
66
"license": "ISC",
7-
"sideEffects": [
8-
"*.css",
9-
"*.scss"
10-
],
7+
"sideEffects": ["*.css", "*.scss"],
118
"scripts": {
129
"clean": "rimraf dist",
1310
"start:webpack": "cross-env NODE_ENV=development webpack --mode=development",
@@ -20,31 +17,31 @@
2017
"start:static": "npm run clean && cross-env NODE_ENV=development NO_SSR=true webpack serve --mode development --open",
2118
"build:static": "npm run clean && cross-env NODE_ENV=production NO_SSR=true webpack --mode production",
2219
"build:static:report": "npm run build:static --withReport",
23-
"prettier": "prettier \"src/**/*\" --write --single-quote --no-semi --ignore-unknown --trailing-comma none --jsx-single-quote",
24-
"lint": "ts-standard . && stylelint **/*.{css,scss}",
25-
"lint:fix": "npm run prettier && ts-standard . --fix && stylelint --fix **/*.{css,scss}",
20+
"lint": "npx @biomejs/biome check . && stylelint \"**/*.{css,scss}\"",
21+
"lint:fix": "npx @biomejs/biome check --write && stylelint --fix \"**/*.{css,scss}\"",
2622
"test": "jest",
2723
"add-comp": "node scripts/add-comp.js"
2824
},
2925
"devDependencies": {
26+
"@biomejs/biome": "1.9.4",
3027
"@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
3128
"@prefresh/webpack": "4.0.1",
3229
"@svgr/webpack": "8.1.0",
33-
"@swc/core": "1.7.26",
34-
"@testing-library/jest-dom": "6.5.0",
30+
"@swc/core": "1.7.39",
31+
"@testing-library/jest-dom": "6.6.2",
3532
"@testing-library/preact": "3.2.4",
3633
"@testing-library/react": "16.0.1",
3734
"@testing-library/user-event": "14.5.2",
3835
"@types/compression": "1.7.5",
3936
"@types/cookie-parser": "1.4.7",
4037
"@types/express": "5.0.0",
41-
"@types/jest": "29.5.13",
38+
"@types/jest": "29.5.14",
4239
"@types/loadable__component": "5.13.9",
4340
"@types/loadable__server": "5.12.11",
44-
"@types/node": "22.7.5",
41+
"@types/node": "22.7.9",
4542
"@types/prefresh__webpack": "3.3.3",
46-
"@types/react": "18.3.11",
47-
"@types/react-dom": "18.3.0",
43+
"@types/react": "18.3.12",
44+
"@types/react-dom": "18.3.1",
4845
"@types/react-helmet": "6.1.11",
4946
"@types/react-router-dom": "5.3.3",
5047
"@types/serialize-javascript": "5.0.4",
@@ -60,7 +57,7 @@
6057
"csso-webpack-plugin": "2.0.0-beta.3",
6158
"express": "4.21.1",
6259
"fork-ts-checker-webpack-plugin": "9.0.2",
63-
"html-webpack-plugin": "5.6.0",
60+
"html-webpack-plugin": "5.6.3",
6461
"jest": "29.7.0",
6562
"jest-environment-jsdom": "29.7.0",
6663
"mini-css-extract-plugin": "2.9.1",
@@ -69,19 +66,17 @@
6966
"null-loader": "4.0.1",
7067
"postcss": "8.4.47",
7168
"postcss-scss": "4.0.9",
72-
"prettier": "3.3.3",
7369
"rimraf": "6.0.1",
74-
"sass": "1.79.4",
70+
"sass": "1.80.3",
7571
"sass-loader": "16.0.2",
76-
"stylelint": "16.9.0",
72+
"stylelint": "16.10.0",
7773
"stylelint-config-clean-order": "6.1.0",
7874
"stylelint-config-standard-scss": "13.1.0",
7975
"swc-loader": "0.2.6",
8076
"ts-jest": "29.2.5",
8177
"ts-loader": "9.5.1",
8278
"ts-node": "10.9.2",
83-
"ts-standard": "12.0.2",
84-
"typescript": "5.6.2",
79+
"typescript": "5.6.3",
8580
"typescript-plugin-css-modules": "5.1.0",
8681
"wait-on": "8.0.1",
8782
"webpack": "5.95.0",
@@ -96,19 +91,19 @@
9691
"@apollo/react-ssr": "4.0.0",
9792
"@loadable/server": "5.16.5",
9893
"@loadable/webpack-plugin": "5.15.2",
99-
"@reduxjs/toolkit": "2.2.8",
94+
"@reduxjs/toolkit": "2.3.0",
10095
"@types/loadable__webpack-plugin": "5.7.6",
10196
"compression": "1.7.4",
10297
"cookie-parser": "1.4.7",
10398
"cross-fetch": "4.0.0",
10499
"helmet": "8.0.0",
105100
"identity-obj-proxy": "3.0.0",
106-
"preact": "10.24.2",
101+
"preact": "10.24.3",
107102
"react": "18.3.1",
108103
"react-dom": "18.3.1",
109104
"react-helmet-async": "2.0.5",
110105
"react-redux": "9.1.2",
111-
"react-router-dom": "6.26.2",
106+
"react-router-dom": "6.27.0",
112107
"serialize-javascript": "6.0.2"
113108
}
114109
}

_webpack/src/server/middlewares/csp.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import helmet from 'helmet'
2-
import { randomUUID } from 'crypto'
3-
import { Response, Request, NextFunction } from 'express'
1+
import { randomUUID } from 'node:crypto'
42
import { IS_DEV } from '_webpack/constants'
3+
import type { NextFunction, Request, Response } from 'express'
4+
import helmet from 'helmet'
55

66
const nonce = (_req: Request, res: Response, next: NextFunction): void => {
77
res.locals.cspNonce = Buffer.from(randomUUID()).toString('base64')
88
next()
99
}
1010

11-
const csp = (req: Request, res: Response, next: NextFunction): void => {
11+
const csp = (req: Request, res: Response, next: NextFunction) => {
1212
const middleware = helmet({
1313
contentSecurityPolicy: {
1414
useDefaults: true,
@@ -18,13 +18,13 @@ const csp = (req: Request, res: Response, next: NextFunction): void => {
1818
scriptSrc: [
1919
"'self'",
2020
`'nonce-${String(res.locals.cspNonce)}'`,
21-
IS_DEV ? "'unsafe-eval'" : ''
22-
]
23-
}
21+
IS_DEV ? "'unsafe-eval'" : '',
22+
],
23+
},
2424
},
2525
crossOriginEmbedderPolicy: { policy: 'credentialless' },
2626
noSniff: false,
27-
originAgentCluster: false
27+
originAgentCluster: false,
2828
})
2929

3030
return middleware(req, res, next)

_webpack/src/server/middlewares/hotReload.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import type { RequestHandler } from 'express'
12
import webpack from 'webpack'
2-
import { RequestHandler } from 'express'
33
import devMiddleware from 'webpack-dev-middleware'
44
import hotMiddleware from 'webpack-hot-middleware'
55

@@ -11,10 +11,10 @@ export const devMiddlewareInstance = devMiddleware(compiler, {
1111
serverSideRender: true,
1212
writeToDisk: true,
1313
publicPath:
14-
config.output?.publicPath != null ? String(config.output.publicPath) : '/'
14+
config.output?.publicPath != null ? String(config.output.publicPath) : '/',
1515
})
1616

17-
export function hotReload (): RequestHandler[] {
17+
export function hotReload(): RequestHandler[] {
1818
return [devMiddlewareInstance, hotMiddleware(compiler)]
1919
}
2020

_webpack/src/server/server.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import path from 'path'
2-
import express, { RequestHandler } from 'express'
1+
import path from 'node:path'
2+
import { ChunkExtractor } from '@loadable/server'
33
import compression from 'compression'
44
import cookieParser from 'cookie-parser'
5-
import { ChunkExtractor } from '@loadable/server'
5+
import express, { type RequestHandler } from 'express'
66

7-
import { csp, serverRenderer, nonce } from 'server/middlewares'
8-
import { IS_RENDER_TO_STREAM, SERVER_PORT } from 'server/constants'
97
import { DIST_DIR, IS_DEV, SRC_DIR } from '_webpack/constants'
8+
import { IS_RENDER_TO_STREAM, SERVER_PORT } from 'server/constants'
9+
import { csp, nonce, serverRenderer } from 'server/middlewares'
1010

1111
const { PORT = SERVER_PORT } = process.env
1212

@@ -39,7 +39,7 @@ const runServer = (hotReload?: () => RequestHandler[]): void => {
3939
console.log(
4040
`App listening on port ${PORT}! (render to ${
4141
IS_RENDER_TO_STREAM ? 'stream' : 'string'
42-
})`
42+
})`,
4343
)
4444
})
4545
}

_webpack/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
"compilerOptions": { "module": "commonjs" }
3838
},
3939
"include": ["src", "webpack", "webpack.config.ts", "jest.config.ts"],
40-
"exclude": ["node_modules", "**/*.js"],
40+
"exclude": ["node_modules", "**/*.js"]
4141
}

0 commit comments

Comments
 (0)