@oxog/react-check 1.1.6 → 1.3.0
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.
- package/CHANGELOG.md +115 -1
- package/README.md +149 -51
- package/dist/browser-inject.global.js +705 -158
- package/dist/chain.cjs +8 -531
- package/dist/chain.cjs.map +1 -1
- package/dist/chain.d.cts +2 -2
- package/dist/chain.d.ts +2 -2
- package/dist/chain.js +2 -533
- package/dist/chain.js.map +1 -1
- package/dist/chunk-27R56V2S.js +473 -0
- package/dist/chunk-27R56V2S.js.map +1 -0
- package/dist/chunk-3K2AER5M.cjs +356 -0
- package/dist/chunk-3K2AER5M.cjs.map +1 -0
- package/dist/chunk-7R4KKJTW.cjs +255 -0
- package/dist/chunk-7R4KKJTW.cjs.map +1 -0
- package/dist/chunk-7YYMP3PP.js +723 -0
- package/dist/chunk-7YYMP3PP.js.map +1 -0
- package/dist/chunk-DWM55ACO.cjs +294 -0
- package/dist/chunk-DWM55ACO.cjs.map +1 -0
- package/dist/chunk-G7YVIPS7.cjs +475 -0
- package/dist/chunk-G7YVIPS7.cjs.map +1 -0
- package/dist/chunk-GE2ZX7I7.cjs +727 -0
- package/dist/chunk-GE2ZX7I7.cjs.map +1 -0
- package/dist/chunk-GS7T56RP.cjs +9 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -0
- package/dist/chunk-IM6OG2IC.js +338 -0
- package/dist/chunk-IM6OG2IC.js.map +1 -0
- package/dist/chunk-RQYHXWUC.js +292 -0
- package/dist/chunk-RQYHXWUC.js.map +1 -0
- package/dist/chunk-WLN7ZVO4.js +253 -0
- package/dist/chunk-WLN7ZVO4.js.map +1 -0
- package/dist/cli.js +1443 -207
- package/dist/cli.js.map +1 -1
- package/dist/detect.cjs +22 -324
- package/dist/detect.cjs.map +1 -1
- package/dist/detect.d.cts +8 -2
- package/dist/detect.d.ts +8 -2
- package/dist/detect.js +1 -324
- package/dist/detect.js.map +1 -1
- package/dist/{event-emitter-CxKUDo9q.d.cts → event-emitter-BVYUPYLd.d.cts} +3 -2
- package/dist/{event-emitter-CxKUDo9q.d.ts → event-emitter-BVYUPYLd.d.ts} +3 -2
- package/dist/fix.cjs +6 -715
- package/dist/fix.cjs.map +1 -1
- package/dist/fix.d.cts +2 -2
- package/dist/fix.d.ts +2 -2
- package/dist/fix.js +2 -719
- package/dist/fix.js.map +1 -1
- package/dist/index.cjs +2380 -3308
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +255 -88
- package/dist/index.d.ts +255 -88
- package/dist/index.js +2289 -3290
- package/dist/index.js.map +1 -1
- package/dist/{scanner-CTBraprQ.d.ts → scanner-D0mBQGTx.d.ts} +23 -3
- package/dist/{scanner-5j2LEM-q.d.cts → scanner-DUBgwztZ.d.cts} +23 -3
- package/dist/scanner.cjs +8 -1652
- package/dist/scanner.cjs.map +1 -1
- package/dist/scanner.d.cts +3 -3
- package/dist/scanner.d.ts +3 -3
- package/dist/scanner.js +4 -1656
- package/dist/scanner.js.map +1 -1
- package/dist/{types-xAXT9cir.d.cts → types-BZ3OeZ-5.d.cts} +28 -10
- package/dist/{types-xAXT9cir.d.ts → types-BZ3OeZ-5.d.ts} +28 -10
- package/package.json +20 -11
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,120 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.3.0] - 2026-11-30
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **Importing the package crashed in Node.js.** `import`/`require('@oxog/react-check')` threw
|
|
13
|
+
`ReferenceError: window is not defined` in 1.2.0 (ESM and CommonJS) because the browser
|
|
14
|
+
injection script, including its self-installing IIFE, was bundled into the main entry. The
|
|
15
|
+
entry is now side-effect free and safe for Node.js, SSR and test runners; the IIFE only lives
|
|
16
|
+
in `dist/browser-inject.global.js`.
|
|
17
|
+
- **Render counts were wrong.** Every commit was processed twice (the injected hook and
|
|
18
|
+
`BrowserScanner.start()` both forwarded it) and the whole fiber tree was walked each time, so
|
|
19
|
+
every mounted component was reported as rendering on every commit (e.g. a memoized child that
|
|
20
|
+
rendered once was reported 61 times and flagged critical). Only fibers that actually rendered
|
|
21
|
+
are counted now (React's `PerformedWork` flag, untouched subtrees skipped), `React.memo`
|
|
22
|
+
wrappers are not double counted, and "unnecessary" renders are judged against the previous
|
|
23
|
+
committed fiber instead of stale state. Works with development and production React builds.
|
|
24
|
+
- `quickScan()` never worked: it launched the browser without the ReactCheck script and always
|
|
25
|
+
failed with `REACT_NOT_FOUND`. It now runs the same pipeline as the CLI (internal WebSocket
|
|
26
|
+
server on a free port, injected script, scanner) and returns a real report.
|
|
27
|
+
- `--proxy` mode printed a `<script>` URL that nothing served. The CLI now starts the proxy on
|
|
28
|
+
`--port + 1`, which serves the real browser script and injects it at the start of `<head>`.
|
|
29
|
+
`ProxyServer` also served a stub instead of the scanner, injected after `</body>` (too late
|
|
30
|
+
for React) and forwarded `Transfer-Encoding: chunked` together with `Content-Length`, which
|
|
31
|
+
produced invalid HTTP responses for chunked upstream pages.
|
|
32
|
+
- Config file values (`thresholds`, `report.output`, `report.formats`) were always overridden
|
|
33
|
+
by the CLI's built-in defaults. Precedence is now: command-line flag > config file > default.
|
|
34
|
+
Config `include`/`exclude` and `rules` are applied too.
|
|
35
|
+
- Config file lookup (`findUp`) only checked the current directory and its parent; it now
|
|
36
|
+
walks up to the filesystem root.
|
|
37
|
+
- `react-check detect` and `react-check report` (documented in the README) did not exist: the
|
|
38
|
+
words were treated as URLs and a browser was launched at `http://detect`. Both commands are
|
|
39
|
+
implemented.
|
|
40
|
+
- `--format html,json` (documented) was rejected; comma-separated formats are accepted.
|
|
41
|
+
- Unknown options and options missing a value were silently ignored (`--duraton 30` scanned
|
|
42
|
+
forever in CI); they now exit with code 2. Non-http(s) targets are rejected.
|
|
43
|
+
- `--version` printed 1.1.6 and reports were stamped `1.1.6`; the exported `VERSION` was
|
|
44
|
+
`1.0.0`. All now come from one constant that a test keeps equal to `package.json`.
|
|
45
|
+
- "Avg FPS" was renders per second (e.g. 232). FPS is now measured in the page with
|
|
46
|
+
`requestAnimationFrame`; `Scanner.recordFps()` accepts external samples.
|
|
47
|
+
- `createScanner({ include, exclude })` ignored both options.
|
|
48
|
+
- Framework detection: `rsc` was reported for every Next.js version (and `^9.5.0` was parsed
|
|
49
|
+
as 95), Gatsby 4 was reported as `v5`, and `middleware.js` / `vite.config.js` were never
|
|
50
|
+
detected (`Promise || Promise`).
|
|
51
|
+
- Render chains were missed at random when two renders 1 ms apart straddled a 16 ms bucket.
|
|
52
|
+
- Browser cleanup: `ReactCheckInjector.destroy()` reconnected right after closing the socket,
|
|
53
|
+
left the DevTools hook wrapped and timers running; `Overlay.destroy()` left document
|
|
54
|
+
listeners behind and a pending init retry could re-create the overlay; `BrowserScanner.stop()`
|
|
55
|
+
kept processing commits when it had installed its own hook and restored a bound copy of the
|
|
56
|
+
original hook function. The offline message queue is now bounded.
|
|
57
|
+
- Very wide component trees (100k siblings) overflowed the stack; traversal is iterative.
|
|
58
|
+
- Component names and chain triggers were inserted into the overlay HTML unescaped.
|
|
59
|
+
- The WebSocket server buffered frames of any announced size; frames over 16 MiB now close
|
|
60
|
+
the connection. Handler exceptions are no longer hidden by the JSON parse `try`.
|
|
61
|
+
- `Scanner` timers no longer keep a Node.js process alive.
|
|
62
|
+
- `EventEmitter<T>` rejected plain `interface` event maps (index signature required).
|
|
63
|
+
- `FiberType` rejected class components; `ReactDevToolsHook` lacked the optional React hooks;
|
|
64
|
+
`RuleOptions` only allowed three rule ids that did not exist.
|
|
65
|
+
- A leftover debug `console.log` ("Overlay check") was printed during every scan.
|
|
66
|
+
|
|
67
|
+
### Added
|
|
68
|
+
|
|
69
|
+
- `react-check detect [path] [--json]` and `react-check report <file.json>` commands.
|
|
70
|
+
- Exit codes are documented: `0` clean, `1` critical issues found, `2` usage or runtime error.
|
|
71
|
+
- `quickScan` options `thresholds`, `include`, `exclude`, `port`, `browserArgs`.
|
|
72
|
+
- `installReactCheck(window)`, `loadInjectionScript(port)`, `matchComponentPattern()` and
|
|
73
|
+
`Scanner.recordFps()` / `isComponentIncluded()` exports; `WebSocketServer` and
|
|
74
|
+
`ProxyServer` accept port `0` and report the real port.
|
|
75
|
+
- `"./package.json"` export.
|
|
76
|
+
|
|
77
|
+
### Changed
|
|
78
|
+
|
|
79
|
+
- Puppeteer is only auto-installed in an interactive terminal outside CI. In CI, without a
|
|
80
|
+
TTY, or with `REACTCHECK_NO_INSTALL=1` the scan exits with code 2 and explains what to
|
|
81
|
+
install. Missing `browser-inject.global.js` is now an error instead of a silent no-op script.
|
|
82
|
+
- Shared code is split into chunks, so `@oxog/react-check` and its subpath entries
|
|
83
|
+
(`/scanner`, `/chain`, `/fix`, `/detect`) share one copy of each class (`instanceof` works
|
|
84
|
+
across entries).
|
|
85
|
+
- `--output` or `--format` imply `--report`.
|
|
86
|
+
- `BrowserLauncher`/`ProxyServer` no longer print debug-level logs.
|
|
87
|
+
- Fix-suggestion rule ids in generated configs are the real ones
|
|
88
|
+
(`unnecessary-rerenders-memo`, `function-prop-stability`, ...).
|
|
89
|
+
- Tooling: lint covers `src` and `tests` with zero warnings, tests are type-checked, coverage
|
|
90
|
+
thresholds are enforced, `npm run test:package` verifies the packed archive (ESM, CJS,
|
|
91
|
+
NodeNext types, CLI bins, and an end-to-end scan when Chrome is available), CI runs on
|
|
92
|
+
Node 18–24 and publishing is a manual workflow.
|
|
93
|
+
|
|
94
|
+
## [1.2.0] - 2025-12-31
|
|
95
|
+
|
|
96
|
+
### Added
|
|
97
|
+
|
|
98
|
+
- WebUI mode now automatically shows visible browser window for user interaction
|
|
99
|
+
- Improved headless mode prompt with clearer default (No = visible browser)
|
|
100
|
+
|
|
101
|
+
### Changed
|
|
102
|
+
|
|
103
|
+
- WebUI mode skips headless browser question (always shows browser for interaction)
|
|
104
|
+
- Default headless answer changed from Yes to No for better user experience
|
|
105
|
+
- Updated homepage URL to reactcheck.oxog.dev
|
|
106
|
+
- Reorganized documentation files into /docs folder
|
|
107
|
+
|
|
108
|
+
### Fixed
|
|
109
|
+
|
|
110
|
+
- Fixed browser window not appearing in WebUI mode due to default headless=true
|
|
111
|
+
- Memory leak from excessive WebSocket broadcasts (throttled to 500ms intervals)
|
|
112
|
+
- Render event flooding (limited to max 10 broadcasts per second)
|
|
113
|
+
- Overlay initialization infinite loop (added max 10 retries)
|
|
114
|
+
|
|
115
|
+
## [1.1.6] - 2025-12-31
|
|
116
|
+
|
|
117
|
+
### Fixed
|
|
118
|
+
|
|
119
|
+
- Improved React DevTools hook integration for better render detection
|
|
120
|
+
- Fixed overlay initialization timing issues
|
|
121
|
+
|
|
8
122
|
## [1.1.5] - 2025-12-31
|
|
9
123
|
|
|
10
124
|
### Fixed
|
|
@@ -57,7 +171,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
57
171
|
- WebSocket-based live updates
|
|
58
172
|
- Auto-opens in default browser
|
|
59
173
|
- `--webui` flag to enable dashboard
|
|
60
|
-
- `--webui-port` option for custom port (default:
|
|
174
|
+
- `--webui-port` option for custom port (default: 3099)
|
|
61
175
|
|
|
62
176
|
- **Browser Overlay Enhancements**: Visual feedback for component renders
|
|
63
177
|
- Flash effect with colored background on each render
|
package/README.md
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
# ReactCheck
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@oxog/react-check)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org)
|
|
6
|
+
|
|
3
7
|
A zero-dependency React performance scanner that detects unnecessary re-renders, analyzes render chains, and provides actionable fix suggestions.
|
|
4
8
|
|
|
9
|
+
**[Documentation](https://reactcheck.oxog.dev)** | **[npm](https://www.npmjs.com/package/@oxog/react-check)** | **[GitHub](https://github.com/ersinkoc/ReactCheck)**
|
|
10
|
+
|
|
5
11
|
## Features
|
|
6
12
|
|
|
7
13
|
- **Real-time Render Detection**: Monitor React component renders in real-time via React DevTools hook
|
|
@@ -10,22 +16,33 @@ A zero-dependency React performance scanner that detects unnecessary re-renders,
|
|
|
10
16
|
- **Multiple Report Formats**: Export reports as HTML, JSON, or Markdown
|
|
11
17
|
- **Framework Detection**: Automatic detection and framework-specific tips for Next.js, Remix, Vite, CRA, Gatsby
|
|
12
18
|
- **Interactive TUI**: Terminal-based UI for real-time monitoring
|
|
13
|
-
- **WebUI Dashboard**: Real-time web dashboard with live updates
|
|
14
|
-
- **Browser Overlay**: Visual overlay showing component render statistics
|
|
19
|
+
- **WebUI Dashboard**: Real-time web dashboard with live updates at localhost:3199
|
|
20
|
+
- **Browser Overlay**: Visual overlay showing component render statistics with severity colors
|
|
15
21
|
- **Zero Dependencies**: Core functionality has no external dependencies
|
|
16
22
|
|
|
17
23
|
## Installation
|
|
18
24
|
|
|
19
25
|
```bash
|
|
20
|
-
npm install @oxog/react-check
|
|
26
|
+
npm install --save-dev @oxog/react-check
|
|
21
27
|
```
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
Scanning a URL launches Chrome through [Puppeteer](https://pptr.dev), an optional peer dependency:
|
|
24
30
|
|
|
25
31
|
```bash
|
|
26
|
-
npm install @oxog/react-check puppeteer
|
|
32
|
+
npm install --save-dev @oxog/react-check puppeteer
|
|
27
33
|
```
|
|
28
34
|
|
|
35
|
+
- Node.js 18 or newer. The package ships ESM and CommonJS builds with TypeScript types.
|
|
36
|
+
- React is **not** a dependency: ReactCheck observes the page through the React DevTools
|
|
37
|
+
global hook, so it works with React 16.8+ development and production builds (verified with
|
|
38
|
+
React 18). There is no static source analysis; nothing in your project is parsed.
|
|
39
|
+
- When Puppeteer is missing, the CLI offers to install it only in an interactive terminal.
|
|
40
|
+
In CI (`CI` set), without a TTY, or with `REACTCHECK_NO_INSTALL=1` it exits with code 2
|
|
41
|
+
and tells you what to install instead.
|
|
42
|
+
- Importing `@oxog/react-check` has no side effects and does not touch `window`, so it is safe
|
|
43
|
+
in Node.js scripts, SSR bundles and test runners. The browser part ships separately as
|
|
44
|
+
`dist/browser-inject.global.js` and is injected by the CLI.
|
|
45
|
+
|
|
29
46
|
## Quick Start
|
|
30
47
|
|
|
31
48
|
### CLI Usage
|
|
@@ -36,11 +53,11 @@ Scan a React application:
|
|
|
36
53
|
npx react-check scan http://localhost:3000
|
|
37
54
|
```
|
|
38
55
|
|
|
39
|
-
With options:
|
|
56
|
+
With options (durations are in **seconds**):
|
|
40
57
|
|
|
41
58
|
```bash
|
|
42
59
|
npx react-check scan http://localhost:3000 \
|
|
43
|
-
--duration
|
|
60
|
+
--duration 60 \
|
|
44
61
|
--output ./reports \
|
|
45
62
|
--format html,json \
|
|
46
63
|
--headless
|
|
@@ -58,15 +75,25 @@ WebUI + custom port:
|
|
|
58
75
|
npx react-check scan http://localhost:3000 --webui --webui-port 8080
|
|
59
76
|
```
|
|
60
77
|
|
|
78
|
+
In CI:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npx react-check http://localhost:3000 --silent --headless --duration 30 --format json --output ./reactcheck-reports
|
|
82
|
+
```
|
|
83
|
+
|
|
61
84
|
### Programmatic Usage
|
|
62
85
|
|
|
86
|
+
`Scanner` aggregates render events (`RenderInfo`) that you feed it, computes per-component
|
|
87
|
+
statistics, severities, render chains and fix suggestions. The CLI and `quickScan()` feed it
|
|
88
|
+
from the browser; you can also feed it yourself.
|
|
89
|
+
|
|
63
90
|
```typescript
|
|
64
91
|
import { createScanner, generateHTMLReport } from '@oxog/react-check';
|
|
65
92
|
|
|
66
93
|
// Create a scanner instance
|
|
67
94
|
const scanner = createScanner({
|
|
68
95
|
thresholds: { critical: 50, warning: 20 },
|
|
69
|
-
include: ['MyComponent*'],
|
|
96
|
+
include: ['MyComponent*'], // glob patterns: * and ?
|
|
70
97
|
exclude: ['DebugPanel'],
|
|
71
98
|
});
|
|
72
99
|
|
|
@@ -75,16 +102,24 @@ scanner.on('render', (info) => {
|
|
|
75
102
|
console.log(`${info.componentName} rendered in ${info.renderTime}ms`);
|
|
76
103
|
});
|
|
77
104
|
|
|
78
|
-
// Start scanning
|
|
79
105
|
scanner.start();
|
|
106
|
+
scanner.addRender({
|
|
107
|
+
componentName: 'MyComponentList',
|
|
108
|
+
renderCount: 1,
|
|
109
|
+
renderTime: 2.4,
|
|
110
|
+
phase: 'update',
|
|
111
|
+
necessary: false,
|
|
112
|
+
timestamp: Date.now(),
|
|
113
|
+
});
|
|
114
|
+
scanner.stop();
|
|
80
115
|
|
|
81
|
-
//
|
|
82
|
-
const report = scanner.getReport();
|
|
83
|
-
const html = generateHTMLReport(report);
|
|
116
|
+
console.log(scanner.getSnapshot()); // per-component stats, sorted by severity
|
|
84
117
|
```
|
|
85
118
|
|
|
86
119
|
### Quick Scan API
|
|
87
120
|
|
|
121
|
+
Requires Puppeteer and Chrome. `duration` is in milliseconds here.
|
|
122
|
+
|
|
88
123
|
```typescript
|
|
89
124
|
import { quickScan } from '@oxog/react-check';
|
|
90
125
|
|
|
@@ -98,29 +133,68 @@ const report = await quickScan('http://localhost:3000', {
|
|
|
98
133
|
console.log(`Found ${report.summary.criticalIssues} critical issues`);
|
|
99
134
|
```
|
|
100
135
|
|
|
136
|
+
`quickScan` throws a `ReactCheckError` with code `BROWSER_LAUNCH_FAILED` when Puppeteer or
|
|
137
|
+
the page is unavailable and `REACT_NOT_FOUND` when no React render was observed.
|
|
138
|
+
|
|
101
139
|
## CLI Commands
|
|
102
140
|
|
|
103
|
-
### `scan <url>`
|
|
141
|
+
### `scan <url>` (default command)
|
|
104
142
|
|
|
105
|
-
Scan a React application for performance issues.
|
|
143
|
+
Scan a React application for performance issues. `react-check <url>` is the same as
|
|
144
|
+
`react-check scan <url>`; without a URL in an interactive terminal a setup wizard starts.
|
|
106
145
|
|
|
107
146
|
```bash
|
|
108
147
|
react-check scan <url> [options]
|
|
109
148
|
|
|
110
|
-
|
|
111
|
-
-
|
|
112
|
-
-
|
|
113
|
-
|
|
114
|
-
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
--
|
|
118
|
-
--
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
149
|
+
General:
|
|
150
|
+
-h, --help Show help message
|
|
151
|
+
-v, --version Show version number
|
|
152
|
+
--verbose Include detailed output
|
|
153
|
+
-c, --config <path> Config file path
|
|
154
|
+
|
|
155
|
+
Mode:
|
|
156
|
+
-P, --proxy Start a proxy on <port + 1> that injects ReactCheck into any browser
|
|
157
|
+
-t, --tui Terminal UI only (no browser)
|
|
158
|
+
-s, --silent No TUI (for CI/CD)
|
|
159
|
+
--headless Run browser in headless mode
|
|
160
|
+
-w, --watch Keep scanning until quit
|
|
161
|
+
-W, --webui Enable WebUI dashboard
|
|
162
|
+
--webui-port <port> WebUI dashboard port (default: 3199)
|
|
163
|
+
|
|
164
|
+
Report:
|
|
165
|
+
-r, --report Generate reports (implied by --format / --output)
|
|
166
|
+
-f, --format <formats> html, json, md, all or a comma-separated list (default: all)
|
|
167
|
+
-o, --output <dir> Report output directory (default: ./reactcheck-reports)
|
|
168
|
+
--fix Show fix suggestions
|
|
169
|
+
|
|
170
|
+
Thresholds:
|
|
171
|
+
--threshold-critical <n> Render count for critical (default: 50)
|
|
172
|
+
--threshold-warning <n> Render count for warning (default: 20)
|
|
173
|
+
--fps-threshold <n> FPS drop threshold (default: 30)
|
|
174
|
+
|
|
175
|
+
Network:
|
|
176
|
+
-p, --port <port> WebSocket server port (default: 3099)
|
|
177
|
+
-d, --duration <seconds> Stop after this many seconds (otherwise Ctrl+C / q)
|
|
122
178
|
```
|
|
123
179
|
|
|
180
|
+
Unknown options are rejected. Options given on the command line override the config file,
|
|
181
|
+
which overrides the defaults.
|
|
182
|
+
|
|
183
|
+
#### Exit codes
|
|
184
|
+
|
|
185
|
+
| Code | Meaning |
|
|
186
|
+
|------|---------|
|
|
187
|
+
| `0` | Scan finished without critical issues |
|
|
188
|
+
| `1` | Scan finished and found critical issues |
|
|
189
|
+
| `2` | Invalid usage, or the scan could not run (browser, port or page problems) |
|
|
190
|
+
|
|
191
|
+
#### Proxy mode
|
|
192
|
+
|
|
193
|
+
`react-check <url> --proxy` starts a proxy on `--port + 1` (default 3100). Open
|
|
194
|
+
`http://localhost:3100/<path>` in any browser; the proxy injects ReactCheck into every HTML
|
|
195
|
+
page. Alternatively add `<script src="http://localhost:3100/__reactcheck__/scanner.js"></script>`
|
|
196
|
+
to your page before React loads.
|
|
197
|
+
|
|
124
198
|
### `report <input>`
|
|
125
199
|
|
|
126
200
|
Generate reports from a JSON scan result.
|
|
@@ -131,7 +205,8 @@ react-check report scan-results.json --format html,md --output ./reports
|
|
|
131
205
|
|
|
132
206
|
### `detect [path]`
|
|
133
207
|
|
|
134
|
-
Detect the React framework
|
|
208
|
+
Detect the React framework of a project (path to a directory or a `package.json`; `--json`
|
|
209
|
+
prints machine-readable output).
|
|
135
210
|
|
|
136
211
|
```bash
|
|
137
212
|
react-check detect ./my-react-app
|
|
@@ -246,26 +321,36 @@ GitHub-friendly Markdown report suitable for issue tracking or documentation.
|
|
|
246
321
|
|
|
247
322
|
## Configuration
|
|
248
323
|
|
|
249
|
-
|
|
324
|
+
ReactCheck looks for `reactcheck.config.{js,mjs,cjs,json}`, `.reactcheckrc`,
|
|
325
|
+
`.reactcheckrc.js` or `.reactcheckrc.json` in the current directory and its parents
|
|
326
|
+
(`react-check init` creates one).
|
|
250
327
|
|
|
251
328
|
```typescript
|
|
252
|
-
|
|
253
|
-
|
|
329
|
+
/** @type {import('@oxog/react-check').ReactCheckConfig} */
|
|
330
|
+
export default {
|
|
331
|
+
// Component name patterns (* and ?)
|
|
332
|
+
include: [],
|
|
333
|
+
exclude: ['DebugPanel'],
|
|
254
334
|
thresholds: {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
335
|
+
critical: 50, // render count for critical severity
|
|
336
|
+
warning: 20, // render count for warning severity
|
|
337
|
+
fps: 30, // FPS drop threshold
|
|
338
|
+
},
|
|
339
|
+
report: {
|
|
340
|
+
formats: ['html', 'json'],
|
|
341
|
+
output: './reactcheck-reports',
|
|
342
|
+
},
|
|
343
|
+
// Fix-suggestion rules: 'off' disables a rule
|
|
344
|
+
rules: {
|
|
345
|
+
'state-too-high': 'off',
|
|
346
|
+
},
|
|
347
|
+
};
|
|
267
348
|
```
|
|
268
349
|
|
|
350
|
+
Rule ids: `unnecessary-rerenders-memo`, `expensive-computation-memo`,
|
|
351
|
+
`function-prop-stability`, `context-over-subscription`, `state-too-high`,
|
|
352
|
+
`extract-heavy-child`.
|
|
353
|
+
|
|
269
354
|
### Fix Categories
|
|
270
355
|
|
|
271
356
|
ReactCheck provides fix suggestions in these categories:
|
|
@@ -338,19 +423,30 @@ formatRenderTime(ms);
|
|
|
338
423
|
### Manual Injection
|
|
339
424
|
|
|
340
425
|
```typescript
|
|
341
|
-
import {
|
|
426
|
+
import { installReactCheck } from '@oxog/react-check';
|
|
342
427
|
|
|
343
|
-
|
|
344
|
-
const
|
|
428
|
+
// Must run before React loads; connects to a CLI started with --proxy or a scan
|
|
429
|
+
const injector = installReactCheck(window);
|
|
345
430
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
431
|
+
// Later: restores the React DevTools hook, removes the overlay, stops reconnecting
|
|
432
|
+
injector?.destroy();
|
|
433
|
+
```
|
|
349
434
|
|
|
350
|
-
scanner
|
|
351
|
-
|
|
435
|
+
Or use the scanner directly:
|
|
436
|
+
|
|
437
|
+
```typescript
|
|
438
|
+
import { BrowserScanner } from '@oxog/react-check';
|
|
439
|
+
|
|
440
|
+
const scanner = new BrowserScanner({ exclude: ['DevTools*'] }, window);
|
|
441
|
+
scanner.on('render', ({ render, element }) => {
|
|
442
|
+
console.log(render.componentName, render.necessary ? '' : '(unnecessary)', element);
|
|
443
|
+
});
|
|
444
|
+
scanner.start(); // hooks into React; stop() unhooks
|
|
352
445
|
```
|
|
353
446
|
|
|
447
|
+
Only components that actually rendered in a commit are reported; React.memo bail-outs and
|
|
448
|
+
untouched subtrees are not counted.
|
|
449
|
+
|
|
354
450
|
### Proxy Server
|
|
355
451
|
|
|
356
452
|
```typescript
|
|
@@ -364,7 +460,7 @@ const proxy = new ProxyServer({
|
|
|
364
460
|
});
|
|
365
461
|
|
|
366
462
|
await wsServer.start();
|
|
367
|
-
await proxy.start();
|
|
463
|
+
await proxy.start(); // serves the bundled browser script at /__reactcheck__/scanner.js
|
|
368
464
|
|
|
369
465
|
// Open http://localhost:8080 in browser
|
|
370
466
|
```
|
|
@@ -392,6 +488,8 @@ src/
|
|
|
392
488
|
│ ├── stats.ts # Statistics collector
|
|
393
489
|
│ └── fiber.ts # React fiber utilities
|
|
394
490
|
├── browser/ # Browser-side modules
|
|
491
|
+
│ ├── injector.ts # Page injector (side-effect free)
|
|
492
|
+
│ ├── inject.ts # IIFE entry -> dist/browser-inject.global.js
|
|
395
493
|
│ ├── scanner.ts # Browser scanner
|
|
396
494
|
│ └── overlay.ts # Visual overlay
|
|
397
495
|
├── server/ # Node.js server modules
|