@sarj/eslint-plugin 9.13.0 → 9.13.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 sarj-ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -46,7 +46,7 @@ changes only the call; import cleanup remains explicit. Other UUID versions,
46
46
  custom-randomness arguments, re-exports, and function references are untouched.
47
47
 
48
48
  Neither rule is in the general presets. The application profile configures them
49
- for its Node 22+ runtime contract and supplies catalog entries to the loader
49
+ for its Node 22.13+ runtime contract and supplies catalog entries to the loader
50
50
  rule:
51
51
 
52
52
  ```js
package/dist/index.cjs CHANGED
@@ -6777,16 +6777,23 @@ function unwrapExpression(node) {
6777
6777
  }
6778
6778
  return node;
6779
6779
  }
6780
- function isObjectFreeze(node) {
6780
+ function isObjectFreeze(node, isUnshadowedGlobal) {
6781
6781
  const inner = unwrapExpression(node);
6782
- return inner.type === import_utils49.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze";
6782
+ if (inner.type === import_utils49.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1) {
6783
+ const argument = inner.arguments[0];
6784
+ return argument !== void 0 && argument.type !== import_utils49.AST_NODE_TYPES.SpreadElement && collectionKind(argument, isUnshadowedGlobal) === "literal";
6785
+ }
6786
+ return false;
6783
6787
  }
6784
- function collectionKind(node) {
6788
+ function collectionKind(node, isUnshadowedGlobal) {
6785
6789
  const inner = unwrapExpression(node);
6790
+ if (inner.type === import_utils49.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils49.AST_NODE_TYPES.SpreadElement) {
6791
+ return collectionKind(inner.arguments[0], isUnshadowedGlobal);
6792
+ }
6786
6793
  if (inner.type === import_utils49.AST_NODE_TYPES.ArrayExpression || inner.type === import_utils49.AST_NODE_TYPES.ObjectExpression) {
6787
6794
  return "literal";
6788
6795
  }
6789
- if (inner.type === import_utils49.AST_NODE_TYPES.NewExpression && inner.callee.type === import_utils49.AST_NODE_TYPES.Identifier && (inner.callee.name === "Set" || inner.callee.name === "Map")) {
6796
+ if (inner.type === import_utils49.AST_NODE_TYPES.NewExpression && inner.callee.type === import_utils49.AST_NODE_TYPES.Identifier && (inner.callee.name === "Set" || inner.callee.name === "Map") && isUnshadowedGlobal(inner.callee)) {
6790
6797
  return inner.callee.name;
6791
6798
  }
6792
6799
  return null;
@@ -6799,7 +6806,7 @@ function isReadonlyType(node, kind) {
6799
6806
  return false;
6800
6807
  }
6801
6808
  if (node.typeName.name === "Readonly") {
6802
- return true;
6809
+ return kind === "literal";
6803
6810
  }
6804
6811
  return kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
6805
6812
  }
@@ -6846,6 +6853,10 @@ var prefer_immutable_module_constant_default = createRule({
6846
6853
  defaultOptions: [],
6847
6854
  create(context) {
6848
6855
  const sourceCode = context.sourceCode;
6856
+ const isUnshadowedGlobal = (identifier) => {
6857
+ const variable = import_utils49.ASTUtils.findVariable(sourceCode.getScope(identifier), identifier.name);
6858
+ return variable === null || variable.defs.length === 0;
6859
+ };
6849
6860
  if (isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
6850
6861
  return {};
6851
6862
  }
@@ -6859,10 +6870,10 @@ var prefer_immutable_module_constant_default = createRule({
6859
6870
  if (container.type !== import_utils49.AST_NODE_TYPES.Program && !(container.type === import_utils49.AST_NODE_TYPES.ExportNamedDeclaration && container.parent.type === import_utils49.AST_NODE_TYPES.Program)) {
6860
6871
  return;
6861
6872
  }
6862
- if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init)) {
6873
+ if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init, isUnshadowedGlobal)) {
6863
6874
  return;
6864
6875
  }
6865
- const kind = collectionKind(node.init);
6876
+ const kind = collectionKind(node.init, isUnshadowedGlobal);
6866
6877
  if (kind === null || declaredReadonlyType(node, kind)) {
6867
6878
  return;
6868
6879
  }
@@ -7239,7 +7250,7 @@ var prefer_module_level_constant_default = createRule({
7239
7250
  }
7240
7251
  ],
7241
7252
  messages: {
7242
- hoistCollection: "`{{name}}` is a literal-only {{kind}} rebuilt on every call. Hoist it to module scope so it is allocated once and can be reused, exported, and tested.",
7253
+ hoistCollection: "`{{name}}` is a literal-only {{kind}} rebuilt on every call. Hoist it to module scope in immutable form (`as const`, a readonly collection, or `Object.freeze`) so it is allocated once without exposing mutable shared state.",
7243
7254
  hoistRegex: "`{{name}}` is a constant regex recompiled on every call. Hoist it to module scope."
7244
7255
  }
7245
7256
  },
@@ -10631,7 +10642,7 @@ var rules = {
10631
10642
  };
10632
10643
  var meta = {
10633
10644
  name: "@sarj/eslint-plugin",
10634
- version: "9.13.0"
10645
+ version: "9.13.1"
10635
10646
  };
10636
10647
  var applicationOnlyRules = [
10637
10648
  "no-restricted-library-load",
package/dist/index.d.cts CHANGED
@@ -446,7 +446,7 @@ type FlatPreset = {
446
446
  declare const plugin: {
447
447
  meta: {
448
448
  readonly name: "@sarj/eslint-plugin";
449
- readonly version: "9.13.0";
449
+ readonly version: "9.13.1";
450
450
  };
451
451
  rules: {
452
452
  "enforce-file-structure": _typescript_eslint_utils_ts_eslint.RuleModule<"importsFirst" | "useServerDirective", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
package/dist/index.d.ts CHANGED
@@ -446,7 +446,7 @@ type FlatPreset = {
446
446
  declare const plugin: {
447
447
  meta: {
448
448
  readonly name: "@sarj/eslint-plugin";
449
- readonly version: "9.13.0";
449
+ readonly version: "9.13.1";
450
450
  };
451
451
  rules: {
452
452
  "enforce-file-structure": _typescript_eslint_utils_ts_eslint.RuleModule<"importsFirst" | "useServerDirective", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
package/dist/index.js CHANGED
@@ -6709,7 +6709,7 @@ var prefer_input_group_search_default = createRule({
6709
6709
  });
6710
6710
 
6711
6711
  // src/rules/prefer-immutable-module-constant.ts
6712
- import { AST_NODE_TYPES as AST_NODE_TYPES35 } from "@typescript-eslint/utils";
6712
+ import { AST_NODE_TYPES as AST_NODE_TYPES35, ASTUtils as ASTUtils3 } from "@typescript-eslint/utils";
6713
6713
  var CONSTANT_NAME = /^_?[A-Z][A-Z0-9_]*$/;
6714
6714
  var MUTATING_METHODS = /* @__PURE__ */ new Set([
6715
6715
  "add",
@@ -6738,16 +6738,23 @@ function unwrapExpression(node) {
6738
6738
  }
6739
6739
  return node;
6740
6740
  }
6741
- function isObjectFreeze(node) {
6741
+ function isObjectFreeze(node, isUnshadowedGlobal) {
6742
6742
  const inner = unwrapExpression(node);
6743
- return inner.type === AST_NODE_TYPES35.CallExpression && inner.callee.type === AST_NODE_TYPES35.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES35.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === AST_NODE_TYPES35.Identifier && inner.callee.property.name === "freeze";
6743
+ if (inner.type === AST_NODE_TYPES35.CallExpression && inner.callee.type === AST_NODE_TYPES35.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES35.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === AST_NODE_TYPES35.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1) {
6744
+ const argument = inner.arguments[0];
6745
+ return argument !== void 0 && argument.type !== AST_NODE_TYPES35.SpreadElement && collectionKind(argument, isUnshadowedGlobal) === "literal";
6746
+ }
6747
+ return false;
6744
6748
  }
6745
- function collectionKind(node) {
6749
+ function collectionKind(node, isUnshadowedGlobal) {
6746
6750
  const inner = unwrapExpression(node);
6751
+ if (inner.type === AST_NODE_TYPES35.CallExpression && inner.callee.type === AST_NODE_TYPES35.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES35.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === AST_NODE_TYPES35.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES35.SpreadElement) {
6752
+ return collectionKind(inner.arguments[0], isUnshadowedGlobal);
6753
+ }
6747
6754
  if (inner.type === AST_NODE_TYPES35.ArrayExpression || inner.type === AST_NODE_TYPES35.ObjectExpression) {
6748
6755
  return "literal";
6749
6756
  }
6750
- if (inner.type === AST_NODE_TYPES35.NewExpression && inner.callee.type === AST_NODE_TYPES35.Identifier && (inner.callee.name === "Set" || inner.callee.name === "Map")) {
6757
+ if (inner.type === AST_NODE_TYPES35.NewExpression && inner.callee.type === AST_NODE_TYPES35.Identifier && (inner.callee.name === "Set" || inner.callee.name === "Map") && isUnshadowedGlobal(inner.callee)) {
6751
6758
  return inner.callee.name;
6752
6759
  }
6753
6760
  return null;
@@ -6760,7 +6767,7 @@ function isReadonlyType(node, kind) {
6760
6767
  return false;
6761
6768
  }
6762
6769
  if (node.typeName.name === "Readonly") {
6763
- return true;
6770
+ return kind === "literal";
6764
6771
  }
6765
6772
  return kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
6766
6773
  }
@@ -6807,6 +6814,10 @@ var prefer_immutable_module_constant_default = createRule({
6807
6814
  defaultOptions: [],
6808
6815
  create(context) {
6809
6816
  const sourceCode = context.sourceCode;
6817
+ const isUnshadowedGlobal = (identifier) => {
6818
+ const variable = ASTUtils3.findVariable(sourceCode.getScope(identifier), identifier.name);
6819
+ return variable === null || variable.defs.length === 0;
6820
+ };
6810
6821
  if (isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
6811
6822
  return {};
6812
6823
  }
@@ -6820,10 +6831,10 @@ var prefer_immutable_module_constant_default = createRule({
6820
6831
  if (container.type !== AST_NODE_TYPES35.Program && !(container.type === AST_NODE_TYPES35.ExportNamedDeclaration && container.parent.type === AST_NODE_TYPES35.Program)) {
6821
6832
  return;
6822
6833
  }
6823
- if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init)) {
6834
+ if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init, isUnshadowedGlobal)) {
6824
6835
  return;
6825
6836
  }
6826
- const kind = collectionKind(node.init);
6837
+ const kind = collectionKind(node.init, isUnshadowedGlobal);
6827
6838
  if (kind === null || declaredReadonlyType(node, kind)) {
6828
6839
  return;
6829
6840
  }
@@ -7200,7 +7211,7 @@ var prefer_module_level_constant_default = createRule({
7200
7211
  }
7201
7212
  ],
7202
7213
  messages: {
7203
- hoistCollection: "`{{name}}` is a literal-only {{kind}} rebuilt on every call. Hoist it to module scope so it is allocated once and can be reused, exported, and tested.",
7214
+ hoistCollection: "`{{name}}` is a literal-only {{kind}} rebuilt on every call. Hoist it to module scope in immutable form (`as const`, a readonly collection, or `Object.freeze`) so it is allocated once without exposing mutable shared state.",
7204
7215
  hoistRegex: "`{{name}}` is a constant regex recompiled on every call. Hoist it to module scope."
7205
7216
  }
7206
7217
  },
@@ -7617,7 +7628,7 @@ var prefer_module_level_schema_default = createRule({
7617
7628
  });
7618
7629
 
7619
7630
  // src/rules/prefer-native-random-uuid.ts
7620
- import { AST_NODE_TYPES as AST_NODE_TYPES39, ASTUtils as ASTUtils3 } from "@typescript-eslint/utils";
7631
+ import { AST_NODE_TYPES as AST_NODE_TYPES39, ASTUtils as ASTUtils4 } from "@typescript-eslint/utils";
7621
7632
  function requireUuid(node) {
7622
7633
  return node?.type === AST_NODE_TYPES39.CallExpression && node.callee.type === AST_NODE_TYPES39.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === AST_NODE_TYPES39.Literal && node.arguments[0].value === "uuid";
7623
7634
  }
@@ -7640,7 +7651,7 @@ var prefer_native_random_uuid_default = createRule({
7640
7651
  const directBindings = /* @__PURE__ */ new Set();
7641
7652
  const namespaceBindings = /* @__PURE__ */ new Set();
7642
7653
  function resolve(identifier) {
7643
- return ASTUtils3.findVariable(context.sourceCode.getScope(identifier), identifier.name);
7654
+ return ASTUtils4.findVariable(context.sourceCode.getScope(identifier), identifier.name);
7644
7655
  }
7645
7656
  function record(identifier, destination) {
7646
7657
  const variable = resolve(identifier);
@@ -9786,7 +9797,7 @@ var require_assert_never_default = createRule({
9786
9797
  });
9787
9798
 
9788
9799
  // src/rules/require-fetch-timeout.ts
9789
- import { AST_NODE_TYPES as AST_NODE_TYPES48, ASTUtils as ASTUtils4 } from "@typescript-eslint/utils";
9800
+ import { AST_NODE_TYPES as AST_NODE_TYPES48, ASTUtils as ASTUtils5 } from "@typescript-eslint/utils";
9790
9801
  var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
9791
9802
  "globalThis",
9792
9803
  "window",
@@ -9856,7 +9867,7 @@ var require_fetch_timeout_default = createRule({
9856
9867
  }
9857
9868
  function resolvesToGlobal(identifier) {
9858
9869
  const scope = context.sourceCode.getScope(identifier);
9859
- const variable = ASTUtils4.findVariable(scope, identifier.name);
9870
+ const variable = ASTUtils5.findVariable(scope, identifier.name);
9860
9871
  return variable === null || variable.defs.length === 0;
9861
9872
  }
9862
9873
  function isGlobalFetchCall2(callee) {
@@ -10595,7 +10606,7 @@ var rules = {
10595
10606
  };
10596
10607
  var meta = {
10597
10608
  name: "@sarj/eslint-plugin",
10598
- version: "9.13.0"
10609
+ version: "9.13.1"
10599
10610
  };
10600
10611
  var applicationOnlyRules = [
10601
10612
  "no-restricted-library-load",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarj/eslint-plugin",
3
- "version": "9.13.0",
3
+ "version": "9.13.1",
4
4
  "packageManager": "npm@11.19.0",
5
5
  "description": "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
6
6
  "type": "module",
@@ -16,7 +16,8 @@
16
16
  },
17
17
  "files": [
18
18
  "dist",
19
- "README.md"
19
+ "README.md",
20
+ "LICENSE"
20
21
  ],
21
22
  "publishConfig": {
22
23
  "access": "public"
@@ -79,7 +80,7 @@
79
80
  "typescript": ">=5.0.0"
80
81
  },
81
82
  "engines": {
82
- "node": ">=22.0.0"
83
+ "node": ">=22.13.0"
83
84
  },
84
85
  "allowScripts": {
85
86
  "esbuild@0.28.1": true,