@localeguard/core 0.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.
Files changed (43) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +32 -0
  3. package/dist/src/check.d.ts +29 -0
  4. package/dist/src/check.d.ts.map +1 -0
  5. package/dist/src/check.js +175 -0
  6. package/dist/src/check.js.map +1 -0
  7. package/dist/src/flatten.d.ts +10 -0
  8. package/dist/src/flatten.d.ts.map +1 -0
  9. package/dist/src/flatten.js +32 -0
  10. package/dist/src/flatten.js.map +1 -0
  11. package/dist/src/index.d.ts +19 -0
  12. package/dist/src/index.d.ts.map +1 -0
  13. package/dist/src/index.js +43 -0
  14. package/dist/src/index.js.map +1 -0
  15. package/dist/src/json/parse.d.ts +28 -0
  16. package/dist/src/json/parse.d.ts.map +1 -0
  17. package/dist/src/json/parse.js +269 -0
  18. package/dist/src/json/parse.js.map +1 -0
  19. package/dist/src/key-comparator/compare.d.ts +13 -0
  20. package/dist/src/key-comparator/compare.d.ts.map +1 -0
  21. package/dist/src/key-comparator/compare.js +31 -0
  22. package/dist/src/key-comparator/compare.js.map +1 -0
  23. package/dist/src/locale-parser/load.d.ts +19 -0
  24. package/dist/src/locale-parser/load.d.ts.map +1 -0
  25. package/dist/src/locale-parser/load.js +154 -0
  26. package/dist/src/locale-parser/load.js.map +1 -0
  27. package/dist/src/placeholder-validator/placeholder.d.ts +25 -0
  28. package/dist/src/placeholder-validator/placeholder.d.ts.map +1 -0
  29. package/dist/src/placeholder-validator/placeholder.js +99 -0
  30. package/dist/src/placeholder-validator/placeholder.js.map +1 -0
  31. package/dist/src/reporters/json.d.ts +6 -0
  32. package/dist/src/reporters/json.d.ts.map +1 -0
  33. package/dist/src/reporters/json.js +16 -0
  34. package/dist/src/reporters/json.js.map +1 -0
  35. package/dist/src/reporters/text.d.ts +10 -0
  36. package/dist/src/reporters/text.d.ts.map +1 -0
  37. package/dist/src/reporters/text.js +78 -0
  38. package/dist/src/reporters/text.js.map +1 -0
  39. package/dist/src/types.d.ts +92 -0
  40. package/dist/src/types.d.ts.map +1 -0
  41. package/dist/src/types.js +35 -0
  42. package/dist/src/types.js.map +1 -0
  43. package/package.json +37 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/reporters/json.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAYtD"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /**
3
+ * Machine-readable JSON reporter, suitable for piping into other tooling.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.formatJson = formatJson;
7
+ function formatJson(result) {
8
+ return JSON.stringify({
9
+ schemaVersion: 1,
10
+ tool: "localeguard",
11
+ stats: result.stats,
12
+ missingLocales: result.missingLocales,
13
+ issues: result.issues,
14
+ }, null, 2);
15
+ }
16
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/reporters/json.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAIH,gCAYC;AAZD,SAAgB,UAAU,CAAC,MAAmB;IAC5C,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,aAAa,EAAE,CAAC;QAChB,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Human-readable terminal reporter.
3
+ */
4
+ import type { CheckResult } from "../types";
5
+ export interface TextReporterOptions {
6
+ /** Emit ANSI color codes. */
7
+ color?: boolean;
8
+ }
9
+ export declare function formatText(result: CheckResult, opts?: TextReporterOptions): string;
10
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/reporters/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAS,MAAM,UAAU,CAAC;AAEnD,MAAM,WAAW,mBAAmB;IAClC,6BAA6B;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAYD,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,GAAE,mBAAwB,GAAG,MAAM,CAmDtF"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /**
3
+ * Human-readable terminal reporter.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.formatText = formatText;
7
+ const ANSI = {
8
+ reset: "",
9
+ bold: "",
10
+ dim: "",
11
+ red: "",
12
+ green: "",
13
+ yellow: "",
14
+ cyan: "",
15
+ };
16
+ function formatText(result, opts = {}) {
17
+ const color = opts.color ?? false;
18
+ const c = (code, text) => (color ? `${code}${text}${ANSI.reset}` : text);
19
+ const lines = [];
20
+ lines.push(c(ANSI.bold, "LocaleGuard"));
21
+ lines.push("");
22
+ lines.push(`${c(ANSI.green, "✓")} ${result.stats.sourceLocale} reference locale loaded ` +
23
+ c(ANSI.dim, `(${result.stats.sourceKeyCount} keys)`));
24
+ if (result.issues.length === 0) {
25
+ lines.push("");
26
+ lines.push(c(ANSI.green, "✓ Localization check passed."));
27
+ return lines.join("\n");
28
+ }
29
+ // Group issues by locale (issues without a locale go under "general").
30
+ const groups = new Map();
31
+ for (const issue of result.issues) {
32
+ const key = issue.locale ?? "general";
33
+ const list = groups.get(key) ?? [];
34
+ list.push(issue);
35
+ groups.set(key, list);
36
+ }
37
+ for (const [locale, group] of groups) {
38
+ lines.push("");
39
+ lines.push(c(ANSI.bold, locale === "general" ? "general" : locale));
40
+ for (const issue of group) {
41
+ const symbol = issue.severity === "error" ? c(ANSI.red, "✗") : c(ANSI.yellow, "⚠");
42
+ const where = issue.line ? `${issue.file}:${issue.line}` : issue.file;
43
+ const tag = c(ANSI.dim, `[${issue.type}]`);
44
+ lines.push(` ${symbol} ${c(ANSI.cyan, where)} ${tag} ${issue.message}`);
45
+ if (issue.suggestion) {
46
+ lines.push(` ${c(ANSI.dim, `→ ${issue.suggestion}`)}`);
47
+ }
48
+ }
49
+ }
50
+ lines.push("");
51
+ lines.push(summaryLine(result, c));
52
+ lines.push("");
53
+ lines.push(result.stats.failed
54
+ ? c(ANSI.red, "Localization check failed.")
55
+ : c(ANSI.green, "Localization check passed (warnings only)."));
56
+ return lines.join("\n");
57
+ }
58
+ function summaryLine(result, c) {
59
+ const t = result.stats.byType;
60
+ const parts = [];
61
+ if (t["missing-key"])
62
+ parts.push(`${t["missing-key"]} missing`);
63
+ if (t["extra-key"])
64
+ parts.push(`${t["extra-key"]} extra`);
65
+ if (t["placeholder-mismatch"])
66
+ parts.push(`${t["placeholder-mismatch"]} interpolation`);
67
+ if (t["duplicate-key"])
68
+ parts.push(`${t["duplicate-key"]} duplicate`);
69
+ if (t["invalid-json"])
70
+ parts.push(`${t["invalid-json"]} invalid-json`);
71
+ if (t["hardcoded-string"])
72
+ parts.push(`${t["hardcoded-string"]} hardcoded-text`);
73
+ if (t["hardcoded-attribute"])
74
+ parts.push(`${t["hardcoded-attribute"]} hardcoded-attr`);
75
+ const detail = parts.length ? parts.join(", ") : "no issues";
76
+ return c(ANSI.bold, "Summary: ") + detail;
77
+ }
78
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/reporters/text.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAmBH,gCAmDC;AA7DD,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,OAAO;IACZ,KAAK,EA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AC,cAAc,CAAC,eAAe,CAAC,CAAC;IACvE,IAAI,CAAC,CAAC,kBAAkB,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;IACjF,IAAI,CAAC,CAAC,qBAAqB,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IAC7D,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Shared type definitions for LocaleGuard's core checks.
3
+ */
4
+ export type JsonPrimitive = string | number | boolean | null;
5
+ export type JsonValue = JsonPrimitive | JsonValue[] | {
6
+ [key: string]: JsonValue;
7
+ };
8
+ export type IssueSeverity = "error" | "warning";
9
+ /**
10
+ * The categories of problems LocaleGuard can detect.
11
+ * - Locale-file checks: invalid-json, missing-key, extra-key, duplicate-key,
12
+ * placeholder-mismatch.
13
+ * - Source-code checks (Phase 2): hardcoded-string, hardcoded-attribute.
14
+ */
15
+ export type IssueType = "invalid-json" | "missing-key" | "extra-key" | "duplicate-key" | "placeholder-mismatch" | "hardcoded-string" | "hardcoded-attribute";
16
+ /** Every issue type, in display order. */
17
+ export declare const ISSUE_TYPES: IssueType[];
18
+ export interface Issue {
19
+ type: IssueType;
20
+ severity: IssueSeverity;
21
+ /** Target locale the issue concerns (omitted for source-only issues). */
22
+ locale?: string;
23
+ /** Namespace (file basename) when locales are split into multiple files. */
24
+ namespace?: string;
25
+ /** Flattened, dot-delimited key path the issue concerns. */
26
+ key?: string;
27
+ /** Path to the file the issue was found in, relative to the project root. */
28
+ file: string;
29
+ /** 1-based line number within `file`, when known. */
30
+ line?: number;
31
+ message: string;
32
+ /** Actionable remediation hint shown in reports. */
33
+ suggestion?: string;
34
+ }
35
+ export interface LocaleGuardConfig {
36
+ /** Reference locale every other locale is compared against. */
37
+ sourceLocale: string;
38
+ /** Target locales to validate. */
39
+ locales: string[];
40
+ /** Directory holding locale files, relative to the project root. */
41
+ localesPath: string;
42
+ /** Glob patterns of source files to analyze (defaults to src/**\/*.{ts,tsx}). */
43
+ include?: string[];
44
+ /** Translation function names, e.g. "t", "i18n.t" (used by code analysis). */
45
+ translationFunctions?: string[];
46
+ /** Translation component names, e.g. "Trans" (text inside is not flagged). */
47
+ translationComponents?: string[];
48
+ /** Glob patterns to exclude from code analysis. */
49
+ ignore?: string[];
50
+ /** Issue types that should fail the check (non-zero exit). */
51
+ blockOn?: IssueType[];
52
+ }
53
+ /** A single translation entry resolved from a locale file. */
54
+ export interface LocaleEntry {
55
+ value: JsonValue;
56
+ file: string;
57
+ line: number;
58
+ }
59
+ /** All entries for one locale, keyed by `namespace:flatKey` (or `flatKey`). */
60
+ export interface LoadedLocale {
61
+ locale: string;
62
+ /** Map of fully-qualified key -> entry. */
63
+ entries: Map<string, LocaleEntry>;
64
+ /** Issues encountered while loading (invalid JSON, duplicate keys). */
65
+ issues: Issue[];
66
+ /** Whether any locale file was found for this locale. */
67
+ found: boolean;
68
+ }
69
+ export interface CheckStats {
70
+ sourceLocale: string;
71
+ sourceKeyCount: number;
72
+ byType: Record<IssueType, number>;
73
+ byLocale: Record<string, {
74
+ missing: number;
75
+ extra: number;
76
+ placeholder: number;
77
+ }>;
78
+ errorCount: number;
79
+ warningCount: number;
80
+ /** True when at least one issue matches a `blockOn` type. */
81
+ failed: boolean;
82
+ }
83
+ export interface CheckResult {
84
+ issues: Issue[];
85
+ stats: CheckStats;
86
+ /** Locales that had no files on disk. */
87
+ missingLocales: string[];
88
+ }
89
+ export declare const DEFAULT_BLOCK_ON: IssueType[];
90
+ /** Fixed severity per issue type for this release. */
91
+ export declare const SEVERITY_BY_TYPE: Record<IssueType, IssueSeverity>;
92
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEnF,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GACjB,cAAc,GACd,aAAa,GACb,WAAW,GACX,eAAe,GACf,sBAAsB,GACtB,kBAAkB,GAClB,qBAAqB,CAAC;AAE1B,0CAA0C;AAC1C,eAAO,MAAM,WAAW,EAAE,SAAS,EAQlC,CAAC;AAEF,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,aAAa,CAAC;IACxB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,OA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,EAAE,SAAS,EAKvC,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,SAAS,EAAE,aAAa,CAU7D,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * Shared type definitions for LocaleGuard's core checks.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SEVERITY_BY_TYPE = exports.DEFAULT_BLOCK_ON = exports.ISSUE_TYPES = void 0;
7
+ /** Every issue type, in display order. */
8
+ exports.ISSUE_TYPES = [
9
+ "invalid-json",
10
+ "duplicate-key",
11
+ "missing-key",
12
+ "extra-key",
13
+ "placeholder-mismatch",
14
+ "hardcoded-string",
15
+ "hardcoded-attribute",
16
+ ];
17
+ exports.DEFAULT_BLOCK_ON = [
18
+ "invalid-json",
19
+ "missing-key",
20
+ "duplicate-key",
21
+ "placeholder-mismatch",
22
+ ];
23
+ /** Fixed severity per issue type for this release. */
24
+ exports.SEVERITY_BY_TYPE = {
25
+ "invalid-json": "error",
26
+ "missing-key": "error",
27
+ "extra-key": "warning",
28
+ "duplicate-key": "error",
29
+ "placeholder-mismatch": "error",
30
+ // Hardcoded text is reported but non-blocking by default: it is more
31
+ // prone to false positives, so teams opt in via `blockOn`.
32
+ "hardcoded-string": "warning",
33
+ "hardcoded-attribute": "warning",
34
+ };
35
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAsBH,0CAA0C;AAC7B,QAAA,WAAW,GAAgB;IACtC,cAAc;IACd,eAAe;IACf,aAAa;IACb,WAAW;IACX,sBAAsB;IACtB,kBAAkB;IAClB,qBAAqB;CACtB,CAAC;AA2EW,QAAA,gBAAgB,GAAgB;IAC3C,cAAc;IACd,aAAa;IACb,eAAe;IACf,sBAAsB;CACvB,CAAC;AAEF,sDAAsD;AACzC,QAAA,gBAAgB,GAAqC;IAChE,cAAc,EAAE,OAAO;IACvB,aAAa,EAAE,OAAO;IACtB,WAAW,EAAE,SAAS;IACtB,eAAe,EAAE,OAAO;IACxB,sBAAsB,EAAE,OAAO;IAC/B,qEAAqE;IACrE,2DAA2D;IAC3D,kBAAkB,EAAE,SAAS;IAC7B,qBAAqB,EAAE,SAAS;CACjC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@localeguard/core",
3
+ "version": "0.1.0",
4
+ "description": "Core localization checks for LocaleGuard: locale parsing, key comparison, and interpolation validation.",
5
+ "license": "Apache-2.0",
6
+ "author": "isamrish",
7
+ "homepage": "https://github.com/isamrish/localeguard/tree/main/packages/core#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/isamrish/localeguard.git",
11
+ "directory": "packages/core"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/isamrish/localeguard/issues"
15
+ },
16
+ "main": "dist/src/index.js",
17
+ "types": "dist/src/index.d.ts",
18
+ "files": [
19
+ "dist/src"
20
+ ],
21
+ "engines": {
22
+ "node": ">=18"
23
+ },
24
+ "scripts": {
25
+ "prepublishOnly": "tsc -b"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "keywords": [
31
+ "localization",
32
+ "i18n",
33
+ "react-i18next",
34
+ "linter",
35
+ "translations"
36
+ ]
37
+ }