@sarj/eslint-plugin 5.1.0 → 6.1.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
@@ -31,7 +31,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  default: () => index_default,
34
- rules: () => rules
34
+ recommendedRules: () => recommendedRules,
35
+ rules: () => rules,
36
+ strictRules: () => strictRules
35
37
  });
36
38
  module.exports = __toCommonJS(index_exports);
37
39
 
@@ -8645,6 +8647,258 @@ var no_hand_rolled_sleep_default = import_utils55.ESLintUtils.RuleCreator(
8645
8647
  }
8646
8648
  });
8647
8649
 
8650
+ // src/rules/prefer-module-level-schema.ts
8651
+ var import_utils56 = require("@typescript-eslint/utils");
8652
+ var DEFAULT_FACTORIES = [
8653
+ "discriminatedUnion",
8654
+ "intersection",
8655
+ "looseObject",
8656
+ "object",
8657
+ "record",
8658
+ "strictObject",
8659
+ "tuple",
8660
+ "union"
8661
+ ];
8662
+ var DEFAULT_MIN_PROPERTIES = 1;
8663
+ var MEMO_CALLEES = /* @__PURE__ */ new Set([
8664
+ "lazy",
8665
+ "memo",
8666
+ "once",
8667
+ "useMemo"
8668
+ ]);
8669
+ var TERMINAL_METHODS = /* @__PURE__ */ new Set([
8670
+ "isNullable",
8671
+ "isOptional",
8672
+ "parse",
8673
+ "parseAsync",
8674
+ "safeParse",
8675
+ "safeParseAsync",
8676
+ "spa"
8677
+ ]);
8678
+ var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
8679
+ import_utils56.AST_NODE_TYPES.ArrowFunctionExpression,
8680
+ import_utils56.AST_NODE_TYPES.FunctionDeclaration,
8681
+ import_utils56.AST_NODE_TYPES.FunctionExpression
8682
+ ]);
8683
+ function schemaExpression(node) {
8684
+ let current = node;
8685
+ for (; ; ) {
8686
+ const parent = current.parent ?? void 0;
8687
+ if (parent === void 0) {
8688
+ return current;
8689
+ }
8690
+ if (parent.type === import_utils56.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.computed && parent.property.type === import_utils56.AST_NODE_TYPES.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
8691
+ return current;
8692
+ }
8693
+ if (parent.type === import_utils56.AST_NODE_TYPES.MemberExpression && parent.object === current || parent.type === import_utils56.AST_NODE_TYPES.CallExpression && parent.callee === current || parent.type === import_utils56.AST_NODE_TYPES.TSAsExpression && parent.expression === current || parent.type === import_utils56.AST_NODE_TYPES.TSNonNullExpression && parent.expression === current) {
8694
+ current = parent;
8695
+ continue;
8696
+ }
8697
+ return current;
8698
+ }
8699
+ }
8700
+ function outermostEnclosingFunction(node) {
8701
+ let outermost;
8702
+ let current = node.parent ?? void 0;
8703
+ while (current !== void 0) {
8704
+ if (FUNCTION_TYPES6.has(current.type)) {
8705
+ outermost = current;
8706
+ }
8707
+ current = current.parent ?? void 0;
8708
+ }
8709
+ return outermost;
8710
+ }
8711
+ function readsReceiver(node) {
8712
+ let found = false;
8713
+ const visit = (value) => {
8714
+ if (found || value === null || typeof value !== "object") {
8715
+ return;
8716
+ }
8717
+ if (Array.isArray(value)) {
8718
+ for (const item of value) {
8719
+ visit(item);
8720
+ }
8721
+ return;
8722
+ }
8723
+ const candidate = value;
8724
+ if (typeof candidate.type !== "string") {
8725
+ return;
8726
+ }
8727
+ if (candidate.type === import_utils56.AST_NODE_TYPES.ThisExpression || candidate.type === import_utils56.AST_NODE_TYPES.Super || candidate.type === import_utils56.AST_NODE_TYPES.Identifier && candidate.name === "arguments") {
8728
+ found = true;
8729
+ return;
8730
+ }
8731
+ for (const key of Object.keys(candidate)) {
8732
+ if (key === "parent" || key === "loc" || key === "range") {
8733
+ continue;
8734
+ }
8735
+ visit(candidate[key]);
8736
+ }
8737
+ };
8738
+ visit(node);
8739
+ return found;
8740
+ }
8741
+ function collectReferences(scope, out) {
8742
+ out.push(...scope.references);
8743
+ for (const child of scope.childScopes) {
8744
+ collectReferences(child, out);
8745
+ }
8746
+ }
8747
+ var prefer_module_level_schema_default = import_utils56.ESLintUtils.RuleCreator(
8748
+ (name) => `https://github.com/sarj-ai/standards/tree/main/packages/typescript#${name}`
8749
+ )({
8750
+ name: "prefer-module-level-schema",
8751
+ meta: {
8752
+ type: "problem",
8753
+ docs: {
8754
+ description: "Declare a Zod schema at module scope when it closes over nothing in the enclosing function"
8755
+ },
8756
+ schema: [
8757
+ {
8758
+ type: "object",
8759
+ properties: {
8760
+ factories: {
8761
+ type: "array",
8762
+ items: { type: "string" },
8763
+ description: "Zod factory names to check. Defaults to the object-like composites; add `array` / `enum` to widen."
8764
+ },
8765
+ ignoreTestFiles: {
8766
+ type: "boolean",
8767
+ description: "Skip test files, where a fixture schema belongs next to its assertion."
8768
+ },
8769
+ minProperties: {
8770
+ type: "number",
8771
+ minimum: 0,
8772
+ description: "Minimum key count before an object-like schema is reported."
8773
+ }
8774
+ },
8775
+ additionalProperties: false
8776
+ }
8777
+ ],
8778
+ messages: {
8779
+ hoistSchema: "Move this `{{factory}}` schema to module scope. It uses nothing from `{{owner}}`, so it is rebuilt on every call for no benefit and cannot be exported, reused, or `z.infer`-ed from where it is."
8780
+ }
8781
+ },
8782
+ defaultOptions: [{}],
8783
+ create(context, [options]) {
8784
+ const factories = new Set(options?.factories ?? DEFAULT_FACTORIES);
8785
+ const ignoreTestFiles = options?.ignoreTestFiles ?? true;
8786
+ const minProperties = options?.minProperties ?? DEFAULT_MIN_PROPERTIES;
8787
+ const sourceCode = context.sourceCode;
8788
+ const filename = context.filename;
8789
+ if (isGeneratedFile(filename, sourceCode.getText())) {
8790
+ return {};
8791
+ }
8792
+ if (ignoreTestFiles && isTestFile(filename)) {
8793
+ return {};
8794
+ }
8795
+ const zodNamespaces = /* @__PURE__ */ new Set();
8796
+ function isZodCall(node) {
8797
+ return node.type === import_utils56.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils56.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils56.AST_NODE_TYPES.Identifier && zodNamespaces.has(node.callee.object.name);
8798
+ }
8799
+ function isCovered(node) {
8800
+ let current = node.parent ?? void 0;
8801
+ while (current !== void 0) {
8802
+ if (current !== node && isZodCall(current) && current.callee.type === import_utils56.AST_NODE_TYPES.MemberExpression && current.callee.property.type === import_utils56.AST_NODE_TYPES.Identifier && factories.has(current.callee.property.name)) {
8803
+ return true;
8804
+ }
8805
+ if (current.type === import_utils56.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils56.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === import_utils56.AST_NODE_TYPES.MemberExpression && !current.callee.computed && current.callee.property.type === import_utils56.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
8806
+ return true;
8807
+ }
8808
+ current = current.parent ?? void 0;
8809
+ }
8810
+ return false;
8811
+ }
8812
+ function closesOverNothing(node, enclosing) {
8813
+ const references = [];
8814
+ collectReferences(sourceCode.getScope(node), references);
8815
+ const [schemaStart, schemaEnd] = node.range;
8816
+ const [functionStart, functionEnd] = enclosing.range;
8817
+ for (const reference of references) {
8818
+ const [identifierStart] = reference.identifier.range;
8819
+ if (identifierStart < schemaStart || identifierStart >= schemaEnd) {
8820
+ continue;
8821
+ }
8822
+ const resolved = reference.resolved;
8823
+ if (resolved === null) {
8824
+ continue;
8825
+ }
8826
+ for (const definition of resolved.defs) {
8827
+ if (definition.type === "ImportBinding") {
8828
+ continue;
8829
+ }
8830
+ const [defStart, defEnd] = definition.node.range;
8831
+ if (defStart >= functionStart && defEnd <= functionEnd) {
8832
+ return false;
8833
+ }
8834
+ }
8835
+ }
8836
+ return true;
8837
+ }
8838
+ function ownerName(enclosing) {
8839
+ const parent = enclosing.parent ?? void 0;
8840
+ if (enclosing.type === import_utils56.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
8841
+ return enclosing.id.name;
8842
+ }
8843
+ if (parent !== void 0 && parent.type === import_utils56.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils56.AST_NODE_TYPES.Identifier) {
8844
+ return parent.id.name;
8845
+ }
8846
+ if (parent !== void 0 && (parent.type === import_utils56.AST_NODE_TYPES.MethodDefinition || parent.type === import_utils56.AST_NODE_TYPES.Property) && parent.key.type === import_utils56.AST_NODE_TYPES.Identifier) {
8847
+ return parent.key.name;
8848
+ }
8849
+ return "this function";
8850
+ }
8851
+ return {
8852
+ ImportDeclaration(node) {
8853
+ if (!isZodModule(node.source.value)) {
8854
+ return;
8855
+ }
8856
+ for (const specifier of node.specifiers) {
8857
+ if (specifier.type === import_utils56.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils56.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils56.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils56.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
8858
+ zodNamespaces.add(specifier.local.name);
8859
+ }
8860
+ }
8861
+ },
8862
+ CallExpression(node) {
8863
+ if (zodNamespaces.size === 0 || !isZodCall(node)) {
8864
+ return;
8865
+ }
8866
+ const callee = node.callee;
8867
+ if (callee.property.type !== import_utils56.AST_NODE_TYPES.Identifier) {
8868
+ return;
8869
+ }
8870
+ const factory = callee.property.name;
8871
+ if (!factories.has(factory)) {
8872
+ return;
8873
+ }
8874
+ const enclosing = outermostEnclosingFunction(node);
8875
+ if (enclosing === void 0) {
8876
+ return;
8877
+ }
8878
+ if (isCovered(node)) {
8879
+ return;
8880
+ }
8881
+ const shape = node.arguments[0];
8882
+ if (shape !== void 0 && shape.type === import_utils56.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
8883
+ return;
8884
+ }
8885
+ const expression = schemaExpression(node);
8886
+ if (readsReceiver(expression)) {
8887
+ return;
8888
+ }
8889
+ if (!closesOverNothing(expression, enclosing)) {
8890
+ return;
8891
+ }
8892
+ context.report({
8893
+ node,
8894
+ messageId: "hoistSchema",
8895
+ data: { factory: `z.${factory}`, owner: ownerName(enclosing) }
8896
+ });
8897
+ }
8898
+ };
8899
+ }
8900
+ });
8901
+
8648
8902
  // src/index.ts
8649
8903
  var rules = {
8650
8904
  "enforce-file-structure": enforce_file_structure_default,
@@ -8696,205 +8950,232 @@ var rules = {
8696
8950
  "require-interface-for-injected-service": require_interface_for_injected_service_default,
8697
8951
  "strict-test-assertions": strict_test_assertions_default,
8698
8952
  "prefer-non-nullable-collection": prefer_non_nullable_collection_default,
8699
- "no-async-callback-in-waitfor": no_async_callback_in_waitfor_default
8953
+ "no-async-callback-in-waitfor": no_async_callback_in_waitfor_default,
8954
+ "prefer-module-level-schema": prefer_module_level_schema_default
8955
+ };
8956
+ var meta = {
8957
+ name: "@sarj/eslint-plugin",
8958
+ version: "6.1.0"
8959
+ };
8960
+ var recommendedRules = {
8961
+ "@sarj/zod-naming-convention": "warn",
8962
+ "@sarj/require-assert-never": "error",
8963
+ "@sarj/require-zod-form-validation": "error",
8964
+ "@sarj/enforce-file-structure": "warn",
8965
+ "@sarj/no-client-side-data-fetching": "warn",
8966
+ "@sarj/prefer-server-actions": "warn",
8967
+ "@sarj/no-unnecessary-use-client": "warn",
8968
+ "@sarj/prefer-schema-for-api-payload": "warn",
8969
+ // Distilled from sarj-audit skills — warn in recommended, error in strict.
8970
+ "@sarj/no-sentinel-return-on-catch": "warn",
8971
+ "@sarj/no-log-only-catch": "warn",
8972
+ "@sarj/no-insecure-random-id": "warn",
8973
+ "@sarj/no-json-stringify-error": "warn",
8974
+ "@sarj/no-string-concat-in-loop": "warn",
8975
+ "@sarj/prefer-discriminated-union": "warn",
8976
+ "@sarj/no-comment-cruft": "warn",
8977
+ // Frontend / styling — distilled from frontend PR-review mining.
8978
+ "@sarj/prefer-semantic-colors": [
8979
+ "warn",
8980
+ { requireSemanticTokens: true }
8981
+ ],
8982
+ // Ported from sarj-python-lint (SARJ), corpus-validated FP~0.
8983
+ "@sarj/no-fat-try-blocks": "warn",
8984
+ "@sarj/no-cors-wildcard-with-credentials": "warn",
8985
+ "@sarj/no-secret-in-log": "warn",
8986
+ "@sarj/no-unsafe-mock-casting": "warn",
8987
+ "@sarj/prefer-string-literal-union": "warn",
8988
+ "@sarj/prefer-zod-enum": "warn",
8989
+ // A type hand-written beside the Zod schema it restates drifts the
8990
+ // moment the schema gains a field. 30,759-file, 17-repo sweep
8991
+ // (2026-07): 5 reports, 5 true positives, all in public repos.
8992
+ // `requireIdenticalShape: false` widens it to 8 reports, 1 of them noise.
8993
+ "@sarj/prefer-zod-infer": "warn",
8994
+ // Mined from 2y of PR review feedback + 5-repo code-smell audit (2026-07).
8995
+ "@sarj/require-fetch-timeout": "warn",
8996
+ "@sarj/no-silent-promise-catch": "warn",
8997
+ // Second SARJ port wave — the TS/Python parity gap. Each targets a
8998
+ // defect class seen in production Workers code: timing-leaky secret
8999
+ // compares, non-idempotent store writes under queue redelivery,
9000
+ // O(N) pagination, implicit row contracts, flaky timed tests.
9001
+ "@sarj/prefer-constant-time-secret-compare": "error",
9002
+ "@sarj/store-insert-requires-on-conflict": "warn",
9003
+ "@sarj/no-offset-pagination": "warn",
9004
+ "@sarj/no-select-star": "warn",
9005
+ // Uncancellable hand-rolled timers. Verified against the shipped
9006
+ // strict config (205 enabled rules) that nothing already reports this
9007
+ // position; `unicorn` 72 has no promisified-timer rule at all.
9008
+ "@sarj/no-hand-rolled-sleep": "warn",
9009
+ "@sarj/no-sleep-in-test-body": "warn",
9010
+ "@sarj/no-conditional-in-test": "warn",
9011
+ "@sarj/no-repeated-string-literal": "warn",
9012
+ "@sarj/no-positional-tuple-return": "warn",
9013
+ // Injection guard — low FP, applies to any repo touching SQL.
9014
+ "@sarj/no-dynamic-sql": "warn",
9015
+ // Mined from two years of PR review (SARJ-928). Schema-layer sibling of
9016
+ // `no-enum`; autofixable for inline string-literal objects.
9017
+ "@sarj/no-zod-native-enum": "warn",
9018
+ // Mined from two years of PR review — the single most frequent uncovered
9019
+ // theme (~37 PRs). Measured 17 hits / 1085 real TS files, all true
9020
+ // positives, so it is safe to run everywhere.
9021
+ "@sarj/prefer-module-level-constant": "warn",
9022
+ // Anti-comment-verbosity family (2026-07), from a 37,918-comment,
9023
+ // nine-repo measurement study. Each is a deletion-class finding, so each
9024
+ // was validated against pydantic / trio / attrs as well as the maintained
9025
+ // repos: `no-restated-comment` 0 hits in the flagship first-party
9026
+ // repo and 4 in the three famous
9027
+ // corpora combined; `trailing-value-narration` 18 hits, 18 true
9028
+ // positives; `jsdoc-restates-signature` 36 hits, 0 measured false
9029
+ // positives, and it offers a suggestion rather than a `--fix` because a
9030
+ // wrong deletion is silent information loss.
9031
+ "@sarj/no-restated-comment": "warn",
9032
+ "@sarj/jsdoc-restates-signature": "warn",
9033
+ "@sarj/trailing-value-narration": "warn",
9034
+ // The VOLUME arm of the same family (2026-07). Its siblings judge one
9035
+ // comment at a time and can only condemn one that adds nothing; this
9036
+ // one judges a TYPE, so it can report ten rows that each add a word.
9037
+ // 33 OSS TS repos / 46,861 files: 22 findings, all read, 0 false; zero
9038
+ // across ten first-party repos, where the generated-file sniff alone
9039
+ // removed 321 of the 407 raw hits. Measurements and the six false
9040
+ // positives that shaped the guards: docs/rules/no-type-member-comment-wall.md
9041
+ "@sarj/no-type-member-comment-wall": "warn",
9042
+ // The TS half of SARJ057 (2026-07). Python has caught the
9043
+ // assertion-FREE test since 0.15.0 (SARJ043) and had no TS
9044
+ // counterpart, which is how `expect(true).toBe(true); // placeholder`
9045
+ // survived in a first-party repo: the file HAS an assertion.
9046
+ // Measured across 5,819 .ts/.tsx files (1,003 of them test files) in
9047
+ // six internal repos plus got / hono / swr / trpc: 3 hits, 3 true
9048
+ // positives, 0 false positives.
9049
+ "@sarj/no-tautological-expect": "warn",
9050
+ // Substitutability: an exported service class with injected
9051
+ // collaborators and no interface above it can only be tested by
9052
+ // mocking. 11-repo sweep: 229 exported classes, 82% already carry a
9053
+ // port, 29 fire, 28 of them true positives.
9054
+ "@sarj/require-interface-for-injected-service": "warn",
9055
+ "@sarj/prefer-non-nullable-collection": "warn",
9056
+ "@sarj/no-async-callback-in-waitfor": "warn",
9057
+ // A Zod schema built inside a function is rebuilt on every call, every
9058
+ // request, every render. Zod sibling of `prefer-module-level-constant`,
9059
+ // which cannot reach it: that rule's hoist gate requires literal leaves and
9060
+ // `z.object({...})` is a call. 378 reports over 30,546 .ts/.tsx files in 17
9061
+ // repos; the free-variable, chain and `this` gates are what keep the schema
9062
+ // FACTORY case (closes over a parameter, a type parameter, or a local type)
9063
+ // silent.
9064
+ "@sarj/prefer-module-level-schema": "warn",
9065
+ // `strict-test-assertions` shipped in `rules` but in NEITHER preset, so a
9066
+ // consumer using `configs.recommended`/`configs.strict` instead of the shared
9067
+ // `eslint.strict.mjs` had silently never run it. `flat-presets.test.ts`
9068
+ // asserts strict wires every rule the plugin ships, so it cannot recur.
9069
+ "@sarj/strict-test-assertions": "warn"
9070
+ };
9071
+ var strictRules = {
9072
+ "@sarj/zod-naming-convention": "error",
9073
+ "@sarj/require-assert-never": "error",
9074
+ "@sarj/require-zod-form-validation": "error",
9075
+ "@sarj/enforce-file-structure": "error",
9076
+ "@sarj/no-raw-env": "error",
9077
+ "@sarj/no-enum": "error",
9078
+ "@sarj/no-client-side-data-fetching": "error",
9079
+ "@sarj/prefer-server-actions": "error",
9080
+ "@sarj/no-unnecessary-use-client": "error",
9081
+ "@sarj/prefer-schema-for-api-payload": "error",
9082
+ // Distilled from sarj-audit skills.
9083
+ "@sarj/no-sentinel-return-on-catch": "error",
9084
+ "@sarj/no-log-only-catch": "error",
9085
+ "@sarj/no-insecure-random-id": "error",
9086
+ "@sarj/no-json-stringify-error": "error",
9087
+ "@sarj/no-string-concat-in-loop": "error",
9088
+ "@sarj/prefer-discriminated-union": "error",
9089
+ "@sarj/no-comment-cruft": "error",
9090
+ // Frontend / styling — distilled from frontend PR-review mining. Stylistic,
9091
+ // no autofix → warn (rollout should prove the FP rate before raising it).
9092
+ "@sarj/prefer-semantic-colors": [
9093
+ "error",
9094
+ { requireSemanticTokens: true }
9095
+ ],
9096
+ // Ported from sarj-python-lint (SARJ), corpus-validated FP~0.
9097
+ "@sarj/no-fat-try-blocks": "error",
9098
+ "@sarj/no-cors-wildcard-with-credentials": "error",
9099
+ "@sarj/no-secret-in-log": "error",
9100
+ "@sarj/no-unsafe-mock-casting": "error",
9101
+ // Promoted to error 2026-07-25 — strict means strict (user directive).
9102
+ "@sarj/prefer-string-literal-union": "error",
9103
+ "@sarj/prefer-zod-enum": "error",
9104
+ // See the `recommended` block for the measured counts.
9105
+ "@sarj/prefer-zod-infer": "error",
9106
+ // Mined from 2y of PR review feedback + 5-repo code-smell audit (2026-07).
9107
+ "@sarj/require-fetch-timeout": "error",
9108
+ "@sarj/no-silent-promise-catch": "error",
9109
+ // Second SARJ port wave — the TS/Python parity gap.
9110
+ "@sarj/prefer-constant-time-secret-compare": "error",
9111
+ "@sarj/store-insert-requires-on-conflict": "error",
9112
+ "@sarj/no-offset-pagination": "error",
9113
+ "@sarj/no-select-star": "error",
9114
+ // Uncancellable hand-rolled timers. Verified against the shipped
9115
+ // strict config (205 enabled rules) that nothing already reports this
9116
+ // position; `unicorn` 72 has no promisified-timer rule at all.
9117
+ "@sarj/no-hand-rolled-sleep": "error",
9118
+ "@sarj/no-sleep-in-test-body": "error",
9119
+ "@sarj/no-conditional-in-test": "error",
9120
+ "@sarj/no-repeated-string-literal": "error",
9121
+ // API-shape advice rather than a runtime defect — a corpus sweep found its
9122
+ // only hits are parser `[value, cursor]` returns, which are conventional.
9123
+ // Warn even in strict until a rollout justifies more.
9124
+ "@sarj/no-positional-tuple-return": "error",
9125
+ "@sarj/no-dynamic-sql": "error",
9126
+ // Architectural: both need per-repo config to be meaningful, so they
9127
+ // are strict-only. `no-storage-in-stateless-modules` is a no-op until
9128
+ // its `modules` option names the directories a team declared stateless;
9129
+ // `no-raw-fetch-outside-clients` defaults to the `clients/` convention
9130
+ // and takes an `allow` list for repos that lay their client layer out
9131
+ // differently.
9132
+ "@sarj/no-raw-fetch-outside-clients": "error",
9133
+ "@sarj/no-storage-in-stateless-modules": "error",
9134
+ // Mined from two years of PR review (SARJ-928).
9135
+ "@sarj/no-zod-native-enum": "error",
9136
+ "@sarj/prefer-module-level-constant": "error",
9137
+ // Anti-comment-verbosity family (2026-07) — see the `recommended` block
9138
+ // for the measured hit counts and false-positive rates.
9139
+ "@sarj/no-restated-comment": "error",
9140
+ "@sarj/jsdoc-restates-signature": "error",
9141
+ "@sarj/trailing-value-narration": "error",
9142
+ "@sarj/no-type-member-comment-wall": "error",
9143
+ // TS half of SARJ057 — see the `recommended` block for the measurement.
9144
+ "@sarj/no-tautological-expect": "error",
9145
+ // Substitutability: the TS sibling of the Python `prefer-real-store-in-tests`
9146
+ // / `prefer-library-fake` wave. The convention already exists in the
9147
+ // corpus (175 `implements` clauses vs 29 hits), so strict enforces it.
9148
+ "@sarj/require-interface-for-injected-service": "error",
9149
+ "@sarj/prefer-non-nullable-collection": "error",
9150
+ "@sarj/no-async-callback-in-waitfor": "error",
9151
+ // Zod sibling of `prefer-module-level-constant` -- see `recommended`.
9152
+ "@sarj/prefer-module-level-schema": "error",
9153
+ // See the `recommended` block.
9154
+ "@sarj/strict-test-assertions": "error"
8700
9155
  };
8701
9156
  var plugin = {
8702
- meta: {
8703
- name: "@sarj/eslint-plugin",
8704
- version: "5.1.0"
8705
- },
9157
+ meta,
8706
9158
  rules,
8707
9159
  configs: {
8708
- recommended: {
8709
- plugins: ["@sarj"],
8710
- rules: {
8711
- "@sarj/zod-naming-convention": "warn",
8712
- "@sarj/require-assert-never": "error",
8713
- "@sarj/require-zod-form-validation": "error",
8714
- "@sarj/enforce-file-structure": "warn",
8715
- "@sarj/no-client-side-data-fetching": "warn",
8716
- "@sarj/prefer-server-actions": "warn",
8717
- "@sarj/no-unnecessary-use-client": "warn",
8718
- "@sarj/prefer-schema-for-api-payload": "warn",
8719
- // Distilled from sarj-audit skills — warn in recommended, error in strict.
8720
- "@sarj/no-sentinel-return-on-catch": "warn",
8721
- "@sarj/no-log-only-catch": "warn",
8722
- "@sarj/no-insecure-random-id": "warn",
8723
- "@sarj/no-json-stringify-error": "warn",
8724
- "@sarj/no-string-concat-in-loop": "warn",
8725
- "@sarj/prefer-discriminated-union": "warn",
8726
- "@sarj/no-comment-cruft": "warn",
8727
- // Frontend / styling — distilled from frontend PR-review mining.
8728
- "@sarj/prefer-semantic-colors": [
8729
- "warn",
8730
- { requireSemanticTokens: true }
8731
- ],
8732
- // Ported from sarj-python-lint (SARJ), corpus-validated FP~0.
8733
- "@sarj/no-fat-try-blocks": "warn",
8734
- "@sarj/no-cors-wildcard-with-credentials": "warn",
8735
- "@sarj/no-secret-in-log": "warn",
8736
- "@sarj/no-unsafe-mock-casting": "warn",
8737
- "@sarj/prefer-string-literal-union": "warn",
8738
- "@sarj/prefer-zod-enum": "warn",
8739
- // A type hand-written beside the Zod schema it restates drifts the
8740
- // moment the schema gains a field. 30,759-file, 17-repo sweep
8741
- // (2026-07): 5 reports, 5 true positives, all in public repos.
8742
- // `requireIdenticalShape: false` widens it to 8 reports, 1 of them noise.
8743
- "@sarj/prefer-zod-infer": "warn",
8744
- // Mined from 2y of PR review feedback + 5-repo code-smell audit (2026-07).
8745
- "@sarj/require-fetch-timeout": "warn",
8746
- "@sarj/no-silent-promise-catch": "warn",
8747
- // Second SARJ port wave — the TS/Python parity gap. Each targets a
8748
- // defect class seen in production Workers code: timing-leaky secret
8749
- // compares, non-idempotent store writes under queue redelivery,
8750
- // O(N) pagination, implicit row contracts, flaky timed tests.
8751
- "@sarj/prefer-constant-time-secret-compare": "error",
8752
- "@sarj/store-insert-requires-on-conflict": "warn",
8753
- "@sarj/no-offset-pagination": "warn",
8754
- "@sarj/no-select-star": "warn",
8755
- // Uncancellable hand-rolled timers. Verified against the shipped
8756
- // strict config (205 enabled rules) that nothing already reports this
8757
- // position; `unicorn` 72 has no promisified-timer rule at all.
8758
- "@sarj/no-hand-rolled-sleep": "warn",
8759
- "@sarj/no-sleep-in-test-body": "warn",
8760
- "@sarj/no-conditional-in-test": "warn",
8761
- "@sarj/no-repeated-string-literal": "warn",
8762
- "@sarj/no-positional-tuple-return": "warn",
8763
- // Injection guard — low FP, applies to any repo touching SQL.
8764
- "@sarj/no-dynamic-sql": "warn",
8765
- // Mined from two years of PR review (SARJ-928). Schema-layer sibling of
8766
- // `no-enum`; autofixable for inline string-literal objects.
8767
- "@sarj/no-zod-native-enum": "warn",
8768
- // Mined from two years of PR review — the single most frequent uncovered
8769
- // theme (~37 PRs). Measured 17 hits / 1085 real TS files, all true
8770
- // positives, so it is safe to run everywhere.
8771
- "@sarj/prefer-module-level-constant": "warn",
8772
- // Anti-comment-verbosity family (2026-07), from a 37,918-comment,
8773
- // nine-repo measurement study. Each is a deletion-class finding, so each
8774
- // was validated against pydantic / trio / attrs as well as the maintained
8775
- // repos: `no-restated-comment` 0 hits in the flagship first-party
8776
- // repo and 4 in the three famous
8777
- // corpora combined; `trailing-value-narration` 18 hits, 18 true
8778
- // positives; `jsdoc-restates-signature` 36 hits, 0 measured false
8779
- // positives, and it offers a suggestion rather than a `--fix` because a
8780
- // wrong deletion is silent information loss.
8781
- "@sarj/no-restated-comment": "warn",
8782
- "@sarj/jsdoc-restates-signature": "warn",
8783
- "@sarj/trailing-value-narration": "warn",
8784
- // The VOLUME arm of the same family (2026-07). Its siblings judge one
8785
- // comment at a time and can only condemn one that adds nothing; this
8786
- // one judges a TYPE, so it can report ten rows that each add a word.
8787
- // 33 OSS TS repos / 46,861 files: 22 findings, all read, 0 false; zero
8788
- // across ten first-party repos, where the generated-file sniff alone
8789
- // removed 321 of the 407 raw hits. Measurements and the six false
8790
- // positives that shaped the guards: docs/rules/no-type-member-comment-wall.md
8791
- "@sarj/no-type-member-comment-wall": "warn",
8792
- // The TS half of SARJ057 (2026-07). Python has caught the
8793
- // assertion-FREE test since 0.15.0 (SARJ043) and had no TS
8794
- // counterpart, which is how `expect(true).toBe(true); // placeholder`
8795
- // survived in a first-party repo: the file HAS an assertion.
8796
- // Measured across 5,819 .ts/.tsx files (1,003 of them test files) in
8797
- // six internal repos plus got / hono / swr / trpc: 3 hits, 3 true
8798
- // positives, 0 false positives.
8799
- "@sarj/no-tautological-expect": "warn",
8800
- // Substitutability: an exported service class with injected
8801
- // collaborators and no interface above it can only be tested by
8802
- // mocking. 11-repo sweep: 229 exported classes, 82% already carry a
8803
- // port, 29 fire, 28 of them true positives.
8804
- "@sarj/require-interface-for-injected-service": "warn",
8805
- "@sarj/prefer-non-nullable-collection": "warn",
8806
- "@sarj/no-async-callback-in-waitfor": "warn"
8807
- }
8808
- },
8809
- strict: {
8810
- plugins: ["@sarj"],
8811
- rules: {
8812
- "@sarj/zod-naming-convention": "error",
8813
- "@sarj/require-assert-never": "error",
8814
- "@sarj/require-zod-form-validation": "error",
8815
- "@sarj/enforce-file-structure": "error",
8816
- "@sarj/no-raw-env": "error",
8817
- "@sarj/no-enum": "error",
8818
- "@sarj/no-client-side-data-fetching": "error",
8819
- "@sarj/prefer-server-actions": "error",
8820
- "@sarj/no-unnecessary-use-client": "error",
8821
- "@sarj/prefer-schema-for-api-payload": "error",
8822
- // Distilled from sarj-audit skills.
8823
- "@sarj/no-sentinel-return-on-catch": "error",
8824
- "@sarj/no-log-only-catch": "error",
8825
- "@sarj/no-insecure-random-id": "error",
8826
- "@sarj/no-json-stringify-error": "error",
8827
- "@sarj/no-string-concat-in-loop": "error",
8828
- "@sarj/prefer-discriminated-union": "error",
8829
- "@sarj/no-comment-cruft": "error",
8830
- // Frontend / styling — distilled from frontend PR-review mining. Stylistic,
8831
- // no autofix → warn (rollout should prove the FP rate before raising it).
8832
- "@sarj/prefer-semantic-colors": [
8833
- "error",
8834
- { requireSemanticTokens: true }
8835
- ],
8836
- // Ported from sarj-python-lint (SARJ), corpus-validated FP~0.
8837
- "@sarj/no-fat-try-blocks": "error",
8838
- "@sarj/no-cors-wildcard-with-credentials": "error",
8839
- "@sarj/no-secret-in-log": "error",
8840
- "@sarj/no-unsafe-mock-casting": "error",
8841
- // Promoted to error 2026-07-25 — strict means strict (user directive).
8842
- "@sarj/prefer-string-literal-union": "error",
8843
- "@sarj/prefer-zod-enum": "error",
8844
- // See the `recommended` block for the measured counts.
8845
- "@sarj/prefer-zod-infer": "error",
8846
- // Mined from 2y of PR review feedback + 5-repo code-smell audit (2026-07).
8847
- "@sarj/require-fetch-timeout": "error",
8848
- "@sarj/no-silent-promise-catch": "error",
8849
- // Second SARJ port wave — the TS/Python parity gap.
8850
- "@sarj/prefer-constant-time-secret-compare": "error",
8851
- "@sarj/store-insert-requires-on-conflict": "error",
8852
- "@sarj/no-offset-pagination": "error",
8853
- "@sarj/no-select-star": "error",
8854
- // Uncancellable hand-rolled timers. Verified against the shipped
8855
- // strict config (205 enabled rules) that nothing already reports this
8856
- // position; `unicorn` 72 has no promisified-timer rule at all.
8857
- "@sarj/no-hand-rolled-sleep": "error",
8858
- "@sarj/no-sleep-in-test-body": "error",
8859
- "@sarj/no-conditional-in-test": "error",
8860
- "@sarj/no-repeated-string-literal": "error",
8861
- // API-shape advice rather than a runtime defect — a corpus sweep found its
8862
- // only hits are parser `[value, cursor]` returns, which are conventional.
8863
- // Warn even in strict until a rollout justifies more.
8864
- "@sarj/no-positional-tuple-return": "error",
8865
- "@sarj/no-dynamic-sql": "error",
8866
- // Architectural: both need per-repo config to be meaningful, so they
8867
- // are strict-only. `no-storage-in-stateless-modules` is a no-op until
8868
- // its `modules` option names the directories a team declared stateless;
8869
- // `no-raw-fetch-outside-clients` defaults to the `clients/` convention
8870
- // and takes an `allow` list for repos that lay their client layer out
8871
- // differently.
8872
- "@sarj/no-raw-fetch-outside-clients": "error",
8873
- "@sarj/no-storage-in-stateless-modules": "error",
8874
- // Mined from two years of PR review (SARJ-928).
8875
- "@sarj/no-zod-native-enum": "error",
8876
- "@sarj/prefer-module-level-constant": "error",
8877
- // Anti-comment-verbosity family (2026-07) — see the `recommended` block
8878
- // for the measured hit counts and false-positive rates.
8879
- "@sarj/no-restated-comment": "error",
8880
- "@sarj/jsdoc-restates-signature": "error",
8881
- "@sarj/trailing-value-narration": "error",
8882
- "@sarj/no-type-member-comment-wall": "error",
8883
- // TS half of SARJ057 — see the `recommended` block for the measurement.
8884
- "@sarj/no-tautological-expect": "error",
8885
- // Substitutability: the TS sibling of the Python `prefer-real-store-in-tests`
8886
- // / `prefer-library-fake` wave. The convention already exists in the
8887
- // corpus (175 `implements` clauses vs 29 hits), so strict enforces it.
8888
- "@sarj/require-interface-for-injected-service": "error",
8889
- "@sarj/prefer-non-nullable-collection": "error",
8890
- "@sarj/no-async-callback-in-waitfor": "error"
8891
- }
8892
- }
9160
+ recommended: {},
9161
+ strict: {}
8893
9162
  }
8894
9163
  };
9164
+ plugin.configs.recommended = {
9165
+ name: "@sarj/recommended",
9166
+ plugins: { "@sarj": plugin },
9167
+ rules: recommendedRules
9168
+ };
9169
+ plugin.configs.strict = {
9170
+ name: "@sarj/strict",
9171
+ plugins: { "@sarj": plugin },
9172
+ rules: strictRules
9173
+ };
8895
9174
  var index_default = plugin;
8896
9175
  // Annotate the CommonJS export names for ESM import in node:
8897
9176
  0 && (module.exports = {
8898
- rules
9177
+ recommendedRules,
9178
+ rules,
9179
+ strictRules
8899
9180
  });
8900
9181
  //# sourceMappingURL=index.cjs.map