melta-app 0.5.1 → 0.5.2
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 +34 -5
- package/docs/patterns.md +2 -0
- package/eslint-rules/melta.mjs +98 -0
- package/llms.txt +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ export default function App() {
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
テーマは `ThemeProvider` が OS の light / dark に自動追従(`forcedMode` で固定も可)。トークンは `useTheme()` / `nativeTheme`
|
|
39
|
+
テーマは `ThemeProvider` が OS の light / dark に自動追従(`forcedMode` で固定も可)。トークンは `useTheme()` / `nativeTheme` から取れる。本体エントリ以外は subpath 3 つ([Icon](#subpath-エントリ-iconmelta-appicons) / [SafeArea 差替](#safearea-の差し替えmelta-appsafe-area) / [lint plugin](#lint-pluginmelta-appeslint-plugin))。
|
|
40
40
|
|
|
41
41
|
### ブランドテーマを注入する
|
|
42
42
|
|
|
@@ -221,9 +221,10 @@ npm run ios # または android / web
|
|
|
221
221
|
| tooltip | — | 🚫 not-planned | — | hover 前提のため。iPhone HIG に tooltip 概念なし。必要になれば長押し Hint として別契約を切る |
|
|
222
222
|
<!-- END GENERATED: component-status -->
|
|
223
223
|
|
|
224
|
-
###
|
|
224
|
+
### subpath エントリ: Icon(`melta-app/icons`)
|
|
225
225
|
|
|
226
|
-
Icon
|
|
226
|
+
subpath は Icon / SafeArea 差替(`melta-app/safe-area`)/ lint plugin(`melta-app/eslint-plugin`)の 3 つ。
|
|
227
|
+
このうち Icon は唯一 `react-native-svg`(optional peerDependency)に依存するため、本体エントリから分離している。
|
|
227
228
|
本体 `melta-app` は依存ゼロのまま — Icon を使うアプリだけが以下を行う:
|
|
228
229
|
|
|
229
230
|
```bash
|
|
@@ -272,18 +273,46 @@ enableSafeAreaContext({ edges: ["top"] });
|
|
|
272
273
|
- safe-area と合成する padding は**数値のみ**サポート(`"5%"` 等の非数値は基底として扱えず、
|
|
273
274
|
対象 edge は inset 値に置き換わる)。RTL / `paddingStart`・`paddingEnd` は対応済み
|
|
274
275
|
|
|
276
|
+
### lint plugin(`melta-app/eslint-plugin`)
|
|
277
|
+
|
|
278
|
+
melta 契約からの逸脱を機械検知する eslint カスタムルール 4 本を同梱している。
|
|
279
|
+
消費者プロジェクトの flat config に組み込むと、生値の直書きが lint で止まる:
|
|
280
|
+
|
|
281
|
+
```js
|
|
282
|
+
// eslint.config.mjs
|
|
283
|
+
import { meltaPlugin } from "melta-app/eslint-plugin";
|
|
284
|
+
|
|
285
|
+
export default [
|
|
286
|
+
{
|
|
287
|
+
plugins: { melta: meltaPlugin },
|
|
288
|
+
rules: {
|
|
289
|
+
"melta/no-raw-color": "error", // 生 hex/rgb/hsl → theme.color.*
|
|
290
|
+
"melta/no-raw-radius": "error", // borderRadius 数値直書き → theme.radius.*
|
|
291
|
+
"melta/no-raw-spacing": "warn", // padding/margin/gap 数値直書き(false positive あり)
|
|
292
|
+
"melta/no-raw-fontsize": "warn", // fontSize 数値直書き
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
];
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
- 依存ゼロの自己完結 ESM(eslint 本体以外に何も要らない)。ESLint 9+ の flat config を想定(このリポでは 10.x で検証)
|
|
299
|
+
- `meltaPlugin` は **named export のみ**(default export なし)
|
|
300
|
+
- 検知は AST の構文形状ベースの補助線。変数経由・spread は漏れるので、値の純度の本丸は
|
|
301
|
+
token 経由(`theme.*`)で書く習慣の側にある
|
|
302
|
+
|
|
275
303
|
## ステータス
|
|
276
304
|
|
|
277
305
|
- ✅ ライブラリ化(root=ライブラリ / example=カタログアプリ、peerDeps react + react-native、runtime deps ゼロ)
|
|
278
306
|
- ✅ `melta-contracts` を npm 依存として購読(recipes/app の styleRefs 同梱)
|
|
279
307
|
- ✅ conformance: 契約源 ↔ 生成メタ ↔ `__contract` 宣言の照合 + consumer テスト(契約 subset / token 実在 / contractVersion 同期)+ styleRefs conformance(全実装コンポーネント展開済み)+ RN mount smoke(light/dark × 全公開コンポーネント)
|
|
280
|
-
- ✅ ハーネス: design lint(CI `--max-warnings 0` + PostToolUse hook)/ drift 検査(README・catalog・allowlist 突合)/ installability ゲート(pack → install → import →
|
|
308
|
+
- ✅ ハーネス: design lint(CI `--max-warnings 0` + PostToolUse hook)/ drift 検査(README・catalog・allowlist 突合)/ installability ゲート(pack → tarball 実体検査 → fixture へ install → 本体 / icons / safe-area の import + typecheck → eslint plugin を実 import してルール 4 本の実在を照合 → exports の解決先確認。`npm run release` チェーンの必須ステップ)
|
|
281
309
|
- ✅ layout 6 個(Stack / Row / Screen / Header / Icon / Avatar)— dogfood 不足 1〜4 を解消、ProjectFeedScreen は公開 primitive だけで構成
|
|
282
310
|
- Screen の SafeArea は adapter registry 化済み: default は RN core SafeAreaView(依存ゼロ維持)、`melta-app/safe-area` の `enableSafeAreaContext()` で react-native-safe-area-context に差し替え可(optional peer)
|
|
283
311
|
- ✅ form / feedback 10 個(TextField / Toggle / Checkbox / Radio / Alert / Toast / Progress / Modal / ActionSheet / BottomSheet)— checkbox / radio は Pressable + 描画(svg 非依存)、ActionSheet / BottomSheet は select / dropdown の adapted 変換先の受け皿
|
|
284
312
|
- ✅ showcase(https://app.melta.tsubotax.com — melta-ui 様式シェル + 実 RN カタログの Live 埋め込み。表・統計は契約からビルド時生成)
|
|
285
313
|
- ✅ AI 入口: [llms.txt](https://app.melta.tsubotax.com/llms.txt)(契約から生成・drift 検査対象)+ [docs/patterns.md](docs/patterns.md)(フォームの組み方規範。スニペットは実コードと機械同期)
|
|
286
|
-
- ✅
|
|
314
|
+
- ✅ lint 強制層の npm 配布(0.5.2): `melta-app/eslint-plugin` を公開 subpath 化。消費者プロジェクトの flat config に組めば、生値の直書きが消費者側でも lint で止まる
|
|
315
|
+
- ✅ [npm publish(0.5.2)](https://www.npmjs.com/package/melta-app)
|
|
287
316
|
- ⬜ React Native Directory 登録([PR #2606](https://github.com/react-native-community/directory/pull/2606) レビュー待ち)
|
|
288
317
|
|
|
289
318
|
詳細は D2I リポの `.team/specs/requirements-melta-app.md`。
|
package/docs/patterns.md
CHANGED
|
@@ -261,3 +261,5 @@ form ライブラリを DS として強制しない。素の React で必要十
|
|
|
261
261
|
| disabled-until-valid の常用 | 「なぜ押せないか」を伝えられない。常時活性 + submit 時全量検証 + サマリー Alert |
|
|
262
262
|
| placeholder をラベル代わりにする | 入力を始めた瞬間に文脈が消える。placeholder は例示専用 |
|
|
263
263
|
| 生値スタイル(hex / 数値 spacing 直書き) | lint(--max-warnings 0)が落とす。`theme.color.*` / `theme.spacing[*]` 経由のみ |
|
|
264
|
+
|
|
265
|
+
※ この lint はこのリポジトリ専用ではない。消費者プロジェクトでも `melta-app/eslint-plugin` を flat config に組めば(`plugins: { melta: meltaPlugin }` + `melta/no-raw-color` 等)、同じルールが同じように効く。設定は README の「lint plugin」節を参照。
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* melta design lint ルール(設計書 §5、D-1)。
|
|
3
|
+
*
|
|
4
|
+
* RN で機械検知できる raw 値の 4 類型のみを対象とする補助線(AST 検知は変数経由/spread で漏れるので
|
|
5
|
+
* 純度の本丸は A-3 conformance)。token 経由(theme.* の MemberExpression)は許可、生値を弾く。
|
|
6
|
+
*
|
|
7
|
+
* - no-raw-color : hex/rgb/hsl の文字列リテラル → error
|
|
8
|
+
* - no-raw-radius : borderRadius 系プロパティに数値リテラル直書き → error
|
|
9
|
+
* - no-raw-spacing : padding/margin/gap 系に数値リテラル直書き → warn(false positive 多)
|
|
10
|
+
* - no-raw-fontsize: fontSize に数値リテラル直書き → warn
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const COLOR_RE = /#[0-9a-fA-F]{3,8}\b|\brgba?\s*\(|\bhsla?\s*\(/;
|
|
14
|
+
// RN の特殊カラーキーワードは token 化対象外として許可する(subtle variant の背景透明など)。
|
|
15
|
+
const SAFE_COLORS = new Set(["transparent", "currentColor", "inherit", "none"]);
|
|
16
|
+
|
|
17
|
+
/** Property の key 名を取る(Identifier / 文字列 Literal の両対応)。 */
|
|
18
|
+
function keyName(node) {
|
|
19
|
+
if (!node.key) return null;
|
|
20
|
+
if (node.key.type === "Identifier") return node.key.name;
|
|
21
|
+
if (node.key.type === "Literal" && typeof node.key.value === "string") return node.key.value;
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** value が数値リテラル直書きか(負数 UnaryExpression も拾う)。token 由来の MemberExpression は false。 */
|
|
26
|
+
function isRawNumber(value) {
|
|
27
|
+
if (!value) return false;
|
|
28
|
+
if (value.type === "Literal" && typeof value.value === "number") return true;
|
|
29
|
+
if (value.type === "UnaryExpression" && value.operator === "-") return isRawNumber(value.argument);
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const isRadiusKey = (k) => typeof k === "string" && /^border([A-Za-z]*)Radius$/.test(k);
|
|
34
|
+
const isSpacingKey = (k) =>
|
|
35
|
+
typeof k === "string" &&
|
|
36
|
+
(/^(padding|margin)([A-Za-z]*)?$/.test(k) || k === "gap" || k === "rowGap" || k === "columnGap");
|
|
37
|
+
|
|
38
|
+
export const meltaPlugin = {
|
|
39
|
+
rules: {
|
|
40
|
+
"no-raw-color": {
|
|
41
|
+
meta: { type: "problem", docs: { description: "色は theme.color.* を使う(生 hex/rgb/hsl 禁止)" } },
|
|
42
|
+
create(context) {
|
|
43
|
+
const check = (node, text) => {
|
|
44
|
+
if (typeof text === "string" && !SAFE_COLORS.has(text) && COLOR_RE.test(text)) {
|
|
45
|
+
context.report({ node, message: `生の色 "${text}" は禁止。theme.color.* を使う。` });
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
Literal(node) {
|
|
50
|
+
check(node, node.value);
|
|
51
|
+
},
|
|
52
|
+
// テンプレートリテラル内の生色も拾う(`#fff` や `rgb(...)` を quasi に直書きするケース)。
|
|
53
|
+
TemplateLiteral(node) {
|
|
54
|
+
for (const quasi of node.quasis) {
|
|
55
|
+
check(quasi, quasi.value.cooked);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
"no-raw-radius": {
|
|
62
|
+
meta: { type: "problem", docs: { description: "borderRadius は theme.radius.* を使う" } },
|
|
63
|
+
create(context) {
|
|
64
|
+
return {
|
|
65
|
+
Property(node) {
|
|
66
|
+
if (isRadiusKey(keyName(node)) && isRawNumber(node.value)) {
|
|
67
|
+
context.report({ node, message: "borderRadius の生数値は禁止。theme.radius.* を使う。" });
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
"no-raw-spacing": {
|
|
74
|
+
meta: { type: "suggestion", docs: { description: "padding/margin/gap は theme.spacing.* を使う" } },
|
|
75
|
+
create(context) {
|
|
76
|
+
return {
|
|
77
|
+
Property(node) {
|
|
78
|
+
if (isSpacingKey(keyName(node)) && isRawNumber(node.value)) {
|
|
79
|
+
context.report({ node, message: "spacing の生数値は theme.spacing.* 推奨。" });
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
"no-raw-fontsize": {
|
|
86
|
+
meta: { type: "suggestion", docs: { description: "fontSize は theme.typography.fontSize.* を使う" } },
|
|
87
|
+
create(context) {
|
|
88
|
+
return {
|
|
89
|
+
Property(node) {
|
|
90
|
+
if (keyName(node) === "fontSize" && isRawNumber(node.value)) {
|
|
91
|
+
context.report({ node, message: "fontSize の生数値は theme.typography.fontSize.* 推奨。" });
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
};
|
package/llms.txt
CHANGED
|
@@ -58,5 +58,5 @@ UI を組む前に docs/patterns.md(組み方の規範)を読むこと。exa
|
|
|
58
58
|
## Optional
|
|
59
59
|
|
|
60
60
|
- [melta-ui llms.txt](https://melta.tsubotax.com/llms.txt): web 版デザインシステムの AI 入口(デザイン言語の一次資料)
|
|
61
|
-
- [npm](https://www.npmjs.com/package/melta-app):
|
|
61
|
+
- [npm](https://www.npmjs.com/package/melta-app): パッケージ(サブパスは Icon = melta-app/icons、SafeArea 差替 = melta-app/safe-area、lint 強制層 = melta-app/eslint-plugin の 3 つ)
|
|
62
62
|
- [THIRD_PARTY_LICENSES.md](https://github.com/tsubotax/melta-app/blob/main/THIRD_PARTY_LICENSES.md): Icon グリフの帰属表示
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melta-app",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "melta for APP — melta デザインシステムの React Native UI kit。melta-contracts(デザイン契約)を single source of truth に RN 実装でその契約を満たす。アプリ本体ではなくライブラリ。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://app.melta.tsubotax.com",
|
|
@@ -37,12 +37,15 @@
|
|
|
37
37
|
"import": "./lib/module/safe-area/index.js",
|
|
38
38
|
"default": "./lib/module/safe-area/index.js"
|
|
39
39
|
},
|
|
40
|
+
"./eslint-plugin": "./eslint-rules/melta.mjs",
|
|
41
|
+
"./eslint-rules/melta.mjs": "./eslint-rules/melta.mjs",
|
|
40
42
|
"./package.json": "./package.json"
|
|
41
43
|
},
|
|
42
44
|
"files": [
|
|
43
45
|
"lib",
|
|
44
46
|
"src",
|
|
45
47
|
"!src/**/*.test.*",
|
|
48
|
+
"eslint-rules",
|
|
46
49
|
"llms.txt",
|
|
47
50
|
"docs",
|
|
48
51
|
"THIRD_PARTY_LICENSES.md"
|
|
@@ -104,7 +107,7 @@
|
|
|
104
107
|
"check:drift": "tsx scripts/check-drift.ts",
|
|
105
108
|
"check:installability": "bash scripts/check-installability.sh",
|
|
106
109
|
"check:build-fresh": "tsx scripts/check-build-fresh.ts",
|
|
107
|
-
"release": "npm run build && npm run typecheck && npm run lint && npm test && npm run test:rn && npm run check:drift && npm run check:build-fresh && npm publish",
|
|
110
|
+
"release": "npm run build && npm run typecheck && npm run lint && npm test && npm run test:rn && npm run check:drift && npm run check:build-fresh && npm run check:installability && npm publish",
|
|
108
111
|
"build:llms": "tsx scripts/build-llms-txt.ts"
|
|
109
112
|
},
|
|
110
113
|
"jest": {
|