@sarj/eslint-plugin 6.0.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/README.md +1 -0
- package/dist/index.cjs +265 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +268 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -437,6 +437,13 @@ declare const rules: {
|
|
|
437
437
|
"no-async-callback-in-waitfor": _typescript_eslint_utils_ts_eslint.RuleModule<"noAsyncCallbackInWaitFor", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
438
438
|
name: string;
|
|
439
439
|
};
|
|
440
|
+
"prefer-module-level-schema": _typescript_eslint_utils_ts_eslint.RuleModule<"hoistSchema", readonly [{
|
|
441
|
+
factories?: readonly string[];
|
|
442
|
+
ignoreTestFiles?: boolean;
|
|
443
|
+
minProperties?: number;
|
|
444
|
+
}?], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
445
|
+
name: string;
|
|
446
|
+
};
|
|
440
447
|
};
|
|
441
448
|
declare const recommendedRules: {
|
|
442
449
|
readonly "@sarj/zod-naming-convention": "warn";
|
|
@@ -486,6 +493,7 @@ declare const recommendedRules: {
|
|
|
486
493
|
readonly "@sarj/require-interface-for-injected-service": "warn";
|
|
487
494
|
readonly "@sarj/prefer-non-nullable-collection": "warn";
|
|
488
495
|
readonly "@sarj/no-async-callback-in-waitfor": "warn";
|
|
496
|
+
readonly "@sarj/prefer-module-level-schema": "warn";
|
|
489
497
|
readonly "@sarj/strict-test-assertions": "warn";
|
|
490
498
|
};
|
|
491
499
|
declare const strictRules: {
|
|
@@ -540,6 +548,7 @@ declare const strictRules: {
|
|
|
540
548
|
readonly "@sarj/require-interface-for-injected-service": "error";
|
|
541
549
|
readonly "@sarj/prefer-non-nullable-collection": "error";
|
|
542
550
|
readonly "@sarj/no-async-callback-in-waitfor": "error";
|
|
551
|
+
readonly "@sarj/prefer-module-level-schema": "error";
|
|
543
552
|
readonly "@sarj/strict-test-assertions": "error";
|
|
544
553
|
};
|
|
545
554
|
type FlatPreset = {
|
|
@@ -572,7 +581,7 @@ type FlatPreset = {
|
|
|
572
581
|
declare const plugin: {
|
|
573
582
|
meta: {
|
|
574
583
|
readonly name: "@sarj/eslint-plugin";
|
|
575
|
-
readonly version: "6.
|
|
584
|
+
readonly version: "6.1.0";
|
|
576
585
|
};
|
|
577
586
|
rules: {
|
|
578
587
|
"enforce-file-structure": _typescript_eslint_utils_ts_eslint.RuleModule<"importsFirst" | "useServerDirective", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
@@ -745,6 +754,13 @@ declare const plugin: {
|
|
|
745
754
|
"no-async-callback-in-waitfor": _typescript_eslint_utils_ts_eslint.RuleModule<"noAsyncCallbackInWaitFor", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
746
755
|
name: string;
|
|
747
756
|
};
|
|
757
|
+
"prefer-module-level-schema": _typescript_eslint_utils_ts_eslint.RuleModule<"hoistSchema", readonly [{
|
|
758
|
+
factories?: readonly string[];
|
|
759
|
+
ignoreTestFiles?: boolean;
|
|
760
|
+
minProperties?: number;
|
|
761
|
+
}?], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
762
|
+
name: string;
|
|
763
|
+
};
|
|
748
764
|
};
|
|
749
765
|
configs: {
|
|
750
766
|
recommended: FlatPreset;
|
package/dist/index.d.ts
CHANGED
|
@@ -437,6 +437,13 @@ declare const rules: {
|
|
|
437
437
|
"no-async-callback-in-waitfor": _typescript_eslint_utils_ts_eslint.RuleModule<"noAsyncCallbackInWaitFor", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
438
438
|
name: string;
|
|
439
439
|
};
|
|
440
|
+
"prefer-module-level-schema": _typescript_eslint_utils_ts_eslint.RuleModule<"hoistSchema", readonly [{
|
|
441
|
+
factories?: readonly string[];
|
|
442
|
+
ignoreTestFiles?: boolean;
|
|
443
|
+
minProperties?: number;
|
|
444
|
+
}?], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
445
|
+
name: string;
|
|
446
|
+
};
|
|
440
447
|
};
|
|
441
448
|
declare const recommendedRules: {
|
|
442
449
|
readonly "@sarj/zod-naming-convention": "warn";
|
|
@@ -486,6 +493,7 @@ declare const recommendedRules: {
|
|
|
486
493
|
readonly "@sarj/require-interface-for-injected-service": "warn";
|
|
487
494
|
readonly "@sarj/prefer-non-nullable-collection": "warn";
|
|
488
495
|
readonly "@sarj/no-async-callback-in-waitfor": "warn";
|
|
496
|
+
readonly "@sarj/prefer-module-level-schema": "warn";
|
|
489
497
|
readonly "@sarj/strict-test-assertions": "warn";
|
|
490
498
|
};
|
|
491
499
|
declare const strictRules: {
|
|
@@ -540,6 +548,7 @@ declare const strictRules: {
|
|
|
540
548
|
readonly "@sarj/require-interface-for-injected-service": "error";
|
|
541
549
|
readonly "@sarj/prefer-non-nullable-collection": "error";
|
|
542
550
|
readonly "@sarj/no-async-callback-in-waitfor": "error";
|
|
551
|
+
readonly "@sarj/prefer-module-level-schema": "error";
|
|
543
552
|
readonly "@sarj/strict-test-assertions": "error";
|
|
544
553
|
};
|
|
545
554
|
type FlatPreset = {
|
|
@@ -572,7 +581,7 @@ type FlatPreset = {
|
|
|
572
581
|
declare const plugin: {
|
|
573
582
|
meta: {
|
|
574
583
|
readonly name: "@sarj/eslint-plugin";
|
|
575
|
-
readonly version: "6.
|
|
584
|
+
readonly version: "6.1.0";
|
|
576
585
|
};
|
|
577
586
|
rules: {
|
|
578
587
|
"enforce-file-structure": _typescript_eslint_utils_ts_eslint.RuleModule<"importsFirst" | "useServerDirective", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
@@ -745,6 +754,13 @@ declare const plugin: {
|
|
|
745
754
|
"no-async-callback-in-waitfor": _typescript_eslint_utils_ts_eslint.RuleModule<"noAsyncCallbackInWaitFor", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
746
755
|
name: string;
|
|
747
756
|
};
|
|
757
|
+
"prefer-module-level-schema": _typescript_eslint_utils_ts_eslint.RuleModule<"hoistSchema", readonly [{
|
|
758
|
+
factories?: readonly string[];
|
|
759
|
+
ignoreTestFiles?: boolean;
|
|
760
|
+
minProperties?: number;
|
|
761
|
+
}?], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
762
|
+
name: string;
|
|
763
|
+
};
|
|
748
764
|
};
|
|
749
765
|
configs: {
|
|
750
766
|
recommended: FlatPreset;
|
package/dist/index.js
CHANGED
|
@@ -8645,6 +8645,261 @@ var no_hand_rolled_sleep_default = ESLintUtils50.RuleCreator(
|
|
|
8645
8645
|
}
|
|
8646
8646
|
});
|
|
8647
8647
|
|
|
8648
|
+
// src/rules/prefer-module-level-schema.ts
|
|
8649
|
+
import {
|
|
8650
|
+
AST_NODE_TYPES as AST_NODE_TYPES41,
|
|
8651
|
+
ESLintUtils as ESLintUtils51
|
|
8652
|
+
} from "@typescript-eslint/utils";
|
|
8653
|
+
var DEFAULT_FACTORIES = [
|
|
8654
|
+
"discriminatedUnion",
|
|
8655
|
+
"intersection",
|
|
8656
|
+
"looseObject",
|
|
8657
|
+
"object",
|
|
8658
|
+
"record",
|
|
8659
|
+
"strictObject",
|
|
8660
|
+
"tuple",
|
|
8661
|
+
"union"
|
|
8662
|
+
];
|
|
8663
|
+
var DEFAULT_MIN_PROPERTIES = 1;
|
|
8664
|
+
var MEMO_CALLEES = /* @__PURE__ */ new Set([
|
|
8665
|
+
"lazy",
|
|
8666
|
+
"memo",
|
|
8667
|
+
"once",
|
|
8668
|
+
"useMemo"
|
|
8669
|
+
]);
|
|
8670
|
+
var TERMINAL_METHODS = /* @__PURE__ */ new Set([
|
|
8671
|
+
"isNullable",
|
|
8672
|
+
"isOptional",
|
|
8673
|
+
"parse",
|
|
8674
|
+
"parseAsync",
|
|
8675
|
+
"safeParse",
|
|
8676
|
+
"safeParseAsync",
|
|
8677
|
+
"spa"
|
|
8678
|
+
]);
|
|
8679
|
+
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
8680
|
+
AST_NODE_TYPES41.ArrowFunctionExpression,
|
|
8681
|
+
AST_NODE_TYPES41.FunctionDeclaration,
|
|
8682
|
+
AST_NODE_TYPES41.FunctionExpression
|
|
8683
|
+
]);
|
|
8684
|
+
function schemaExpression(node) {
|
|
8685
|
+
let current = node;
|
|
8686
|
+
for (; ; ) {
|
|
8687
|
+
const parent = current.parent ?? void 0;
|
|
8688
|
+
if (parent === void 0) {
|
|
8689
|
+
return current;
|
|
8690
|
+
}
|
|
8691
|
+
if (parent.type === AST_NODE_TYPES41.MemberExpression && parent.object === current && !parent.computed && parent.property.type === AST_NODE_TYPES41.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
8692
|
+
return current;
|
|
8693
|
+
}
|
|
8694
|
+
if (parent.type === AST_NODE_TYPES41.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES41.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES41.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES41.TSNonNullExpression && parent.expression === current) {
|
|
8695
|
+
current = parent;
|
|
8696
|
+
continue;
|
|
8697
|
+
}
|
|
8698
|
+
return current;
|
|
8699
|
+
}
|
|
8700
|
+
}
|
|
8701
|
+
function outermostEnclosingFunction(node) {
|
|
8702
|
+
let outermost;
|
|
8703
|
+
let current = node.parent ?? void 0;
|
|
8704
|
+
while (current !== void 0) {
|
|
8705
|
+
if (FUNCTION_TYPES6.has(current.type)) {
|
|
8706
|
+
outermost = current;
|
|
8707
|
+
}
|
|
8708
|
+
current = current.parent ?? void 0;
|
|
8709
|
+
}
|
|
8710
|
+
return outermost;
|
|
8711
|
+
}
|
|
8712
|
+
function readsReceiver(node) {
|
|
8713
|
+
let found = false;
|
|
8714
|
+
const visit = (value) => {
|
|
8715
|
+
if (found || value === null || typeof value !== "object") {
|
|
8716
|
+
return;
|
|
8717
|
+
}
|
|
8718
|
+
if (Array.isArray(value)) {
|
|
8719
|
+
for (const item of value) {
|
|
8720
|
+
visit(item);
|
|
8721
|
+
}
|
|
8722
|
+
return;
|
|
8723
|
+
}
|
|
8724
|
+
const candidate = value;
|
|
8725
|
+
if (typeof candidate.type !== "string") {
|
|
8726
|
+
return;
|
|
8727
|
+
}
|
|
8728
|
+
if (candidate.type === AST_NODE_TYPES41.ThisExpression || candidate.type === AST_NODE_TYPES41.Super || candidate.type === AST_NODE_TYPES41.Identifier && candidate.name === "arguments") {
|
|
8729
|
+
found = true;
|
|
8730
|
+
return;
|
|
8731
|
+
}
|
|
8732
|
+
for (const key of Object.keys(candidate)) {
|
|
8733
|
+
if (key === "parent" || key === "loc" || key === "range") {
|
|
8734
|
+
continue;
|
|
8735
|
+
}
|
|
8736
|
+
visit(candidate[key]);
|
|
8737
|
+
}
|
|
8738
|
+
};
|
|
8739
|
+
visit(node);
|
|
8740
|
+
return found;
|
|
8741
|
+
}
|
|
8742
|
+
function collectReferences(scope, out) {
|
|
8743
|
+
out.push(...scope.references);
|
|
8744
|
+
for (const child of scope.childScopes) {
|
|
8745
|
+
collectReferences(child, out);
|
|
8746
|
+
}
|
|
8747
|
+
}
|
|
8748
|
+
var prefer_module_level_schema_default = ESLintUtils51.RuleCreator(
|
|
8749
|
+
(name) => `https://github.com/sarj-ai/standards/tree/main/packages/typescript#${name}`
|
|
8750
|
+
)({
|
|
8751
|
+
name: "prefer-module-level-schema",
|
|
8752
|
+
meta: {
|
|
8753
|
+
type: "problem",
|
|
8754
|
+
docs: {
|
|
8755
|
+
description: "Declare a Zod schema at module scope when it closes over nothing in the enclosing function"
|
|
8756
|
+
},
|
|
8757
|
+
schema: [
|
|
8758
|
+
{
|
|
8759
|
+
type: "object",
|
|
8760
|
+
properties: {
|
|
8761
|
+
factories: {
|
|
8762
|
+
type: "array",
|
|
8763
|
+
items: { type: "string" },
|
|
8764
|
+
description: "Zod factory names to check. Defaults to the object-like composites; add `array` / `enum` to widen."
|
|
8765
|
+
},
|
|
8766
|
+
ignoreTestFiles: {
|
|
8767
|
+
type: "boolean",
|
|
8768
|
+
description: "Skip test files, where a fixture schema belongs next to its assertion."
|
|
8769
|
+
},
|
|
8770
|
+
minProperties: {
|
|
8771
|
+
type: "number",
|
|
8772
|
+
minimum: 0,
|
|
8773
|
+
description: "Minimum key count before an object-like schema is reported."
|
|
8774
|
+
}
|
|
8775
|
+
},
|
|
8776
|
+
additionalProperties: false
|
|
8777
|
+
}
|
|
8778
|
+
],
|
|
8779
|
+
messages: {
|
|
8780
|
+
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."
|
|
8781
|
+
}
|
|
8782
|
+
},
|
|
8783
|
+
defaultOptions: [{}],
|
|
8784
|
+
create(context, [options]) {
|
|
8785
|
+
const factories = new Set(options?.factories ?? DEFAULT_FACTORIES);
|
|
8786
|
+
const ignoreTestFiles = options?.ignoreTestFiles ?? true;
|
|
8787
|
+
const minProperties = options?.minProperties ?? DEFAULT_MIN_PROPERTIES;
|
|
8788
|
+
const sourceCode = context.sourceCode;
|
|
8789
|
+
const filename = context.filename;
|
|
8790
|
+
if (isGeneratedFile(filename, sourceCode.getText())) {
|
|
8791
|
+
return {};
|
|
8792
|
+
}
|
|
8793
|
+
if (ignoreTestFiles && isTestFile(filename)) {
|
|
8794
|
+
return {};
|
|
8795
|
+
}
|
|
8796
|
+
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8797
|
+
function isZodCall(node) {
|
|
8798
|
+
return node.type === AST_NODE_TYPES41.CallExpression && node.callee.type === AST_NODE_TYPES41.MemberExpression && !node.callee.computed && node.callee.object.type === AST_NODE_TYPES41.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
8799
|
+
}
|
|
8800
|
+
function isCovered(node) {
|
|
8801
|
+
let current = node.parent ?? void 0;
|
|
8802
|
+
while (current !== void 0) {
|
|
8803
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES41.MemberExpression && current.callee.property.type === AST_NODE_TYPES41.Identifier && factories.has(current.callee.property.name)) {
|
|
8804
|
+
return true;
|
|
8805
|
+
}
|
|
8806
|
+
if (current.type === AST_NODE_TYPES41.CallExpression && (current.callee.type === AST_NODE_TYPES41.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === AST_NODE_TYPES41.MemberExpression && !current.callee.computed && current.callee.property.type === AST_NODE_TYPES41.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
8807
|
+
return true;
|
|
8808
|
+
}
|
|
8809
|
+
current = current.parent ?? void 0;
|
|
8810
|
+
}
|
|
8811
|
+
return false;
|
|
8812
|
+
}
|
|
8813
|
+
function closesOverNothing(node, enclosing) {
|
|
8814
|
+
const references = [];
|
|
8815
|
+
collectReferences(sourceCode.getScope(node), references);
|
|
8816
|
+
const [schemaStart, schemaEnd] = node.range;
|
|
8817
|
+
const [functionStart, functionEnd] = enclosing.range;
|
|
8818
|
+
for (const reference of references) {
|
|
8819
|
+
const [identifierStart] = reference.identifier.range;
|
|
8820
|
+
if (identifierStart < schemaStart || identifierStart >= schemaEnd) {
|
|
8821
|
+
continue;
|
|
8822
|
+
}
|
|
8823
|
+
const resolved = reference.resolved;
|
|
8824
|
+
if (resolved === null) {
|
|
8825
|
+
continue;
|
|
8826
|
+
}
|
|
8827
|
+
for (const definition of resolved.defs) {
|
|
8828
|
+
if (definition.type === "ImportBinding") {
|
|
8829
|
+
continue;
|
|
8830
|
+
}
|
|
8831
|
+
const [defStart, defEnd] = definition.node.range;
|
|
8832
|
+
if (defStart >= functionStart && defEnd <= functionEnd) {
|
|
8833
|
+
return false;
|
|
8834
|
+
}
|
|
8835
|
+
}
|
|
8836
|
+
}
|
|
8837
|
+
return true;
|
|
8838
|
+
}
|
|
8839
|
+
function ownerName(enclosing) {
|
|
8840
|
+
const parent = enclosing.parent ?? void 0;
|
|
8841
|
+
if (enclosing.type === AST_NODE_TYPES41.FunctionDeclaration && enclosing.id !== null) {
|
|
8842
|
+
return enclosing.id.name;
|
|
8843
|
+
}
|
|
8844
|
+
if (parent !== void 0 && parent.type === AST_NODE_TYPES41.VariableDeclarator && parent.id.type === AST_NODE_TYPES41.Identifier) {
|
|
8845
|
+
return parent.id.name;
|
|
8846
|
+
}
|
|
8847
|
+
if (parent !== void 0 && (parent.type === AST_NODE_TYPES41.MethodDefinition || parent.type === AST_NODE_TYPES41.Property) && parent.key.type === AST_NODE_TYPES41.Identifier) {
|
|
8848
|
+
return parent.key.name;
|
|
8849
|
+
}
|
|
8850
|
+
return "this function";
|
|
8851
|
+
}
|
|
8852
|
+
return {
|
|
8853
|
+
ImportDeclaration(node) {
|
|
8854
|
+
if (!isZodModule(node.source.value)) {
|
|
8855
|
+
return;
|
|
8856
|
+
}
|
|
8857
|
+
for (const specifier of node.specifiers) {
|
|
8858
|
+
if (specifier.type === AST_NODE_TYPES41.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES41.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES41.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES41.Identifier && specifier.imported.name === "z") {
|
|
8859
|
+
zodNamespaces.add(specifier.local.name);
|
|
8860
|
+
}
|
|
8861
|
+
}
|
|
8862
|
+
},
|
|
8863
|
+
CallExpression(node) {
|
|
8864
|
+
if (zodNamespaces.size === 0 || !isZodCall(node)) {
|
|
8865
|
+
return;
|
|
8866
|
+
}
|
|
8867
|
+
const callee = node.callee;
|
|
8868
|
+
if (callee.property.type !== AST_NODE_TYPES41.Identifier) {
|
|
8869
|
+
return;
|
|
8870
|
+
}
|
|
8871
|
+
const factory = callee.property.name;
|
|
8872
|
+
if (!factories.has(factory)) {
|
|
8873
|
+
return;
|
|
8874
|
+
}
|
|
8875
|
+
const enclosing = outermostEnclosingFunction(node);
|
|
8876
|
+
if (enclosing === void 0) {
|
|
8877
|
+
return;
|
|
8878
|
+
}
|
|
8879
|
+
if (isCovered(node)) {
|
|
8880
|
+
return;
|
|
8881
|
+
}
|
|
8882
|
+
const shape = node.arguments[0];
|
|
8883
|
+
if (shape !== void 0 && shape.type === AST_NODE_TYPES41.ObjectExpression && shape.properties.length < minProperties) {
|
|
8884
|
+
return;
|
|
8885
|
+
}
|
|
8886
|
+
const expression = schemaExpression(node);
|
|
8887
|
+
if (readsReceiver(expression)) {
|
|
8888
|
+
return;
|
|
8889
|
+
}
|
|
8890
|
+
if (!closesOverNothing(expression, enclosing)) {
|
|
8891
|
+
return;
|
|
8892
|
+
}
|
|
8893
|
+
context.report({
|
|
8894
|
+
node,
|
|
8895
|
+
messageId: "hoistSchema",
|
|
8896
|
+
data: { factory: `z.${factory}`, owner: ownerName(enclosing) }
|
|
8897
|
+
});
|
|
8898
|
+
}
|
|
8899
|
+
};
|
|
8900
|
+
}
|
|
8901
|
+
});
|
|
8902
|
+
|
|
8648
8903
|
// src/index.ts
|
|
8649
8904
|
var rules = {
|
|
8650
8905
|
"enforce-file-structure": enforce_file_structure_default,
|
|
@@ -8696,11 +8951,12 @@ var rules = {
|
|
|
8696
8951
|
"require-interface-for-injected-service": require_interface_for_injected_service_default,
|
|
8697
8952
|
"strict-test-assertions": strict_test_assertions_default,
|
|
8698
8953
|
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
8699
|
-
"no-async-callback-in-waitfor": no_async_callback_in_waitfor_default
|
|
8954
|
+
"no-async-callback-in-waitfor": no_async_callback_in_waitfor_default,
|
|
8955
|
+
"prefer-module-level-schema": prefer_module_level_schema_default
|
|
8700
8956
|
};
|
|
8701
8957
|
var meta = {
|
|
8702
8958
|
name: "@sarj/eslint-plugin",
|
|
8703
|
-
version: "6.
|
|
8959
|
+
version: "6.1.0"
|
|
8704
8960
|
};
|
|
8705
8961
|
var recommendedRules = {
|
|
8706
8962
|
"@sarj/zod-naming-convention": "warn",
|
|
@@ -8799,6 +9055,14 @@ var recommendedRules = {
|
|
|
8799
9055
|
"@sarj/require-interface-for-injected-service": "warn",
|
|
8800
9056
|
"@sarj/prefer-non-nullable-collection": "warn",
|
|
8801
9057
|
"@sarj/no-async-callback-in-waitfor": "warn",
|
|
9058
|
+
// A Zod schema built inside a function is rebuilt on every call, every
|
|
9059
|
+
// request, every render. Zod sibling of `prefer-module-level-constant`,
|
|
9060
|
+
// which cannot reach it: that rule's hoist gate requires literal leaves and
|
|
9061
|
+
// `z.object({...})` is a call. 378 reports over 30,546 .ts/.tsx files in 17
|
|
9062
|
+
// repos; the free-variable, chain and `this` gates are what keep the schema
|
|
9063
|
+
// FACTORY case (closes over a parameter, a type parameter, or a local type)
|
|
9064
|
+
// silent.
|
|
9065
|
+
"@sarj/prefer-module-level-schema": "warn",
|
|
8802
9066
|
// `strict-test-assertions` shipped in `rules` but in NEITHER preset, so a
|
|
8803
9067
|
// consumer using `configs.recommended`/`configs.strict` instead of the shared
|
|
8804
9068
|
// `eslint.strict.mjs` had silently never run it. `flat-presets.test.ts`
|
|
@@ -8885,6 +9149,8 @@ var strictRules = {
|
|
|
8885
9149
|
"@sarj/require-interface-for-injected-service": "error",
|
|
8886
9150
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
8887
9151
|
"@sarj/no-async-callback-in-waitfor": "error",
|
|
9152
|
+
// Zod sibling of `prefer-module-level-constant` -- see `recommended`.
|
|
9153
|
+
"@sarj/prefer-module-level-schema": "error",
|
|
8888
9154
|
// See the `recommended` block.
|
|
8889
9155
|
"@sarj/strict-test-assertions": "error"
|
|
8890
9156
|
};
|