@eslint-react/jsx 1.23.2-next.6 → 1.23.3-next.0

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
@@ -72,8 +72,12 @@ function getProp(props, propName, initialScope) {
72
72
  function getPropValue(attribute, initialScope) {
73
73
  if (attribute.type === types.AST_NODE_TYPES.JSXAttribute && "value" in attribute) {
74
74
  const { value } = attribute;
75
- if (value === null) return eff.O.none();
76
- if (value.type === types.AST_NODE_TYPES.Literal) return VAR__namespace.getStaticValue(value, initialScope);
75
+ if (value === null) {
76
+ return eff.O.none();
77
+ }
78
+ if (value.type === types.AST_NODE_TYPES.Literal) {
79
+ return VAR__namespace.getStaticValue(value, initialScope);
80
+ }
77
81
  if (value.type === types.AST_NODE_TYPES.JSXExpressionContainer) {
78
82
  return VAR__namespace.getStaticValue(value.expression, initialScope);
79
83
  }
@@ -93,7 +97,9 @@ function findPropInProperties(properties, initialScope, seenProps = []) {
93
97
  switch (true) {
94
98
  case prop.argument.type === types.AST_NODE_TYPES.Identifier: {
95
99
  const { name } = prop.argument;
96
- if (seenProps.includes(name)) return false;
100
+ if (seenProps.includes(name)) {
101
+ return false;
102
+ }
97
103
  return eff.F.pipe(
98
104
  VAR__namespace.findVariable(name, initialScope),
99
105
  eff.O.flatMap(VAR__namespace.getVariableNode(0)),
@@ -190,16 +196,22 @@ var JSXValueHint = {
190
196
  };
191
197
  var DEFAULT_JSX_VALUE_HINT = 0n | JSXValueHint.SkipUndefinedLiteral | JSXValueHint.SkipBooleanLiteral;
192
198
  function isJSXValue(node, jsxCtx, hint = DEFAULT_JSX_VALUE_HINT) {
193
- if (!node) return false;
199
+ if (!node) {
200
+ return false;
201
+ }
194
202
  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) => {
195
203
  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);
196
204
  }).with({ type: types.AST_NODE_TYPES.TemplateLiteral }, () => !(hint & JSXValueHint.SkipStringLiteral)).with({ type: types.AST_NODE_TYPES.ArrayExpression }, (node2) => {
197
- if (hint & JSXValueHint.StrictArray) return node2.elements.every((n) => isJSXValue(n, jsxCtx, hint));
205
+ if (hint & JSXValueHint.StrictArray) {
206
+ return node2.elements.every((n) => isJSXValue(n, jsxCtx, hint));
207
+ }
198
208
  return node2.elements.some((n) => isJSXValue(n, jsxCtx, hint));
199
209
  }).with({ type: types.AST_NODE_TYPES.ConditionalExpression }, (node2) => {
200
210
  function leftHasJSX(node3) {
201
211
  if (Array.isArray(node3.consequent)) {
202
- if (node3.consequent.length === 0) return !(hint & JSXValueHint.SkipEmptyArray);
212
+ if (node3.consequent.length === 0) {
213
+ return !(hint & JSXValueHint.SkipEmptyArray);
214
+ }
203
215
  if (hint & JSXValueHint.StrictArray) {
204
216
  return node3.consequent.every((n) => isJSXValue(n, jsxCtx, hint));
205
217
  }
@@ -223,12 +235,18 @@ function isJSXValue(node, jsxCtx, hint = DEFAULT_JSX_VALUE_HINT) {
223
235
  const exp = node2.expressions.at(-1);
224
236
  return isJSXValue(exp, jsxCtx, hint);
225
237
  }).with({ type: types.AST_NODE_TYPES.CallExpression }, (node2) => {
226
- if (hint & JSXValueHint.SkipCreateElement) return false;
238
+ if (hint & JSXValueHint.SkipCreateElement) {
239
+ return false;
240
+ }
227
241
  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);
228
242
  }).with({ type: types.AST_NODE_TYPES.Identifier }, (node2) => {
229
243
  const { name } = node2;
230
- if (name === "undefined") return !(hint & JSXValueHint.SkipUndefinedLiteral);
231
- if (AST2__namespace.isJSXTagNameExpression(node2)) return true;
244
+ if (name === "undefined") {
245
+ return !(hint & JSXValueHint.SkipUndefinedLiteral);
246
+ }
247
+ if (AST2__namespace.isJSXTagNameExpression(node2)) {
248
+ return true;
249
+ }
232
250
  const initialScope = jsxCtx.getScope(node2);
233
251
  return eff.F.pipe(
234
252
  VAR__namespace.findVariable(name, initialScope),
package/dist/index.mjs CHANGED
@@ -49,8 +49,12 @@ function getProp(props, propName, initialScope) {
49
49
  function getPropValue(attribute, initialScope) {
50
50
  if (attribute.type === AST_NODE_TYPES.JSXAttribute && "value" in attribute) {
51
51
  const { value } = attribute;
52
- if (value === null) return O.none();
53
- if (value.type === AST_NODE_TYPES.Literal) return VAR.getStaticValue(value, initialScope);
52
+ if (value === null) {
53
+ return O.none();
54
+ }
55
+ if (value.type === AST_NODE_TYPES.Literal) {
56
+ return VAR.getStaticValue(value, initialScope);
57
+ }
54
58
  if (value.type === AST_NODE_TYPES.JSXExpressionContainer) {
55
59
  return VAR.getStaticValue(value.expression, initialScope);
56
60
  }
@@ -70,7 +74,9 @@ function findPropInProperties(properties, initialScope, seenProps = []) {
70
74
  switch (true) {
71
75
  case prop.argument.type === AST_NODE_TYPES.Identifier: {
72
76
  const { name } = prop.argument;
73
- if (seenProps.includes(name)) return false;
77
+ if (seenProps.includes(name)) {
78
+ return false;
79
+ }
74
80
  return F.pipe(
75
81
  VAR.findVariable(name, initialScope),
76
82
  O.flatMap(VAR.getVariableNode(0)),
@@ -167,16 +173,22 @@ var JSXValueHint = {
167
173
  };
168
174
  var DEFAULT_JSX_VALUE_HINT = 0n | JSXValueHint.SkipUndefinedLiteral | JSXValueHint.SkipBooleanLiteral;
169
175
  function isJSXValue(node, jsxCtx, hint = DEFAULT_JSX_VALUE_HINT) {
170
- if (!node) return false;
176
+ if (!node) {
177
+ return false;
178
+ }
171
179
  return match(node).with({ type: AST_NODE_TYPES.JSXElement }, F.constTrue).with({ type: AST_NODE_TYPES.JSXFragment }, F.constTrue).with({ type: AST_NODE_TYPES.JSXMemberExpression }, F.constTrue).with({ type: AST_NODE_TYPES.JSXNamespacedName }, F.constTrue).with({ type: AST_NODE_TYPES.Literal }, (node2) => {
172
180
  return match(node2.value).with(null, () => !(hint & JSXValueHint.SkipNullLiteral)).with(P.boolean, () => !(hint & JSXValueHint.SkipBooleanLiteral)).with(P.string, () => !(hint & JSXValueHint.SkipStringLiteral)).with(P.number, () => !(hint & JSXValueHint.SkipNumberLiteral)).otherwise(F.constFalse);
173
181
  }).with({ type: AST_NODE_TYPES.TemplateLiteral }, () => !(hint & JSXValueHint.SkipStringLiteral)).with({ type: AST_NODE_TYPES.ArrayExpression }, (node2) => {
174
- if (hint & JSXValueHint.StrictArray) return node2.elements.every((n) => isJSXValue(n, jsxCtx, hint));
182
+ if (hint & JSXValueHint.StrictArray) {
183
+ return node2.elements.every((n) => isJSXValue(n, jsxCtx, hint));
184
+ }
175
185
  return node2.elements.some((n) => isJSXValue(n, jsxCtx, hint));
176
186
  }).with({ type: AST_NODE_TYPES.ConditionalExpression }, (node2) => {
177
187
  function leftHasJSX(node3) {
178
188
  if (Array.isArray(node3.consequent)) {
179
- if (node3.consequent.length === 0) return !(hint & JSXValueHint.SkipEmptyArray);
189
+ if (node3.consequent.length === 0) {
190
+ return !(hint & JSXValueHint.SkipEmptyArray);
191
+ }
180
192
  if (hint & JSXValueHint.StrictArray) {
181
193
  return node3.consequent.every((n) => isJSXValue(n, jsxCtx, hint));
182
194
  }
@@ -200,12 +212,18 @@ function isJSXValue(node, jsxCtx, hint = DEFAULT_JSX_VALUE_HINT) {
200
212
  const exp = node2.expressions.at(-1);
201
213
  return isJSXValue(exp, jsxCtx, hint);
202
214
  }).with({ type: AST_NODE_TYPES.CallExpression }, (node2) => {
203
- if (hint & JSXValueHint.SkipCreateElement) return false;
215
+ if (hint & JSXValueHint.SkipCreateElement) {
216
+ return false;
217
+ }
204
218
  return match(node2.callee).with({ type: AST_NODE_TYPES.Identifier, name: "createElement" }, F.constTrue).with({ type: AST_NODE_TYPES.MemberExpression, property: { name: "createElement" } }, F.constTrue).otherwise(F.constFalse);
205
219
  }).with({ type: AST_NODE_TYPES.Identifier }, (node2) => {
206
220
  const { name } = node2;
207
- if (name === "undefined") return !(hint & JSXValueHint.SkipUndefinedLiteral);
208
- if (AST2.isJSXTagNameExpression(node2)) return true;
221
+ if (name === "undefined") {
222
+ return !(hint & JSXValueHint.SkipUndefinedLiteral);
223
+ }
224
+ if (AST2.isJSXTagNameExpression(node2)) {
225
+ return true;
226
+ }
209
227
  const initialScope = jsxCtx.getScope(node2);
210
228
  return F.pipe(
211
229
  VAR.findVariable(name, initialScope),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/jsx",
3
- "version": "1.23.2-next.6",
3
+ "version": "1.23.3-next.0",
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": {
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "license": "MIT",
15
15
  "author": "Eva1ent<rel1cx@proton.me>",
16
+ "sideEffects": false,
16
17
  "exports": {
17
18
  ".": {
18
19
  "import": {
@@ -27,6 +28,7 @@
27
28
  "./package.json": "./package.json"
28
29
  },
29
30
  "main": "dist/index.js",
31
+ "module": "dist/index.mjs",
30
32
  "types": "dist/index.d.ts",
31
33
  "files": [
32
34
  "dist",
@@ -37,10 +39,10 @@
37
39
  "@typescript-eslint/types": "^8.19.1",
38
40
  "@typescript-eslint/utils": "^8.19.1",
39
41
  "ts-pattern": "^5.6.0",
40
- "@eslint-react/ast": "1.23.2-next.6",
41
- "@eslint-react/eff": "1.23.2-next.6",
42
- "@eslint-react/types": "1.23.2-next.6",
43
- "@eslint-react/var": "1.23.2-next.6"
42
+ "@eslint-react/ast": "1.23.3-next.0",
43
+ "@eslint-react/eff": "1.23.3-next.0",
44
+ "@eslint-react/types": "1.23.3-next.0",
45
+ "@eslint-react/var": "1.23.3-next.0"
44
46
  },
45
47
  "devDependencies": {
46
48
  "tsup": "^8.3.5",
@@ -50,8 +52,6 @@
50
52
  "bun": ">=1.0.15",
51
53
  "node": ">=18.18.0"
52
54
  },
53
- "sideEffects": false,
54
- "module": "dist/index.mjs",
55
55
  "scripts": {
56
56
  "build": "tsup",
57
57
  "lint:publish": "publint",