Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { describe, expect, it } from "vitest";
import { noInlineFractionDigits } from "./no-inline-fraction-digits";
describe("no-inline-fraction-digits", () => {
it("flags inline fraction-digit options", () => {
const src = [
"const f = new Intl.NumberFormat(locale, {",
" minimumFractionDigits: 2,",
" maximumFractionDigits: 4",
"});"
].join("\n");
const violations = noInlineFractionDigits.scan("a.tsx", src);
expect(violations).toHaveLength(2);
expect(violations[0]?.message).toContain("named kind");
});
it("excludes the one file where digits are defined", () => {
const src = "const opts = { maximumFractionDigits: SCALE };";
expect(
noInlineFractionDigits.scan("packages/utils/src/format.ts", src)
).toHaveLength(0);
});
it("does NOT exclude a file that merely consumes a kind", () => {
// Hook files were once listed as exclusions even though they contain no
// digits at all, which exempted whatever got added to them later. A file
// that consumes a kind has nothing to exempt, so it must still be scanned.
const src = "const opts = { maximumFractionDigits: 2 };";
for (const file of [
"apps/erp/app/hooks/usePercentFormatter.tsx",
"apps/erp/app/hooks/useQuantityFormatter.tsx",
"packages/documents/src/utils/shared.ts"
]) {
expect(noInlineFractionDigits.scan(file, src)).toHaveLength(1);
}
});
it("allows named kinds", () => {
const src = "formatOptions={INPUT_FORMAT.percent}";
expect(noInlineFractionDigits.scan("a.tsx", src)).toHaveLength(0);
});
});