eslint-plugin-react-x 2.8.2-beta.0 → 2.8.2-beta.4
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 +9 -10
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import { ESLintUtils } from "@typescript-eslint/utils";
|
|
|
4
4
|
import { P, isMatching, match } from "ts-pattern";
|
|
5
5
|
import ts from "typescript";
|
|
6
6
|
import * as core from "@eslint-react/core";
|
|
7
|
-
import { ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, isComponentDidCatch, isGetDerivedStateFromError, useComponentCollector, useComponentCollectorLegacy } from "@eslint-react/core";
|
|
8
7
|
import * as ast from "@eslint-react/ast";
|
|
9
8
|
import { findEnclosingAssignmentTarget, findVariable, getChildScopes, getObjectType, getVariableDefinitionNode, isAssignmentTargetEqual } from "@eslint-react/var";
|
|
10
9
|
import { constFalse, constTrue, flow, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
|
|
@@ -68,7 +67,7 @@ const rules$7 = {
|
|
|
68
67
|
//#endregion
|
|
69
68
|
//#region package.json
|
|
70
69
|
var name$6 = "eslint-plugin-react-x";
|
|
71
|
-
var version = "2.8.2-beta.
|
|
70
|
+
var version = "2.8.2-beta.4";
|
|
72
71
|
|
|
73
72
|
//#endregion
|
|
74
73
|
//#region src/utils/create-rule.ts
|
|
@@ -937,10 +936,10 @@ var no_class_component_default = createRule({
|
|
|
937
936
|
});
|
|
938
937
|
function create$45(context) {
|
|
939
938
|
if (!context.sourceCode.text.includes("Component")) return {};
|
|
940
|
-
const { ctx, visitor } = useComponentCollectorLegacy(context);
|
|
939
|
+
const { ctx, visitor } = core.useComponentCollectorLegacy(context);
|
|
941
940
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
942
941
|
for (const { name = "anonymous", node: component } of ctx.getAllComponents(program)) {
|
|
943
|
-
if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) continue;
|
|
942
|
+
if (component.body.body.some((m) => core.isComponentDidCatch(m) || core.isGetDerivedStateFromError(m))) continue;
|
|
944
943
|
context.report({
|
|
945
944
|
messageId: "noClassComponent",
|
|
946
945
|
node: component,
|
|
@@ -1443,7 +1442,7 @@ function create$33(context) {
|
|
|
1443
1442
|
}, ({ left, right }) => {
|
|
1444
1443
|
if (left.type === AST_NODE_TYPES.UnaryExpression && left.operator === "!") return getReportDescriptor(right);
|
|
1445
1444
|
const initialScope = context.sourceCode.getScope(left);
|
|
1446
|
-
if (ast.
|
|
1445
|
+
if (ast.isIdentifier(left, "NaN") || getStaticValue(left, initialScope)?.value === "NaN") return {
|
|
1447
1446
|
messageId: "noLeakedConditionalRendering",
|
|
1448
1447
|
node: left,
|
|
1449
1448
|
data: { value: context.sourceCode.getText(left) }
|
|
@@ -1481,14 +1480,14 @@ var no_missing_component_display_name_default = createRule({
|
|
|
1481
1480
|
});
|
|
1482
1481
|
function create$32(context) {
|
|
1483
1482
|
if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
|
|
1484
|
-
const { ctx, visitor } = useComponentCollector(context, {
|
|
1483
|
+
const { ctx, visitor } = core.useComponentCollector(context, {
|
|
1485
1484
|
collectDisplayName: true,
|
|
1486
|
-
hint: DEFAULT_COMPONENT_DETECTION_HINT
|
|
1485
|
+
hint: core.DEFAULT_COMPONENT_DETECTION_HINT
|
|
1487
1486
|
});
|
|
1488
1487
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
1489
1488
|
for (const { node, displayName, flag } of ctx.getAllComponents(program)) {
|
|
1490
1489
|
const id = ast.getFunctionId(node);
|
|
1491
|
-
const isMemoOrForwardRef = (flag & (ComponentFlag.ForwardRef | ComponentFlag.Memo)) > 0n;
|
|
1490
|
+
const isMemoOrForwardRef = (flag & (core.ComponentFlag.ForwardRef | core.ComponentFlag.Memo)) > 0n;
|
|
1492
1491
|
if (id != null) continue;
|
|
1493
1492
|
if (!isMemoOrForwardRef) continue;
|
|
1494
1493
|
if (displayName == null) context.report({
|
|
@@ -2460,7 +2459,7 @@ var no_unstable_context_value_default = createRule({
|
|
|
2460
2459
|
defaultOptions: []
|
|
2461
2460
|
});
|
|
2462
2461
|
function create$12(context) {
|
|
2463
|
-
if (ast.
|
|
2462
|
+
if (ast.getFileDirectives(context.sourceCode.ast).some((d) => d.value === "use memo")) return {};
|
|
2464
2463
|
const { version } = getSettingsFromContext(context);
|
|
2465
2464
|
const isReact18OrBelow = compare(version, "19.0.0", "<");
|
|
2466
2465
|
const { ctx, visitor } = core.useComponentCollector(context);
|
|
@@ -2537,7 +2536,7 @@ function extractIdentifier(node) {
|
|
|
2537
2536
|
return null;
|
|
2538
2537
|
}
|
|
2539
2538
|
function create$11(context, [options]) {
|
|
2540
|
-
if (ast.
|
|
2539
|
+
if (ast.getFileDirectives(context.sourceCode.ast).some((d) => d.value === "use memo")) return {};
|
|
2541
2540
|
const { ctx, visitor } = core.useComponentCollector(context);
|
|
2542
2541
|
const declarators = /* @__PURE__ */ new WeakMap();
|
|
2543
2542
|
const { safeDefaultProps = [] } = options;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "2.8.2-beta.
|
|
3
|
+
"version": "2.8.2-beta.4",
|
|
4
4
|
"description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"string-ts": "^2.3.1",
|
|
47
47
|
"ts-api-utils": "^2.4.0",
|
|
48
48
|
"ts-pattern": "^5.9.0",
|
|
49
|
-
"@eslint-react/ast": "2.8.2-beta.
|
|
50
|
-
"@eslint-react/core": "2.8.2-beta.
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/
|
|
49
|
+
"@eslint-react/ast": "2.8.2-beta.4",
|
|
50
|
+
"@eslint-react/core": "2.8.2-beta.4",
|
|
51
|
+
"@eslint-react/eff": "2.8.2-beta.4",
|
|
52
|
+
"@eslint-react/var": "2.8.2-beta.4",
|
|
53
|
+
"@eslint-react/shared": "2.8.2-beta.4"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/react": "^19.2.10",
|