eslint-plugin-react-x 3.0.0-next.76 → 3.0.0-next.78
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 +13 -10
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -146,7 +146,7 @@ const rules$7 = {
|
|
|
146
146
|
//#endregion
|
|
147
147
|
//#region package.json
|
|
148
148
|
var name$6 = "eslint-plugin-react-x";
|
|
149
|
-
var version = "3.0.0-next.
|
|
149
|
+
var version = "3.0.0-next.78";
|
|
150
150
|
|
|
151
151
|
//#endregion
|
|
152
152
|
//#region src/utils/create-rule.ts
|
|
@@ -1378,7 +1378,7 @@ function create$60(context) {
|
|
|
1378
1378
|
* position 0 of any ancestor function.
|
|
1379
1379
|
*
|
|
1380
1380
|
* Uses scope resolution so that references to `props` inside nested arrow
|
|
1381
|
-
* functions (
|
|
1381
|
+
* functions (ex: event handlers) are correctly traced back to the component
|
|
1382
1382
|
* parameter, e.g.:
|
|
1383
1383
|
*
|
|
1384
1384
|
* function Component(props) { // ← props defined here
|
|
@@ -1563,7 +1563,7 @@ const RULE_NAME$57 = "jsx-no-comment-textnodes";
|
|
|
1563
1563
|
var jsx_no_comment_textnodes_default = createRule({
|
|
1564
1564
|
meta: {
|
|
1565
1565
|
type: "problem",
|
|
1566
|
-
docs: { description: "Prevents comment strings (
|
|
1566
|
+
docs: { description: "Prevents comment strings (ex: beginning with '//' or '/*') from being accidentally inserted into a JSX element's text nodes." },
|
|
1567
1567
|
messages: { default: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces." },
|
|
1568
1568
|
schema: []
|
|
1569
1569
|
},
|
|
@@ -5918,7 +5918,7 @@ function isForkingByTrueOrFalse(node) {
|
|
|
5918
5918
|
/**
|
|
5919
5919
|
* Gets the boolean value of a given literal node.
|
|
5920
5920
|
*
|
|
5921
|
-
* This is used to detect infinity loops (
|
|
5921
|
+
* This is used to detect infinity loops (ex: `while (true) {}`).
|
|
5922
5922
|
* Statements preceded by an infinity loop are unreachable if the loop didn't
|
|
5923
5923
|
* have any `break` statement.
|
|
5924
5924
|
*/
|
|
@@ -6751,7 +6751,7 @@ var set_state_in_effect_default = createRule({
|
|
|
6751
6751
|
});
|
|
6752
6752
|
function create$5(context) {
|
|
6753
6753
|
if (!/use\w*Effect/u.test(context.sourceCode.text)) return {};
|
|
6754
|
-
const { additionalStateHooks } = getSettingsFromContext(context);
|
|
6754
|
+
const { additionalStateHooks, additionalEffectHooks } = getSettingsFromContext(context);
|
|
6755
6755
|
const functionEntries = [];
|
|
6756
6756
|
const setupFnRef = { current: null };
|
|
6757
6757
|
const setupFnIds = [];
|
|
@@ -6773,15 +6773,18 @@ function create$5(context) {
|
|
|
6773
6773
|
function isUseStateCall(node) {
|
|
6774
6774
|
return core.isUseStateLikeCall(node, additionalStateHooks);
|
|
6775
6775
|
}
|
|
6776
|
+
function isUseEffectCall(node) {
|
|
6777
|
+
return core.isUseEffectLikeCall(node, additionalEffectHooks);
|
|
6778
|
+
}
|
|
6776
6779
|
function isUseEffectSetupCallback(node) {
|
|
6777
|
-
return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node &&
|
|
6780
|
+
return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node && isUseEffectCall(node.parent);
|
|
6778
6781
|
}
|
|
6779
6782
|
function getCallName(node) {
|
|
6780
6783
|
if (node.type === AST_NODE_TYPES.CallExpression) return ast.getFullyQualifiedName(node.callee, getText);
|
|
6781
6784
|
return ast.getFullyQualifiedName(node, getText);
|
|
6782
6785
|
}
|
|
6783
6786
|
function getCallKind(node) {
|
|
6784
|
-
return match(node).when(isUseStateCall, () => "useState").when(
|
|
6787
|
+
return match(node).when(isUseStateCall, () => "useState").when(isUseEffectCall, () => "useEffect").when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
|
|
6785
6788
|
}
|
|
6786
6789
|
function getFunctionKind(node) {
|
|
6787
6790
|
const parent = ast.findParentNode(node, not(ast.isTypeExpression)) ?? node.parent;
|
|
@@ -6912,7 +6915,7 @@ function create$5(context) {
|
|
|
6912
6915
|
if (init != null) getOrElseUpdate(setStateInEffectArg, init, () => []).push(node);
|
|
6913
6916
|
break;
|
|
6914
6917
|
}
|
|
6915
|
-
if (
|
|
6918
|
+
if (isUseEffectCall(node.parent)) getOrElseUpdate(setStateInEffectSetup, node.parent, () => []).push(node);
|
|
6916
6919
|
}
|
|
6917
6920
|
},
|
|
6918
6921
|
"Program:exit"() {
|
|
@@ -7267,10 +7270,10 @@ var use_state_default = createRule({
|
|
|
7267
7270
|
defaultOptions
|
|
7268
7271
|
});
|
|
7269
7272
|
function create$1(context) {
|
|
7270
|
-
if (!context.sourceCode.text.includes("useState")) return {};
|
|
7271
7273
|
const { enforceAssignment = true, enforceLazyInitialization = true, enforceSetterName = true } = context.options[0] ?? defaultOptions[0];
|
|
7274
|
+
const { additionalStateHooks } = getSettingsFromContext(context);
|
|
7272
7275
|
return defineRuleListener({ CallExpression(node) {
|
|
7273
|
-
if (!core.
|
|
7276
|
+
if (!core.isUseStateLikeCall(node, additionalStateHooks)) return;
|
|
7274
7277
|
if (enforceLazyInitialization) {
|
|
7275
7278
|
const [useStateInput] = node.arguments;
|
|
7276
7279
|
if (useStateInput != null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.78",
|
|
4
4
|
"description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-api-utils": "^2.4.0",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/ast": "3.0.0-next.
|
|
49
|
-
"@eslint-react/core": "3.0.0-next.
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@
|
|
52
|
-
"@eslint-react/var": "3.0.0-next.76"
|
|
48
|
+
"@eslint-react/ast": "3.0.0-next.78",
|
|
49
|
+
"@eslint-react/core": "3.0.0-next.78",
|
|
50
|
+
"@eslint-react/var": "3.0.0-next.78",
|
|
51
|
+
"@eslint-react/shared": "3.0.0-next.78"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
55
54
|
"@types/react": "^19.2.14",
|
|
56
55
|
"@types/react-dom": "^19.2.3",
|
|
57
56
|
"eslint": "^10.0.2",
|
|
58
|
-
"tsdown": "^0.21.0
|
|
57
|
+
"tsdown": "^0.21.0",
|
|
59
58
|
"tsl-dx": "^0.9.0",
|
|
60
|
-
"@local/configs": "0.0.0"
|
|
59
|
+
"@local/configs": "0.0.0",
|
|
60
|
+
"@local/eff": "3.0.0-beta.72"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"eslint": "^10.0.0",
|