eslint-plugin-react-x 5.9.0 → 5.9.2

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 +64 -48
  2. package/package.json +14 -14
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { compare } from "compare-versions";
13
13
  import { getConstrainedTypeAtLocation } from "@typescript-eslint/type-utils";
14
14
  import { unionConstituents } from "ts-api-utils";
15
15
  import { simpleTraverse } from "@typescript-eslint/typescript-estree";
16
- import { snakeCase } from "string-ts";
16
+ import { delimiterCase, snakeCase, toLowerCase } from "string-ts";
17
17
 
18
18
  //#region \0rolldown/runtime.js
19
19
  var __defProp = Object.defineProperty;
@@ -143,7 +143,7 @@ const rules$6 = {
143
143
  //#endregion
144
144
  //#region package.json
145
145
  var name$6 = "eslint-plugin-react-x";
146
- var version = "5.9.0";
146
+ var version = "5.9.2";
147
147
 
148
148
  //#endregion
149
149
  //#region src/utils/create-rule.ts
@@ -1145,7 +1145,7 @@ function getUnknownDependenciesMessage(reactiveHookName) {
1145
1145
  * Array methods that mutate the array in place.
1146
1146
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
1147
1147
  */
1148
- const MUTATING_ARRAY_METHODS$1 = new Set([
1148
+ const MUTATING_ARRAY_METHODS$1 = /* @__PURE__ */ new Set([
1149
1149
  "copyWithin",
1150
1150
  "fill",
1151
1151
  "pop",
@@ -1283,7 +1283,7 @@ function create$49(context) {
1283
1283
  * Array methods that mutate the array in place.
1284
1284
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
1285
1285
  */
1286
- const MUTATING_ARRAY_METHODS = new Set([
1286
+ const MUTATING_ARRAY_METHODS = /* @__PURE__ */ new Set([
1287
1287
  "copyWithin",
1288
1288
  "fill",
1289
1289
  "pop",
@@ -1804,7 +1804,7 @@ function report$2(context) {
1804
1804
  * `map` and `forEach` also cover `Children.map` and `Children.forEach`,
1805
1805
  * whose callback is the second argument instead of the first.
1806
1806
  */
1807
- const INDEX_PARAM_POSITIONS = new Map([
1807
+ const INDEX_PARAM_POSITIONS$1 = /* @__PURE__ */ new Map([
1808
1808
  ["every", 1],
1809
1809
  ["filter", 1],
1810
1810
  ["find", 1],
@@ -1837,7 +1837,7 @@ function isArrayIndexReference(context, node) {
1837
1837
  const callee = Extract.unwrap(call.callee);
1838
1838
  if (callee.type !== AST_NODE_TYPES.MemberExpression) return false;
1839
1839
  if (callee.property.type !== AST_NODE_TYPES.Identifier) return false;
1840
- const indexPosition = INDEX_PARAM_POSITIONS.get(callee.property.name);
1840
+ const indexPosition = INDEX_PARAM_POSITIONS$1.get(callee.property.name);
1841
1841
  if (indexPosition == null) return false;
1842
1842
  const callbackPosition = core.isChildrenMap(context, callee) || core.isChildrenForEach(context, callee) ? 1 : 0;
1843
1843
  if (call.arguments[callbackPosition] !== argument) return false;
@@ -1861,7 +1861,7 @@ function getIdentifiersFromBinaryExpression(side) {
1861
1861
  //#region src/rules/no-array-index-key/no-array-index-key.ts
1862
1862
  const RULE_NAME$46 = "no-array-index-key";
1863
1863
  /** Global functions that convert their first argument while preserving its identity as a key. */
1864
- const COERCION_FUNCTIONS = new Set(["Number", "String"]);
1864
+ const COERCION_FUNCTIONS = /* @__PURE__ */ new Set(["Number", "String"]);
1865
1865
  var no_array_index_key_default = createRule({
1866
1866
  meta: {
1867
1867
  type: "suggestion",
@@ -2818,6 +2818,16 @@ function create$25(context) {
2818
2818
  //#endregion
2819
2819
  //#region src/rules/no-missing-key/lib.ts
2820
2820
  /**
2821
+ * Iterator-like methods whose callback's return value becomes an item in a rendered list,
2822
+ * mapped to the position of the callback in the call's argument list.
2823
+ * `from` covers `Array.from(iterable, mapFn)`.
2824
+ */
2825
+ const INDEX_PARAM_POSITIONS = /* @__PURE__ */ new Map([
2826
+ ["flatMap", 0],
2827
+ ["from", 1],
2828
+ ["map", 0]
2829
+ ]);
2830
+ /**
2821
2831
  * Creates a report function for the given rule context.
2822
2832
  * @param context The ESLint rule context.
2823
2833
  * @returns A function that can be used to report violations.
@@ -2847,16 +2857,6 @@ function getNestedReturnStatements$1(node) {
2847
2857
  //#endregion
2848
2858
  //#region src/rules/no-missing-key/no-missing-key.ts
2849
2859
  const RULE_NAME$24 = "no-missing-key";
2850
- /**
2851
- * Iterator-like methods whose callback's return value becomes an item in a rendered list,
2852
- * mapped to the position of the callback in the call's argument list.
2853
- * `from` covers `Array.from(iterable, mapFn)`.
2854
- */
2855
- const ITERATOR_METHOD_CALLBACK_POSITIONS = new Map([
2856
- ["flatMap", 0],
2857
- ["from", 1],
2858
- ["map", 0]
2859
- ]);
2860
2860
  var no_missing_key_default = createRule({
2861
2861
  meta: {
2862
2862
  type: "problem",
@@ -2880,7 +2880,7 @@ function getIteratorCallback(node) {
2880
2880
  const callee = Extract.unwrap(node.callee);
2881
2881
  if (callee.type !== AST_NODE_TYPES.MemberExpression) return null;
2882
2882
  if (callee.property.type !== AST_NODE_TYPES.Identifier) return null;
2883
- const position = ITERATOR_METHOD_CALLBACK_POSITIONS.get(callee.property.name);
2883
+ const position = INDEX_PARAM_POSITIONS.get(callee.property.name);
2884
2884
  if (position == null) return null;
2885
2885
  const callback = node.arguments[position];
2886
2886
  if (callback == null || !Check.isFunction(callback)) return null;
@@ -3401,6 +3401,14 @@ function isContextName(name, isReact18OrBelow) {
3401
3401
  if (!isReact18OrBelow) return name.endsWith("Context") || name.endsWith("CONTEXT");
3402
3402
  return false;
3403
3403
  }
3404
+ function getHumanReadableKind$1(node) {
3405
+ if (node.type === AST_NODE_TYPES.Literal) {
3406
+ if ("regex" in node) return "regexp literal";
3407
+ if (node.value === null) return "null literal";
3408
+ return `${typeof node.value} literal`;
3409
+ }
3410
+ return toLowerCase(delimiterCase(node.type, " "));
3411
+ }
3404
3412
 
3405
3413
  //#endregion
3406
3414
  //#region src/rules/no-unstable-context-value/no-unstable-context-value.ts
@@ -3449,7 +3457,7 @@ function create$13(context) {
3449
3457
  const suggestion = kind === "function" ? "Consider wrapping it in a useCallback hook." : "Consider wrapping it in a useMemo hook.";
3450
3458
  context.report({
3451
3459
  data: {
3452
- kind: Extract.getHumanReadableKind(constructionNode),
3460
+ kind: getHumanReadableKind$1(constructionNode),
3453
3461
  suggestion
3454
3462
  },
3455
3463
  messageId: "unstableContextValue",
@@ -3468,6 +3476,14 @@ const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
3468
3476
  "[id.type='ObjectPattern']",
3469
3477
  "[init.type='Identifier']"
3470
3478
  ].join("");
3479
+ function getHumanReadableKind(node) {
3480
+ if (node.type === AST_NODE_TYPES.Literal) {
3481
+ if ("regex" in node) return "regexp literal";
3482
+ if (node.value === null) return "null literal";
3483
+ return `${typeof node.value} literal`;
3484
+ }
3485
+ return toLowerCase(delimiterCase(node.type, " "));
3486
+ }
3471
3487
 
3472
3488
  //#endregion
3473
3489
  //#region src/rules/no-unstable-default-props/no-unstable-default-props.ts
@@ -3536,7 +3552,7 @@ function create$12(context, [options]) {
3536
3552
  if (identifier != null && safePatterns.some((pattern) => pattern.test(identifier))) continue;
3537
3553
  }
3538
3554
  context.report({
3539
- data: { kind: Extract.getHumanReadableKind(right) },
3555
+ data: { kind: getHumanReadableKind(right) },
3540
3556
  messageId: "default",
3541
3557
  node: right
3542
3558
  });
@@ -3553,7 +3569,7 @@ function create$12(context, [options]) {
3553
3569
 
3554
3570
  //#endregion
3555
3571
  //#region src/rules/no-unused-class-component-members/lib.ts
3556
- const LIFECYCLE_METHODS = new Set([
3572
+ const LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
3557
3573
  "componentDidCatch",
3558
3574
  "componentDidMount",
3559
3575
  "componentDidUpdate",
@@ -3886,8 +3902,8 @@ function create$8(context) {
3886
3902
  /**
3887
3903
  * Known impure functions
3888
3904
  */
3889
- const IMPURE_FUNCS = new Map([
3890
- ["Atomics", new Set([
3905
+ const IMPURE_FUNCS = /* @__PURE__ */ new Map([
3906
+ ["Atomics", /* @__PURE__ */ new Set([
3891
3907
  "add",
3892
3908
  "and",
3893
3909
  "compareExchange",
@@ -3901,28 +3917,28 @@ const IMPURE_FUNCS = new Map([
3901
3917
  "waitAsync",
3902
3918
  "xor"
3903
3919
  ])],
3904
- ["caches", new Set([
3920
+ ["caches", /* @__PURE__ */ new Set([
3905
3921
  "delete",
3906
3922
  "has",
3907
3923
  "keys",
3908
3924
  "match",
3909
3925
  "open"
3910
3926
  ])],
3911
- ["clipboard", new Set([
3927
+ ["clipboard", /* @__PURE__ */ new Set([
3912
3928
  "read",
3913
3929
  "readText",
3914
3930
  "write",
3915
3931
  "writeText"
3916
3932
  ])],
3917
- ["cookieStore", new Set([
3933
+ ["cookieStore", /* @__PURE__ */ new Set([
3918
3934
  "delete",
3919
3935
  "get",
3920
3936
  "getAll",
3921
3937
  "set"
3922
3938
  ])],
3923
- ["crypto", new Set(["getRandomValues", "randomUUID"])],
3924
- ["Date", new Set(["now"])],
3925
- ["document", new Set([
3939
+ ["crypto", /* @__PURE__ */ new Set(["getRandomValues", "randomUUID"])],
3940
+ ["Date", /* @__PURE__ */ new Set(["now"])],
3941
+ ["document", /* @__PURE__ */ new Set([
3926
3942
  "adoptNode",
3927
3943
  "append",
3928
3944
  "close",
@@ -3965,7 +3981,7 @@ const IMPURE_FUNCS = new Map([
3965
3981
  "write",
3966
3982
  "writeln"
3967
3983
  ])],
3968
- ["globalThis", new Set([
3984
+ ["globalThis", /* @__PURE__ */ new Set([
3969
3985
  "addEventListener",
3970
3986
  "alert",
3971
3987
  "blur",
@@ -4002,32 +4018,32 @@ const IMPURE_FUNCS = new Map([
4002
4018
  "stop",
4003
4019
  "structuredClone"
4004
4020
  ])],
4005
- ["history", new Set([
4021
+ ["history", /* @__PURE__ */ new Set([
4006
4022
  "back",
4007
4023
  "forward",
4008
4024
  "go",
4009
4025
  "pushState",
4010
4026
  "replaceState"
4011
4027
  ])],
4012
- ["indexedDB", new Set([
4028
+ ["indexedDB", /* @__PURE__ */ new Set([
4013
4029
  "databases",
4014
4030
  "deleteDatabase",
4015
4031
  "open"
4016
4032
  ])],
4017
- ["localStorage", new Set([
4033
+ ["localStorage", /* @__PURE__ */ new Set([
4018
4034
  "clear",
4019
4035
  "getItem",
4020
4036
  "key",
4021
4037
  "removeItem",
4022
4038
  "setItem"
4023
4039
  ])],
4024
- ["location", new Set([
4040
+ ["location", /* @__PURE__ */ new Set([
4025
4041
  "assign",
4026
4042
  "reload",
4027
4043
  "replace"
4028
4044
  ])],
4029
- ["Math", new Set(["random"])],
4030
- ["navigation", new Set([
4045
+ ["Math", /* @__PURE__ */ new Set(["random"])],
4046
+ ["navigation", /* @__PURE__ */ new Set([
4031
4047
  "back",
4032
4048
  "forward",
4033
4049
  "navigate",
@@ -4035,7 +4051,7 @@ const IMPURE_FUNCS = new Map([
4035
4051
  "traverseTo",
4036
4052
  "updateCurrentEntry"
4037
4053
  ])],
4038
- ["navigator", new Set([
4054
+ ["navigator", /* @__PURE__ */ new Set([
4039
4055
  "canShare",
4040
4056
  "getBattery",
4041
4057
  "getGamepads",
@@ -4048,8 +4064,8 @@ const IMPURE_FUNCS = new Map([
4048
4064
  "share",
4049
4065
  "vibrate"
4050
4066
  ])],
4051
- ["Notification", new Set(["requestPermission"])],
4052
- ["Object", new Set([
4067
+ ["Notification", /* @__PURE__ */ new Set(["requestPermission"])],
4068
+ ["Object", /* @__PURE__ */ new Set([
4053
4069
  "assign",
4054
4070
  "defineProperties",
4055
4071
  "defineProperty",
@@ -4058,7 +4074,7 @@ const IMPURE_FUNCS = new Map([
4058
4074
  "seal",
4059
4075
  "setPrototypeOf"
4060
4076
  ])],
4061
- ["performance", new Set([
4077
+ ["performance", /* @__PURE__ */ new Set([
4062
4078
  "clearMarks",
4063
4079
  "clearMeasures",
4064
4080
  "getEntries",
@@ -4068,7 +4084,7 @@ const IMPURE_FUNCS = new Map([
4068
4084
  "measure",
4069
4085
  "now"
4070
4086
  ])],
4071
- ["process", new Set([
4087
+ ["process", /* @__PURE__ */ new Set([
4072
4088
  "abort",
4073
4089
  "chdir",
4074
4090
  "cpuUsage",
@@ -4082,23 +4098,23 @@ const IMPURE_FUNCS = new Map([
4082
4098
  "stderr",
4083
4099
  "stdout"
4084
4100
  ])],
4085
- ["Reflect", new Set([
4101
+ ["Reflect", /* @__PURE__ */ new Set([
4086
4102
  "defineProperty",
4087
4103
  "deleteProperty",
4088
4104
  "preventExtensions",
4089
4105
  "set",
4090
4106
  "setPrototypeOf"
4091
4107
  ])],
4092
- ["scheduler", new Set(["postTask", "yield"])],
4093
- ["sessionStorage", new Set([
4108
+ ["scheduler", /* @__PURE__ */ new Set(["postTask", "yield"])],
4109
+ ["sessionStorage", /* @__PURE__ */ new Set([
4094
4110
  "clear",
4095
4111
  "getItem",
4096
4112
  "key",
4097
4113
  "removeItem",
4098
4114
  "setItem"
4099
4115
  ])],
4100
- ["URL", new Set(["createObjectURL", "revokeObjectURL"])],
4101
- ["window", new Set([
4116
+ ["URL", /* @__PURE__ */ new Set(["createObjectURL", "revokeObjectURL"])],
4117
+ ["window", /* @__PURE__ */ new Set([
4102
4118
  "addEventListener",
4103
4119
  "alert",
4104
4120
  "blur",
@@ -4139,7 +4155,7 @@ const IMPURE_FUNCS = new Map([
4139
4155
  /**
4140
4156
  * Known impure global constructors used with `new`
4141
4157
  */
4142
- const IMPURE_CTORS = new Set([
4158
+ const IMPURE_CTORS = /* @__PURE__ */ new Set([
4143
4159
  "Audio",
4144
4160
  "AudioContext",
4145
4161
  "BroadcastChannel",
@@ -4432,7 +4448,7 @@ function create$6(context) {
4432
4448
  "Program:exit"(program) {
4433
4449
  const comps = fc.api.getAllComponents(program);
4434
4450
  const hooks = hc.api.getAllHooks(program);
4435
- const funcs = new Set([...comps.map((c) => c.node), ...hooks.map((h) => h.node)]);
4451
+ const funcs = /* @__PURE__ */ new Set([...comps.map((c) => c.node), ...hooks.map((h) => h.node)]);
4436
4452
  const isCompOrHookFn = (n) => Check.isFunction(n) && funcs.has(n);
4437
4453
  for (const { isWrite, node } of refAccesses) {
4438
4454
  const obj = Extract.unwrap(node.object);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "5.9.0",
3
+ "version": "5.9.2",
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",
@@ -36,30 +36,30 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@typescript-eslint/scope-manager": "^8.61.0",
40
- "@typescript-eslint/type-utils": "^8.61.0",
41
- "@typescript-eslint/types": "^8.61.0",
42
- "@typescript-eslint/typescript-estree": "^8.61.0",
43
- "@typescript-eslint/utils": "^8.61.0",
39
+ "@typescript-eslint/scope-manager": "^8.61.1",
40
+ "@typescript-eslint/type-utils": "^8.61.1",
41
+ "@typescript-eslint/types": "^8.61.1",
42
+ "@typescript-eslint/typescript-estree": "^8.61.1",
43
+ "@typescript-eslint/utils": "^8.61.1",
44
44
  "compare-versions": "^6.1.1",
45
45
  "string-ts": "^2.3.1",
46
46
  "ts-api-utils": "^2.5.0",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/core": "5.9.0",
49
- "@eslint-react/eslint": "5.9.0",
50
- "@eslint-react/var": "5.9.0",
51
- "@eslint-react/ast": "5.9.0",
52
- "@eslint-react/jsx": "5.9.0",
53
- "@eslint-react/shared": "5.9.0"
48
+ "@eslint-react/ast": "5.9.2",
49
+ "@eslint-react/core": "5.9.2",
50
+ "@eslint-react/eslint": "5.9.2",
51
+ "@eslint-react/jsx": "5.9.2",
52
+ "@eslint-react/shared": "5.9.2",
53
+ "@eslint-react/var": "5.9.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/react": "^19.2.17",
57
57
  "@types/react-dom": "^19.2.3",
58
58
  "dedent": "^1.7.2",
59
- "eslint": "^10.4.1",
59
+ "eslint": "^10.5.0",
60
60
  "react": "^19.2.7",
61
61
  "react-dom": "^19.2.7",
62
- "tsdown": "^0.22.2",
62
+ "tsdown": "^0.22.3",
63
63
  "tsl": "^1.0.30",
64
64
  "tsl-dx": "^0.12.2",
65
65
  "typescript": "6.0.3",