eslint-plugin-react-rsc 5.2.1-next.1 → 5.2.2-beta.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/dist/index.js +8 -7
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared";
|
|
2
|
-
import
|
|
2
|
+
import { Check } from "@eslint-react/ast";
|
|
3
|
+
import * as core from "@eslint-react/core";
|
|
3
4
|
import { merge } from "@eslint-react/eslint";
|
|
4
5
|
import { resolve } from "@eslint-react/var";
|
|
5
6
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
@@ -33,7 +34,7 @@ const rules$4 = { "react-rsc/function-definition": "off" };
|
|
|
33
34
|
//#endregion
|
|
34
35
|
//#region package.json
|
|
35
36
|
var name$4 = "eslint-plugin-react-rsc";
|
|
36
|
-
var version = "5.2.
|
|
37
|
+
var version = "5.2.2-beta.0";
|
|
37
38
|
|
|
38
39
|
//#endregion
|
|
39
40
|
//#region src/utils/create-rule.ts
|
|
@@ -62,7 +63,7 @@ var function_definition_default = createRule({
|
|
|
62
63
|
});
|
|
63
64
|
function create(context) {
|
|
64
65
|
if (!context.sourceCode.text.includes("use server")) return {};
|
|
65
|
-
const hasFileLevelUseServerDirective =
|
|
66
|
+
const hasFileLevelUseServerDirective = context.sourceCode.ast.body.some((stmt) => Check.directive(stmt) && stmt.directive === "use server");
|
|
66
67
|
/**
|
|
67
68
|
* Check if `node` is an async function, and report if not
|
|
68
69
|
* @param node The function node to check
|
|
@@ -78,7 +79,7 @@ function create(context) {
|
|
|
78
79
|
return null;
|
|
79
80
|
}
|
|
80
81
|
function reportNonAsyncFunction(node, messageId) {
|
|
81
|
-
if (!
|
|
82
|
+
if (!Check.isFunction(node)) return false;
|
|
82
83
|
if (!node.async) {
|
|
83
84
|
context.report({
|
|
84
85
|
fix: getAsyncFix(node),
|
|
@@ -94,7 +95,7 @@ function create(context) {
|
|
|
94
95
|
* @param node The function node to check
|
|
95
96
|
*/
|
|
96
97
|
function checkLocalServerFunction(node) {
|
|
97
|
-
if (
|
|
98
|
+
if (core.getFunctionDirectives(node).some((d) => d.directive === "use server")) reportNonAsyncFunction(node, "local");
|
|
98
99
|
}
|
|
99
100
|
/**
|
|
100
101
|
* Find function declarations from exports and check them
|
|
@@ -103,7 +104,7 @@ function create(context) {
|
|
|
103
104
|
*/
|
|
104
105
|
function findAndCheckExportedFunctionDeclarations(id, node) {
|
|
105
106
|
const initNode = resolve(context, id);
|
|
106
|
-
if (initNode == null || !
|
|
107
|
+
if (initNode == null || !Check.isFunction(initNode)) return;
|
|
107
108
|
reportNonAsyncFunction(initNode, "file");
|
|
108
109
|
}
|
|
109
110
|
return merge({
|
|
@@ -114,7 +115,7 @@ function create(context) {
|
|
|
114
115
|
if (!hasFileLevelUseServerDirective) return;
|
|
115
116
|
const decl = node.declaration;
|
|
116
117
|
if (reportNonAsyncFunction(decl, "file")) return;
|
|
117
|
-
if (
|
|
118
|
+
if (Check.identifier(decl)) findAndCheckExportedFunctionDeclarations(decl, node);
|
|
118
119
|
},
|
|
119
120
|
ExportNamedDeclaration(node) {
|
|
120
121
|
if (!hasFileLevelUseServerDirective) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-rsc",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2-beta.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for RSC related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -42,10 +42,11 @@
|
|
|
42
42
|
"@typescript-eslint/types": "^8.58.1",
|
|
43
43
|
"@typescript-eslint/utils": "^8.58.1",
|
|
44
44
|
"ts-pattern": "^5.9.0",
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/shared": "5.2.
|
|
45
|
+
"@eslint-react/core": "5.2.2-beta.0",
|
|
46
|
+
"@eslint-react/ast": "5.2.2-beta.0",
|
|
47
|
+
"@eslint-react/eslint": "5.2.2-beta.0",
|
|
48
|
+
"@eslint-react/shared": "5.2.2-beta.0",
|
|
49
|
+
"@eslint-react/var": "5.2.2-beta.0"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@types/react": "^19.2.14",
|