@eslint-react/core 5.26.4 → 5.26.6

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -4
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Check, Extract, Traverse } from "@eslint-react/ast";
2
2
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
3
- import { randomBytes } from "node:crypto";
4
3
  import { RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE } from "@eslint-react/shared";
5
4
  import { resolve } from "@eslint-react/var";
6
5
  import { P, isMatching, match } from "ts-pattern";
@@ -252,6 +251,12 @@ function isThisSetStateCall(node) {
252
251
  return callee.type === AST_NODE_TYPES.MemberExpression && Extract.unwrap(callee.object).type === AST_NODE_TYPES.ThisExpression && Extract.getCalleeName(node) === "setState";
253
252
  }
254
253
  //#endregion
254
+ //#region src/collector-key.ts
255
+ let key = 0;
256
+ function getNextCollectorKey() {
257
+ return String(key++);
258
+ }
259
+ //#endregion
255
260
  //#region src/class-component-collector.ts
256
261
  function getClassComponentCollector(context) {
257
262
  const components = /* @__PURE__ */ new Map();
@@ -259,7 +264,7 @@ function getClassComponentCollector(context) {
259
264
  const collect = (node) => {
260
265
  if (!isClassComponent(node)) return;
261
266
  const id = getClassId(node);
262
- const key = randomBytes(8).toString("hex");
267
+ const key = getNextCollectorKey();
263
268
  const name = id == null ? null : Extract.getFullyQualifiedName(id, getText);
264
269
  components.set(key, {
265
270
  id,
@@ -642,7 +647,7 @@ function getFunctionComponentCollector(context, options = {}) {
642
647
  const getText = (n) => context.sourceCode.getText(n);
643
648
  const getCurrentEntry = () => functionEntries.at(-1) ?? null;
644
649
  const onFunctionEnter = (node) => {
645
- const key = randomBytes(8).toString("hex");
650
+ const key = getNextCollectorKey();
646
651
  const exp = Traverse.findParent(node, (n) => n.type === AST_NODE_TYPES.ExportDefaultDeclaration);
647
652
  const isExportDefault = exp != null;
648
653
  const isExportDefaultDeclaration = exp != null && Extract.unwrap(exp.declaration) === node;
@@ -739,7 +744,7 @@ function getHookCollector(context) {
739
744
  const id = getFunctionId(node);
740
745
  const entry = {
741
746
  id,
742
- key: randomBytes(8).toString("hex"),
747
+ key: getNextCollectorKey(),
743
748
  kind: "hook",
744
749
  name: id == null ? null : Extract.getFullyQualifiedName(id, getText),
745
750
  directives: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "5.26.4",
3
+ "version": "5.26.6",
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,13 +29,13 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@eslint-react/ast": "5.26.4",
33
- "@eslint-react/eslint": "5.26.4",
34
- "@eslint-react/shared": "5.26.4",
35
- "@eslint-react/var": "5.26.4",
32
+ "@eslint-react/ast": "5.26.6",
33
+ "@eslint-react/eslint": "5.26.6",
34
+ "@eslint-react/shared": "5.26.6",
35
+ "@eslint-react/var": "5.26.6",
36
36
  "@typescript-eslint/types": "^8.71.2",
37
37
  "@typescript-eslint/utils": "^8.71.2",
38
- "ts-pattern": "^5.9.0"
38
+ "ts-pattern": "^5.9.2"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@local/configs": "0.0.0",