eslint-plugin-react-rsc 5.14.0 → 5.14.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.
- package/dist/index.js +23 -25
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ const rules$4 = { "react-rsc/function-definition": "off" };
|
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region package.json
|
|
36
36
|
var name$4 = "eslint-plugin-react-rsc";
|
|
37
|
-
var version = "5.14.
|
|
37
|
+
var version = "5.14.1";
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/utils/create-rule.ts
|
|
@@ -409,11 +409,6 @@ var function_definition_default = createRule({
|
|
|
409
409
|
function isDirectiveName(value) {
|
|
410
410
|
return value === "use client" || value === "use server";
|
|
411
411
|
}
|
|
412
|
-
/**
|
|
413
|
-
* Match a statement against directive-like expressions (`'use client'`, `"use server"`, `` `use server` ``, etc.)
|
|
414
|
-
* @param stmt The statement to match
|
|
415
|
-
* @returns The match result, or `null` if the statement is not directive-like
|
|
416
|
-
*/
|
|
417
412
|
function matchDirective(stmt) {
|
|
418
413
|
if (stmt.type !== AST_NODE_TYPES.ExpressionStatement) return null;
|
|
419
414
|
const { expression } = stmt;
|
|
@@ -443,22 +438,34 @@ function create(context) {
|
|
|
443
438
|
const text = context.sourceCode.text;
|
|
444
439
|
if (!text.includes("use server") && !text.includes("use client")) return {};
|
|
445
440
|
const hasFileLevelUseServerDirective = context.sourceCode.ast.body.some((stmt) => Check.isDirective(stmt, "use server"));
|
|
446
|
-
/**
|
|
447
|
-
* Build a fix that makes `node` an async function
|
|
448
|
-
* @param node The function node to fix
|
|
449
|
-
* @returns The fix function, or `null` if no fix is available
|
|
450
|
-
*/
|
|
451
441
|
function buildFixForAsync(node) {
|
|
452
442
|
if (node.type === AST_NODE_TYPES.ArrowFunctionExpression) return (fixer) => fixer.insertTextBefore(node, "async ");
|
|
443
|
+
if (node.type === AST_NODE_TYPES.FunctionExpression) {
|
|
444
|
+
const { parent } = node;
|
|
445
|
+
if (parent.type === AST_NODE_TYPES.Property && parent.value === node) {
|
|
446
|
+
if (parent.kind !== "init") return null;
|
|
447
|
+
if (parent.method) return (fixer) => fixer.insertTextBefore(parent, "async ");
|
|
448
|
+
}
|
|
449
|
+
if (parent.type === AST_NODE_TYPES.MethodDefinition && parent.value === node) {
|
|
450
|
+
if (parent.kind !== "method") return null;
|
|
451
|
+
let target = parent.key;
|
|
452
|
+
if (parent.computed) {
|
|
453
|
+
const openBracket = context.sourceCode.getTokenBefore(parent.key);
|
|
454
|
+
if (openBracket?.value !== "[") return null;
|
|
455
|
+
target = openBracket;
|
|
456
|
+
}
|
|
457
|
+
if (node.generator) {
|
|
458
|
+
const star = context.sourceCode.getTokenBefore(target);
|
|
459
|
+
if (star?.value !== "*") return null;
|
|
460
|
+
target = star;
|
|
461
|
+
}
|
|
462
|
+
return (fixer) => fixer.insertTextBefore(target, "async ");
|
|
463
|
+
}
|
|
464
|
+
}
|
|
453
465
|
const functionToken = context.sourceCode.getFirstToken(node);
|
|
454
466
|
if (functionToken == null) return null;
|
|
455
467
|
return (fixer) => fixer.insertTextBefore(functionToken, "async ");
|
|
456
468
|
}
|
|
457
|
-
/**
|
|
458
|
-
* Report `node` if it resolves to a non-async function
|
|
459
|
-
* @param node The node to check, may be `null` for convenience at call sites
|
|
460
|
-
* @param messageId The message to report with
|
|
461
|
-
*/
|
|
462
469
|
function reportNonAsyncFunction(node, messageId) {
|
|
463
470
|
if (node == null) return;
|
|
464
471
|
const fn = Extract.unwrap(node);
|
|
@@ -469,10 +476,6 @@ function create(context) {
|
|
|
469
476
|
node: fn
|
|
470
477
|
});
|
|
471
478
|
}
|
|
472
|
-
/**
|
|
473
|
-
* Check file-level directives for correct position and quote style.
|
|
474
|
-
* @param program The Program node
|
|
475
|
-
*/
|
|
476
479
|
function checkFileDirectives(program) {
|
|
477
480
|
for (const stmt of program.body) {
|
|
478
481
|
const match = matchDirective(stmt);
|
|
@@ -484,11 +487,6 @@ function create(context) {
|
|
|
484
487
|
});
|
|
485
488
|
}
|
|
486
489
|
}
|
|
487
|
-
/**
|
|
488
|
-
* Check function-level directives for correct position and quote style,
|
|
489
|
-
* and report if a `use server` function is not async.
|
|
490
|
-
* @param node The function node to check
|
|
491
|
-
*/
|
|
492
490
|
function checkFunction(node) {
|
|
493
491
|
if (node.body.type !== AST_NODE_TYPES.BlockStatement) return;
|
|
494
492
|
for (const stmt of node.body.body) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-rsc",
|
|
3
|
-
"version": "5.14.
|
|
3
|
+
"version": "5.14.1",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for RSC related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@typescript-eslint/types": "^8.63.0",
|
|
40
40
|
"@typescript-eslint/utils": "^8.63.0",
|
|
41
|
-
"@eslint-react/ast": "5.14.
|
|
42
|
-
"@eslint-react/core": "5.14.
|
|
43
|
-
"@eslint-react/eslint": "5.14.
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
41
|
+
"@eslint-react/ast": "5.14.1",
|
|
42
|
+
"@eslint-react/core": "5.14.1",
|
|
43
|
+
"@eslint-react/eslint": "5.14.1",
|
|
44
|
+
"@eslint-react/var": "5.14.1",
|
|
45
|
+
"@eslint-react/shared": "5.14.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/react": "^19.2.17",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"eslint": "^10.6.0",
|
|
52
52
|
"tsdown": "^0.22.4",
|
|
53
53
|
"typescript": "6.0.3",
|
|
54
|
-
"@local/
|
|
55
|
-
"@local/
|
|
54
|
+
"@local/eff": "0.0.0",
|
|
55
|
+
"@local/configs": "0.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"eslint": "*",
|