You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/isolated-functions.md
+27-7Lines changed: 27 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,11 @@
5
5
<!-- end auto-generated rule header -->
6
6
<!-- Do not manually modify this header. Run: `npm run fix:eslint-docs` -->
7
7
8
-
Some functions need to be isolated from their surrounding scope due to execution context constraints. For example, functions passed to `makeSynchronous()` are executed in a subprocess and cannot access variables from outside their scope. This rule helps identify when functions are using external variables that may cause runtime errors.
8
+
Some functions need to be isolated from their surrounding scope due to execution context constraints. For example, functions passed to [`makeSynchronous()`](https://github.com/sindresorhus/make-synchronous) are executed in a worker or subprocess and cannot access variables from outside their scope. This rule helps identify when functions are using external variables that may cause runtime errors.
9
9
10
10
Common scenarios where functions must be isolated:
11
11
12
-
- Functions passed to `makeSynchronous()` (executed in subprocess)
12
+
- Functions passed to `makeSynchronous()` (executed in worker)
13
13
- Functions that will be serialized via `Function.prototype.toString()`
14
14
- Server actions or other remote execution contexts
15
15
- Functions with specific JSDoc annotations
@@ -23,10 +23,12 @@ import makeSynchronous from 'make-synchronous';
23
23
24
24
exportconstfetchSync= () => {
25
25
consturl='https://example.com';
26
+
26
27
constgetText=makeSynchronous(async () => {
27
28
constres=awaitfetch(url); // ❌ 'url' is not defined in isolated function scope
0 commit comments