@eslint-react/var 1.23.3-next.5 → 1.23.3-next.7

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 CHANGED
@@ -5,7 +5,6 @@ var ASTUtils = require('@typescript-eslint/utils/ast-utils');
5
5
  var types = require('@typescript-eslint/types');
6
6
  var AST3 = require('@eslint-react/ast');
7
7
  var scopeManager = require('@typescript-eslint/scope-manager');
8
- var tsPattern = require('ts-pattern');
9
8
 
10
9
  function _interopNamespace(e) {
11
10
  if (e && e.__esModule) return e;
@@ -41,10 +40,10 @@ function getScope(node, scopeManager) {
41
40
  const { type, parent } = node;
42
41
  const inner = type !== types.AST_NODE_TYPES.Program;
43
42
  const scope = scopeManager.acquire(node, inner);
44
- if (scope) {
43
+ if (scope != null) {
45
44
  return scope;
46
45
  }
47
- if (parent) {
46
+ if (parent != null) {
48
47
  return getScope(parent, scopeManager);
49
48
  }
50
49
  return null;
@@ -80,7 +79,7 @@ function getVariableNode(at) {
80
79
  return def.node;
81
80
  case (def.type === scopeManager.DefinitionType.Parameter && AST3__namespace.isFunction(def.node)):
82
81
  return def.node;
83
- case ("init" in def.node && def.node.init && !("declarations" in def.node.init)):
82
+ case ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)):
84
83
  return def.node.init;
85
84
  default:
86
85
  return null;
@@ -104,7 +103,7 @@ function isInitializedFromSource(name, source, initialScope) {
104
103
  return false;
105
104
  }
106
105
  const { node, parent } = latestDef.value;
107
- if (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init) {
106
+ if (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init != null) {
108
107
  const { init } = node;
109
108
  if (init.type === types.AST_NODE_TYPES.MemberExpression && init.object.type === types.AST_NODE_TYPES.Identifier) {
110
109
  return isInitializedFromSource(init.object.name, source, initialScope);
@@ -120,7 +119,7 @@ function isInitializedFromSource(name, source, initialScope) {
120
119
  eff.O.exists((arg) => arg.value === source || arg.value.startsWith(`${source}/`))
121
120
  );
122
121
  }
123
- return tsPattern.isMatching({ type: "ImportDeclaration", source: { value: source } }, parent);
122
+ return parent?.type === types.AST_NODE_TYPES.ImportDeclaration && parent.source.value === source;
124
123
  }
125
124
  function getRequireExpressionArguments(node) {
126
125
  switch (true) {
package/dist/index.mjs CHANGED
@@ -3,7 +3,6 @@ import * as ASTUtils from '@typescript-eslint/utils/ast-utils';
3
3
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
4
4
  import * as AST3 from '@eslint-react/ast';
5
5
  import { DefinitionType, ScopeType } from '@typescript-eslint/scope-manager';
6
- import { isMatching } from 'ts-pattern';
7
6
 
8
7
  // src/find-variable.ts
9
8
  var findVariable2 = F.dual(2, (nameOrNode, initialScope) => {
@@ -18,10 +17,10 @@ function getScope(node, scopeManager) {
18
17
  const { type, parent } = node;
19
18
  const inner = type !== AST_NODE_TYPES.Program;
20
19
  const scope = scopeManager.acquire(node, inner);
21
- if (scope) {
20
+ if (scope != null) {
22
21
  return scope;
23
22
  }
24
- if (parent) {
23
+ if (parent != null) {
25
24
  return getScope(parent, scopeManager);
26
25
  }
27
26
  return null;
@@ -57,7 +56,7 @@ function getVariableNode(at) {
57
56
  return def.node;
58
57
  case (def.type === DefinitionType.Parameter && AST3.isFunction(def.node)):
59
58
  return def.node;
60
- case ("init" in def.node && def.node.init && !("declarations" in def.node.init)):
59
+ case ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)):
61
60
  return def.node.init;
62
61
  default:
63
62
  return null;
@@ -81,7 +80,7 @@ function isInitializedFromSource(name, source, initialScope) {
81
80
  return false;
82
81
  }
83
82
  const { node, parent } = latestDef.value;
84
- if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init) {
83
+ if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) {
85
84
  const { init } = node;
86
85
  if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) {
87
86
  return isInitializedFromSource(init.object.name, source, initialScope);
@@ -97,7 +96,7 @@ function isInitializedFromSource(name, source, initialScope) {
97
96
  O.exists((arg) => arg.value === source || arg.value.startsWith(`${source}/`))
98
97
  );
99
98
  }
100
- return isMatching({ type: "ImportDeclaration", source: { value: source } }, parent);
99
+ return parent?.type === AST_NODE_TYPES.ImportDeclaration && parent.source.value === source;
101
100
  }
102
101
  function getRequireExpressionArguments(node) {
103
102
  switch (true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/var",
3
- "version": "1.23.3-next.5",
3
+ "version": "1.23.3-next.7",
4
4
  "description": "ESLint React's TSESTree AST utility module for static analysis of variables",
5
5
  "homepage": "https://github.com/rEl1cx/eslint-react",
6
6
  "bugs": {
@@ -38,9 +38,9 @@
38
38
  "@typescript-eslint/utils": "^8.19.1",
39
39
  "string-ts": "^2.2.0",
40
40
  "ts-pattern": "^5.6.0",
41
- "@eslint-react/ast": "1.23.3-next.5",
42
- "@eslint-react/types": "1.23.3-next.5",
43
- "@eslint-react/eff": "1.23.3-next.5"
41
+ "@eslint-react/ast": "1.23.3-next.7",
42
+ "@eslint-react/eff": "1.23.3-next.7",
43
+ "@eslint-react/types": "1.23.3-next.7"
44
44
  },
45
45
  "devDependencies": {
46
46
  "tsup": "^8.3.5",