@eslint-react/core 5.19.1 → 5.20.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.d.ts +2 -2
- package/dist/index.js +11 -16
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -741,7 +741,7 @@ export declare namespace getHookCollector {
|
|
|
741
741
|
/** The api and visitor pair returned by {@link getHookCollector}. */
|
|
742
742
|
type ReturnType = {
|
|
743
743
|
api: {
|
|
744
|
-
getAllHooks(node: TSESTree.Program)
|
|
744
|
+
getAllHooks: (node: TSESTree.Program) => HookSemanticNode[];
|
|
745
745
|
};
|
|
746
746
|
visitor: ESLintUtils.RuleListener;
|
|
747
747
|
};
|
|
@@ -865,7 +865,7 @@ export declare function getJsxConfigFromAnnotation(context: RuleContext): JsxCon
|
|
|
865
865
|
* Get the fully‑merged JSX configuration for the current file.
|
|
866
866
|
*
|
|
867
867
|
* Compiler options provide the base values; pragma annotations found in the
|
|
868
|
-
* source override them where present.
|
|
868
|
+
* source override them where present. The result is cached per `sourceCode`.
|
|
869
869
|
*
|
|
870
870
|
* This is the main entry‑point most consumers should use.
|
|
871
871
|
*
|
package/dist/index.js
CHANGED
|
@@ -18,9 +18,7 @@ function isAPI(api) {
|
|
|
18
18
|
const expr = Extract.unwrap(node);
|
|
19
19
|
const getText = (n) => context.sourceCode.getText(n);
|
|
20
20
|
const name = Extract.getFullyQualifiedName(expr, getText);
|
|
21
|
-
|
|
22
|
-
if (name.endsWith(`.${api}`)) return true;
|
|
23
|
-
return false;
|
|
21
|
+
return name === api || name.endsWith(`.${api}`);
|
|
24
22
|
};
|
|
25
23
|
function dual(context, ...rest) {
|
|
26
24
|
return rest.length === 1 ? func(context, rest[0]) : (node) => func(context, node);
|
|
@@ -314,9 +312,6 @@ function isAssignmentToThisState(node) {
|
|
|
314
312
|
*/
|
|
315
313
|
function getClassComponentCollector(context) {
|
|
316
314
|
const components = /* @__PURE__ */ new Map();
|
|
317
|
-
const api = { getAllComponents(_) {
|
|
318
|
-
return [...components.values()];
|
|
319
|
-
} };
|
|
320
315
|
const getText = (n) => context.sourceCode.getText(n);
|
|
321
316
|
const collect = (node) => {
|
|
322
317
|
if (!isClassComponent(node)) return;
|
|
@@ -336,7 +331,9 @@ function getClassComponentCollector(context) {
|
|
|
336
331
|
});
|
|
337
332
|
};
|
|
338
333
|
return {
|
|
339
|
-
api
|
|
334
|
+
api: { getAllComponents(_) {
|
|
335
|
+
return [...components.values()];
|
|
336
|
+
} },
|
|
340
337
|
visitor: {
|
|
341
338
|
ClassDeclaration: collect,
|
|
342
339
|
ClassExpression: collect
|
|
@@ -663,7 +660,7 @@ function isJsxLike(context, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
663
660
|
case AST_NODE_TYPES.SequenceExpression: return visit(node.expressions.at(-1) ?? null);
|
|
664
661
|
case AST_NODE_TYPES.CallExpression:
|
|
665
662
|
if (hint & JsxDetectionHint.DoNotIncludeJsxWithCreateElementValue) return false;
|
|
666
|
-
return
|
|
663
|
+
return isCreateElementCall(context, node);
|
|
667
664
|
case AST_NODE_TYPES.Identifier:
|
|
668
665
|
if (node.name === "undefined") return !(hint & JsxDetectionHint.DoNotIncludeJsxWithUndefinedValue);
|
|
669
666
|
if (seen.has(node)) return false;
|
|
@@ -847,8 +844,7 @@ function isFunctionComponentDefinition(context, node, hint) {
|
|
|
847
844
|
AST_NODE_TYPES.ClassBody
|
|
848
845
|
]));
|
|
849
846
|
if (significantParent == null) return true;
|
|
850
|
-
|
|
851
|
-
return true;
|
|
847
|
+
return significantParent.type !== AST_NODE_TYPES.JSXExpressionContainer;
|
|
852
848
|
}
|
|
853
849
|
|
|
854
850
|
//#endregion
|
|
@@ -1577,16 +1573,15 @@ function getFunctionComponentCollector(context, options = {}) {
|
|
|
1577
1573
|
* @returns The api and visitor of the collector.
|
|
1578
1574
|
*/
|
|
1579
1575
|
function getHookCollector(context) {
|
|
1580
|
-
const hooks = /* @__PURE__ */ new Map();
|
|
1581
1576
|
const functionEntries = [];
|
|
1577
|
+
const hooks = /* @__PURE__ */ new Map();
|
|
1582
1578
|
const getText = (n) => context.sourceCode.getText(n);
|
|
1583
1579
|
const getCurrentEntry = () => functionEntries.at(-1) ?? null;
|
|
1584
1580
|
const onFunctionEnter = (node) => {
|
|
1585
1581
|
const id = getFunctionId(node);
|
|
1586
|
-
const key = randomBytes(8).toString("hex");
|
|
1587
1582
|
const entry = {
|
|
1588
1583
|
id,
|
|
1589
|
-
key,
|
|
1584
|
+
key: randomBytes(8).toString("hex"),
|
|
1590
1585
|
kind: "hook",
|
|
1591
1586
|
name: id == null ? null : Extract.getFullyQualifiedName(id, getText),
|
|
1592
1587
|
directives: [],
|
|
@@ -1599,10 +1594,10 @@ function getHookCollector(context) {
|
|
|
1599
1594
|
};
|
|
1600
1595
|
functionEntries.push(entry);
|
|
1601
1596
|
if (!entry.isHookDefinition) return;
|
|
1602
|
-
hooks.set(key, entry);
|
|
1597
|
+
hooks.set(entry.key, entry);
|
|
1603
1598
|
};
|
|
1604
1599
|
const onFunctionExit = () => {
|
|
1605
|
-
functionEntries.pop();
|
|
1600
|
+
return functionEntries.pop();
|
|
1606
1601
|
};
|
|
1607
1602
|
return {
|
|
1608
1603
|
api: { getAllHooks(_) {
|
|
@@ -1706,7 +1701,7 @@ function getJsxConfigFromAnnotation(context) {
|
|
|
1706
1701
|
* Get the fully‑merged JSX configuration for the current file.
|
|
1707
1702
|
*
|
|
1708
1703
|
* Compiler options provide the base values; pragma annotations found in the
|
|
1709
|
-
* source override them where present.
|
|
1704
|
+
* source override them where present. The result is cached per `sourceCode`.
|
|
1710
1705
|
*
|
|
1711
1706
|
* This is the main entry‑point most consumers should use.
|
|
1712
1707
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20.1",
|
|
4
4
|
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@eslint-react/ast": "5.
|
|
33
|
-
"@eslint-react/eslint": "5.
|
|
34
|
-
"@eslint-react/shared": "5.
|
|
35
|
-
"@eslint-react/var": "5.
|
|
32
|
+
"@eslint-react/ast": "5.20.1",
|
|
33
|
+
"@eslint-react/eslint": "5.20.1",
|
|
34
|
+
"@eslint-react/shared": "5.20.1",
|
|
35
|
+
"@eslint-react/var": "5.20.1",
|
|
36
36
|
"@typescript-eslint/scope-manager": "^8.70.0",
|
|
37
37
|
"@typescript-eslint/types": "^8.70.0",
|
|
38
38
|
"@typescript-eslint/utils": "^8.70.0",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"@local/testkit": "0.0.0",
|
|
45
45
|
"@typescript-eslint/parser": "^8.70.0",
|
|
46
46
|
"@typescript-eslint/typescript-estree": "^8.70.0",
|
|
47
|
-
"eslint": "^10.
|
|
47
|
+
"eslint": "^10.11.0",
|
|
48
48
|
"tsdown": "^0.23.0",
|
|
49
49
|
"typescript": "6.0.3",
|
|
50
|
-
"vitest": "^5.0.
|
|
50
|
+
"vitest": "^5.0.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"eslint": "*",
|