@eslint-react/jsx 1.20.2-next.2 → 1.20.2-next.5

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.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TSESTree } from '@typescript-eslint/types';
2
- import { O } from '@eslint-react/tools';
2
+ import { O } from '@eslint-react/eff';
3
3
  import { Scope } from '@typescript-eslint/scope-manager';
4
4
  import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
5
5
  import * as birecord from 'birecord';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TSESTree } from '@typescript-eslint/types';
2
- import { O } from '@eslint-react/tools';
2
+ import { O } from '@eslint-react/eff';
3
3
  import { Scope } from '@typescript-eslint/scope-manager';
4
4
  import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
5
5
  import * as birecord from 'birecord';
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var types = require('@typescript-eslint/types');
4
4
  var AST = require('@eslint-react/ast');
5
- var tools = require('@eslint-react/tools');
5
+ var eff = require('@eslint-react/eff');
6
6
  var VAR = require('@eslint-react/var');
7
7
  var tsPattern = require('ts-pattern');
8
8
  var birecord = require('birecord');
@@ -69,19 +69,19 @@ function getProp(props, propName, initialScope) {
69
69
  function getPropValue(attribute, initialScope) {
70
70
  if (attribute.type === types.AST_NODE_TYPES.JSXAttribute && "value" in attribute) {
71
71
  const { value } = attribute;
72
- if (value === null) return tools.O.none();
72
+ if (value === null) return eff.O.none();
73
73
  if (value.type === types.AST_NODE_TYPES.Literal) return VAR__namespace.getStaticValue(value, initialScope);
74
74
  if (value.type === types.AST_NODE_TYPES.JSXExpressionContainer) {
75
75
  return VAR__namespace.getStaticValue(value.expression, initialScope);
76
76
  }
77
- return tools.O.none();
77
+ return eff.O.none();
78
78
  }
79
79
  const { argument } = attribute;
80
80
  return VAR__namespace.getStaticValue(argument, initialScope);
81
81
  }
82
82
  function findPropInProperties(properties, initialScope, seenProps = []) {
83
83
  return (propName) => {
84
- return tools.O.fromNullable(
84
+ return eff.O.fromNullable(
85
85
  properties.findLast((prop) => {
86
86
  switch (true) {
87
87
  case (prop.type === types.AST_NODE_TYPES.Property && "name" in prop.key && prop.key.name === propName):
@@ -90,20 +90,20 @@ function findPropInProperties(properties, initialScope, seenProps = []) {
90
90
  switch (true) {
91
91
  case prop.argument.type === types.AST_NODE_TYPES.Identifier: {
92
92
  const { name } = prop.argument;
93
- const maybeInit = tools.O.flatMap(
93
+ const maybeInit = eff.O.flatMap(
94
94
  VAR__namespace.findVariable(name, initialScope),
95
95
  VAR__namespace.getVariableNode(0)
96
96
  );
97
- if (tools.O.isNone(maybeInit)) return false;
97
+ if (eff.O.isNone(maybeInit)) return false;
98
98
  const init = maybeInit.value;
99
99
  if (!AST__namespace.is(types.AST_NODE_TYPES.ObjectExpression)(init)) return false;
100
100
  if (seenProps.includes(name)) return false;
101
- return tools.O.isSome(
101
+ return eff.O.isSome(
102
102
  findPropInProperties(init.properties, initialScope, [...seenProps, name])(propName)
103
103
  );
104
104
  }
105
105
  case prop.argument.type === types.AST_NODE_TYPES.ObjectExpression: {
106
- return tools.O.isSome(
106
+ return eff.O.isSome(
107
107
  findPropInProperties(prop.argument.properties, initialScope, seenProps)(propName)
108
108
  );
109
109
  }
@@ -122,7 +122,7 @@ function findPropInProperties(properties, initialScope, seenProps = []) {
122
122
  }
123
123
  function findPropInAttributes(attributes, initialScope) {
124
124
  return (propName) => {
125
- return tools.O.fromNullable(
125
+ return eff.O.fromNullable(
126
126
  attributes.findLast((attr) => {
127
127
  switch (attr.type) {
128
128
  case types.AST_NODE_TYPES.JSXAttribute:
@@ -133,19 +133,19 @@ function findPropInAttributes(attributes, initialScope) {
133
133
  return false;
134
134
  case types.AST_NODE_TYPES.Identifier: {
135
135
  const { name } = attr.argument;
136
- const maybeInit = tools.O.flatMap(
136
+ const maybeInit = eff.O.flatMap(
137
137
  VAR__namespace.findVariable(name, initialScope),
138
138
  VAR__namespace.getVariableNode(0)
139
139
  );
140
- if (tools.O.isNone(maybeInit)) return false;
140
+ if (eff.O.isNone(maybeInit)) return false;
141
141
  const init = maybeInit.value;
142
142
  if (!AST__namespace.is(types.AST_NODE_TYPES.ObjectExpression)(init)) return false;
143
- return tools.O.isSome(findPropInProperties(init.properties, initialScope)(propName));
143
+ return eff.O.isSome(findPropInProperties(init.properties, initialScope)(propName));
144
144
  }
145
145
  case types.AST_NODE_TYPES.MemberExpression:
146
146
  return false;
147
147
  case types.AST_NODE_TYPES.ObjectExpression:
148
- return tools.O.isSome(findPropInProperties(attr.argument.properties, initialScope)(propName));
148
+ return eff.O.isSome(findPropInProperties(attr.argument.properties, initialScope)(propName));
149
149
  default:
150
150
  return false;
151
151
  }
@@ -157,7 +157,7 @@ function findPropInAttributes(attributes, initialScope) {
157
157
  };
158
158
  }
159
159
  function hasProp(attributes, propName, initialScope) {
160
- return tools.O.isSome(findPropInAttributes(attributes, initialScope)(propName));
160
+ return eff.O.isSome(findPropInAttributes(attributes, initialScope)(propName));
161
161
  }
162
162
  function hasAnyProp(attributes, propNames, initialScope) {
163
163
  return propNames.some((propName) => hasProp(attributes, propName, initialScope));
@@ -190,8 +190,8 @@ var JSXValueHint = {
190
190
  var DEFAULT_JSX_VALUE_HINT = 0n | JSXValueHint.SkipUndefinedLiteral | JSXValueHint.SkipBooleanLiteral;
191
191
  function isJSXValue(node, jsxCtx, hint = DEFAULT_JSX_VALUE_HINT) {
192
192
  if (!node) return false;
193
- return tsPattern.match(node).with({ type: types.AST_NODE_TYPES.JSXElement }, tools.F.constTrue).with({ type: types.AST_NODE_TYPES.JSXFragment }, tools.F.constTrue).with({ type: types.AST_NODE_TYPES.JSXMemberExpression }, tools.F.constTrue).with({ type: types.AST_NODE_TYPES.JSXNamespacedName }, tools.F.constTrue).with({ type: types.AST_NODE_TYPES.Literal }, (node2) => {
194
- return tsPattern.match(node2.value).with(null, () => !(hint & JSXValueHint.SkipNullLiteral)).with(tsPattern.P.boolean, () => !(hint & JSXValueHint.SkipBooleanLiteral)).with(tsPattern.P.string, () => !(hint & JSXValueHint.SkipStringLiteral)).with(tsPattern.P.number, () => !(hint & JSXValueHint.SkipNumberLiteral)).otherwise(tools.F.constFalse);
193
+ return tsPattern.match(node).with({ type: types.AST_NODE_TYPES.JSXElement }, eff.F.constTrue).with({ type: types.AST_NODE_TYPES.JSXFragment }, eff.F.constTrue).with({ type: types.AST_NODE_TYPES.JSXMemberExpression }, eff.F.constTrue).with({ type: types.AST_NODE_TYPES.JSXNamespacedName }, eff.F.constTrue).with({ type: types.AST_NODE_TYPES.Literal }, (node2) => {
194
+ return tsPattern.match(node2.value).with(null, () => !(hint & JSXValueHint.SkipNullLiteral)).with(tsPattern.P.boolean, () => !(hint & JSXValueHint.SkipBooleanLiteral)).with(tsPattern.P.string, () => !(hint & JSXValueHint.SkipStringLiteral)).with(tsPattern.P.number, () => !(hint & JSXValueHint.SkipNumberLiteral)).otherwise(eff.F.constFalse);
195
195
  }).with({ type: types.AST_NODE_TYPES.TemplateLiteral }, () => !(hint & JSXValueHint.SkipStringLiteral)).with({ type: types.AST_NODE_TYPES.ArrayExpression }, (node2) => {
196
196
  if (hint & JSXValueHint.StrictArray) return node2.elements.every((n) => isJSXValue(n, jsxCtx, hint));
197
197
  return node2.elements.some((n) => isJSXValue(n, jsxCtx, hint));
@@ -223,22 +223,22 @@ function isJSXValue(node, jsxCtx, hint = DEFAULT_JSX_VALUE_HINT) {
223
223
  return isJSXValue(exp, jsxCtx, hint);
224
224
  }).with({ type: types.AST_NODE_TYPES.CallExpression }, (node2) => {
225
225
  if (hint & JSXValueHint.SkipCreateElement) return false;
226
- return tsPattern.match(node2.callee).with({ type: types.AST_NODE_TYPES.Identifier, name: "createElement" }, tools.F.constTrue).with({ type: types.AST_NODE_TYPES.MemberExpression, property: { name: "createElement" } }, tools.F.constTrue).otherwise(tools.F.constFalse);
226
+ return tsPattern.match(node2.callee).with({ type: types.AST_NODE_TYPES.Identifier, name: "createElement" }, eff.F.constTrue).with({ type: types.AST_NODE_TYPES.MemberExpression, property: { name: "createElement" } }, eff.F.constTrue).otherwise(eff.F.constFalse);
227
227
  }).with({ type: types.AST_NODE_TYPES.Identifier }, (node2) => {
228
228
  const { name } = node2;
229
229
  if (name === "undefined") return !(hint & JSXValueHint.SkipUndefinedLiteral);
230
230
  if (AST__namespace.isJSXTagNameExpression(node2)) return true;
231
231
  const initialScope = jsxCtx.getScope(node2);
232
- return tools.F.pipe(
232
+ return eff.F.pipe(
233
233
  VAR__namespace.findVariable(name, initialScope),
234
- tools.O.flatMap(VAR__namespace.getVariableNode(0)),
235
- tools.O.exists((n) => isJSXValue(n, jsxCtx, hint))
234
+ eff.O.flatMap(VAR__namespace.getVariableNode(0)),
235
+ eff.O.exists((n) => isJSXValue(n, jsxCtx, hint))
236
236
  );
237
- }).otherwise(tools.F.constFalse);
237
+ }).otherwise(eff.F.constFalse);
238
238
  }
239
239
  var isLiteral = AST__namespace.isOneOf([types.AST_NODE_TYPES.Literal, types.AST_NODE_TYPES.JSXText]);
240
240
  function isWhiteSpace(node) {
241
- return tools.isString(node.value) && node.value.trim() === "";
241
+ return eff.isString(node.value) && node.value.trim() === "";
242
242
  }
243
243
  function isLineBreak(node) {
244
244
  return isLiteral(node) && isWhiteSpace(node) && AST__namespace.isMultiLine(node);
@@ -246,7 +246,7 @@ function isLineBreak(node) {
246
246
  function isPaddingSpaces(node) {
247
247
  return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
248
248
  }
249
- function traverseUpProp(node, predicate = tools.F.constTrue) {
249
+ function traverseUpProp(node, predicate = eff.F.constTrue) {
250
250
  const guard = (node2) => {
251
251
  return node2.type === types.AST_NODE_TYPES.JSXAttribute && predicate(node2);
252
252
  };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
2
2
  import * as AST from '@eslint-react/ast';
3
- import { O, F, isString } from '@eslint-react/tools';
3
+ import { O, F, isString } from '@eslint-react/eff';
4
4
  import * as VAR from '@eslint-react/var';
5
5
  import { match, P } from 'ts-pattern';
6
6
  import birecord from 'birecord';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/jsx",
3
- "version": "1.20.2-next.2",
3
+ "version": "1.20.2-next.5",
4
4
  "description": "ESLint React's TSESTree AST utility module for static analysis of JSX.",
5
5
  "homepage": "https://github.com/rel1cx/eslint-react",
6
6
  "bugs": {
@@ -40,10 +40,10 @@
40
40
  "@typescript-eslint/utils": "^8.18.1",
41
41
  "birecord": "^0.1.1",
42
42
  "ts-pattern": "^5.6.0",
43
- "@eslint-react/ast": "1.20.2-next.2",
44
- "@eslint-react/tools": "1.20.2-next.2",
45
- "@eslint-react/var": "1.20.2-next.2",
46
- "@eslint-react/types": "1.20.2-next.2"
43
+ "@eslint-react/ast": "1.20.2-next.5",
44
+ "@eslint-react/eff": "1.20.2-next.5",
45
+ "@eslint-react/types": "1.20.2-next.5",
46
+ "@eslint-react/var": "1.20.2-next.5"
47
47
  },
48
48
  "devDependencies": {
49
49
  "tsup": "^8.3.5",