@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.cjs CHANGED
@@ -159,7 +159,9 @@ function nativeSpec(config, documentation) {
159
159
  throw new TypeError("rule references must use https");
160
160
  }
161
161
  const examples = [...documentation.examples ?? []];
162
- examples.forEach(validateExample);
162
+ const messageIds = Object.keys(meta2.messages).sort();
163
+ const knownMessages = new Set(messageIds);
164
+ examples.forEach((example) => validateExample(example, knownMessages));
163
165
  assertUnique(examples.map((example) => example.id), "rule example IDs");
164
166
  const publicExamples = examples.filter((example) => example.public === true);
165
167
  const scenarios = new Set(publicExamples.map((example) => example.scenarioId ?? "primary"));
@@ -170,7 +172,6 @@ function nativeSpec(config, documentation) {
170
172
  throw new TypeError(`published example scenario ${scenario} must contain both matching and non-matching cases exactly once`);
171
173
  }
172
174
  }
173
- const messageIds = Object.keys(meta2.messages).sort();
174
175
  const schema = optionsSchema(meta2.schema);
175
176
  const spec = {
176
177
  engine: "eslint",
@@ -206,7 +207,7 @@ function optionsSchema(value) {
206
207
  function isObject(value) {
207
208
  return value !== null && typeof value === "object";
208
209
  }
209
- function validateExample(example) {
210
+ function validateExample(example, messageIds) {
210
211
  if (!KEBAB_CASE.test(example.id)) {
211
212
  throw new TypeError("example ID must be lowercase kebab-case");
212
213
  }
@@ -241,6 +242,58 @@ function validateExample(example) {
241
242
  throw new TypeError("example focus path must name one example file");
242
243
  }
243
244
  assertUnique((example.fixedFiles ?? []).map((file) => file.path), "fixed example file paths");
245
+ if (example.expectedDiagnostics !== void 0) {
246
+ validateExpectedDiagnostics(example.expectedDiagnostics, example, messageIds);
247
+ }
248
+ }
249
+ function validateExpectedDiagnostics(value, example, messageIds) {
250
+ if (!Array.isArray(value) || value.length !== example.expectedCount) {
251
+ throw new TypeError(`${example.id}: expectedDiagnostics must be an array matching expectedCount`);
252
+ }
253
+ const diagnostics = value;
254
+ for (const diagnostic of diagnostics) {
255
+ validateExpectedDiagnostic(diagnostic, example.id, messageIds);
256
+ }
257
+ }
258
+ function validateExpectedDiagnostic(value, exampleId, messageIds) {
259
+ 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)) {
260
+ throw new TypeError(`${exampleId}: invalid expected diagnostic identity, message or delivery`);
261
+ }
262
+ assertFields(value, ["messageId", "message", "location", "automaticFix", "suggestions"], exampleId);
263
+ validateExpectedLocation(value.location, exampleId);
264
+ const suggestions = value.suggestions;
265
+ for (const suggestion of suggestions) {
266
+ validateExpectedSuggestion(suggestion, exampleId, messageIds);
267
+ }
268
+ }
269
+ function validateExpectedSuggestion(value, exampleId, messageIds) {
270
+ if (!isObject(value) || !("messageId" in value) || typeof value.messageId !== "string" || !messageIds.has(value.messageId) || !("output" in value) || typeof value.output !== "string") {
271
+ throw new TypeError(`${exampleId}: invalid expected suggestion identity or output`);
272
+ }
273
+ assertFields(value, ["messageId", "output"], exampleId);
274
+ }
275
+ function validateExpectedLocation(value, exampleId) {
276
+ if (!isObject(value) || !("line" in value) || !positiveCoordinate(value.line) || !("column" in value) || !positiveCoordinate(value.column)) {
277
+ throw new TypeError(`${exampleId}: expected diagnostic location requires positive integer coordinates`);
278
+ }
279
+ if (!("end" in value)) {
280
+ assertFields(value, ["line", "column"], exampleId);
281
+ return;
282
+ }
283
+ 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) {
284
+ throw new TypeError(`${exampleId}: expected diagnostic end point must be complete and ordered`);
285
+ }
286
+ assertFields(value.end, ["line", "column"], exampleId);
287
+ assertFields(value, ["line", "column", "end"], exampleId);
288
+ }
289
+ function positiveCoordinate(value) {
290
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
291
+ }
292
+ function assertFields(value, expected, exampleId) {
293
+ const fields2 = Object.keys(value);
294
+ if (fields2.length !== expected.length || fields2.some((field) => !expected.includes(field))) {
295
+ throw new TypeError(`${exampleId}: unexpected or missing diagnostic expectation fields`);
296
+ }
244
297
  }
245
298
  function assertSafeRelativePath(path, label) {
246
299
  if (path.length === 0 || path.startsWith("/") || path.startsWith("\\") || /^[A-Za-z]:[\\/]/u.test(path) || path.split(/[\\/]/u).includes("..")) {
@@ -3900,7 +3953,7 @@ function isSearchParamReceiver(call, services) {
3900
3953
  // package.json
3901
3954
  var package_default = {
3902
3955
  name: "@sarj/eslint-plugin",
3903
- version: "16.35.1",
3956
+ version: "16.36.0",
3904
3957
  packageManager: "npm@12.2.1",
3905
3958
  description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
3906
3959
  type: "module",
@@ -17906,7 +17959,23 @@ var NO_RESTRICTED_LIBRARY_LOAD_DOCUMENTATION = {
17906
17959
  examples: [
17907
17960
  { 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" }] }] },
17908
17961
  { 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" }] }] },
17909
- { 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" }] }] }
17962
+ { 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" }] }] },
17963
+ {
17964
+ id: "checked-runtime-load",
17965
+ title: "Identify the exact restricted runtime argument",
17966
+ outcome: "match",
17967
+ files: [{ path: "src/client.ts", source: "const client = require('axios');" }],
17968
+ focusPath: "src/client.ts",
17969
+ expectedCount: 1,
17970
+ ruleOptions: [{ libraries: [{ id: "LIB101", module: "axios", replacement: "Ky" }] }],
17971
+ expectedDiagnostics: [{
17972
+ messageId: "restrictedLibraryLoad",
17973
+ message: "LIB101: Replace this runtime dependency reference to axios with Ky.",
17974
+ location: { line: 1, column: 24, end: { line: 1, column: 31 } },
17975
+ automaticFix: false,
17976
+ suggestions: []
17977
+ }]
17978
+ }
17910
17979
  ]
17911
17980
  };
17912
17981
  function staticModule(node) {
@@ -27266,6 +27335,16 @@ var PREFER_NATIVE_RANDOM_UUID_DOCUMENTATION = {
27266
27335
  ],
27267
27336
  focusPath: "src/ids.ts",
27268
27337
  expectedCount: 1,
27338
+ expectedDiagnostics: [{
27339
+ messageId: "preferNative",
27340
+ message: "Where supported by the deployment runtime, prefer native `globalThis.crypto.randomUUID()` over the `uuid` package for UUID v4.",
27341
+ location: { line: 1, column: 175, end: { line: 1, column: 179 } },
27342
+ automaticFix: true,
27343
+ suggestions: [{
27344
+ messageId: "replaceWithNative",
27345
+ 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]; }"
27346
+ }]
27347
+ }],
27269
27348
  fixedFiles: [
27270
27349
  {
27271
27350
  path: "src/ids.ts",
@@ -27273,6 +27352,24 @@ var PREFER_NATIVE_RANDOM_UUID_DOCUMENTATION = {
27273
27352
  }
27274
27353
  ],
27275
27354
  public: false
27355
+ },
27356
+ {
27357
+ id: "uuid-v4-suggestion-only",
27358
+ title: "Keep the unproven native replacement as a suggestion",
27359
+ outcome: "match",
27360
+ files: [{ path: "src/id.ts", source: "import { v4 } from 'uuid'; const id = v4();" }],
27361
+ focusPath: "src/id.ts",
27362
+ expectedCount: 1,
27363
+ expectedDiagnostics: [{
27364
+ messageId: "preferNative",
27365
+ message: "Where supported by the deployment runtime, prefer native `globalThis.crypto.randomUUID()` over the `uuid` package for UUID v4.",
27366
+ location: { line: 1, column: 39, end: { line: 1, column: 43 } },
27367
+ automaticFix: false,
27368
+ suggestions: [{
27369
+ messageId: "replaceWithNative",
27370
+ output: "import { v4 } from 'uuid'; const id = globalThis.crypto.randomUUID();"
27371
+ }]
27372
+ }]
27276
27373
  }
27277
27374
  ]
27278
27375
  };
@@ -28321,7 +28418,35 @@ var PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION = {
28321
28418
  files: [{ path: "src/autofix-example.ts", source: "const present = [{ id: 'kept' }, null].filter(Boolean);" }],
28322
28419
  fixedFiles: [{ path: "src/autofix-example.ts", source: "const present = [{ id: 'kept' }, null].filter((value) => value !== null && value !== undefined);" }],
28323
28420
  focusPath: "src/autofix-example.ts",
28324
- expectedCount: 1
28421
+ expectedCount: 1,
28422
+ expectedDiagnostics: [{
28423
+ messageId: "preferNullishPredicate",
28424
+ 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.",
28425
+ location: { line: 1, column: 47, end: { line: 1, column: 54 } },
28426
+ automaticFix: true,
28427
+ suggestions: [{
28428
+ messageId: "replaceBoolean",
28429
+ output: "const present = [{ id: 'kept' }, null].filter((value) => value !== null && value !== undefined);"
28430
+ }]
28431
+ }]
28432
+ },
28433
+ {
28434
+ id: "nonfresh-suggestion-only",
28435
+ title: "Suggest a nullish predicate without assuming a fresh receiver",
28436
+ outcome: "match",
28437
+ files: [{ path: "src/users.ts", source: "declare const users: readonly ({ id: string } | null)[];\nconst present = users.filter(Boolean);" }],
28438
+ focusPath: "src/users.ts",
28439
+ expectedCount: 1,
28440
+ expectedDiagnostics: [{
28441
+ messageId: "preferNullishPredicate",
28442
+ 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.",
28443
+ location: { line: 2, column: 30, end: { line: 2, column: 37 } },
28444
+ automaticFix: false,
28445
+ suggestions: [{
28446
+ messageId: "replaceBoolean",
28447
+ output: "declare const users: readonly ({ id: string } | null)[];\nconst present = users.filter((value) => value !== null && value !== undefined);"
28448
+ }]
28449
+ }]
28325
28450
  }
28326
28451
  ]
28327
28452
  };
@@ -35864,335 +35989,214 @@ var LIBRARY_IMPORT_POLICY = ["error", {
35864
35989
  paths: LIBRARY_POLICY.map(({ module: module2, note }) => ({ name: module2, message: note })),
35865
35990
  patterns: LIBRARY_POLICY.map(({ module: module2, note }) => ({ group: [`${module2}/*`], message: note }))
35866
35991
  }];
35867
- var ADVISORY_RULES = [
35868
- "@sarj/excessive-commentary",
35869
- "@sarj/no-bespoke-api-case-conversion",
35870
- "@sarj/no-boolean-selector-parameter",
35871
- "@sarj/no-cors-wildcard-with-credentials",
35872
- "@sarj/no-credential-in-browser-storage",
35873
- "@sarj/no-discarded-validation-result",
35874
- "@sarj/no-exception-text-in-5xx-response",
35875
- "@sarj/no-excess-jsx-props",
35876
- "@sarj/no-generic-json-parser",
35877
- "@sarj/no-mutating-container-transform",
35878
- "@sarj/no-mutating-input-with-result",
35879
- "@sarj/no-negative-only-http-status-assertion",
35880
- "@sarj/no-numeric-search-param-coercion",
35881
- "@sarj/no-redundant-consumer-union",
35882
- "@sarj/no-redundant-local-alias",
35883
- "@sarj/no-restated-comment",
35884
- "@sarj/no-restated-jsdoc",
35885
- "@sarj/no-return-disposed-resource",
35886
- "@sarj/no-test-comments",
35887
- "@sarj/prefer-dependency-interface",
35888
- "@sarj/prefer-discriminated-union",
35889
- "@sarj/prefer-millisecond-control-duration-schema",
35890
- "@sarj/prefer-minimal-parameter-contract",
35891
- "@sarj/prefer-module-level-refined-schema",
35892
- "@sarj/prefer-native-fetch-in-server-actions",
35893
- "@sarj/prefer-node-crypto-hash",
35894
- "@sarj/prefer-node-fs-promises",
35895
- "@sarj/prefer-shared-zod-enum",
35896
- "@sarj/prefer-test-fixture-reuse",
35897
- "@sarj/prefer-whole-object-assertion",
35898
- "@sarj/prefer-zod-parse-output-type",
35899
- "@sarj/production-derived-test-cases",
35900
- "@sarj/require-constrained-schema-integer",
35901
- "@sarj/require-jwt-lifetime",
35902
- "@sarj/require-sql-access-class"
35903
- ];
35904
- var RECOMMENDED_RULES = {
35905
- "@sarj/no-excess-jsx-props": "warn",
35906
- "@sarj/no-redundant-consumer-union": "warn",
35907
- "@sarj/prefer-minimal-parameter-contract": "warn",
35908
- "@sarj/named-child-schema-type": "error",
35909
- "@sarj/no-conditional-empty-object-spread": "error",
35910
- "@sarj/prefer-typed-reflection": "error",
35911
- "@sarj/no-broad-return-type": "error",
35912
- "@sarj/no-reduce-accumulator-copy": "error",
35913
- "@sarj/no-known-value-widening": "error",
35914
- "@sarj/no-invalid-typed-mutation": "error",
35915
- "@sarj/no-contradictory-type-predicate": "error",
35916
- "@sarj/no-partial-type-predicate": "error",
35917
- "@sarj/no-boolean-selector-parameter": "warn",
35918
- "@sarj/no-invalid-zod-custom-parse": "error",
35919
- "@sarj/no-contradictory-overload-return": "error",
35920
- "@sarj/require-button-accessible-name": "error",
35921
- "@sarj/require-camelcase-properties": "error",
35922
- "@sarj/require-svg-accessible-name": "error",
35923
- "@sarj/prefer-logical-tailwind-utilities": ["error", { enabled: false }],
35924
- "@sarj/no-unlocalized-toast": ["error", { enabled: false }],
35925
- "@sarj/no-unlocalized-jsx-attributes": ["error", { enabled: false }],
35926
- "@sarj/no-unlocalized-jsx-text": ["error", { enabled: false }],
35927
- "no-restricted-imports": LIBRARY_IMPORT_POLICY,
35928
- "@sarj/no-restricted-library-load": ["error", { libraries: LIBRARY_POLICY }],
35929
- "@sarj/no-redundant-local-alias": "warn",
35930
- "@sarj/prefer-test-fixture-reuse": "warn",
35931
- "@sarj/no-negative-only-http-status-assertion": "warn",
35932
- "@sarj/no-mutating-input-with-result": "warn",
35933
- "@sarj/no-return-disposed-resource": "warn",
35934
- "@sarj/no-discarded-validation-result": "warn",
35935
- "@sarj/require-jwt-lifetime": "warn",
35936
- "@sarj/prefer-dependency-interface": "warn",
35937
- "@sarj/no-generic-json-parser": "warn",
35938
- "@sarj/require-constrained-schema-integer": "warn",
35939
- "@sarj/production-derived-test-cases": "warn",
35940
- "@sarj/no-test-comments": "warn",
35941
- "@sarj/no-mutating-container-transform": "warn",
35942
- "@sarj/prefer-native-random-uuid": "error",
35943
- "@sarj/prefer-shadcn-primitives": "error",
35944
- "@sarj/excessive-commentary": "warn",
35945
- "@sarj/no-excessive-cognitive-complexity": "error",
35946
- "@sarj/interface-contract-members-private": "error",
35947
- "@sarj/iac-source-coupled-test": "error",
35948
- "@sarj/duplicate-test-body": "error",
35949
- "@sarj/enforce-file-structure": "error",
35950
- "@sarj/no-client-side-data-fetching": "error",
35951
- "@sarj/no-comment-cruft": "error",
35952
- "@sarj/no-cors-wildcard-with-credentials": "warn",
35953
- "@sarj/no-dynamic-sql": "error",
35954
- "@sarj/no-fat-try-blocks": ["error", { max: 5 }],
35955
- "@sarj/no-hand-rolled-sleep": "error",
35956
- "@sarj/no-hand-rolled-spinner": "error",
35957
- "@sarj/no-insecure-random-id": "error",
35958
- "@sarj/no-exception-text-in-5xx-response": "warn",
35959
- "@sarj/no-json-stringify-error": "error",
35960
- "@sarj/no-impossible-zod-literal-bounds": "error",
35961
- "@sarj/no-in-operator-on-built-in-collections": "error",
35962
- "@sarj/no-log-only-catch": "error",
35963
- "@sarj/no-bare-return-from-test-catch": "error",
35964
- "@sarj/no-bespoke-api-case-conversion": "warn",
35965
- "@sarj/no-detached-global-fetch": "error",
35966
- "@sarj/no-json-stringify-object-equality": "error",
35967
- "@sarj/no-dangerously-allow-svg": "error",
35968
- "@sarj/no-credential-in-browser-storage": "warn",
35969
- "@sarj/no-numeric-search-param-coercion": "warn",
35970
- "@sarj/prefer-native-fetch-in-server-actions": "warn",
35971
- "@sarj/no-duplicate-lifecycle-refresh-listeners": "error",
35972
- "@sarj/no-long-comment": "error",
35973
- "@sarj/no-vague-suppression-description": "error",
35974
- "@sarj/no-generic-single-export-module": "error",
35975
- "@sarj/no-offset-pagination": "error",
35976
- "@sarj/no-positional-tuple-return": "error",
35977
- "@sarj/no-production-browser-source-maps": "error",
35978
- "@sarj/no-repeated-string-literal": "error",
35979
- "@sarj/no-redundant-optional-array-default": "error",
35980
- "@sarj/no-router-refresh-polling": "error",
35981
- "@sarj/no-restated-comment": "warn",
35982
- "@sarj/no-restated-jsdoc": "warn",
35983
- "@sarj/no-secret-in-log": "error",
35984
- "@sarj/no-server-env-in-client-component": "error",
35985
- "@sarj/no-select-star": "error",
35986
- "@sarj/no-sentinel-return-on-catch": "error",
35987
- "@sarj/no-silent-promise-catch": "error",
35988
- "@sarj/no-sleep-in-test-body": "error",
35989
- "@sarj/no-string-concat-in-loop": "error",
35990
- "@sarj/no-tautological-expect": "error",
35991
- "@sarj/no-duplicate-test-case": "error",
35992
- "@sarj/no-typed-doc-sections": "error",
35993
- "@sarj/no-trailing-value-narration": "error",
35994
- "@sarj/no-declaration-comment-wall": "error",
35995
- "@sarj/no-union-in-comment": "error",
35996
- "@sarj/no-type-member-comment-wall": "error",
35997
- "@sarj/no-unnecessary-use-client": "error",
35998
- "@sarj/no-unsafe-mock-casting": "error",
35999
- "@sarj/no-unsafe-test-double-cast": "error",
36000
- "@sarj/no-first-party-module-mock": "error",
36001
- "@sarj/no-zod-native-enum": "error",
36002
- "@sarj/test-loops-over-literal-cases": "error",
36003
- "@sarj/prefer-constant-time-secret-compare": "error",
36004
- "@sarj/prefer-ecmascript-private-members": "error",
36005
- "@sarj/prefer-discriminated-union": "warn",
36006
- "@sarj/prefer-input-group-search": "error",
36007
- "@sarj/prefer-millisecond-control-duration-schema": "warn",
36008
- "@sarj/prefer-immutable-module-constant": "error",
36009
- "@sarj/prefer-module-level-constant": "error",
36010
- "@sarj/prefer-module-level-schema": "error",
36011
- "@sarj/prefer-module-level-refined-schema": "warn",
36012
- "@sarj/prefer-multi-value-zod-literal": ["error", { zodMajorVersion: 4 }],
36013
- "@sarj/prefer-named-callback-domain": "error",
36014
- "@sarj/prefer-nominal-id-types": "error",
36015
- "@sarj/prefer-named-complex-return-type": "error",
36016
- "@sarj/prefer-node-crypto-hash": "warn",
36017
- "@sarj/prefer-node-fs-promises": "warn",
36018
- "@sarj/prefer-non-nullable-collection": "error",
36019
- "@sarj/prefer-nullish-filter-predicate": "error",
36020
- "@sarj/prefer-await-in-async-return": "error",
36021
- "@sarj/prefer-schema-for-api-payload": "error",
36022
- "@sarj/prefer-shared-zod-enum": "warn",
36023
- "@sarj/prefer-switch-for-repeated-equality": "error",
36024
- "@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
36025
- "@sarj/prefer-server-actions": "error",
36026
- "@sarj/prefer-whole-object-assertion": "warn",
36027
- "@sarj/repeated-static-call-cases": "error",
36028
- "@sarj/prefer-zod-infer": "error",
36029
- "@sarj/prefer-zod-parse-output-type": "warn",
36030
- "@sarj/require-assert-never": "error",
36031
- "@sarj/require-fetch-timeout": "error",
36032
- "@sarj/require-explicit-contract-implementation": "error",
36033
- "@sarj/require-explicit-service-contract": "error",
36034
- "@sarj/require-interface-for-exported-class": "error",
36035
- "@sarj/require-port-for-service": "error",
36036
- "@sarj/require-sql-access-class": "warn",
36037
- "@sarj/require-static-next-matcher": "error",
36038
- "@sarj/require-use-form-default-values": "error",
36039
- "@sarj/require-use-server-in-actions-file": "error",
36040
- "@sarj/require-zod-form-validation": "error",
36041
- "@sarj/store-insert-requires-on-conflict": "error",
36042
- "@sarj/stepdown": "error",
36043
- "@sarj/source-coupled-test": "error",
36044
- "@sarj/sole-export-matches-filename": "error",
36045
- "@sarj/test-phase-label-comment": "error",
36046
- "@sarj/require-pascal-case-zod-schema-name": "error"
36047
- };
36048
- var STRICT_RULES = {
36049
- "@sarj/no-discarded-validation-result": "warn",
36050
- "@sarj/no-generic-json-parser": "warn",
36051
- "@sarj/no-mutating-container-transform": "warn",
36052
- "@sarj/no-mutating-input-with-result": "warn",
36053
- "@sarj/no-negative-only-http-status-assertion": "warn",
36054
- "@sarj/no-redundant-local-alias": "warn",
36055
- "@sarj/no-return-disposed-resource": "warn",
36056
- "@sarj/no-test-comments": "warn",
36057
- "@sarj/prefer-dependency-interface": "warn",
36058
- "@sarj/prefer-test-fixture-reuse": "warn",
36059
- "@sarj/production-derived-test-cases": "warn",
36060
- "@sarj/require-constrained-schema-integer": "warn",
36061
- "@sarj/require-jwt-lifetime": "warn",
36062
- "@sarj/no-excess-jsx-props": "warn",
36063
- "@sarj/no-redundant-consumer-union": "warn",
36064
- "@sarj/prefer-minimal-parameter-contract": "warn",
36065
- "@sarj/named-child-schema-type": "error",
36066
- "@sarj/no-conditional-empty-object-spread": "error",
36067
- "@sarj/prefer-typed-reflection": "error",
36068
- "@sarj/no-broad-return-type": "error",
36069
- "@sarj/no-reduce-accumulator-copy": "error",
36070
- "@sarj/no-known-value-widening": "error",
36071
- "@sarj/no-invalid-typed-mutation": "error",
36072
- "@sarj/no-contradictory-type-predicate": "error",
36073
- "@sarj/no-partial-type-predicate": "error",
36074
- "@sarj/no-boolean-selector-parameter": "warn",
36075
- "@sarj/no-invalid-zod-custom-parse": "error",
36076
- "@sarj/no-contradictory-overload-return": "error",
36077
- "@sarj/require-button-accessible-name": "error",
36078
- "@sarj/require-camelcase-properties": "error",
36079
- "@sarj/require-svg-accessible-name": "error",
36080
- "@sarj/prefer-logical-tailwind-utilities": ["error", { enabled: false }],
36081
- "@sarj/no-unlocalized-toast": ["error", { enabled: false }],
36082
- "@sarj/no-unlocalized-jsx-attributes": ["error", { enabled: false }],
36083
- "@sarj/no-unlocalized-jsx-text": ["error", { enabled: false }],
36084
- "no-restricted-imports": LIBRARY_IMPORT_POLICY,
36085
- "@sarj/no-restricted-library-load": ["error", { libraries: LIBRARY_POLICY }],
36086
- "@sarj/prefer-native-random-uuid": "error",
36087
- "@sarj/prefer-shadcn-primitives": "error",
36088
- "@sarj/excessive-commentary": "warn",
36089
- "@sarj/no-excessive-cognitive-complexity": "error",
36090
- "@sarj/interface-contract-members-private": "error",
36091
- "@sarj/iac-source-coupled-test": "error",
36092
- "@sarj/duplicate-test-body": "error",
36093
- "@sarj/enforce-file-structure": "error",
36094
- "@sarj/no-client-side-data-fetching": "error",
36095
- "@sarj/no-comment-cruft": "error",
36096
- "@sarj/no-cors-wildcard-with-credentials": "warn",
36097
- "@sarj/no-dynamic-sql": "error",
36098
- "@sarj/no-enum": "error",
36099
- "@sarj/no-fat-try-blocks": ["error", { max: 5 }],
36100
- "@sarj/no-hand-rolled-sleep": "error",
36101
- "@sarj/no-hand-rolled-spinner": "error",
36102
- "@sarj/no-insecure-random-id": "error",
36103
- "@sarj/no-exception-text-in-5xx-response": "warn",
36104
- "@sarj/no-json-stringify-error": "error",
36105
- "@sarj/no-impossible-zod-literal-bounds": "error",
36106
- "@sarj/no-in-operator-on-built-in-collections": "error",
36107
- "@sarj/no-log-only-catch": "error",
36108
- "@sarj/no-bare-return-from-test-catch": "error",
36109
- "@sarj/no-bespoke-api-case-conversion": "warn",
36110
- "@sarj/no-detached-global-fetch": "error",
36111
- "@sarj/no-json-stringify-object-equality": "error",
36112
- "@sarj/no-dangerously-allow-svg": "error",
36113
- "@sarj/no-credential-in-browser-storage": "warn",
36114
- "@sarj/no-numeric-search-param-coercion": "warn",
36115
- "@sarj/prefer-native-fetch-in-server-actions": "warn",
36116
- "@sarj/no-duplicate-lifecycle-refresh-listeners": "error",
36117
- "@sarj/no-long-comment": "error",
36118
- "@sarj/no-vague-suppression-description": "error",
36119
- "@sarj/no-generic-single-export-module": "error",
36120
- "@sarj/no-offset-pagination": "error",
36121
- "@sarj/no-positional-tuple-return": "error",
36122
- "@sarj/no-production-browser-source-maps": "error",
36123
- "@sarj/no-raw-env": "error",
36124
- "@sarj/no-raw-fetch-outside-clients": "error",
36125
- "@sarj/no-repeated-string-literal": "error",
36126
- "@sarj/no-redundant-optional-array-default": "error",
36127
- "@sarj/no-router-refresh-polling": "error",
36128
- "@sarj/no-restated-comment": "warn",
36129
- "@sarj/no-restated-jsdoc": "warn",
36130
- "@sarj/no-secret-in-log": "error",
36131
- "@sarj/no-server-env-in-client-component": "error",
36132
- "@sarj/no-select-star": "error",
36133
- "@sarj/no-sentinel-return-on-catch": "error",
36134
- "@sarj/no-silent-promise-catch": "error",
36135
- "@sarj/no-sleep-in-test-body": "error",
36136
- "@sarj/no-storage-in-stateless-modules": "error",
36137
- "@sarj/no-string-concat-in-loop": "error",
36138
- "@sarj/no-tautological-expect": "error",
36139
- "@sarj/no-duplicate-test-case": "error",
36140
- "@sarj/no-typed-doc-sections": "error",
36141
- "@sarj/no-trailing-value-narration": "error",
36142
- "@sarj/no-declaration-comment-wall": "error",
36143
- "@sarj/no-union-in-comment": "error",
36144
- "@sarj/no-type-member-comment-wall": "error",
36145
- "@sarj/no-unnecessary-use-client": "error",
36146
- "@sarj/no-unsafe-mock-casting": "error",
36147
- "@sarj/no-unsafe-test-double-cast": "error",
36148
- "@sarj/no-first-party-module-mock": "error",
36149
- "@sarj/no-zod-native-enum": "error",
36150
- "@sarj/test-loops-over-literal-cases": "error",
36151
- "@sarj/prefer-constant-time-secret-compare": "error",
36152
- "@sarj/prefer-ecmascript-private-members": "error",
36153
- "@sarj/prefer-discriminated-union": "warn",
36154
- "@sarj/prefer-input-group-search": "error",
36155
- "@sarj/prefer-millisecond-control-duration-schema": "warn",
36156
- "@sarj/prefer-immutable-module-constant": "error",
36157
- "@sarj/prefer-module-level-constant": "error",
36158
- "@sarj/prefer-module-level-schema": "error",
36159
- "@sarj/prefer-module-level-refined-schema": "warn",
36160
- "@sarj/prefer-multi-value-zod-literal": ["error", { zodMajorVersion: 4 }],
36161
- "@sarj/prefer-named-callback-domain": "error",
36162
- "@sarj/prefer-nominal-id-types": "error",
36163
- "@sarj/prefer-named-complex-return-type": "error",
36164
- "@sarj/prefer-node-crypto-hash": "warn",
36165
- "@sarj/prefer-node-fs-promises": "warn",
36166
- "@sarj/prefer-non-nullable-collection": "error",
36167
- "@sarj/prefer-nullish-filter-predicate": "error",
36168
- "@sarj/prefer-await-in-async-return": "error",
36169
- "@sarj/prefer-schema-for-api-payload": "error",
36170
- "@sarj/prefer-shared-zod-enum": "warn",
36171
- "@sarj/prefer-switch-for-repeated-equality": "error",
36172
- "@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
36173
- "@sarj/prefer-server-actions": "error",
36174
- "@sarj/prefer-whole-object-assertion": "warn",
36175
- "@sarj/repeated-static-call-cases": "error",
36176
- "@sarj/prefer-zod-infer": "error",
36177
- "@sarj/prefer-zod-parse-output-type": "warn",
36178
- "@sarj/require-assert-never": "error",
36179
- "@sarj/require-fetch-timeout": "error",
36180
- "@sarj/require-explicit-contract-implementation": "error",
36181
- "@sarj/require-explicit-service-contract": "error",
36182
- "@sarj/require-interface-for-exported-class": "error",
36183
- "@sarj/require-port-for-service": "error",
36184
- "@sarj/require-sql-access-class": "warn",
36185
- "@sarj/require-static-next-matcher": "error",
36186
- "@sarj/require-use-form-default-values": "error",
36187
- "@sarj/require-use-server-in-actions-file": "error",
36188
- "@sarj/require-zod-form-validation": "error",
36189
- "@sarj/store-insert-requires-on-conflict": "error",
36190
- "@sarj/stepdown": "error",
36191
- "@sarj/source-coupled-test": "error",
36192
- "@sarj/sole-export-matches-filename": "error",
36193
- "@sarj/test-phase-label-comment": "error",
36194
- "@sarj/require-pascal-case-zod-schema-name": "error"
35992
+ var RULE_POLICY = {
35993
+ "@sarj/no-excess-jsx-props": ["warn", "both"],
35994
+ "@sarj/no-redundant-consumer-union": ["warn", "both"],
35995
+ "@sarj/prefer-minimal-parameter-contract": ["warn", "both"],
35996
+ "@sarj/named-child-schema-type": ["error", "both"],
35997
+ "@sarj/no-conditional-empty-object-spread": ["error", "both"],
35998
+ "@sarj/prefer-typed-reflection": ["error", "both"],
35999
+ "@sarj/no-broad-return-type": ["error", "both"],
36000
+ "@sarj/no-reduce-accumulator-copy": ["error", "both"],
36001
+ "@sarj/no-known-value-widening": ["error", "both"],
36002
+ "@sarj/no-invalid-typed-mutation": ["error", "both"],
36003
+ "@sarj/no-contradictory-type-predicate": ["error", "both"],
36004
+ "@sarj/no-partial-type-predicate": ["error", "both"],
36005
+ "@sarj/no-boolean-selector-parameter": ["warn", "both"],
36006
+ "@sarj/no-invalid-zod-custom-parse": ["error", "both"],
36007
+ "@sarj/no-contradictory-overload-return": ["error", "both"],
36008
+ "@sarj/require-button-accessible-name": ["error", "both"],
36009
+ "@sarj/require-camelcase-properties": ["error", "both"],
36010
+ "@sarj/require-svg-accessible-name": ["error", "both"],
36011
+ "@sarj/prefer-logical-tailwind-utilities": [
36012
+ "error",
36013
+ "both",
36014
+ () => [{ enabled: false }]
36015
+ ],
36016
+ "@sarj/no-unlocalized-toast": [
36017
+ "error",
36018
+ "both",
36019
+ () => [{ enabled: false }]
36020
+ ],
36021
+ "@sarj/no-unlocalized-jsx-attributes": [
36022
+ "error",
36023
+ "both",
36024
+ () => [{ enabled: false }]
36025
+ ],
36026
+ "@sarj/no-unlocalized-jsx-text": [
36027
+ "error",
36028
+ "both",
36029
+ () => [{ enabled: false }]
36030
+ ],
36031
+ "no-restricted-imports": ["shared", "both", LIBRARY_IMPORT_POLICY],
36032
+ "@sarj/no-restricted-library-load": [
36033
+ "error",
36034
+ "both",
36035
+ () => [{ libraries: LIBRARY_POLICY }]
36036
+ ],
36037
+ "@sarj/no-redundant-local-alias": ["warn", "both", "strict-order", 5],
36038
+ "@sarj/prefer-test-fixture-reuse": ["warn", "both", "strict-order", 9],
36039
+ "@sarj/no-negative-only-http-status-assertion": ["warn", "both", "strict-order", 4],
36040
+ "@sarj/no-mutating-input-with-result": ["warn", "both", "strict-order", 3],
36041
+ "@sarj/no-return-disposed-resource": ["warn", "both", "strict-order", 6],
36042
+ "@sarj/no-discarded-validation-result": ["warn", "both", "strict-order", 0],
36043
+ "@sarj/require-jwt-lifetime": ["warn", "both", "strict-order", 12],
36044
+ "@sarj/prefer-dependency-interface": ["warn", "both", "strict-order", 8],
36045
+ "@sarj/no-generic-json-parser": ["warn", "both", "strict-order", 1],
36046
+ "@sarj/require-constrained-schema-integer": ["warn", "both", "strict-order", 11],
36047
+ "@sarj/production-derived-test-cases": ["warn", "both", "strict-order", 10],
36048
+ "@sarj/no-test-comments": ["warn", "both", "strict-order", 7],
36049
+ "@sarj/no-mutating-container-transform": ["warn", "both", "strict-order", 2],
36050
+ "@sarj/prefer-native-random-uuid": ["error", "both"],
36051
+ "@sarj/prefer-shadcn-primitives": ["error", "both"],
36052
+ "@sarj/excessive-commentary": ["warn", "both"],
36053
+ "@sarj/no-excessive-cognitive-complexity": ["error", "both"],
36054
+ "@sarj/interface-contract-members-private": ["error", "both"],
36055
+ "@sarj/iac-source-coupled-test": ["error", "both"],
36056
+ "@sarj/duplicate-test-body": ["error", "both"],
36057
+ "@sarj/enforce-file-structure": ["error", "both"],
36058
+ "@sarj/no-client-side-data-fetching": ["error", "both"],
36059
+ "@sarj/no-comment-cruft": ["error", "both"],
36060
+ "@sarj/no-cors-wildcard-with-credentials": ["warn", "both"],
36061
+ "@sarj/no-dynamic-sql": ["error", "both"],
36062
+ "@sarj/no-enum": ["error", "strict"],
36063
+ "@sarj/no-fat-try-blocks": [
36064
+ "error",
36065
+ "both",
36066
+ () => [{ max: 5 }]
36067
+ ],
36068
+ "@sarj/no-hand-rolled-sleep": ["error", "both"],
36069
+ "@sarj/no-hand-rolled-spinner": ["error", "both"],
36070
+ "@sarj/no-insecure-random-id": ["error", "both"],
36071
+ "@sarj/no-exception-text-in-5xx-response": ["warn", "both"],
36072
+ "@sarj/no-json-stringify-error": ["error", "both"],
36073
+ "@sarj/no-impossible-zod-literal-bounds": ["error", "both"],
36074
+ "@sarj/no-in-operator-on-built-in-collections": ["error", "both"],
36075
+ "@sarj/no-log-only-catch": ["error", "both"],
36076
+ "@sarj/no-bare-return-from-test-catch": ["error", "both"],
36077
+ "@sarj/no-bespoke-api-case-conversion": ["warn", "both"],
36078
+ "@sarj/no-detached-global-fetch": ["error", "both"],
36079
+ "@sarj/no-json-stringify-object-equality": ["error", "both"],
36080
+ "@sarj/no-dangerously-allow-svg": ["error", "both"],
36081
+ "@sarj/no-credential-in-browser-storage": ["warn", "both"],
36082
+ "@sarj/no-numeric-search-param-coercion": ["warn", "both"],
36083
+ "@sarj/prefer-native-fetch-in-server-actions": ["warn", "both"],
36084
+ "@sarj/no-duplicate-lifecycle-refresh-listeners": ["error", "both"],
36085
+ "@sarj/no-long-comment": ["error", "both"],
36086
+ "@sarj/no-vague-suppression-description": ["error", "both"],
36087
+ "@sarj/no-generic-single-export-module": ["error", "both"],
36088
+ "@sarj/no-offset-pagination": ["error", "both"],
36089
+ "@sarj/no-positional-tuple-return": ["error", "both"],
36090
+ "@sarj/no-production-browser-source-maps": ["error", "both"],
36091
+ "@sarj/no-raw-env": ["error", "strict"],
36092
+ "@sarj/no-raw-fetch-outside-clients": ["error", "strict"],
36093
+ "@sarj/no-repeated-string-literal": ["error", "both"],
36094
+ "@sarj/no-redundant-optional-array-default": ["error", "both"],
36095
+ "@sarj/no-router-refresh-polling": ["error", "both"],
36096
+ "@sarj/no-restated-comment": ["warn", "both"],
36097
+ "@sarj/no-restated-jsdoc": ["warn", "both"],
36098
+ "@sarj/no-secret-in-log": ["error", "both"],
36099
+ "@sarj/no-server-env-in-client-component": ["error", "both"],
36100
+ "@sarj/no-select-star": ["error", "both"],
36101
+ "@sarj/no-sentinel-return-on-catch": ["error", "both"],
36102
+ "@sarj/no-silent-promise-catch": ["error", "both"],
36103
+ "@sarj/no-sleep-in-test-body": ["error", "both"],
36104
+ "@sarj/no-storage-in-stateless-modules": ["error", "strict"],
36105
+ "@sarj/no-string-concat-in-loop": ["error", "both"],
36106
+ "@sarj/no-tautological-expect": ["error", "both"],
36107
+ "@sarj/no-duplicate-test-case": ["error", "both"],
36108
+ "@sarj/no-typed-doc-sections": ["error", "both"],
36109
+ "@sarj/no-trailing-value-narration": ["error", "both"],
36110
+ "@sarj/no-declaration-comment-wall": ["error", "both"],
36111
+ "@sarj/no-union-in-comment": ["error", "both"],
36112
+ "@sarj/no-type-member-comment-wall": ["error", "both"],
36113
+ "@sarj/no-unnecessary-use-client": ["error", "both"],
36114
+ "@sarj/no-unsafe-mock-casting": ["error", "both"],
36115
+ "@sarj/no-unsafe-test-double-cast": ["error", "both"],
36116
+ "@sarj/no-first-party-module-mock": ["error", "both"],
36117
+ "@sarj/no-zod-native-enum": ["error", "both"],
36118
+ "@sarj/test-loops-over-literal-cases": ["error", "both"],
36119
+ "@sarj/prefer-constant-time-secret-compare": ["error", "both"],
36120
+ "@sarj/prefer-ecmascript-private-members": ["error", "both"],
36121
+ "@sarj/prefer-discriminated-union": ["warn", "both"],
36122
+ "@sarj/prefer-input-group-search": ["error", "both"],
36123
+ "@sarj/prefer-millisecond-control-duration-schema": ["warn", "both"],
36124
+ "@sarj/prefer-immutable-module-constant": ["error", "both"],
36125
+ "@sarj/prefer-module-level-constant": ["error", "both"],
36126
+ "@sarj/prefer-module-level-schema": ["error", "both"],
36127
+ "@sarj/prefer-module-level-refined-schema": ["warn", "both"],
36128
+ "@sarj/prefer-multi-value-zod-literal": [
36129
+ "error",
36130
+ "both",
36131
+ () => [{ zodMajorVersion: 4 }]
36132
+ ],
36133
+ "@sarj/prefer-named-callback-domain": ["error", "both"],
36134
+ "@sarj/prefer-nominal-id-types": ["error", "both"],
36135
+ "@sarj/prefer-named-complex-return-type": ["error", "both"],
36136
+ "@sarj/prefer-node-crypto-hash": ["warn", "both"],
36137
+ "@sarj/prefer-node-fs-promises": ["warn", "both"],
36138
+ "@sarj/prefer-non-nullable-collection": ["error", "both"],
36139
+ "@sarj/prefer-nullish-filter-predicate": ["error", "both"],
36140
+ "@sarj/prefer-await-in-async-return": ["error", "both"],
36141
+ "@sarj/prefer-schema-for-api-payload": ["error", "both"],
36142
+ "@sarj/prefer-shared-zod-enum": ["warn", "both"],
36143
+ "@sarj/prefer-switch-for-repeated-equality": ["error", "both"],
36144
+ "@sarj/prefer-semantic-colors": [
36145
+ "error",
36146
+ "both",
36147
+ () => [{ requireSemanticTokens: true }]
36148
+ ],
36149
+ "@sarj/prefer-server-actions": ["error", "both"],
36150
+ "@sarj/prefer-whole-object-assertion": ["warn", "both"],
36151
+ "@sarj/repeated-static-call-cases": ["error", "both"],
36152
+ "@sarj/prefer-zod-infer": ["error", "both"],
36153
+ "@sarj/prefer-zod-parse-output-type": ["warn", "both"],
36154
+ "@sarj/require-assert-never": ["error", "both"],
36155
+ "@sarj/require-fetch-timeout": ["error", "both"],
36156
+ "@sarj/require-explicit-contract-implementation": ["error", "both"],
36157
+ "@sarj/require-explicit-service-contract": ["error", "both"],
36158
+ "@sarj/require-interface-for-exported-class": ["error", "both"],
36159
+ "@sarj/require-port-for-service": ["error", "both"],
36160
+ "@sarj/require-sql-access-class": ["warn", "both"],
36161
+ "@sarj/require-static-next-matcher": ["error", "both"],
36162
+ "@sarj/require-use-form-default-values": ["error", "both"],
36163
+ "@sarj/require-use-server-in-actions-file": ["error", "both"],
36164
+ "@sarj/require-zod-form-validation": ["error", "both"],
36165
+ "@sarj/store-insert-requires-on-conflict": ["error", "both"],
36166
+ "@sarj/stepdown": ["error", "both"],
36167
+ "@sarj/source-coupled-test": ["error", "both"],
36168
+ "@sarj/sole-export-matches-filename": ["error", "both"],
36169
+ "@sarj/test-phase-label-comment": ["error", "both"],
36170
+ "@sarj/require-pascal-case-zod-schema-name": ["error", "both"]
36195
36171
  };
36172
+ var ADVISORY_RULES = Object.keys(RULE_POLICY).filter(isAdvisoryRuleName).toSorted();
36173
+ var RECOMMENDED_RULES = presetRules("recommended");
36174
+ var STRICT_RULES = presetRules("strict");
36175
+ function isAdvisoryRuleName(name) {
36176
+ return isPolicyName(name) && RULE_POLICY[name][0] === "warn";
36177
+ }
36178
+ function isPolicyName(name) {
36179
+ return Object.hasOwn(RULE_POLICY, name);
36180
+ }
36181
+ function presetRules(preset) {
36182
+ const rows = Object.entries(RULE_POLICY).filter(([, row]) => preset === "strict" || row[1] === "both");
36183
+ if (preset === "strict") rows.sort((left, right) => strictOrder(left[1]) - strictOrder(right[1]));
36184
+ const entries = rows.map(([name, row]) => [name, policySetting(row)]);
36185
+ const result = Object.fromEntries(entries);
36186
+ const names = Object.keys(result);
36187
+ if (names.length !== entries.length || names.some((name, index) => name !== entries[index]?.[0])) {
36188
+ throw new Error("Preset projection changed its closed policy key order.");
36189
+ }
36190
+ return result;
36191
+ }
36192
+ function strictOrder(row) {
36193
+ return row.length === 4 ? row[3] : Number.MAX_SAFE_INTEGER;
36194
+ }
36195
+ function policySetting(row) {
36196
+ if (row[0] === "shared") return row[2];
36197
+ if (row.length !== 3) return row[0];
36198
+ return [row[0], ...row[2]()];
36199
+ }
36196
36200
  var PLUGIN = {
36197
36201
  meta,
36198
36202
  rules: RULES,