@noctcore/eslint-plugin-contracts 0.3.0 → 0.4.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.d.cts CHANGED
@@ -1,5 +1,61 @@
1
1
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
2
 
3
+ /**
4
+ * Translation catalog loading for the i18n rules.
5
+ *
6
+ * A catalog is a JSON file (or a subtree of one) that holds the keys of ONE
7
+ * namespace. Projects lay catalogs out in a handful of shapes, and a
8
+ * `CatalogSource` describes each of them without the rule knowing any project:
9
+ *
10
+ * one file per namespace `{ file: 'locales/en/{ns}.json' }`
11
+ * one file, ns at the top `{ file: 'locales/en.json', keyPath: '{ns}' }`
12
+ * a fixed file for one ns `{ file: 'src/i18n/en.json', namespace: 'common' }`
13
+ * single-namespace app `{ file: 'src/i18n/en.json' }` (the default namespace)
14
+ *
15
+ * `{ns}` is substituted with the namespace being resolved. A templated source
16
+ * whose file or subtree does not exist simply does not supply that namespace;
17
+ * a FIXED source that cannot be read is a configuration error and is surfaced.
18
+ */
19
+ interface CatalogSource {
20
+ /** JSON catalog path, relative to the ESLint cwd. May contain `{ns}`. */
21
+ readonly file: string;
22
+ /** Namespace a fixed (non-templated) source supplies. Defaults to the default namespace. */
23
+ readonly namespace?: string;
24
+ /** Dot-separated subtree inside the file holding the namespace's keys. May contain `{ns}`. */
25
+ readonly keyPath?: string;
26
+ }
27
+
28
+ interface TranslationKeyExistsOptions {
29
+ /** Where each namespace's catalog lives. Empty = rule is inert. */
30
+ readonly catalogs?: readonly CatalogSource[];
31
+ /** The namespace an unqualified `useTranslation()` / `i18n.t` resolves to (i18next `defaultNS`). */
32
+ readonly defaultNamespace?: string;
33
+ /** Namespaces searched after the bound ones (i18next `fallbackNS`). */
34
+ readonly fallbackNamespaces?: readonly string[];
35
+ /** Hooks returning a namespace-bound `t` (`useTranslation`). */
36
+ readonly hooks?: readonly string[];
37
+ /** i18next instance identifiers: `<instance>.t(...)`, `<instance>.getFixedT(...)`. */
38
+ readonly instances?: readonly string[];
39
+ /** Free translation functions bound to the default namespace when imported or global (`t`). */
40
+ readonly functions?: readonly string[];
41
+ /** Type names whose first type argument names a parameter's namespace (`TFunction<'ns'>`). */
42
+ readonly typeNames?: readonly string[];
43
+ /** JSX components taking an `i18nKey` prop (`Trans`). */
44
+ readonly transComponents?: readonly string[];
45
+ /** Identifiers holding a namespace name that live in another module (`{ HELP_NS: 'help' }`). */
46
+ readonly namespaceIdentifiers?: Readonly<Record<string, string>>;
47
+ /** i18next `nsSeparator`; `false` disables `ns:key` parsing. */
48
+ readonly nsSeparator?: string | false;
49
+ /** i18next `keySeparator`; `false` means flat catalogs. */
50
+ readonly keySeparator?: string | false;
51
+ /** i18next `pluralSeparator`. */
52
+ readonly pluralSeparator?: string;
53
+ /** i18next `contextSeparator`. */
54
+ readonly contextSeparator?: string;
55
+ /** `ignore` stays silent on template keys; `check-prefix` requires their static head to exist. */
56
+ readonly dynamicKeys?: 'ignore' | 'check-prefix';
57
+ }
58
+
3
59
  interface FetchMustCheckOkOptions {
4
60
  /**
5
61
  * Callees whose result is a `Response`: a bare name (`fetch`) or a dotted path
@@ -109,6 +165,9 @@ declare const rules: {
109
165
  'fetch-must-check-ok': _typescript_eslint_utils_ts_eslint.RuleModule<"missingOkCheck", [FetchMustCheckOkOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
110
166
  name: string;
111
167
  };
168
+ 'translation-key-exists': _typescript_eslint_utils_ts_eslint.RuleModule<"missingKey" | "missingKeyPrefix" | "unknownNamespace" | "catalogUnreadable", [TranslationKeyExistsOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
169
+ name: string;
170
+ };
112
171
  };
113
172
 
114
173
  declare const plugin: {
@@ -153,6 +212,9 @@ declare const plugin: {
153
212
  'fetch-must-check-ok': _typescript_eslint_utils_ts_eslint.RuleModule<"missingOkCheck", [FetchMustCheckOkOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
154
213
  name: string;
155
214
  };
215
+ 'translation-key-exists': _typescript_eslint_utils_ts_eslint.RuleModule<"missingKey" | "missingKeyPrefix" | "unknownNamespace" | "catalogUnreadable", [TranslationKeyExistsOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
216
+ name: string;
217
+ };
156
218
  };
157
219
  configs: Record<string, unknown>;
158
220
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,61 @@
1
1
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
2
 
3
+ /**
4
+ * Translation catalog loading for the i18n rules.
5
+ *
6
+ * A catalog is a JSON file (or a subtree of one) that holds the keys of ONE
7
+ * namespace. Projects lay catalogs out in a handful of shapes, and a
8
+ * `CatalogSource` describes each of them without the rule knowing any project:
9
+ *
10
+ * one file per namespace `{ file: 'locales/en/{ns}.json' }`
11
+ * one file, ns at the top `{ file: 'locales/en.json', keyPath: '{ns}' }`
12
+ * a fixed file for one ns `{ file: 'src/i18n/en.json', namespace: 'common' }`
13
+ * single-namespace app `{ file: 'src/i18n/en.json' }` (the default namespace)
14
+ *
15
+ * `{ns}` is substituted with the namespace being resolved. A templated source
16
+ * whose file or subtree does not exist simply does not supply that namespace;
17
+ * a FIXED source that cannot be read is a configuration error and is surfaced.
18
+ */
19
+ interface CatalogSource {
20
+ /** JSON catalog path, relative to the ESLint cwd. May contain `{ns}`. */
21
+ readonly file: string;
22
+ /** Namespace a fixed (non-templated) source supplies. Defaults to the default namespace. */
23
+ readonly namespace?: string;
24
+ /** Dot-separated subtree inside the file holding the namespace's keys. May contain `{ns}`. */
25
+ readonly keyPath?: string;
26
+ }
27
+
28
+ interface TranslationKeyExistsOptions {
29
+ /** Where each namespace's catalog lives. Empty = rule is inert. */
30
+ readonly catalogs?: readonly CatalogSource[];
31
+ /** The namespace an unqualified `useTranslation()` / `i18n.t` resolves to (i18next `defaultNS`). */
32
+ readonly defaultNamespace?: string;
33
+ /** Namespaces searched after the bound ones (i18next `fallbackNS`). */
34
+ readonly fallbackNamespaces?: readonly string[];
35
+ /** Hooks returning a namespace-bound `t` (`useTranslation`). */
36
+ readonly hooks?: readonly string[];
37
+ /** i18next instance identifiers: `<instance>.t(...)`, `<instance>.getFixedT(...)`. */
38
+ readonly instances?: readonly string[];
39
+ /** Free translation functions bound to the default namespace when imported or global (`t`). */
40
+ readonly functions?: readonly string[];
41
+ /** Type names whose first type argument names a parameter's namespace (`TFunction<'ns'>`). */
42
+ readonly typeNames?: readonly string[];
43
+ /** JSX components taking an `i18nKey` prop (`Trans`). */
44
+ readonly transComponents?: readonly string[];
45
+ /** Identifiers holding a namespace name that live in another module (`{ HELP_NS: 'help' }`). */
46
+ readonly namespaceIdentifiers?: Readonly<Record<string, string>>;
47
+ /** i18next `nsSeparator`; `false` disables `ns:key` parsing. */
48
+ readonly nsSeparator?: string | false;
49
+ /** i18next `keySeparator`; `false` means flat catalogs. */
50
+ readonly keySeparator?: string | false;
51
+ /** i18next `pluralSeparator`. */
52
+ readonly pluralSeparator?: string;
53
+ /** i18next `contextSeparator`. */
54
+ readonly contextSeparator?: string;
55
+ /** `ignore` stays silent on template keys; `check-prefix` requires their static head to exist. */
56
+ readonly dynamicKeys?: 'ignore' | 'check-prefix';
57
+ }
58
+
3
59
  interface FetchMustCheckOkOptions {
4
60
  /**
5
61
  * Callees whose result is a `Response`: a bare name (`fetch`) or a dotted path
@@ -109,6 +165,9 @@ declare const rules: {
109
165
  'fetch-must-check-ok': _typescript_eslint_utils_ts_eslint.RuleModule<"missingOkCheck", [FetchMustCheckOkOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
110
166
  name: string;
111
167
  };
168
+ 'translation-key-exists': _typescript_eslint_utils_ts_eslint.RuleModule<"missingKey" | "missingKeyPrefix" | "unknownNamespace" | "catalogUnreadable", [TranslationKeyExistsOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
169
+ name: string;
170
+ };
112
171
  };
113
172
 
114
173
  declare const plugin: {
@@ -153,6 +212,9 @@ declare const plugin: {
153
212
  'fetch-must-check-ok': _typescript_eslint_utils_ts_eslint.RuleModule<"missingOkCheck", [FetchMustCheckOkOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
154
213
  name: string;
155
214
  };
215
+ 'translation-key-exists': _typescript_eslint_utils_ts_eslint.RuleModule<"missingKey" | "missingKeyPrefix" | "unknownNamespace" | "catalogUnreadable", [TranslationKeyExistsOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
216
+ name: string;
217
+ };
156
218
  };
157
219
  configs: Record<string, unknown>;
158
220
  };