@multiplatform.one/config 8.2.1 → 8.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.
Files changed (2) hide show
  1. package/design-lint.mjs +34 -1
  2. package/package.json +2 -2
package/design-lint.mjs CHANGED
@@ -2012,6 +2012,39 @@ function offendersOf(scan, base) {
2012
2012
  return offenders;
2013
2013
  }
2014
2014
 
2015
+ // FZ-10697: a regenerated baseline has to be a file oxfmt leaves alone, or
2016
+ // every lane that lowers the ratchet fails `scripts/format-changed.sh` and has
2017
+ // to hand-run the formatter. JSON.stringify's indent puts every array element
2018
+ // on its own line; oxfmt prints an array on one line whenever the whole line
2019
+ // fits in 100 columns, counting a trailing comma, and leaves objects expanded.
2020
+ const printWidth = 100;
2021
+ function renderJson(node, indent, column, comma) {
2022
+ if (Array.isArray(node)) {
2023
+ if (!node.length) return "[]";
2024
+ const flat = node.every((item) => !item || typeof item !== "object");
2025
+ const inline = `[${node.map((item) => renderJson(item, 0, 0, 0)).join(", ")}]`;
2026
+ if (flat && column + inline.length + comma <= printWidth) return inline;
2027
+ const pad = " ".repeat(indent + 2);
2028
+ const items = node.map(
2029
+ (item, at) => pad + renderJson(item, indent + 2, pad.length, at === node.length - 1 ? 0 : 1),
2030
+ );
2031
+ return `[\n${items.join(",\n")}\n${" ".repeat(indent)}]`;
2032
+ }
2033
+ if (node && typeof node === "object") {
2034
+ const entries = Object.entries(node).filter(([, item]) => item !== undefined);
2035
+ if (!entries.length) return "{}";
2036
+ const pad = " ".repeat(indent + 2);
2037
+ const lines = entries.map(([key, item], at) => {
2038
+ const head = `${pad}${JSON.stringify(key)}: `;
2039
+ return head + renderJson(item, indent + 2, head.length, at === entries.length - 1 ? 0 : 1);
2040
+ });
2041
+ return `{\n${lines.join(",\n")}\n${" ".repeat(indent)}}`;
2042
+ }
2043
+ return JSON.stringify(node) ?? "null";
2044
+ }
2045
+
2046
+ export const formatBaseline = (value) => `${renderJson(value, 0, 0, 0)}\n`;
2047
+
2015
2048
  function ratchet(file, options) {
2016
2049
  const real = (input) => (existsSync(input) ? realpathSync(input) : path.resolve(input));
2017
2050
  const base = real(path.dirname(path.resolve(file)));
@@ -2056,7 +2089,7 @@ function ratchet(file, options) {
2056
2089
  rules: Object.fromEntries(Object.entries(scan.rules).sort()),
2057
2090
  offenders: offendersOf(scan, base),
2058
2091
  };
2059
- const write = () => writeFileSync(file, `${JSON.stringify(next, null, 2)}\n`);
2092
+ const write = () => writeFileSync(file, formatBaseline(next));
2060
2093
  if (!previous) {
2061
2094
  write();
2062
2095
  process.stdout.write(`MPO design guard: ${file} created at ${summary(scan)}.\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/config",
3
- "version": "8.2.1",
3
+ "version": "8.3.0",
4
4
  "description": "Shared build and test configuration presets for multiplatform.one",
5
5
  "keywords": [
6
6
  "config",
@@ -122,7 +122,7 @@
122
122
  "@babel/parser": "^7.29.9",
123
123
  "@babel/plugin-transform-block-scoping": "^7.29.7",
124
124
  "@babel/traverse": "^7.29.10",
125
- "@multiplatform.one/utils": "^8.2.1",
125
+ "@multiplatform.one/utils": "^8.3.0",
126
126
  "@tamagui/vite-plugin": "2.7.6",
127
127
  "@vitejs/plugin-react": "^6.1.2",
128
128
  "dotenv": "^17.4.2",