@sarj/eslint-plugin 16.35.1 → 16.36.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
@@ -108,7 +108,9 @@ function nativeSpec(config, documentation) {
108
108
  throw new TypeError("rule references must use https");
109
109
  }
110
110
  const examples = [...documentation.examples ?? []];
111
- examples.forEach(validateExample);
111
+ const messageIds = Object.keys(meta2.messages).sort();
112
+ const knownMessages = new Set(messageIds);
113
+ examples.forEach((example) => validateExample(example, knownMessages));
112
114
  assertUnique(examples.map((example) => example.id), "rule example IDs");
113
115
  const publicExamples = examples.filter((example) => example.public === true);
114
116
  const scenarios = new Set(publicExamples.map((example) => example.scenarioId ?? "primary"));
@@ -119,7 +121,6 @@ function nativeSpec(config, documentation) {
119
121
  throw new TypeError(`published example scenario ${scenario} must contain both matching and non-matching cases exactly once`);
120
122
  }
121
123
  }
122
- const messageIds = Object.keys(meta2.messages).sort();
123
124
  const schema = optionsSchema(meta2.schema);
124
125
  const spec = {
125
126
  engine: "eslint",
@@ -155,7 +156,7 @@ function optionsSchema(value) {
155
156
  function isObject(value) {
156
157
  return value !== null && typeof value === "object";
157
158
  }
158
- function validateExample(example) {
159
+ function validateExample(example, messageIds) {
159
160
  if (!KEBAB_CASE.test(example.id)) {
160
161
  throw new TypeError("example ID must be lowercase kebab-case");
161
162
  }
@@ -190,6 +191,58 @@ function validateExample(example) {
190
191
  throw new TypeError("example focus path must name one example file");
191
192
  }
192
193
  assertUnique((example.fixedFiles ?? []).map((file) => file.path), "fixed example file paths");
194
+ if (example.expectedDiagnostics !== void 0) {
195
+ validateExpectedDiagnostics(example.expectedDiagnostics, example, messageIds);
196
+ }
197
+ }
198
+ function validateExpectedDiagnostics(value, example, messageIds) {
199
+ if (!Array.isArray(value) || value.length !== example.expectedCount) {
200
+ throw new TypeError(`${example.id}: expectedDiagnostics must be an array matching expectedCount`);
201
+ }
202
+ const diagnostics = value;
203
+ for (const diagnostic of diagnostics) {
204
+ validateExpectedDiagnostic(diagnostic, example.id, messageIds);
205
+ }
206
+ }
207
+ function validateExpectedDiagnostic(value, exampleId, messageIds) {
208
+ if (!isObject(value) || !("messageId" in value) || typeof value.messageId !== "string" || !messageIds.has(value.messageId) || !("message" in value) || typeof value.message !== "string" || !("location" in value) || !("automaticFix" in value) || typeof value.automaticFix !== "boolean" || !("suggestions" in value) || !Array.isArray(value.suggestions)) {
209
+ throw new TypeError(`${exampleId}: invalid expected diagnostic identity, message or delivery`);
210
+ }
211
+ assertFields(value, ["messageId", "message", "location", "automaticFix", "suggestions"], exampleId);
212
+ validateExpectedLocation(value.location, exampleId);
213
+ const suggestions = value.suggestions;
214
+ for (const suggestion of suggestions) {
215
+ validateExpectedSuggestion(suggestion, exampleId, messageIds);
216
+ }
217
+ }
218
+ function validateExpectedSuggestion(value, exampleId, messageIds) {
219
+ if (!isObject(value) || !("messageId" in value) || typeof value.messageId !== "string" || !messageIds.has(value.messageId) || !("output" in value) || typeof value.output !== "string") {
220
+ throw new TypeError(`${exampleId}: invalid expected suggestion identity or output`);
221
+ }
222
+ assertFields(value, ["messageId", "output"], exampleId);
223
+ }
224
+ function validateExpectedLocation(value, exampleId) {
225
+ if (!isObject(value) || !("line" in value) || !positiveCoordinate(value.line) || !("column" in value) || !positiveCoordinate(value.column)) {
226
+ throw new TypeError(`${exampleId}: expected diagnostic location requires positive integer coordinates`);
227
+ }
228
+ if (!("end" in value)) {
229
+ assertFields(value, ["line", "column"], exampleId);
230
+ return;
231
+ }
232
+ if (!isObject(value.end) || !("line" in value.end) || !positiveCoordinate(value.end.line) || !("column" in value.end) || !positiveCoordinate(value.end.column) || value.end.line < value.line || value.end.line === value.line && value.end.column < value.column) {
233
+ throw new TypeError(`${exampleId}: expected diagnostic end point must be complete and ordered`);
234
+ }
235
+ assertFields(value.end, ["line", "column"], exampleId);
236
+ assertFields(value, ["line", "column", "end"], exampleId);
237
+ }
238
+ function positiveCoordinate(value) {
239
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
240
+ }
241
+ function assertFields(value, expected, exampleId) {
242
+ const fields2 = Object.keys(value);
243
+ if (fields2.length !== expected.length || fields2.some((field) => !expected.includes(field))) {
244
+ throw new TypeError(`${exampleId}: unexpected or missing diagnostic expectation fields`);
245
+ }
193
246
  }
194
247
  function assertSafeRelativePath(path, label) {
195
248
  if (path.length === 0 || path.startsWith("/") || path.startsWith("\\") || /^[A-Za-z]:[\\/]/u.test(path) || path.split(/[\\/]/u).includes("..")) {
@@ -3853,7 +3906,7 @@ function isSearchParamReceiver(call, services) {
3853
3906
  // package.json
3854
3907
  var package_default = {
3855
3908
  name: "@sarj/eslint-plugin",
3856
- version: "16.35.1",
3909
+ version: "16.36.0",
3857
3910
  packageManager: "npm@12.2.1",
3858
3911
  description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
3859
3912
  type: "module",
@@ -17934,7 +17987,23 @@ var NO_RESTRICTED_LIBRARY_LOAD_DOCUMENTATION = {
17934
17987
  examples: [
17935
17988
  { id: "configured-replacement", title: "Use the configured library replacement", outcome: "no-match", files: [{ path: "src/client.ts", source: "import ky from 'ky'; const client = ky;" }], focusPath: "src/client.ts", expectedCount: 0, public: true, ruleOptions: [{ libraries: [{ id: "LIB101", module: "axios", replacement: "Ky" }] }] },
17936
17989
  { id: "runtime-load", title: "Do not load a restricted library at runtime", outcome: "match", files: [{ path: "src/client.ts", source: "const client = require('axios');" }], focusPath: "src/client.ts", expectedCount: 1, public: true, ruleOptions: [{ libraries: [{ id: "LIB101", module: "axios", replacement: "Ky" }] }] },
17937
- { id: "static-import-owned-upstream", title: "Leave static restrictions to the owning import rule", outcome: "no-match", files: [{ path: "src/client.ts", source: "import axios from 'axios';" }], focusPath: "src/client.ts", expectedCount: 0, ruleOptions: [{ libraries: [{ id: "LIB101", module: "axios", replacement: "Ky" }] }] }
17990
+ { id: "static-import-owned-upstream", title: "Leave static restrictions to the owning import rule", outcome: "no-match", files: [{ path: "src/client.ts", source: "import axios from 'axios';" }], focusPath: "src/client.ts", expectedCount: 0, ruleOptions: [{ libraries: [{ id: "LIB101", module: "axios", replacement: "Ky" }] }] },
17991
+ {
17992
+ id: "checked-runtime-load",
17993
+ title: "Identify the exact restricted runtime argument",
17994
+ outcome: "match",
17995
+ files: [{ path: "src/client.ts", source: "const client = require('axios');" }],
17996
+ focusPath: "src/client.ts",
17997
+ expectedCount: 1,
17998
+ ruleOptions: [{ libraries: [{ id: "LIB101", module: "axios", replacement: "Ky" }] }],
17999
+ expectedDiagnostics: [{
18000
+ messageId: "restrictedLibraryLoad",
18001
+ message: "LIB101: Replace this runtime dependency reference to axios with Ky.",
18002
+ location: { line: 1, column: 24, end: { line: 1, column: 31 } },
18003
+ automaticFix: false,
18004
+ suggestions: []
18005
+ }]
18006
+ }
17938
18007
  ]
17939
18008
  };
17940
18009
  function staticModule(node) {
@@ -27341,6 +27410,16 @@ var PREFER_NATIVE_RANDOM_UUID_DOCUMENTATION = {
27341
27410
  ],
27342
27411
  focusPath: "src/ids.ts",
27343
27412
  expectedCount: 1,
27413
+ expectedDiagnostics: [{
27414
+ messageId: "preferNative",
27415
+ message: "Where supported by the deployment runtime, prefer native `globalThis.crypto.randomUUID()` over the `uuid` package for UUID v4.",
27416
+ location: { line: 1, column: 175, end: { line: 1, column: 179 } },
27417
+ automaticFix: true,
27418
+ suggestions: [{
27419
+ messageId: "replaceWithNative",
27420
+ output: "import { v4, NIL } from 'uuid'; const nativeUuid = crypto.randomUUID.bind(crypto); function nativeId(): string { return nativeUuid(); } function packageId(): string { return globalThis.crypto.randomUUID(); } export function ids(): string[] { return [nativeId(), packageId(), NIL]; }"
27421
+ }]
27422
+ }],
27344
27423
  fixedFiles: [
27345
27424
  {
27346
27425
  path: "src/ids.ts",
@@ -27348,6 +27427,24 @@ var PREFER_NATIVE_RANDOM_UUID_DOCUMENTATION = {
27348
27427
  }
27349
27428
  ],
27350
27429
  public: false
27430
+ },
27431
+ {
27432
+ id: "uuid-v4-suggestion-only",
27433
+ title: "Keep the unproven native replacement as a suggestion",
27434
+ outcome: "match",
27435
+ files: [{ path: "src/id.ts", source: "import { v4 } from 'uuid'; const id = v4();" }],
27436
+ focusPath: "src/id.ts",
27437
+ expectedCount: 1,
27438
+ expectedDiagnostics: [{
27439
+ messageId: "preferNative",
27440
+ message: "Where supported by the deployment runtime, prefer native `globalThis.crypto.randomUUID()` over the `uuid` package for UUID v4.",
27441
+ location: { line: 1, column: 39, end: { line: 1, column: 43 } },
27442
+ automaticFix: false,
27443
+ suggestions: [{
27444
+ messageId: "replaceWithNative",
27445
+ output: "import { v4 } from 'uuid'; const id = globalThis.crypto.randomUUID();"
27446
+ }]
27447
+ }]
27351
27448
  }
27352
27449
  ]
27353
27450
  };
@@ -28400,7 +28497,35 @@ var PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION = {
28400
28497
  files: [{ path: "src/autofix-example.ts", source: "const present = [{ id: 'kept' }, null].filter(Boolean);" }],
28401
28498
  fixedFiles: [{ path: "src/autofix-example.ts", source: "const present = [{ id: 'kept' }, null].filter((value) => value !== null && value !== undefined);" }],
28402
28499
  focusPath: "src/autofix-example.ts",
28403
- expectedCount: 1
28500
+ expectedCount: 1,
28501
+ expectedDiagnostics: [{
28502
+ messageId: "preferNullishPredicate",
28503
+ message: "This built-in array contains only nullish or provably truthy values, so `filter(Boolean)` preserves runtime values but loses nullish narrowing. Use an explicit nullish predicate.",
28504
+ location: { line: 1, column: 47, end: { line: 1, column: 54 } },
28505
+ automaticFix: true,
28506
+ suggestions: [{
28507
+ messageId: "replaceBoolean",
28508
+ output: "const present = [{ id: 'kept' }, null].filter((value) => value !== null && value !== undefined);"
28509
+ }]
28510
+ }]
28511
+ },
28512
+ {
28513
+ id: "nonfresh-suggestion-only",
28514
+ title: "Suggest a nullish predicate without assuming a fresh receiver",
28515
+ outcome: "match",
28516
+ files: [{ path: "src/users.ts", source: "declare const users: readonly ({ id: string } | null)[];\nconst present = users.filter(Boolean);" }],
28517
+ focusPath: "src/users.ts",
28518
+ expectedCount: 1,
28519
+ expectedDiagnostics: [{
28520
+ messageId: "preferNullishPredicate",
28521
+ message: "This built-in array contains only nullish or provably truthy values, so `filter(Boolean)` preserves runtime values but loses nullish narrowing. Use an explicit nullish predicate.",
28522
+ location: { line: 2, column: 30, end: { line: 2, column: 37 } },
28523
+ automaticFix: false,
28524
+ suggestions: [{
28525
+ messageId: "replaceBoolean",
28526
+ output: "declare const users: readonly ({ id: string } | null)[];\nconst present = users.filter((value) => value !== null && value !== undefined);"
28527
+ }]
28528
+ }]
28404
28529
  }
28405
28530
  ]
28406
28531
  };
@@ -35972,335 +36097,214 @@ var LIBRARY_IMPORT_POLICY = ["error", {
35972
36097
  paths: LIBRARY_POLICY.map(({ module, note }) => ({ name: module, message: note })),
35973
36098
  patterns: LIBRARY_POLICY.map(({ module, note }) => ({ group: [`${module}/*`], message: note }))
35974
36099
  }];
35975
- var ADVISORY_RULES = [
35976
- "@sarj/excessive-commentary",
35977
- "@sarj/no-bespoke-api-case-conversion",
35978
- "@sarj/no-boolean-selector-parameter",
35979
- "@sarj/no-cors-wildcard-with-credentials",
35980
- "@sarj/no-credential-in-browser-storage",
35981
- "@sarj/no-discarded-validation-result",
35982
- "@sarj/no-exception-text-in-5xx-response",
35983
- "@sarj/no-excess-jsx-props",
35984
- "@sarj/no-generic-json-parser",
35985
- "@sarj/no-mutating-container-transform",
35986
- "@sarj/no-mutating-input-with-result",
35987
- "@sarj/no-negative-only-http-status-assertion",
35988
- "@sarj/no-numeric-search-param-coercion",
35989
- "@sarj/no-redundant-consumer-union",
35990
- "@sarj/no-redundant-local-alias",
35991
- "@sarj/no-restated-comment",
35992
- "@sarj/no-restated-jsdoc",
35993
- "@sarj/no-return-disposed-resource",
35994
- "@sarj/no-test-comments",
35995
- "@sarj/prefer-dependency-interface",
35996
- "@sarj/prefer-discriminated-union",
35997
- "@sarj/prefer-millisecond-control-duration-schema",
35998
- "@sarj/prefer-minimal-parameter-contract",
35999
- "@sarj/prefer-module-level-refined-schema",
36000
- "@sarj/prefer-native-fetch-in-server-actions",
36001
- "@sarj/prefer-node-crypto-hash",
36002
- "@sarj/prefer-node-fs-promises",
36003
- "@sarj/prefer-shared-zod-enum",
36004
- "@sarj/prefer-test-fixture-reuse",
36005
- "@sarj/prefer-whole-object-assertion",
36006
- "@sarj/prefer-zod-parse-output-type",
36007
- "@sarj/production-derived-test-cases",
36008
- "@sarj/require-constrained-schema-integer",
36009
- "@sarj/require-jwt-lifetime",
36010
- "@sarj/require-sql-access-class"
36011
- ];
36012
- var RECOMMENDED_RULES = {
36013
- "@sarj/no-excess-jsx-props": "warn",
36014
- "@sarj/no-redundant-consumer-union": "warn",
36015
- "@sarj/prefer-minimal-parameter-contract": "warn",
36016
- "@sarj/named-child-schema-type": "error",
36017
- "@sarj/no-conditional-empty-object-spread": "error",
36018
- "@sarj/prefer-typed-reflection": "error",
36019
- "@sarj/no-broad-return-type": "error",
36020
- "@sarj/no-reduce-accumulator-copy": "error",
36021
- "@sarj/no-known-value-widening": "error",
36022
- "@sarj/no-invalid-typed-mutation": "error",
36023
- "@sarj/no-contradictory-type-predicate": "error",
36024
- "@sarj/no-partial-type-predicate": "error",
36025
- "@sarj/no-boolean-selector-parameter": "warn",
36026
- "@sarj/no-invalid-zod-custom-parse": "error",
36027
- "@sarj/no-contradictory-overload-return": "error",
36028
- "@sarj/require-button-accessible-name": "error",
36029
- "@sarj/require-camelcase-properties": "error",
36030
- "@sarj/require-svg-accessible-name": "error",
36031
- "@sarj/prefer-logical-tailwind-utilities": ["error", { enabled: false }],
36032
- "@sarj/no-unlocalized-toast": ["error", { enabled: false }],
36033
- "@sarj/no-unlocalized-jsx-attributes": ["error", { enabled: false }],
36034
- "@sarj/no-unlocalized-jsx-text": ["error", { enabled: false }],
36035
- "no-restricted-imports": LIBRARY_IMPORT_POLICY,
36036
- "@sarj/no-restricted-library-load": ["error", { libraries: LIBRARY_POLICY }],
36037
- "@sarj/no-redundant-local-alias": "warn",
36038
- "@sarj/prefer-test-fixture-reuse": "warn",
36039
- "@sarj/no-negative-only-http-status-assertion": "warn",
36040
- "@sarj/no-mutating-input-with-result": "warn",
36041
- "@sarj/no-return-disposed-resource": "warn",
36042
- "@sarj/no-discarded-validation-result": "warn",
36043
- "@sarj/require-jwt-lifetime": "warn",
36044
- "@sarj/prefer-dependency-interface": "warn",
36045
- "@sarj/no-generic-json-parser": "warn",
36046
- "@sarj/require-constrained-schema-integer": "warn",
36047
- "@sarj/production-derived-test-cases": "warn",
36048
- "@sarj/no-test-comments": "warn",
36049
- "@sarj/no-mutating-container-transform": "warn",
36050
- "@sarj/prefer-native-random-uuid": "error",
36051
- "@sarj/prefer-shadcn-primitives": "error",
36052
- "@sarj/excessive-commentary": "warn",
36053
- "@sarj/no-excessive-cognitive-complexity": "error",
36054
- "@sarj/interface-contract-members-private": "error",
36055
- "@sarj/iac-source-coupled-test": "error",
36056
- "@sarj/duplicate-test-body": "error",
36057
- "@sarj/enforce-file-structure": "error",
36058
- "@sarj/no-client-side-data-fetching": "error",
36059
- "@sarj/no-comment-cruft": "error",
36060
- "@sarj/no-cors-wildcard-with-credentials": "warn",
36061
- "@sarj/no-dynamic-sql": "error",
36062
- "@sarj/no-fat-try-blocks": ["error", { max: 5 }],
36063
- "@sarj/no-hand-rolled-sleep": "error",
36064
- "@sarj/no-hand-rolled-spinner": "error",
36065
- "@sarj/no-insecure-random-id": "error",
36066
- "@sarj/no-exception-text-in-5xx-response": "warn",
36067
- "@sarj/no-json-stringify-error": "error",
36068
- "@sarj/no-impossible-zod-literal-bounds": "error",
36069
- "@sarj/no-in-operator-on-built-in-collections": "error",
36070
- "@sarj/no-log-only-catch": "error",
36071
- "@sarj/no-bare-return-from-test-catch": "error",
36072
- "@sarj/no-bespoke-api-case-conversion": "warn",
36073
- "@sarj/no-detached-global-fetch": "error",
36074
- "@sarj/no-json-stringify-object-equality": "error",
36075
- "@sarj/no-dangerously-allow-svg": "error",
36076
- "@sarj/no-credential-in-browser-storage": "warn",
36077
- "@sarj/no-numeric-search-param-coercion": "warn",
36078
- "@sarj/prefer-native-fetch-in-server-actions": "warn",
36079
- "@sarj/no-duplicate-lifecycle-refresh-listeners": "error",
36080
- "@sarj/no-long-comment": "error",
36081
- "@sarj/no-vague-suppression-description": "error",
36082
- "@sarj/no-generic-single-export-module": "error",
36083
- "@sarj/no-offset-pagination": "error",
36084
- "@sarj/no-positional-tuple-return": "error",
36085
- "@sarj/no-production-browser-source-maps": "error",
36086
- "@sarj/no-repeated-string-literal": "error",
36087
- "@sarj/no-redundant-optional-array-default": "error",
36088
- "@sarj/no-router-refresh-polling": "error",
36089
- "@sarj/no-restated-comment": "warn",
36090
- "@sarj/no-restated-jsdoc": "warn",
36091
- "@sarj/no-secret-in-log": "error",
36092
- "@sarj/no-server-env-in-client-component": "error",
36093
- "@sarj/no-select-star": "error",
36094
- "@sarj/no-sentinel-return-on-catch": "error",
36095
- "@sarj/no-silent-promise-catch": "error",
36096
- "@sarj/no-sleep-in-test-body": "error",
36097
- "@sarj/no-string-concat-in-loop": "error",
36098
- "@sarj/no-tautological-expect": "error",
36099
- "@sarj/no-duplicate-test-case": "error",
36100
- "@sarj/no-typed-doc-sections": "error",
36101
- "@sarj/no-trailing-value-narration": "error",
36102
- "@sarj/no-declaration-comment-wall": "error",
36103
- "@sarj/no-union-in-comment": "error",
36104
- "@sarj/no-type-member-comment-wall": "error",
36105
- "@sarj/no-unnecessary-use-client": "error",
36106
- "@sarj/no-unsafe-mock-casting": "error",
36107
- "@sarj/no-unsafe-test-double-cast": "error",
36108
- "@sarj/no-first-party-module-mock": "error",
36109
- "@sarj/no-zod-native-enum": "error",
36110
- "@sarj/test-loops-over-literal-cases": "error",
36111
- "@sarj/prefer-constant-time-secret-compare": "error",
36112
- "@sarj/prefer-ecmascript-private-members": "error",
36113
- "@sarj/prefer-discriminated-union": "warn",
36114
- "@sarj/prefer-input-group-search": "error",
36115
- "@sarj/prefer-millisecond-control-duration-schema": "warn",
36116
- "@sarj/prefer-immutable-module-constant": "error",
36117
- "@sarj/prefer-module-level-constant": "error",
36118
- "@sarj/prefer-module-level-schema": "error",
36119
- "@sarj/prefer-module-level-refined-schema": "warn",
36120
- "@sarj/prefer-multi-value-zod-literal": ["error", { zodMajorVersion: 4 }],
36121
- "@sarj/prefer-named-callback-domain": "error",
36122
- "@sarj/prefer-nominal-id-types": "error",
36123
- "@sarj/prefer-named-complex-return-type": "error",
36124
- "@sarj/prefer-node-crypto-hash": "warn",
36125
- "@sarj/prefer-node-fs-promises": "warn",
36126
- "@sarj/prefer-non-nullable-collection": "error",
36127
- "@sarj/prefer-nullish-filter-predicate": "error",
36128
- "@sarj/prefer-await-in-async-return": "error",
36129
- "@sarj/prefer-schema-for-api-payload": "error",
36130
- "@sarj/prefer-shared-zod-enum": "warn",
36131
- "@sarj/prefer-switch-for-repeated-equality": "error",
36132
- "@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
36133
- "@sarj/prefer-server-actions": "error",
36134
- "@sarj/prefer-whole-object-assertion": "warn",
36135
- "@sarj/repeated-static-call-cases": "error",
36136
- "@sarj/prefer-zod-infer": "error",
36137
- "@sarj/prefer-zod-parse-output-type": "warn",
36138
- "@sarj/require-assert-never": "error",
36139
- "@sarj/require-fetch-timeout": "error",
36140
- "@sarj/require-explicit-contract-implementation": "error",
36141
- "@sarj/require-explicit-service-contract": "error",
36142
- "@sarj/require-interface-for-exported-class": "error",
36143
- "@sarj/require-port-for-service": "error",
36144
- "@sarj/require-sql-access-class": "warn",
36145
- "@sarj/require-static-next-matcher": "error",
36146
- "@sarj/require-use-form-default-values": "error",
36147
- "@sarj/require-use-server-in-actions-file": "error",
36148
- "@sarj/require-zod-form-validation": "error",
36149
- "@sarj/store-insert-requires-on-conflict": "error",
36150
- "@sarj/stepdown": "error",
36151
- "@sarj/source-coupled-test": "error",
36152
- "@sarj/sole-export-matches-filename": "error",
36153
- "@sarj/test-phase-label-comment": "error",
36154
- "@sarj/require-pascal-case-zod-schema-name": "error"
36155
- };
36156
- var STRICT_RULES = {
36157
- "@sarj/no-discarded-validation-result": "warn",
36158
- "@sarj/no-generic-json-parser": "warn",
36159
- "@sarj/no-mutating-container-transform": "warn",
36160
- "@sarj/no-mutating-input-with-result": "warn",
36161
- "@sarj/no-negative-only-http-status-assertion": "warn",
36162
- "@sarj/no-redundant-local-alias": "warn",
36163
- "@sarj/no-return-disposed-resource": "warn",
36164
- "@sarj/no-test-comments": "warn",
36165
- "@sarj/prefer-dependency-interface": "warn",
36166
- "@sarj/prefer-test-fixture-reuse": "warn",
36167
- "@sarj/production-derived-test-cases": "warn",
36168
- "@sarj/require-constrained-schema-integer": "warn",
36169
- "@sarj/require-jwt-lifetime": "warn",
36170
- "@sarj/no-excess-jsx-props": "warn",
36171
- "@sarj/no-redundant-consumer-union": "warn",
36172
- "@sarj/prefer-minimal-parameter-contract": "warn",
36173
- "@sarj/named-child-schema-type": "error",
36174
- "@sarj/no-conditional-empty-object-spread": "error",
36175
- "@sarj/prefer-typed-reflection": "error",
36176
- "@sarj/no-broad-return-type": "error",
36177
- "@sarj/no-reduce-accumulator-copy": "error",
36178
- "@sarj/no-known-value-widening": "error",
36179
- "@sarj/no-invalid-typed-mutation": "error",
36180
- "@sarj/no-contradictory-type-predicate": "error",
36181
- "@sarj/no-partial-type-predicate": "error",
36182
- "@sarj/no-boolean-selector-parameter": "warn",
36183
- "@sarj/no-invalid-zod-custom-parse": "error",
36184
- "@sarj/no-contradictory-overload-return": "error",
36185
- "@sarj/require-button-accessible-name": "error",
36186
- "@sarj/require-camelcase-properties": "error",
36187
- "@sarj/require-svg-accessible-name": "error",
36188
- "@sarj/prefer-logical-tailwind-utilities": ["error", { enabled: false }],
36189
- "@sarj/no-unlocalized-toast": ["error", { enabled: false }],
36190
- "@sarj/no-unlocalized-jsx-attributes": ["error", { enabled: false }],
36191
- "@sarj/no-unlocalized-jsx-text": ["error", { enabled: false }],
36192
- "no-restricted-imports": LIBRARY_IMPORT_POLICY,
36193
- "@sarj/no-restricted-library-load": ["error", { libraries: LIBRARY_POLICY }],
36194
- "@sarj/prefer-native-random-uuid": "error",
36195
- "@sarj/prefer-shadcn-primitives": "error",
36196
- "@sarj/excessive-commentary": "warn",
36197
- "@sarj/no-excessive-cognitive-complexity": "error",
36198
- "@sarj/interface-contract-members-private": "error",
36199
- "@sarj/iac-source-coupled-test": "error",
36200
- "@sarj/duplicate-test-body": "error",
36201
- "@sarj/enforce-file-structure": "error",
36202
- "@sarj/no-client-side-data-fetching": "error",
36203
- "@sarj/no-comment-cruft": "error",
36204
- "@sarj/no-cors-wildcard-with-credentials": "warn",
36205
- "@sarj/no-dynamic-sql": "error",
36206
- "@sarj/no-enum": "error",
36207
- "@sarj/no-fat-try-blocks": ["error", { max: 5 }],
36208
- "@sarj/no-hand-rolled-sleep": "error",
36209
- "@sarj/no-hand-rolled-spinner": "error",
36210
- "@sarj/no-insecure-random-id": "error",
36211
- "@sarj/no-exception-text-in-5xx-response": "warn",
36212
- "@sarj/no-json-stringify-error": "error",
36213
- "@sarj/no-impossible-zod-literal-bounds": "error",
36214
- "@sarj/no-in-operator-on-built-in-collections": "error",
36215
- "@sarj/no-log-only-catch": "error",
36216
- "@sarj/no-bare-return-from-test-catch": "error",
36217
- "@sarj/no-bespoke-api-case-conversion": "warn",
36218
- "@sarj/no-detached-global-fetch": "error",
36219
- "@sarj/no-json-stringify-object-equality": "error",
36220
- "@sarj/no-dangerously-allow-svg": "error",
36221
- "@sarj/no-credential-in-browser-storage": "warn",
36222
- "@sarj/no-numeric-search-param-coercion": "warn",
36223
- "@sarj/prefer-native-fetch-in-server-actions": "warn",
36224
- "@sarj/no-duplicate-lifecycle-refresh-listeners": "error",
36225
- "@sarj/no-long-comment": "error",
36226
- "@sarj/no-vague-suppression-description": "error",
36227
- "@sarj/no-generic-single-export-module": "error",
36228
- "@sarj/no-offset-pagination": "error",
36229
- "@sarj/no-positional-tuple-return": "error",
36230
- "@sarj/no-production-browser-source-maps": "error",
36231
- "@sarj/no-raw-env": "error",
36232
- "@sarj/no-raw-fetch-outside-clients": "error",
36233
- "@sarj/no-repeated-string-literal": "error",
36234
- "@sarj/no-redundant-optional-array-default": "error",
36235
- "@sarj/no-router-refresh-polling": "error",
36236
- "@sarj/no-restated-comment": "warn",
36237
- "@sarj/no-restated-jsdoc": "warn",
36238
- "@sarj/no-secret-in-log": "error",
36239
- "@sarj/no-server-env-in-client-component": "error",
36240
- "@sarj/no-select-star": "error",
36241
- "@sarj/no-sentinel-return-on-catch": "error",
36242
- "@sarj/no-silent-promise-catch": "error",
36243
- "@sarj/no-sleep-in-test-body": "error",
36244
- "@sarj/no-storage-in-stateless-modules": "error",
36245
- "@sarj/no-string-concat-in-loop": "error",
36246
- "@sarj/no-tautological-expect": "error",
36247
- "@sarj/no-duplicate-test-case": "error",
36248
- "@sarj/no-typed-doc-sections": "error",
36249
- "@sarj/no-trailing-value-narration": "error",
36250
- "@sarj/no-declaration-comment-wall": "error",
36251
- "@sarj/no-union-in-comment": "error",
36252
- "@sarj/no-type-member-comment-wall": "error",
36253
- "@sarj/no-unnecessary-use-client": "error",
36254
- "@sarj/no-unsafe-mock-casting": "error",
36255
- "@sarj/no-unsafe-test-double-cast": "error",
36256
- "@sarj/no-first-party-module-mock": "error",
36257
- "@sarj/no-zod-native-enum": "error",
36258
- "@sarj/test-loops-over-literal-cases": "error",
36259
- "@sarj/prefer-constant-time-secret-compare": "error",
36260
- "@sarj/prefer-ecmascript-private-members": "error",
36261
- "@sarj/prefer-discriminated-union": "warn",
36262
- "@sarj/prefer-input-group-search": "error",
36263
- "@sarj/prefer-millisecond-control-duration-schema": "warn",
36264
- "@sarj/prefer-immutable-module-constant": "error",
36265
- "@sarj/prefer-module-level-constant": "error",
36266
- "@sarj/prefer-module-level-schema": "error",
36267
- "@sarj/prefer-module-level-refined-schema": "warn",
36268
- "@sarj/prefer-multi-value-zod-literal": ["error", { zodMajorVersion: 4 }],
36269
- "@sarj/prefer-named-callback-domain": "error",
36270
- "@sarj/prefer-nominal-id-types": "error",
36271
- "@sarj/prefer-named-complex-return-type": "error",
36272
- "@sarj/prefer-node-crypto-hash": "warn",
36273
- "@sarj/prefer-node-fs-promises": "warn",
36274
- "@sarj/prefer-non-nullable-collection": "error",
36275
- "@sarj/prefer-nullish-filter-predicate": "error",
36276
- "@sarj/prefer-await-in-async-return": "error",
36277
- "@sarj/prefer-schema-for-api-payload": "error",
36278
- "@sarj/prefer-shared-zod-enum": "warn",
36279
- "@sarj/prefer-switch-for-repeated-equality": "error",
36280
- "@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
36281
- "@sarj/prefer-server-actions": "error",
36282
- "@sarj/prefer-whole-object-assertion": "warn",
36283
- "@sarj/repeated-static-call-cases": "error",
36284
- "@sarj/prefer-zod-infer": "error",
36285
- "@sarj/prefer-zod-parse-output-type": "warn",
36286
- "@sarj/require-assert-never": "error",
36287
- "@sarj/require-fetch-timeout": "error",
36288
- "@sarj/require-explicit-contract-implementation": "error",
36289
- "@sarj/require-explicit-service-contract": "error",
36290
- "@sarj/require-interface-for-exported-class": "error",
36291
- "@sarj/require-port-for-service": "error",
36292
- "@sarj/require-sql-access-class": "warn",
36293
- "@sarj/require-static-next-matcher": "error",
36294
- "@sarj/require-use-form-default-values": "error",
36295
- "@sarj/require-use-server-in-actions-file": "error",
36296
- "@sarj/require-zod-form-validation": "error",
36297
- "@sarj/store-insert-requires-on-conflict": "error",
36298
- "@sarj/stepdown": "error",
36299
- "@sarj/source-coupled-test": "error",
36300
- "@sarj/sole-export-matches-filename": "error",
36301
- "@sarj/test-phase-label-comment": "error",
36302
- "@sarj/require-pascal-case-zod-schema-name": "error"
36100
+ var RULE_POLICY = {
36101
+ "@sarj/no-excess-jsx-props": ["warn", "both"],
36102
+ "@sarj/no-redundant-consumer-union": ["warn", "both"],
36103
+ "@sarj/prefer-minimal-parameter-contract": ["warn", "both"],
36104
+ "@sarj/named-child-schema-type": ["error", "both"],
36105
+ "@sarj/no-conditional-empty-object-spread": ["error", "both"],
36106
+ "@sarj/prefer-typed-reflection": ["error", "both"],
36107
+ "@sarj/no-broad-return-type": ["error", "both"],
36108
+ "@sarj/no-reduce-accumulator-copy": ["error", "both"],
36109
+ "@sarj/no-known-value-widening": ["error", "both"],
36110
+ "@sarj/no-invalid-typed-mutation": ["error", "both"],
36111
+ "@sarj/no-contradictory-type-predicate": ["error", "both"],
36112
+ "@sarj/no-partial-type-predicate": ["error", "both"],
36113
+ "@sarj/no-boolean-selector-parameter": ["warn", "both"],
36114
+ "@sarj/no-invalid-zod-custom-parse": ["error", "both"],
36115
+ "@sarj/no-contradictory-overload-return": ["error", "both"],
36116
+ "@sarj/require-button-accessible-name": ["error", "both"],
36117
+ "@sarj/require-camelcase-properties": ["error", "both"],
36118
+ "@sarj/require-svg-accessible-name": ["error", "both"],
36119
+ "@sarj/prefer-logical-tailwind-utilities": [
36120
+ "error",
36121
+ "both",
36122
+ () => [{ enabled: false }]
36123
+ ],
36124
+ "@sarj/no-unlocalized-toast": [
36125
+ "error",
36126
+ "both",
36127
+ () => [{ enabled: false }]
36128
+ ],
36129
+ "@sarj/no-unlocalized-jsx-attributes": [
36130
+ "error",
36131
+ "both",
36132
+ () => [{ enabled: false }]
36133
+ ],
36134
+ "@sarj/no-unlocalized-jsx-text": [
36135
+ "error",
36136
+ "both",
36137
+ () => [{ enabled: false }]
36138
+ ],
36139
+ "no-restricted-imports": ["shared", "both", LIBRARY_IMPORT_POLICY],
36140
+ "@sarj/no-restricted-library-load": [
36141
+ "error",
36142
+ "both",
36143
+ () => [{ libraries: LIBRARY_POLICY }]
36144
+ ],
36145
+ "@sarj/no-redundant-local-alias": ["warn", "both", "strict-order", 5],
36146
+ "@sarj/prefer-test-fixture-reuse": ["warn", "both", "strict-order", 9],
36147
+ "@sarj/no-negative-only-http-status-assertion": ["warn", "both", "strict-order", 4],
36148
+ "@sarj/no-mutating-input-with-result": ["warn", "both", "strict-order", 3],
36149
+ "@sarj/no-return-disposed-resource": ["warn", "both", "strict-order", 6],
36150
+ "@sarj/no-discarded-validation-result": ["warn", "both", "strict-order", 0],
36151
+ "@sarj/require-jwt-lifetime": ["warn", "both", "strict-order", 12],
36152
+ "@sarj/prefer-dependency-interface": ["warn", "both", "strict-order", 8],
36153
+ "@sarj/no-generic-json-parser": ["warn", "both", "strict-order", 1],
36154
+ "@sarj/require-constrained-schema-integer": ["warn", "both", "strict-order", 11],
36155
+ "@sarj/production-derived-test-cases": ["warn", "both", "strict-order", 10],
36156
+ "@sarj/no-test-comments": ["warn", "both", "strict-order", 7],
36157
+ "@sarj/no-mutating-container-transform": ["warn", "both", "strict-order", 2],
36158
+ "@sarj/prefer-native-random-uuid": ["error", "both"],
36159
+ "@sarj/prefer-shadcn-primitives": ["error", "both"],
36160
+ "@sarj/excessive-commentary": ["warn", "both"],
36161
+ "@sarj/no-excessive-cognitive-complexity": ["error", "both"],
36162
+ "@sarj/interface-contract-members-private": ["error", "both"],
36163
+ "@sarj/iac-source-coupled-test": ["error", "both"],
36164
+ "@sarj/duplicate-test-body": ["error", "both"],
36165
+ "@sarj/enforce-file-structure": ["error", "both"],
36166
+ "@sarj/no-client-side-data-fetching": ["error", "both"],
36167
+ "@sarj/no-comment-cruft": ["error", "both"],
36168
+ "@sarj/no-cors-wildcard-with-credentials": ["warn", "both"],
36169
+ "@sarj/no-dynamic-sql": ["error", "both"],
36170
+ "@sarj/no-enum": ["error", "strict"],
36171
+ "@sarj/no-fat-try-blocks": [
36172
+ "error",
36173
+ "both",
36174
+ () => [{ max: 5 }]
36175
+ ],
36176
+ "@sarj/no-hand-rolled-sleep": ["error", "both"],
36177
+ "@sarj/no-hand-rolled-spinner": ["error", "both"],
36178
+ "@sarj/no-insecure-random-id": ["error", "both"],
36179
+ "@sarj/no-exception-text-in-5xx-response": ["warn", "both"],
36180
+ "@sarj/no-json-stringify-error": ["error", "both"],
36181
+ "@sarj/no-impossible-zod-literal-bounds": ["error", "both"],
36182
+ "@sarj/no-in-operator-on-built-in-collections": ["error", "both"],
36183
+ "@sarj/no-log-only-catch": ["error", "both"],
36184
+ "@sarj/no-bare-return-from-test-catch": ["error", "both"],
36185
+ "@sarj/no-bespoke-api-case-conversion": ["warn", "both"],
36186
+ "@sarj/no-detached-global-fetch": ["error", "both"],
36187
+ "@sarj/no-json-stringify-object-equality": ["error", "both"],
36188
+ "@sarj/no-dangerously-allow-svg": ["error", "both"],
36189
+ "@sarj/no-credential-in-browser-storage": ["warn", "both"],
36190
+ "@sarj/no-numeric-search-param-coercion": ["warn", "both"],
36191
+ "@sarj/prefer-native-fetch-in-server-actions": ["warn", "both"],
36192
+ "@sarj/no-duplicate-lifecycle-refresh-listeners": ["error", "both"],
36193
+ "@sarj/no-long-comment": ["error", "both"],
36194
+ "@sarj/no-vague-suppression-description": ["error", "both"],
36195
+ "@sarj/no-generic-single-export-module": ["error", "both"],
36196
+ "@sarj/no-offset-pagination": ["error", "both"],
36197
+ "@sarj/no-positional-tuple-return": ["error", "both"],
36198
+ "@sarj/no-production-browser-source-maps": ["error", "both"],
36199
+ "@sarj/no-raw-env": ["error", "strict"],
36200
+ "@sarj/no-raw-fetch-outside-clients": ["error", "strict"],
36201
+ "@sarj/no-repeated-string-literal": ["error", "both"],
36202
+ "@sarj/no-redundant-optional-array-default": ["error", "both"],
36203
+ "@sarj/no-router-refresh-polling": ["error", "both"],
36204
+ "@sarj/no-restated-comment": ["warn", "both"],
36205
+ "@sarj/no-restated-jsdoc": ["warn", "both"],
36206
+ "@sarj/no-secret-in-log": ["error", "both"],
36207
+ "@sarj/no-server-env-in-client-component": ["error", "both"],
36208
+ "@sarj/no-select-star": ["error", "both"],
36209
+ "@sarj/no-sentinel-return-on-catch": ["error", "both"],
36210
+ "@sarj/no-silent-promise-catch": ["error", "both"],
36211
+ "@sarj/no-sleep-in-test-body": ["error", "both"],
36212
+ "@sarj/no-storage-in-stateless-modules": ["error", "strict"],
36213
+ "@sarj/no-string-concat-in-loop": ["error", "both"],
36214
+ "@sarj/no-tautological-expect": ["error", "both"],
36215
+ "@sarj/no-duplicate-test-case": ["error", "both"],
36216
+ "@sarj/no-typed-doc-sections": ["error", "both"],
36217
+ "@sarj/no-trailing-value-narration": ["error", "both"],
36218
+ "@sarj/no-declaration-comment-wall": ["error", "both"],
36219
+ "@sarj/no-union-in-comment": ["error", "both"],
36220
+ "@sarj/no-type-member-comment-wall": ["error", "both"],
36221
+ "@sarj/no-unnecessary-use-client": ["error", "both"],
36222
+ "@sarj/no-unsafe-mock-casting": ["error", "both"],
36223
+ "@sarj/no-unsafe-test-double-cast": ["error", "both"],
36224
+ "@sarj/no-first-party-module-mock": ["error", "both"],
36225
+ "@sarj/no-zod-native-enum": ["error", "both"],
36226
+ "@sarj/test-loops-over-literal-cases": ["error", "both"],
36227
+ "@sarj/prefer-constant-time-secret-compare": ["error", "both"],
36228
+ "@sarj/prefer-ecmascript-private-members": ["error", "both"],
36229
+ "@sarj/prefer-discriminated-union": ["warn", "both"],
36230
+ "@sarj/prefer-input-group-search": ["error", "both"],
36231
+ "@sarj/prefer-millisecond-control-duration-schema": ["warn", "both"],
36232
+ "@sarj/prefer-immutable-module-constant": ["error", "both"],
36233
+ "@sarj/prefer-module-level-constant": ["error", "both"],
36234
+ "@sarj/prefer-module-level-schema": ["error", "both"],
36235
+ "@sarj/prefer-module-level-refined-schema": ["warn", "both"],
36236
+ "@sarj/prefer-multi-value-zod-literal": [
36237
+ "error",
36238
+ "both",
36239
+ () => [{ zodMajorVersion: 4 }]
36240
+ ],
36241
+ "@sarj/prefer-named-callback-domain": ["error", "both"],
36242
+ "@sarj/prefer-nominal-id-types": ["error", "both"],
36243
+ "@sarj/prefer-named-complex-return-type": ["error", "both"],
36244
+ "@sarj/prefer-node-crypto-hash": ["warn", "both"],
36245
+ "@sarj/prefer-node-fs-promises": ["warn", "both"],
36246
+ "@sarj/prefer-non-nullable-collection": ["error", "both"],
36247
+ "@sarj/prefer-nullish-filter-predicate": ["error", "both"],
36248
+ "@sarj/prefer-await-in-async-return": ["error", "both"],
36249
+ "@sarj/prefer-schema-for-api-payload": ["error", "both"],
36250
+ "@sarj/prefer-shared-zod-enum": ["warn", "both"],
36251
+ "@sarj/prefer-switch-for-repeated-equality": ["error", "both"],
36252
+ "@sarj/prefer-semantic-colors": [
36253
+ "error",
36254
+ "both",
36255
+ () => [{ requireSemanticTokens: true }]
36256
+ ],
36257
+ "@sarj/prefer-server-actions": ["error", "both"],
36258
+ "@sarj/prefer-whole-object-assertion": ["warn", "both"],
36259
+ "@sarj/repeated-static-call-cases": ["error", "both"],
36260
+ "@sarj/prefer-zod-infer": ["error", "both"],
36261
+ "@sarj/prefer-zod-parse-output-type": ["warn", "both"],
36262
+ "@sarj/require-assert-never": ["error", "both"],
36263
+ "@sarj/require-fetch-timeout": ["error", "both"],
36264
+ "@sarj/require-explicit-contract-implementation": ["error", "both"],
36265
+ "@sarj/require-explicit-service-contract": ["error", "both"],
36266
+ "@sarj/require-interface-for-exported-class": ["error", "both"],
36267
+ "@sarj/require-port-for-service": ["error", "both"],
36268
+ "@sarj/require-sql-access-class": ["warn", "both"],
36269
+ "@sarj/require-static-next-matcher": ["error", "both"],
36270
+ "@sarj/require-use-form-default-values": ["error", "both"],
36271
+ "@sarj/require-use-server-in-actions-file": ["error", "both"],
36272
+ "@sarj/require-zod-form-validation": ["error", "both"],
36273
+ "@sarj/store-insert-requires-on-conflict": ["error", "both"],
36274
+ "@sarj/stepdown": ["error", "both"],
36275
+ "@sarj/source-coupled-test": ["error", "both"],
36276
+ "@sarj/sole-export-matches-filename": ["error", "both"],
36277
+ "@sarj/test-phase-label-comment": ["error", "both"],
36278
+ "@sarj/require-pascal-case-zod-schema-name": ["error", "both"]
36303
36279
  };
36280
+ var ADVISORY_RULES = Object.keys(RULE_POLICY).filter(isAdvisoryRuleName).toSorted();
36281
+ var RECOMMENDED_RULES = presetRules("recommended");
36282
+ var STRICT_RULES = presetRules("strict");
36283
+ function isAdvisoryRuleName(name) {
36284
+ return isPolicyName(name) && RULE_POLICY[name][0] === "warn";
36285
+ }
36286
+ function isPolicyName(name) {
36287
+ return Object.hasOwn(RULE_POLICY, name);
36288
+ }
36289
+ function presetRules(preset) {
36290
+ const rows = Object.entries(RULE_POLICY).filter(([, row]) => preset === "strict" || row[1] === "both");
36291
+ if (preset === "strict") rows.sort((left, right) => strictOrder(left[1]) - strictOrder(right[1]));
36292
+ const entries = rows.map(([name, row]) => [name, policySetting(row)]);
36293
+ const result = Object.fromEntries(entries);
36294
+ const names = Object.keys(result);
36295
+ if (names.length !== entries.length || names.some((name, index) => name !== entries[index]?.[0])) {
36296
+ throw new Error("Preset projection changed its closed policy key order.");
36297
+ }
36298
+ return result;
36299
+ }
36300
+ function strictOrder(row) {
36301
+ return row.length === 4 ? row[3] : Number.MAX_SAFE_INTEGER;
36302
+ }
36303
+ function policySetting(row) {
36304
+ if (row[0] === "shared") return row[2];
36305
+ if (row.length !== 3) return row[0];
36306
+ return [row[0], ...row[2]()];
36307
+ }
36304
36308
  var PLUGIN = {
36305
36309
  meta,
36306
36310
  rules: RULES,