eslint-plugin-react-hooks-extra 2.0.0-next.152 → 2.0.0-next.154

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 CHANGED
@@ -1,4 +1,4 @@
1
- import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
1
+ import * as _eslint_react_shared0 from "@eslint-react/shared";
2
2
  import { RulePreset } from "@eslint-react/kit";
3
3
 
4
4
  //#region src/index.d.ts
@@ -6,23 +6,10 @@ declare const _default: {
6
6
  configs: {
7
7
  recommended: {
8
8
  plugins: {
9
- "react-hooks-extra": {
10
- readonly meta: {
11
- readonly name: string;
12
- readonly version: string;
13
- };
14
- readonly rules: {
15
- readonly "no-direct-set-state-in-use-effect": _typescript_eslint_utils_ts_eslint0.RuleModule<"noDirectSetStateInUseEffect", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
16
- readonly "no-direct-set-state-in-use-layout-effect": _typescript_eslint_utils_ts_eslint0.RuleModule<"noDirectSetStateInUseLayoutEffect", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
17
- readonly "no-unnecessary-use-callback": _typescript_eslint_utils_ts_eslint0.RuleModule<"noUnnecessaryUseCallback", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
18
- readonly "no-unnecessary-use-memo": _typescript_eslint_utils_ts_eslint0.RuleModule<"noUnnecessaryUseMemo", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
19
- readonly "no-unnecessary-use-prefix": _typescript_eslint_utils_ts_eslint0.RuleModule<"noUnnecessaryUsePrefix", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
20
- readonly "prefer-use-state-lazy-initialization": _typescript_eslint_utils_ts_eslint0.RuleModule<"preferUseStateLazyInitialization", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
21
- };
22
- };
9
+ "react-hooks-extra": _eslint_react_shared0.CompatiblePlugin;
23
10
  };
24
- name: string;
25
- rules: RulePreset;
11
+ name?: string;
12
+ rules?: Record<string, any>;
26
13
  };
27
14
  "recommended-legacy": {
28
15
  plugins: string[];
@@ -30,17 +17,10 @@ declare const _default: {
30
17
  };
31
18
  };
32
19
  meta: {
33
- readonly name: string;
34
- readonly version: string;
35
- };
36
- rules: {
37
- readonly "no-direct-set-state-in-use-effect": _typescript_eslint_utils_ts_eslint0.RuleModule<"noDirectSetStateInUseEffect", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
38
- readonly "no-direct-set-state-in-use-layout-effect": _typescript_eslint_utils_ts_eslint0.RuleModule<"noDirectSetStateInUseLayoutEffect", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
39
- readonly "no-unnecessary-use-callback": _typescript_eslint_utils_ts_eslint0.RuleModule<"noUnnecessaryUseCallback", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
40
- readonly "no-unnecessary-use-memo": _typescript_eslint_utils_ts_eslint0.RuleModule<"noUnnecessaryUseMemo", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
41
- readonly "no-unnecessary-use-prefix": _typescript_eslint_utils_ts_eslint0.RuleModule<"noUnnecessaryUsePrefix", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
42
- readonly "prefer-use-state-lazy-initialization": _typescript_eslint_utils_ts_eslint0.RuleModule<"preferUseStateLazyInitialization", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
20
+ name: string;
21
+ version: string;
43
22
  };
23
+ rules: Record<string, any>;
44
24
  };
45
25
  //#endregion
46
26
  export { _default as default };
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ const rules = { "react-hooks-extra/no-direct-set-state-in-use-effect": "warn" };
29
29
  //#endregion
30
30
  //#region package.json
31
31
  var name = "eslint-plugin-react-hooks-extra";
32
- var version = "2.0.0-next.152";
32
+ var version = "2.0.0-next.154";
33
33
 
34
34
  //#endregion
35
35
  //#region src/rules-hooks/use-no-direct-set-state-in-use-effect.ts
@@ -78,7 +78,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
78
78
  }
79
79
  function isIdFromUseStateCall(topLevelId, at) {
80
80
  const variable = VAR.findVariable(topLevelId, context.sourceCode.getScope(topLevelId));
81
- const variableNode = VAR.getVariableInitNode(variable, 0);
81
+ const variableNode = VAR.getVariableDefinitionNode(variable, 0);
82
82
  if (variableNode == null) return false;
83
83
  if (variableNode.type !== AST_NODE_TYPES.CallExpression) return false;
84
84
  if (!ER.isReactHookCallWithNameAlias(context, "useState", hooks.useState)(variableNode)) return false;
@@ -182,7 +182,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
182
182
  },
183
183
  "Program:exit"() {
184
184
  const getSetStateCalls = (id, initialScope) => {
185
- const node = VAR.getVariableInitNode(VAR.findVariable(id, initialScope), 0);
185
+ const node = VAR.getVariableDefinitionNode(VAR.findVariable(id, initialScope), 0);
186
186
  switch (node?.type) {
187
187
  case AST_NODE_TYPES.ArrowFunctionExpression:
188
188
  case AST_NODE_TYPES.FunctionDeclaration:
@@ -344,7 +344,7 @@ function create$3(context) {
344
344
  if (arg0 == null || arg1 == null) return;
345
345
  const hasEmptyDeps = match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
346
346
  const variable = VAR.findVariable(n.name, initialScope);
347
- const variableNode = VAR.getVariableInitNode(variable, 0);
347
+ const variableNode = VAR.getVariableDefinitionNode(variable, 0);
348
348
  if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
349
349
  return variableNode.elements.length === 0;
350
350
  }).otherwise(() => false);
@@ -354,13 +354,13 @@ function create$3(context) {
354
354
  return n;
355
355
  }).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
356
356
  const variable = VAR.findVariable(n.name, initialScope);
357
- const variableNode = VAR.getVariableInitNode(variable, 0);
357
+ const variableNode = VAR.getVariableDefinitionNode(variable, 0);
358
358
  if (variableNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
359
359
  return variableNode;
360
360
  }).otherwise(() => null);
361
361
  if (arg0Node == null) return;
362
362
  const arg0NodeScope = context.sourceCode.getScope(arg0Node);
363
- const arg0NodeReferences = VAR.getChidScopes(arg0NodeScope).flatMap((x) => x.references);
363
+ const arg0NodeReferences = VAR.getChildScopes(arg0NodeScope).flatMap((x) => x.references);
364
364
  const isReferencedToComponentScope = arg0NodeReferences.some((x) => x.resolved?.scope.block === component);
365
365
  if (!isReferencedToComponentScope) context.report({
366
366
  messageId: "noUnnecessaryUseCallback",
@@ -428,7 +428,7 @@ function create$2(context) {
428
428
  if (hasCallInArg0) return;
429
429
  const hasEmptyDeps = match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
430
430
  const variable = VAR.findVariable(n.name, initialScope);
431
- const variableNode = VAR.getVariableInitNode(variable, 0);
431
+ const variableNode = VAR.getVariableDefinitionNode(variable, 0);
432
432
  if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
433
433
  return variableNode.elements.length === 0;
434
434
  }).otherwise(() => false);
@@ -438,13 +438,13 @@ function create$2(context) {
438
438
  return n;
439
439
  }).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
440
440
  const variable = VAR.findVariable(n.name, initialScope);
441
- const variableNode = VAR.getVariableInitNode(variable, 0);
441
+ const variableNode = VAR.getVariableDefinitionNode(variable, 0);
442
442
  if (variableNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
443
443
  return variableNode;
444
444
  }).otherwise(() => null);
445
445
  if (arg0Node == null) return;
446
446
  const arg0NodeScope = context.sourceCode.getScope(arg0Node);
447
- const arg0NodeReferences = VAR.getChidScopes(arg0NodeScope).flatMap((x) => x.references);
447
+ const arg0NodeReferences = VAR.getChildScopes(arg0NodeScope).flatMap((x) => x.references);
448
448
  const isReferencedToComponentScope = arg0NodeReferences.some((x) => x.resolved?.scope.block === component);
449
449
  if (!isReferencedToComponentScope) context.report({
450
450
  messageId: "noUnnecessaryUseMemo",
@@ -507,7 +507,7 @@ function create$1(context) {
507
507
  const allHooks = ctx.getAllHooks(program);
508
508
  for (const { id, name: name$2, node, hookCalls } of allHooks.values()) {
509
509
  if (WELL_KNOWN_HOOKS.includes(name$2)) continue;
510
- if (AST.isEmptyFunction(node)) continue;
510
+ if (AST.isFunctionEmpty(node)) continue;
511
511
  if (hookCalls.length > 0) continue;
512
512
  if (containsUseComments(context, node)) continue;
513
513
  if (id != null) {
@@ -638,13 +638,13 @@ const plugin = {
638
638
 
639
639
  //#endregion
640
640
  //#region src/index.ts
641
- function makeConfig(config) {
641
+ function toFlatConfig(config) {
642
642
  return {
643
643
  ...config,
644
644
  plugins: { "react-hooks-extra": plugin }
645
645
  };
646
646
  }
647
- function makeLegacyConfig({ rules: rules$1 }) {
647
+ function toLegacyConfig({ rules: rules$1 }) {
648
648
  return {
649
649
  plugins: ["react-hooks-extra"],
650
650
  rules: rules$1
@@ -653,8 +653,8 @@ function makeLegacyConfig({ rules: rules$1 }) {
653
653
  var src_default = {
654
654
  ...plugin,
655
655
  configs: {
656
- ["recommended"]: makeConfig(recommended_exports),
657
- ["recommended-legacy"]: makeLegacyConfig(recommended_exports)
656
+ ["recommended"]: toFlatConfig(recommended_exports),
657
+ ["recommended-legacy"]: toLegacyConfig(recommended_exports)
658
658
  }
659
659
  };
660
660
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-hooks-extra",
3
- "version": "2.0.0-next.152",
3
+ "version": "2.0.0-next.154",
4
4
  "description": "ESLint React's ESLint plugin for React Hooks related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -42,16 +42,16 @@
42
42
  "@typescript-eslint/utils": "^8.41.0",
43
43
  "string-ts": "^2.2.1",
44
44
  "ts-pattern": "^5.8.0",
45
- "@eslint-react/ast": "2.0.0-next.152",
46
- "@eslint-react/core": "2.0.0-next.152",
47
- "@eslint-react/kit": "2.0.0-next.152",
48
- "@eslint-react/shared": "2.0.0-next.152",
49
- "@eslint-react/eff": "2.0.0-next.152",
50
- "@eslint-react/var": "2.0.0-next.152"
45
+ "@eslint-react/ast": "2.0.0-next.154",
46
+ "@eslint-react/core": "2.0.0-next.154",
47
+ "@eslint-react/eff": "2.0.0-next.154",
48
+ "@eslint-react/kit": "2.0.0-next.154",
49
+ "@eslint-react/var": "2.0.0-next.154",
50
+ "@eslint-react/shared": "2.0.0-next.154"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/react": "^19.1.11",
54
- "@types/react-dom": "^19.1.8",
53
+ "@types/react": "^19.1.12",
54
+ "@types/react-dom": "^19.1.9",
55
55
  "tsdown": "^0.14.2",
56
56
  "@local/configs": "0.0.0"
57
57
  },
@@ -74,7 +74,7 @@
74
74
  "access": "public"
75
75
  },
76
76
  "scripts": {
77
- "build": "tsdown --dts-resolve",
77
+ "build": "tsdown",
78
78
  "lint:publish": "publint",
79
79
  "lint:ts": "tsc --noEmit"
80
80
  }