@sarj/eslint-plugin 16.5.3 → 16.6.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.cjs CHANGED
@@ -52,7 +52,7 @@ module.exports = __toCommonJS(src_exports);
52
52
  // package.json
53
53
  var package_default = {
54
54
  name: "@sarj/eslint-plugin",
55
- version: "16.5.3",
55
+ version: "16.6.0",
56
56
  packageManager: "npm@12.1.0",
57
57
  description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
58
58
  type: "module",
@@ -7618,7 +7618,8 @@ var NO_IMPOSSIBLE_ZOD_LITERAL_BOUNDS_DOCUMENTATION = {
7618
7618
  remediation: "Choose compatible lower and upper bounds, or remove the constraint that does not express the intended domain.",
7619
7619
  category: "correctness",
7620
7620
  limitations: [
7621
- "Only finite numeric literals in a single number, string, or array schema chain are compared.",
7621
+ "Only finite numeric literals in a single number, string, or array schema chain are compared; explicit int() chains also require an admitted integer.",
7622
+ "Integer-domain comparisons abstain near the JavaScript safe-integer boundary.",
7622
7623
  "Chains with dynamic bounds, non-bound validators, transforms, pipes, or preprocessors are skipped.",
7623
7624
  "Test and generated files are excluded."
7624
7625
  ],
@@ -7657,6 +7658,7 @@ var KINDS = /* @__PURE__ */ new Set(["array", "number", "string"]);
7657
7658
  var NUMBER_METHODS = /* @__PURE__ */ new Set([
7658
7659
  "gt",
7659
7660
  "gte",
7661
+ "int",
7660
7662
  "lt",
7661
7663
  "lte",
7662
7664
  "max",
@@ -7698,9 +7700,20 @@ function strongerUpper(current, candidate2) {
7698
7700
  }
7699
7701
  return current;
7700
7702
  }
7701
- function isEmpty(lower, upper) {
7703
+ function isEmpty(lower, upper, integer) {
7702
7704
  if (lower === null || upper === null) return false;
7703
- return lower.value > upper.value || lower.value === upper.value && (lower.exclusive || upper.exclusive);
7705
+ const realEmpty = lower.value > upper.value || lower.value === upper.value && (lower.exclusive || upper.exclusive);
7706
+ if (integer) {
7707
+ if (realEmpty) return false;
7708
+ const safeMargin = Number.MAX_SAFE_INTEGER - 1;
7709
+ if (Math.abs(lower.value) >= safeMargin || Math.abs(upper.value) >= safeMargin) {
7710
+ return false;
7711
+ }
7712
+ const minimum = lower.exclusive ? Math.floor(lower.value) + 1 : Math.ceil(lower.value);
7713
+ const maximum = upper.exclusive ? Math.ceil(upper.value) - 1 : Math.floor(upper.value);
7714
+ return minimum > maximum;
7715
+ }
7716
+ return realEmpty;
7704
7717
  }
7705
7718
  function isOutermostCall(node) {
7706
7719
  const parent = node.parent;
@@ -7794,6 +7807,7 @@ var no_impossible_zod_literal_bounds_default = createRule({
7794
7807
  const allowed = chain.kind === "number" ? NUMBER_METHODS : LENGTH_METHODS;
7795
7808
  let lower = null;
7796
7809
  let upper = null;
7810
+ let integer = false;
7797
7811
  function addBound(method, semantic, value) {
7798
7812
  const label = `${method}(${String(value)})`;
7799
7813
  if (semantic !== null) {
@@ -7829,6 +7843,11 @@ var no_impossible_zod_literal_bounds_default = createRule({
7829
7843
  }
7830
7844
  for (const { method, node } of chain.calls) {
7831
7845
  if (!allowed.has(method)) return null;
7846
+ if (method === "int") {
7847
+ if (node.arguments.length !== 0) return null;
7848
+ integer = true;
7849
+ continue;
7850
+ }
7832
7851
  const semantic = zeroBoundSemantic(method);
7833
7852
  const value = semantic?.value ?? finiteNumber(node.arguments[0]);
7834
7853
  if (value === null) return null;
@@ -7838,7 +7857,7 @@ var no_impossible_zod_literal_bounds_default = createRule({
7838
7857
  if (semantic !== null && node.arguments.length !== 0) return null;
7839
7858
  addBound(method, semantic, value);
7840
7859
  }
7841
- return isEmpty(lower, upper) && lower !== null && upper !== null ? { lower, upper } : null;
7860
+ return isEmpty(lower, upper, integer) && lower !== null && upper !== null ? { lower, upper } : null;
7842
7861
  }
7843
7862
  return {
7844
7863
  ImportDeclaration(node) {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@sarj/eslint-plugin",
4
- version: "16.5.3",
4
+ version: "16.6.0",
5
5
  packageManager: "npm@12.1.0",
6
6
  description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
7
7
  type: "module",
@@ -7592,7 +7592,8 @@ var NO_IMPOSSIBLE_ZOD_LITERAL_BOUNDS_DOCUMENTATION = {
7592
7592
  remediation: "Choose compatible lower and upper bounds, or remove the constraint that does not express the intended domain.",
7593
7593
  category: "correctness",
7594
7594
  limitations: [
7595
- "Only finite numeric literals in a single number, string, or array schema chain are compared.",
7595
+ "Only finite numeric literals in a single number, string, or array schema chain are compared; explicit int() chains also require an admitted integer.",
7596
+ "Integer-domain comparisons abstain near the JavaScript safe-integer boundary.",
7596
7597
  "Chains with dynamic bounds, non-bound validators, transforms, pipes, or preprocessors are skipped.",
7597
7598
  "Test and generated files are excluded."
7598
7599
  ],
@@ -7631,6 +7632,7 @@ var KINDS = /* @__PURE__ */ new Set(["array", "number", "string"]);
7631
7632
  var NUMBER_METHODS = /* @__PURE__ */ new Set([
7632
7633
  "gt",
7633
7634
  "gte",
7635
+ "int",
7634
7636
  "lt",
7635
7637
  "lte",
7636
7638
  "max",
@@ -7672,9 +7674,20 @@ function strongerUpper(current, candidate2) {
7672
7674
  }
7673
7675
  return current;
7674
7676
  }
7675
- function isEmpty(lower, upper) {
7677
+ function isEmpty(lower, upper, integer) {
7676
7678
  if (lower === null || upper === null) return false;
7677
- return lower.value > upper.value || lower.value === upper.value && (lower.exclusive || upper.exclusive);
7679
+ const realEmpty = lower.value > upper.value || lower.value === upper.value && (lower.exclusive || upper.exclusive);
7680
+ if (integer) {
7681
+ if (realEmpty) return false;
7682
+ const safeMargin = Number.MAX_SAFE_INTEGER - 1;
7683
+ if (Math.abs(lower.value) >= safeMargin || Math.abs(upper.value) >= safeMargin) {
7684
+ return false;
7685
+ }
7686
+ const minimum = lower.exclusive ? Math.floor(lower.value) + 1 : Math.ceil(lower.value);
7687
+ const maximum = upper.exclusive ? Math.ceil(upper.value) - 1 : Math.floor(upper.value);
7688
+ return minimum > maximum;
7689
+ }
7690
+ return realEmpty;
7678
7691
  }
7679
7692
  function isOutermostCall(node) {
7680
7693
  const parent = node.parent;
@@ -7768,6 +7781,7 @@ var no_impossible_zod_literal_bounds_default = createRule({
7768
7781
  const allowed = chain.kind === "number" ? NUMBER_METHODS : LENGTH_METHODS;
7769
7782
  let lower = null;
7770
7783
  let upper = null;
7784
+ let integer = false;
7771
7785
  function addBound(method, semantic, value) {
7772
7786
  const label = `${method}(${String(value)})`;
7773
7787
  if (semantic !== null) {
@@ -7803,6 +7817,11 @@ var no_impossible_zod_literal_bounds_default = createRule({
7803
7817
  }
7804
7818
  for (const { method, node } of chain.calls) {
7805
7819
  if (!allowed.has(method)) return null;
7820
+ if (method === "int") {
7821
+ if (node.arguments.length !== 0) return null;
7822
+ integer = true;
7823
+ continue;
7824
+ }
7806
7825
  const semantic = zeroBoundSemantic(method);
7807
7826
  const value = semantic?.value ?? finiteNumber(node.arguments[0]);
7808
7827
  if (value === null) return null;
@@ -7812,7 +7831,7 @@ var no_impossible_zod_literal_bounds_default = createRule({
7812
7831
  if (semantic !== null && node.arguments.length !== 0) return null;
7813
7832
  addBound(method, semantic, value);
7814
7833
  }
7815
- return isEmpty(lower, upper) && lower !== null && upper !== null ? { lower, upper } : null;
7834
+ return isEmpty(lower, upper, integer) && lower !== null && upper !== null ? { lower, upper } : null;
7816
7835
  }
7817
7836
  return {
7818
7837
  ImportDeclaration(node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarj/eslint-plugin",
3
- "version": "16.5.3",
3
+ "version": "16.6.0",
4
4
  "packageManager": "npm@12.1.0",
5
5
  "description": "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
6
6
  "type": "module",