eslint-plugin-react-x 1.22.1-beta.0 → 1.22.1-beta.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 (3) hide show
  1. package/dist/index.js +26 -49
  2. package/dist/index.mjs +14 -37
  3. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ var compareVersions = require('compare-versions');
11
11
  var VAR = require('@eslint-react/var');
12
12
  var typeUtils = require('@typescript-eslint/type-utils');
13
13
  var utils = require('@typescript-eslint/utils');
14
+ var tsApiUtils = require('ts-api-utils');
14
15
  var ts = require('typescript');
15
16
  var isImmutableType = require('is-immutable-type');
16
17
 
@@ -41,7 +42,7 @@ var ts__default = /*#__PURE__*/_interopDefault(ts);
41
42
 
42
43
  // package.json
43
44
  var name = "eslint-plugin-react-x";
44
- var version = "1.22.1-beta.0";
45
+ var version = "1.22.1-beta.2";
45
46
  var createRule = shared.createRuleForPlugin("x");
46
47
 
47
48
  // src/rules/avoid-shorthand-boolean.ts
@@ -693,10 +694,10 @@ var no_comment_textnodes_default = createRule({
693
694
  node
694
695
  });
695
696
  };
696
- const ruleFunction = eff.F.flow(getReportDescriptor, eff.O.map(context.report), eff.F.constVoid);
697
+ const visitorFunction = eff.F.flow(getReportDescriptor, eff.O.map(context.report), eff.F.constVoid);
697
698
  return {
698
- JSXText: ruleFunction,
699
- Literal: ruleFunction
699
+ JSXText: visitorFunction,
700
+ Literal: visitorFunction
700
701
  };
701
702
  },
702
703
  defaultOptions: []
@@ -728,13 +729,13 @@ var no_complex_conditional_rendering_default = createRule({
728
729
  if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) return eff.O.none();
729
730
  return eff.O.some({ messageId: "noComplexConditionalRendering", node: jsxExpContainer });
730
731
  }
731
- const ruleFunction = eff.F.flow(getReportDescriptor, eff.O.map(context.report), eff.F.constVoid);
732
+ const visitorFunction = eff.F.flow(getReportDescriptor, eff.O.map(context.report), eff.F.constVoid);
732
733
  return {
733
- "JSXExpressionContainer > ConditionalExpression > ConditionalExpression": ruleFunction,
734
- "JSXExpressionContainer > ConditionalExpression > LogicalExpression": ruleFunction,
735
- "JSXExpressionContainer > LogicalExpression > ConditionalExpression": ruleFunction,
736
- "JSXExpressionContainer > LogicalExpression[operator='&&'] > LogicalExpression[operator='||']": ruleFunction,
737
- "JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": ruleFunction
734
+ "JSXExpressionContainer > ConditionalExpression > ConditionalExpression": visitorFunction,
735
+ "JSXExpressionContainer > ConditionalExpression > LogicalExpression": visitorFunction,
736
+ "JSXExpressionContainer > LogicalExpression > ConditionalExpression": visitorFunction,
737
+ "JSXExpressionContainer > LogicalExpression[operator='&&'] > LogicalExpression[operator='||']": visitorFunction,
738
+ "JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
738
739
  };
739
740
  },
740
741
  defaultOptions: []
@@ -1369,58 +1370,34 @@ var no_implicit_key_default = createRule({
1369
1370
  },
1370
1371
  defaultOptions: []
1371
1372
  });
1372
- function isFlagSet(allFlags, flag) {
1373
- return (allFlags & flag) !== 0;
1374
- }
1375
- function isFlagSetOnObject(obj, flag) {
1376
- return isFlagSet(obj.flags, flag);
1377
- }
1378
- var isTypeFlagSet = isFlagSetOnObject;
1379
- ts__default.default.versionMajorMinor.split(".").map((raw) => Number.parseInt(raw, 10));
1380
- ts__default.default.TypeFlags.Intrinsic ?? ts__default.default.TypeFlags.Any | ts__default.default.TypeFlags.Unknown | ts__default.default.TypeFlags.String | ts__default.default.TypeFlags.Number | ts__default.default.TypeFlags.BigInt | ts__default.default.TypeFlags.Boolean | ts__default.default.TypeFlags.BooleanLiteral | ts__default.default.TypeFlags.ESSymbol | ts__default.default.TypeFlags.Void | ts__default.default.TypeFlags.Undefined | ts__default.default.TypeFlags.Null | ts__default.default.TypeFlags.Never | ts__default.default.TypeFlags.NonPrimitive;
1381
- function isUnionType(type) {
1382
- return isTypeFlagSet(type, ts__default.default.TypeFlags.Union);
1383
- }
1384
- function isBooleanLiteralType(type) {
1385
- return isTypeFlagSet(type, ts__default.default.TypeFlags.BooleanLiteral);
1386
- }
1387
- function isFalseLiteralType(type) {
1388
- return isBooleanLiteralType(type) && type.intrinsicName === "false";
1389
- }
1390
- function isTrueLiteralType(type) {
1391
- return isBooleanLiteralType(type) && type.intrinsicName === "true";
1392
- }
1393
- function unionTypeParts(type) {
1394
- return isUnionType(type) ? type.types : [type];
1395
- }
1396
1373
  var RULE_NAME27 = "no-leaked-conditional-rendering";
1397
1374
  var RULE_FEATURES27 = [
1398
1375
  "CHK",
1399
1376
  "TSC"
1400
1377
  ];
1401
1378
  var tsHelpers = {
1402
- isAnyType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.TypeParameter | ts__default.default.TypeFlags.Any),
1403
- isBigIntType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.BigIntLike),
1404
- isBooleanType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.BooleanLike),
1405
- isEnumType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.EnumLike),
1379
+ isAnyType: (type) => tsApiUtils.isTypeFlagSet(type, ts__default.default.TypeFlags.TypeParameter | ts__default.default.TypeFlags.Any),
1380
+ isBigIntType: (type) => tsApiUtils.isTypeFlagSet(type, ts__default.default.TypeFlags.BigIntLike),
1381
+ isBooleanType: (type) => tsApiUtils.isTypeFlagSet(type, ts__default.default.TypeFlags.BooleanLike),
1382
+ isEnumType: (type) => tsApiUtils.isTypeFlagSet(type, ts__default.default.TypeFlags.EnumLike),
1406
1383
  isFalsyBigIntType: (type) => type.isLiteral() && tsPattern.isMatching({ value: { base10Value: "0" } }, type),
1407
1384
  isFalsyNumberType: (type) => type.isNumberLiteral() && type.value === 0,
1408
1385
  isFalsyStringType: (type) => type.isStringLiteral() && type.value === "",
1409
- isNeverType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.Never),
1410
- isNullishType: (type) => isTypeFlagSet(
1386
+ isNeverType: (type) => tsApiUtils.isTypeFlagSet(type, ts__default.default.TypeFlags.Never),
1387
+ isNullishType: (type) => tsApiUtils.isTypeFlagSet(
1411
1388
  type,
1412
1389
  ts__default.default.TypeFlags.Null | ts__default.default.TypeFlags.Undefined | ts__default.default.TypeFlags.VoidLike
1413
1390
  ),
1414
- isNumberType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.NumberLike),
1415
- isObjectType: (type) => !isTypeFlagSet(
1391
+ isNumberType: (type) => tsApiUtils.isTypeFlagSet(type, ts__default.default.TypeFlags.NumberLike),
1392
+ isObjectType: (type) => !tsApiUtils.isTypeFlagSet(
1416
1393
  type,
1417
1394
  ts__default.default.TypeFlags.Null | ts__default.default.TypeFlags.Undefined | ts__default.default.TypeFlags.VoidLike | ts__default.default.TypeFlags.BooleanLike | ts__default.default.TypeFlags.StringLike | ts__default.default.TypeFlags.NumberLike | ts__default.default.TypeFlags.BigIntLike | ts__default.default.TypeFlags.TypeParameter | ts__default.default.TypeFlags.Any | ts__default.default.TypeFlags.Unknown | ts__default.default.TypeFlags.Never
1418
1395
  ),
1419
- isStringType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.StringLike),
1396
+ isStringType: (type) => tsApiUtils.isTypeFlagSet(type, ts__default.default.TypeFlags.StringLike),
1420
1397
  isTruthyBigIntType: (type) => type.isLiteral() && tsPattern.isMatching({ value: { base10Value: tsPattern.P.not("0") } }, type),
1421
1398
  isTruthyNumberType: (type) => type.isNumberLiteral() && type.value !== 0,
1422
1399
  isTruthyStringType: (type) => type.isStringLiteral() && type.value !== "",
1423
- isUnknownType: (type) => isTypeFlagSet(type, ts__default.default.TypeFlags.Unknown)
1400
+ isUnknownType: (type) => tsApiUtils.isTypeFlagSet(type, ts__default.default.TypeFlags.Unknown)
1424
1401
  };
1425
1402
  function inspectVariantTypes(types) {
1426
1403
  const variantTypes = /* @__PURE__ */ new Set();
@@ -1436,7 +1413,7 @@ function inspectVariantTypes(types) {
1436
1413
  case (booleans.length === 1 && !!booleans[0]): {
1437
1414
  const [first] = booleans;
1438
1415
  const evaluated = eff.F.pipe(
1439
- tsPattern.match(first).when(isTrueLiteralType, () => eff.O.some("truthy boolean")).when(isFalseLiteralType, () => eff.O.some("falsy boolean")).otherwise(eff.O.none)
1416
+ tsPattern.match(first).when(tsApiUtils.isTrueLiteralType, () => eff.O.some("truthy boolean")).when(tsApiUtils.isFalseLiteralType, () => eff.O.some("falsy boolean")).otherwise(eff.O.none)
1440
1417
  );
1441
1418
  eff.O.map(evaluated, (v) => variantTypes.add(v));
1442
1419
  break;
@@ -1533,7 +1510,7 @@ var no_leaked_conditional_rendering_default = createRule({
1533
1510
  });
1534
1511
  }
1535
1512
  const leftType = typeUtils.getConstrainedTypeAtLocation(services, left);
1536
- const leftTypeVariants = inspectVariantTypes(unionTypeParts(leftType));
1513
+ const leftTypeVariants = inspectVariantTypes(tsApiUtils.unionTypeParts(leftType));
1537
1514
  const isLeftValid = Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type));
1538
1515
  if (isLeftValid) return getReportDescriptor(right);
1539
1516
  return eff.O.some({
@@ -1551,10 +1528,10 @@ var no_leaked_conditional_rendering_default = createRule({
1551
1528
  );
1552
1529
  }).otherwise(eff.O.none);
1553
1530
  }
1554
- const ruleFunction = eff.F.flow(getReportDescriptor, eff.O.map(context.report), eff.F.constVoid);
1531
+ const visitorFunction = eff.F.flow(getReportDescriptor, eff.O.map(context.report), eff.F.constVoid);
1555
1532
  return {
1556
- "JSXExpressionContainer > ConditionalExpression": ruleFunction,
1557
- "JSXExpressionContainer > LogicalExpression": ruleFunction
1533
+ "JSXExpressionContainer > ConditionalExpression": visitorFunction,
1534
+ "JSXExpressionContainer > LogicalExpression": visitorFunction
1558
1535
  };
1559
1536
  },
1560
1537
  defaultOptions: []
package/dist/index.mjs CHANGED
@@ -9,12 +9,13 @@ import { compare } from 'compare-versions';
9
9
  import * as VAR from '@eslint-react/var';
10
10
  import { getConstrainedTypeAtLocation, isTypeReadonly } from '@typescript-eslint/type-utils';
11
11
  import { ESLintUtils } from '@typescript-eslint/utils';
12
+ import { unionTypeParts, isTrueLiteralType, isFalseLiteralType, isTypeFlagSet } from 'ts-api-utils';
12
13
  import ts from 'typescript';
13
14
  import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReadonlyDeep } from 'is-immutable-type';
14
15
 
15
16
  // package.json
16
17
  var name = "eslint-plugin-react-x";
17
- var version = "1.22.1-beta.0";
18
+ var version = "1.22.1-beta.2";
18
19
  var createRule = createRuleForPlugin("x");
19
20
 
20
21
  // src/rules/avoid-shorthand-boolean.ts
@@ -666,10 +667,10 @@ var no_comment_textnodes_default = createRule({
666
667
  node
667
668
  });
668
669
  };
669
- const ruleFunction = F.flow(getReportDescriptor, O.map(context.report), F.constVoid);
670
+ const visitorFunction = F.flow(getReportDescriptor, O.map(context.report), F.constVoid);
670
671
  return {
671
- JSXText: ruleFunction,
672
- Literal: ruleFunction
672
+ JSXText: visitorFunction,
673
+ Literal: visitorFunction
673
674
  };
674
675
  },
675
676
  defaultOptions: []
@@ -701,13 +702,13 @@ var no_complex_conditional_rendering_default = createRule({
701
702
  if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) return O.none();
702
703
  return O.some({ messageId: "noComplexConditionalRendering", node: jsxExpContainer });
703
704
  }
704
- const ruleFunction = F.flow(getReportDescriptor, O.map(context.report), F.constVoid);
705
+ const visitorFunction = F.flow(getReportDescriptor, O.map(context.report), F.constVoid);
705
706
  return {
706
- "JSXExpressionContainer > ConditionalExpression > ConditionalExpression": ruleFunction,
707
- "JSXExpressionContainer > ConditionalExpression > LogicalExpression": ruleFunction,
708
- "JSXExpressionContainer > LogicalExpression > ConditionalExpression": ruleFunction,
709
- "JSXExpressionContainer > LogicalExpression[operator='&&'] > LogicalExpression[operator='||']": ruleFunction,
710
- "JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": ruleFunction
707
+ "JSXExpressionContainer > ConditionalExpression > ConditionalExpression": visitorFunction,
708
+ "JSXExpressionContainer > ConditionalExpression > LogicalExpression": visitorFunction,
709
+ "JSXExpressionContainer > LogicalExpression > ConditionalExpression": visitorFunction,
710
+ "JSXExpressionContainer > LogicalExpression[operator='&&'] > LogicalExpression[operator='||']": visitorFunction,
711
+ "JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
711
712
  };
712
713
  },
713
714
  defaultOptions: []
@@ -1342,30 +1343,6 @@ var no_implicit_key_default = createRule({
1342
1343
  },
1343
1344
  defaultOptions: []
1344
1345
  });
1345
- function isFlagSet(allFlags, flag) {
1346
- return (allFlags & flag) !== 0;
1347
- }
1348
- function isFlagSetOnObject(obj, flag) {
1349
- return isFlagSet(obj.flags, flag);
1350
- }
1351
- var isTypeFlagSet = isFlagSetOnObject;
1352
- ts.versionMajorMinor.split(".").map((raw) => Number.parseInt(raw, 10));
1353
- ts.TypeFlags.Intrinsic ?? ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.String | ts.TypeFlags.Number | ts.TypeFlags.BigInt | ts.TypeFlags.Boolean | ts.TypeFlags.BooleanLiteral | ts.TypeFlags.ESSymbol | ts.TypeFlags.Void | ts.TypeFlags.Undefined | ts.TypeFlags.Null | ts.TypeFlags.Never | ts.TypeFlags.NonPrimitive;
1354
- function isUnionType(type) {
1355
- return isTypeFlagSet(type, ts.TypeFlags.Union);
1356
- }
1357
- function isBooleanLiteralType(type) {
1358
- return isTypeFlagSet(type, ts.TypeFlags.BooleanLiteral);
1359
- }
1360
- function isFalseLiteralType(type) {
1361
- return isBooleanLiteralType(type) && type.intrinsicName === "false";
1362
- }
1363
- function isTrueLiteralType(type) {
1364
- return isBooleanLiteralType(type) && type.intrinsicName === "true";
1365
- }
1366
- function unionTypeParts(type) {
1367
- return isUnionType(type) ? type.types : [type];
1368
- }
1369
1346
  var RULE_NAME27 = "no-leaked-conditional-rendering";
1370
1347
  var RULE_FEATURES27 = [
1371
1348
  "CHK",
@@ -1524,10 +1501,10 @@ var no_leaked_conditional_rendering_default = createRule({
1524
1501
  );
1525
1502
  }).otherwise(O.none);
1526
1503
  }
1527
- const ruleFunction = F.flow(getReportDescriptor, O.map(context.report), F.constVoid);
1504
+ const visitorFunction = F.flow(getReportDescriptor, O.map(context.report), F.constVoid);
1528
1505
  return {
1529
- "JSXExpressionContainer > ConditionalExpression": ruleFunction,
1530
- "JSXExpressionContainer > LogicalExpression": ruleFunction
1506
+ "JSXExpressionContainer > ConditionalExpression": visitorFunction,
1507
+ "JSXExpressionContainer > LogicalExpression": visitorFunction
1531
1508
  };
1532
1509
  },
1533
1510
  defaultOptions: []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.22.1-beta.0",
3
+ "version": "1.22.1-beta.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",
@@ -48,20 +48,20 @@
48
48
  "@typescript-eslint/utils": "^8.18.1",
49
49
  "compare-versions": "^6.1.1",
50
50
  "is-immutable-type": "^5.0.0",
51
+ "string-ts": "^2.2.0",
52
+ "ts-api-utils": "^2.0.0",
51
53
  "ts-pattern": "^5.6.0",
52
- "@eslint-react/ast": "1.22.1-beta.0",
53
- "@eslint-react/core": "1.22.1-beta.0",
54
- "@eslint-react/eff": "1.22.1-beta.0",
55
- "@eslint-react/jsx": "1.22.1-beta.0",
56
- "@eslint-react/shared": "1.22.1-beta.0",
57
- "@eslint-react/types": "1.22.1-beta.0",
58
- "@eslint-react/var": "1.22.1-beta.0"
54
+ "@eslint-react/ast": "1.22.1-beta.2",
55
+ "@eslint-react/eff": "1.22.1-beta.2",
56
+ "@eslint-react/core": "1.22.1-beta.2",
57
+ "@eslint-react/jsx": "1.22.1-beta.2",
58
+ "@eslint-react/shared": "1.22.1-beta.2",
59
+ "@eslint-react/var": "1.22.1-beta.2",
60
+ "@eslint-react/types": "1.22.1-beta.2"
59
61
  },
60
62
  "devDependencies": {
61
63
  "@types/react": "^19.0.2",
62
64
  "@types/react-dom": "^19.0.2",
63
- "string-ts": "^2.2.0",
64
- "ts-api-utils": "^2.0.0",
65
65
  "tsup": "^8.3.5",
66
66
  "@workspace/configs": "0.0.0"
67
67
  },