@noctcore/eslint-plugin-contracts 0.1.0 → 0.3.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 +20 -7
- package/dist/index.cjs +1119 -37
- package/dist/index.d.cts +85 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +1109 -37
- package/docs/rules/env-var-schema-parity.md +54 -0
- package/docs/rules/fetch-must-check-ok.md +83 -0
- package/docs/rules/require-error-cause.md +67 -0
- package/docs/rules/require-registered-keys.md +62 -0
- package/docs/rules/require-schema-parse-at-boundary.md +47 -0
- package/docs/rules/restrict-throw-to-taxonomy.md +54 -0
- package/docs/rules/schema-enum-field-consistency.md +75 -0
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
|
+
interface FetchMustCheckOkOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Callees whose result is a `Response`: a bare name (`fetch`) or a dotted path
|
|
6
|
+
* (`globalThis.fetch`, `http.fetchWithRetry`). Default `['fetch']`.
|
|
7
|
+
*/
|
|
8
|
+
readonly fetchFunctions?: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface SchemaEnumFieldConsistencyOptions {
|
|
12
|
+
/** Names the zod namespace is imported under. */
|
|
13
|
+
readonly zodIdentifiers?: readonly string[];
|
|
14
|
+
/** Field names allowed to be an enum in one schema and a string in another. */
|
|
15
|
+
readonly ignoreFields?: readonly string[];
|
|
16
|
+
/**
|
|
17
|
+
* Regex source. An IMPORTED identifier counts as an enum only when its name
|
|
18
|
+
* matches. Unset, no imported identifier does.
|
|
19
|
+
*/
|
|
20
|
+
readonly enumIdentifierPattern?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface EnvVarSchemaParityOptions {
|
|
24
|
+
/** Path to the env declaration source — a `.env.example` or a zod-env module. Empty = rule is inert. */
|
|
25
|
+
readonly schema?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface RegisteredKeySink {
|
|
29
|
+
/** Dotted callee path whose key argument must be a registered constant (e.g. `localStorage.getItem`). */
|
|
30
|
+
readonly callee: string;
|
|
31
|
+
/** Zero-based index of the key/name argument to police. */
|
|
32
|
+
readonly argIndex: number;
|
|
33
|
+
}
|
|
34
|
+
interface RequireRegisteredKeysOptions {
|
|
35
|
+
/** Sink APIs whose key argument must be an imported constant, not a raw string. Empty = rule is inert. */
|
|
36
|
+
readonly sinks?: readonly RegisteredKeySink[];
|
|
37
|
+
/** Optional module the constants should be imported from, named in the report. */
|
|
38
|
+
readonly registry?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface RestrictThrowToTaxonomyOptions {
|
|
42
|
+
/** Constructor names permitted as throw targets (your error taxonomy). Default `['Error']`. */
|
|
43
|
+
readonly allow?: readonly string[];
|
|
44
|
+
}
|
|
45
|
+
|
|
3
46
|
interface MoneyMustBeDecimalOptions {
|
|
4
47
|
/** Name of the domain money type to require (e.g. `Decimal`, `Money`, `BigDecimal`). */
|
|
5
48
|
readonly decimalType?: string;
|
|
@@ -45,6 +88,27 @@ declare const rules: {
|
|
|
45
88
|
'money-must-be-decimal': _typescript_eslint_utils_ts_eslint.RuleModule<"moneyMustBeDecimal", [MoneyMustBeDecimalOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
46
89
|
name: string;
|
|
47
90
|
};
|
|
91
|
+
'require-error-cause': _typescript_eslint_utils_ts_eslint.RuleModule<"missingCause", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
92
|
+
name: string;
|
|
93
|
+
};
|
|
94
|
+
'restrict-throw-to-taxonomy': _typescript_eslint_utils_ts_eslint.RuleModule<"disallowedErrorClass" | "nonErrorThrow", [RestrictThrowToTaxonomyOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
95
|
+
name: string;
|
|
96
|
+
};
|
|
97
|
+
'require-registered-keys': _typescript_eslint_utils_ts_eslint.RuleModule<"unregisteredKey", [RequireRegisteredKeysOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
98
|
+
name: string;
|
|
99
|
+
};
|
|
100
|
+
'env-var-schema-parity': _typescript_eslint_utils_ts_eslint.RuleModule<"undeclaredEnvVar", [EnvVarSchemaParityOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
101
|
+
name: string;
|
|
102
|
+
};
|
|
103
|
+
'require-schema-parse-at-boundary': _typescript_eslint_utils_ts_eslint.RuleModule<"castedBoundaryData", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
104
|
+
name: string;
|
|
105
|
+
};
|
|
106
|
+
'schema-enum-field-consistency': _typescript_eslint_utils_ts_eslint.RuleModule<"widenedEnumField", [SchemaEnumFieldConsistencyOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
107
|
+
name: string;
|
|
108
|
+
};
|
|
109
|
+
'fetch-must-check-ok': _typescript_eslint_utils_ts_eslint.RuleModule<"missingOkCheck", [FetchMustCheckOkOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
110
|
+
name: string;
|
|
111
|
+
};
|
|
48
112
|
};
|
|
49
113
|
|
|
50
114
|
declare const plugin: {
|
|
@@ -68,6 +132,27 @@ declare const plugin: {
|
|
|
68
132
|
'money-must-be-decimal': _typescript_eslint_utils_ts_eslint.RuleModule<"moneyMustBeDecimal", [MoneyMustBeDecimalOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
69
133
|
name: string;
|
|
70
134
|
};
|
|
135
|
+
'require-error-cause': _typescript_eslint_utils_ts_eslint.RuleModule<"missingCause", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
136
|
+
name: string;
|
|
137
|
+
};
|
|
138
|
+
'restrict-throw-to-taxonomy': _typescript_eslint_utils_ts_eslint.RuleModule<"disallowedErrorClass" | "nonErrorThrow", [RestrictThrowToTaxonomyOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
139
|
+
name: string;
|
|
140
|
+
};
|
|
141
|
+
'require-registered-keys': _typescript_eslint_utils_ts_eslint.RuleModule<"unregisteredKey", [RequireRegisteredKeysOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
142
|
+
name: string;
|
|
143
|
+
};
|
|
144
|
+
'env-var-schema-parity': _typescript_eslint_utils_ts_eslint.RuleModule<"undeclaredEnvVar", [EnvVarSchemaParityOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
145
|
+
name: string;
|
|
146
|
+
};
|
|
147
|
+
'require-schema-parse-at-boundary': _typescript_eslint_utils_ts_eslint.RuleModule<"castedBoundaryData", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
148
|
+
name: string;
|
|
149
|
+
};
|
|
150
|
+
'schema-enum-field-consistency': _typescript_eslint_utils_ts_eslint.RuleModule<"widenedEnumField", [SchemaEnumFieldConsistencyOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
151
|
+
name: string;
|
|
152
|
+
};
|
|
153
|
+
'fetch-must-check-ok': _typescript_eslint_utils_ts_eslint.RuleModule<"missingOkCheck", [FetchMustCheckOkOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
154
|
+
name: string;
|
|
155
|
+
};
|
|
71
156
|
};
|
|
72
157
|
configs: Record<string, unknown>;
|
|
73
158
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
|
+
interface FetchMustCheckOkOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Callees whose result is a `Response`: a bare name (`fetch`) or a dotted path
|
|
6
|
+
* (`globalThis.fetch`, `http.fetchWithRetry`). Default `['fetch']`.
|
|
7
|
+
*/
|
|
8
|
+
readonly fetchFunctions?: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface SchemaEnumFieldConsistencyOptions {
|
|
12
|
+
/** Names the zod namespace is imported under. */
|
|
13
|
+
readonly zodIdentifiers?: readonly string[];
|
|
14
|
+
/** Field names allowed to be an enum in one schema and a string in another. */
|
|
15
|
+
readonly ignoreFields?: readonly string[];
|
|
16
|
+
/**
|
|
17
|
+
* Regex source. An IMPORTED identifier counts as an enum only when its name
|
|
18
|
+
* matches. Unset, no imported identifier does.
|
|
19
|
+
*/
|
|
20
|
+
readonly enumIdentifierPattern?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface EnvVarSchemaParityOptions {
|
|
24
|
+
/** Path to the env declaration source — a `.env.example` or a zod-env module. Empty = rule is inert. */
|
|
25
|
+
readonly schema?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface RegisteredKeySink {
|
|
29
|
+
/** Dotted callee path whose key argument must be a registered constant (e.g. `localStorage.getItem`). */
|
|
30
|
+
readonly callee: string;
|
|
31
|
+
/** Zero-based index of the key/name argument to police. */
|
|
32
|
+
readonly argIndex: number;
|
|
33
|
+
}
|
|
34
|
+
interface RequireRegisteredKeysOptions {
|
|
35
|
+
/** Sink APIs whose key argument must be an imported constant, not a raw string. Empty = rule is inert. */
|
|
36
|
+
readonly sinks?: readonly RegisteredKeySink[];
|
|
37
|
+
/** Optional module the constants should be imported from, named in the report. */
|
|
38
|
+
readonly registry?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface RestrictThrowToTaxonomyOptions {
|
|
42
|
+
/** Constructor names permitted as throw targets (your error taxonomy). Default `['Error']`. */
|
|
43
|
+
readonly allow?: readonly string[];
|
|
44
|
+
}
|
|
45
|
+
|
|
3
46
|
interface MoneyMustBeDecimalOptions {
|
|
4
47
|
/** Name of the domain money type to require (e.g. `Decimal`, `Money`, `BigDecimal`). */
|
|
5
48
|
readonly decimalType?: string;
|
|
@@ -45,6 +88,27 @@ declare const rules: {
|
|
|
45
88
|
'money-must-be-decimal': _typescript_eslint_utils_ts_eslint.RuleModule<"moneyMustBeDecimal", [MoneyMustBeDecimalOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
46
89
|
name: string;
|
|
47
90
|
};
|
|
91
|
+
'require-error-cause': _typescript_eslint_utils_ts_eslint.RuleModule<"missingCause", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
92
|
+
name: string;
|
|
93
|
+
};
|
|
94
|
+
'restrict-throw-to-taxonomy': _typescript_eslint_utils_ts_eslint.RuleModule<"disallowedErrorClass" | "nonErrorThrow", [RestrictThrowToTaxonomyOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
95
|
+
name: string;
|
|
96
|
+
};
|
|
97
|
+
'require-registered-keys': _typescript_eslint_utils_ts_eslint.RuleModule<"unregisteredKey", [RequireRegisteredKeysOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
98
|
+
name: string;
|
|
99
|
+
};
|
|
100
|
+
'env-var-schema-parity': _typescript_eslint_utils_ts_eslint.RuleModule<"undeclaredEnvVar", [EnvVarSchemaParityOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
101
|
+
name: string;
|
|
102
|
+
};
|
|
103
|
+
'require-schema-parse-at-boundary': _typescript_eslint_utils_ts_eslint.RuleModule<"castedBoundaryData", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
104
|
+
name: string;
|
|
105
|
+
};
|
|
106
|
+
'schema-enum-field-consistency': _typescript_eslint_utils_ts_eslint.RuleModule<"widenedEnumField", [SchemaEnumFieldConsistencyOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
107
|
+
name: string;
|
|
108
|
+
};
|
|
109
|
+
'fetch-must-check-ok': _typescript_eslint_utils_ts_eslint.RuleModule<"missingOkCheck", [FetchMustCheckOkOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
110
|
+
name: string;
|
|
111
|
+
};
|
|
48
112
|
};
|
|
49
113
|
|
|
50
114
|
declare const plugin: {
|
|
@@ -68,6 +132,27 @@ declare const plugin: {
|
|
|
68
132
|
'money-must-be-decimal': _typescript_eslint_utils_ts_eslint.RuleModule<"moneyMustBeDecimal", [MoneyMustBeDecimalOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
69
133
|
name: string;
|
|
70
134
|
};
|
|
135
|
+
'require-error-cause': _typescript_eslint_utils_ts_eslint.RuleModule<"missingCause", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
136
|
+
name: string;
|
|
137
|
+
};
|
|
138
|
+
'restrict-throw-to-taxonomy': _typescript_eslint_utils_ts_eslint.RuleModule<"disallowedErrorClass" | "nonErrorThrow", [RestrictThrowToTaxonomyOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
139
|
+
name: string;
|
|
140
|
+
};
|
|
141
|
+
'require-registered-keys': _typescript_eslint_utils_ts_eslint.RuleModule<"unregisteredKey", [RequireRegisteredKeysOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
142
|
+
name: string;
|
|
143
|
+
};
|
|
144
|
+
'env-var-schema-parity': _typescript_eslint_utils_ts_eslint.RuleModule<"undeclaredEnvVar", [EnvVarSchemaParityOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
145
|
+
name: string;
|
|
146
|
+
};
|
|
147
|
+
'require-schema-parse-at-boundary': _typescript_eslint_utils_ts_eslint.RuleModule<"castedBoundaryData", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
148
|
+
name: string;
|
|
149
|
+
};
|
|
150
|
+
'schema-enum-field-consistency': _typescript_eslint_utils_ts_eslint.RuleModule<"widenedEnumField", [SchemaEnumFieldConsistencyOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
151
|
+
name: string;
|
|
152
|
+
};
|
|
153
|
+
'fetch-must-check-ok': _typescript_eslint_utils_ts_eslint.RuleModule<"missingOkCheck", [FetchMustCheckOkOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
154
|
+
name: string;
|
|
155
|
+
};
|
|
71
156
|
};
|
|
72
157
|
configs: Record<string, unknown>;
|
|
73
158
|
};
|