@akanjs/devkit 3.3.0-rc.10 → 3.3.0-rc.12
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/CHANGELOG.md +5 -0
- package/codeAgent/skills/akan-err/SKILL.md +11 -2
- package/codeAgent/skills/akan-page/SKILL.md +4 -14
- package/docs/apiReference.test.ts +9 -0
- package/docs/apiReference.ts +14 -0
- package/lint/__fixtures__/no-arbitrary-color/every-color-function/bad.tsx +11 -0
- package/lint/__fixtures__/no-arbitrary-color/every-color-function/good.tsx +2 -0
- package/lint/__fixtures__/no-daisyui-legacy-class/every-class/bad.tsx +34 -0
- package/lint/__fixtures__/no-daisyui-legacy-class/every-class/good.tsx +2 -0
- package/lint/__fixtures__/no-inline-color/every-color-function/bad.tsx +10 -0
- package/lint/__fixtures__/no-inline-color/every-color-function/good.tsx +2 -0
- package/lint/__fixtures__/no-raw-palette-class/every-palette/bad.tsx +22 -0
- package/lint/__fixtures__/no-raw-palette-class/every-palette/good.tsx +2 -0
- package/lint/no-arbitrary-color.grit +5 -0
- package/lint/no-conditional-st-hook.grit +5 -1
- package/lint/no-daisyui-legacy-class.grit +8 -0
- package/lint/no-document-cookie.grit +3 -0
- package/lint/no-inline-color.grit +10 -2
- package/lint/no-oversized-list-limit.grit +2 -0
- package/lint/no-raw-palette-class.grit +7 -0
- package/lint/no-unpublished-form-setter.grit +2 -0
- package/lint/no-web-only-api-outside-webkit.grit +5 -0
- package/lint/no-web-storage.grit +3 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -160,6 +160,7 @@
|
|
|
160
160
|
|
|
161
161
|
A chat where the user mentions a record now asks before the first change that follows. `AgentConfirm.set({ afterScreenRead: false })` turns that off together with the ask after `readScreen`.
|
|
162
162
|
|
|
163
|
+
- a291bbb: The path rules an agent loads with every service, signal, page and `.tsx` file are shorter: the `server`, `style` and `ssr` rules keep only what fails the build or silently changes behaviour and point at the skill that explains the rest (server 7.9 KB to 2.4 KB, style 5.8 KB to 2.5 KB, ssr 3.6 KB to 1.9 KB), and the `akan-page` skill no longer repeats what the `page` rule already says. Nothing was dropped: an endpoint's `errors` option and where an adapter's error keys live are now in the `akan-err` skill, the request-schema check in `transportRule`, and the `cn`, multi-slot and enum-to-class conventions in `cssRule`. `cssRule` and `recipeRule` now say the framework recipe list is in the `style` rule, and the API reference says what `akanjs/dictionary`, `document`, `service`, `store`, `client/native`, `native/desktop` and `test` hold. Run `akan agent install` in a workspace to pick up the new files.
|
|
163
164
|
- c44d068: A coding agent reads less to build its first app: the `akanjs` README keeps the path to a first app and links the rest on akanjs.com (17 KB to 7 KB), the `akan-page` and `akan-service` skills ship the API reference one section at a time with every entry named in the skill's index (`Link` now lists the anchor attributes it takes and `Link.Back`, `Link.Close` and `Link.Lang`), the `akan-page` skill holds what a first page looks up while `pageRule` keeps the deeper contract, and each rule is stated once across AGENTS.md, the path rules and the skills. Run `akan agent install` in a workspace to pick up the new files.
|
|
164
165
|
- 19c6fa7: `akan code` on the `local` profile can be told to stop asking about a command for the rest of the session, and one option turns asking off for a run.
|
|
165
166
|
|
|
@@ -177,6 +178,7 @@
|
|
|
177
178
|
The key defaults to false, so existing apps are unchanged. The api report lists one new optional `AkanNativeIosConfig` property; no upgrade step is needed.
|
|
178
179
|
|
|
179
180
|
- 4732186: `akan --version` loads no command module, and `akan tunnel`, `akan subspace` and the package commands such as `akan version` no longer load the TypeScript compiler unless a step compiles.
|
|
181
|
+
- 1879e92: A whole-app lint runs about four times faster: `biome check apps/akan` in this repository went from 8.0 s to 2.0 s (median of five runs each on an Apple M4 Pro, 14 cores), where the same check with no lint plugins takes 0.95 s; `akan lint akan` went from 17.2 s to 5.0 s and `akan lint minimal` from 2.3 s to 1.7 s on the same machine. The ten costliest grit rules shipped in `@akanjs/devkit/lint` (the four colour rules, `no-conditional-st-hook`, `no-web-storage`, `no-web-only-api-outside-webkit`, `no-document-cookie`, `no-oversized-list-limit` and `no-unpublished-form-setter`) now check for a substring every match contains before their regex or code snippet runs, because Biome's GritQL engine pays for a regex or a snippet on every node it tries. Every rule reports the same diagnostics as before, and `biome.base.json` is unchanged, so a workspace picks this up by updating `@akanjs/devkit`.
|
|
180
182
|
- 6ea7242: `akan build`, `akan verify` and `akan start` stop with an error naming the import chain when the server pages bundle would import `react-dom/server` as it loads, instead of building a bundle whose RSC worker throws "react-dom/server is not supported in React Server Components" at boot. A module in the page graph that dynamically imports the app's `server.ts` is the usual cause: it brings the whole server, SSR renderer included, into the pages bundle.
|
|
181
183
|
- 0d5e75e: A stylesheet whose imports use no Tailwind (no `@import "tailwindcss"`, Tailwind at-rule or `theme()` function anywhere in its import graph) is no longer run through the Tailwind compiler: its imports are inlined and it ships without the `/*! tailwindcss … */` banner. A stylesheet that uses Tailwind compiles exactly as before.
|
|
182
184
|
- 98931e4: `akan start` boots the backend while the first base build runs: the backend loads its server graph beside the build and mounts the web surface as soon as the build's artifact is on disk, so the dev server is ready sooner.
|
|
@@ -198,10 +200,12 @@
|
|
|
198
200
|
- Updated dependencies [217b061]
|
|
199
201
|
- Updated dependencies [0baacae]
|
|
200
202
|
- Updated dependencies [e704d16]
|
|
203
|
+
- Updated dependencies [5c7c6cf]
|
|
201
204
|
- Updated dependencies [aff1ba2]
|
|
202
205
|
- Updated dependencies [bf582c1]
|
|
203
206
|
- Updated dependencies [8bbe7c8]
|
|
204
207
|
- Updated dependencies [90d740f]
|
|
208
|
+
- Updated dependencies [1a225e8]
|
|
205
209
|
- Updated dependencies [e9598f3]
|
|
206
210
|
- Updated dependencies [1885caf]
|
|
207
211
|
- Updated dependencies [45e3ffa]
|
|
@@ -225,6 +229,7 @@
|
|
|
225
229
|
- Updated dependencies [5c7e083]
|
|
226
230
|
- Updated dependencies [98931e4]
|
|
227
231
|
- Updated dependencies [4225827]
|
|
232
|
+
- Updated dependencies [8f9d432]
|
|
228
233
|
- akanjs@3.3.0
|
|
229
234
|
- @akanjs/language@3.3.0
|
|
230
235
|
|
|
@@ -30,10 +30,19 @@ import path at all**, so keep throwing code out of them entirely rather than rea
|
|
|
30
30
|
|
|
31
31
|
Best-effort code returns a sentinel (`null`, `undefined`, `{}`) instead of throwing. `try/catch` is rare and
|
|
32
32
|
always converts an exception into a decision: a guard catches, warns, and returns `false`; an adapter
|
|
33
|
-
catches, logs, and returns `null
|
|
34
|
-
the store's `static silent` when no screen waits on it
|
|
33
|
+
catches, logs (`logger.error`), and returns `null`; a UI `try/finally` resets a spinner. A store action never
|
|
34
|
+
catches — let the framework toast the `Err`, or list it in the store's `static silent` when no screen waits on it
|
|
35
|
+
and its caller handles the rejection.
|
|
35
36
|
Client-side validation failure is `msg.error("<key>")` plus an early return, never a throw.
|
|
36
37
|
|
|
38
|
+
An `srvkit/` adapter belongs to no module: its keys go in the app's or lib's own service dictionary,
|
|
39
|
+
`lib/_<name>/<name>.dictionary.ts`, thrown as `new Err("<name>.error.<key>")` with `Err` from `"../lib/dict"`.
|
|
40
|
+
|
|
41
|
+
**An endpoint names the errors it throws on purpose** — `errors: { 409: ["ticket.error.locked"] }` in its signal
|
|
42
|
+
option, with keys its dictionary defines and never `base.error.*`. That is the status's OpenAPI response and a line
|
|
43
|
+
of the MCP tool's description; outside production a thrown key it leaves out warns once. A caller narrows with
|
|
44
|
+
`Err.is(error, "ticket.error.locked")`.
|
|
45
|
+
|
|
37
46
|
**A failure another process reported travels as itself.** A server-to-server `fetch.<endpoint>(…, { origin })`
|
|
38
47
|
restores the remote `Err` with its class, key and data. Rethrow it as-is — wrapping it in a `new Error`
|
|
39
48
|
discards what the endpoint chose to say, and a bare `Error` is generalized to "Internal Server Error" on the
|
|
@@ -33,19 +33,13 @@ export default page()
|
|
|
33
33
|
dropped. `lang` reaches every stage and is never declared.
|
|
34
34
|
3. Gate with `.guard(() => signedIn())` on the `_layout.tsx`, and repeat a stricter guard on a page that needs more.
|
|
35
35
|
`.guard((_, { path }) => signedIn({ path }))` sends a refused visitor to `/signin?redirect=<path>`.
|
|
36
|
-
4. In `.render()`: `usePage()`, then fetch, then return.
|
|
37
|
-
|
|
38
|
-
5. `.head()` takes JSX (or a function returning it), never a metadata object.
|
|
39
|
-
6. Re-skin an `akanjs/ui` component for a subtree with `_overrides.tsx`:
|
|
36
|
+
4. In `.render()`: `usePage()`, then fetch, then return.
|
|
37
|
+
5. Re-skin an `akanjs/ui` component for a subtree with `_overrides.tsx`:
|
|
40
38
|
`export default override({ Slot: AppComponent })`, no logic. Nested ones merge slot by slot, the closest winning;
|
|
41
39
|
`componentRule` lists the slots.
|
|
42
40
|
|
|
43
41
|
## API at a glance
|
|
44
42
|
|
|
45
|
-
`page`, `layout` and `router` come from `akanjs/client`, `Link` from `akanjs/ui`, `usePageLocation` from
|
|
46
|
-
`akanjs/webkit`, and `fetch`, `usePage` and the model namespaces from `@apps/<app>/client`. A stage receives the
|
|
47
|
-
declared params and search keys plus `lang`.
|
|
48
|
-
|
|
49
43
|
- Data-driven title: `.head(async ({ id }) => <title>{((await fetch.book(id)) as Book | null)?.title}</title>)`,
|
|
50
44
|
where `Book` is the `common/` interface for the query's `Any` return (`akan-service`).
|
|
51
45
|
- Async page: `.render(async ({ id }) => { const book = (await fetch.book(id)) as Book | null; if (!book) return router.notFound(); … })`;
|
|
@@ -65,12 +59,8 @@ declared params and search keys plus `lang`.
|
|
|
65
59
|
scrollToTop: false })`` in a `"use client"` component, read back with `usePageLocation().searchParams`. Shallow
|
|
66
60
|
holds only while the path stays the same; a server `.search()` sees the value at the next full navigation.
|
|
67
61
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
- A `fetch.<mutation>()` while rendering — it throws `base.error.mutationInRender`, because opening a link would
|
|
71
|
-
perform it. Send writes from a user action.
|
|
72
|
-
- `useState`, `useEffect`, comments, a named export beside the chain, or the legacy `export default async function`.
|
|
73
|
-
- Editing a lib page through its link in `page/(libs)/` — edit the lib's own `page/` source.
|
|
62
|
+
What a route file must never do — write while rendering, hooks, a second export — is the `page` rule, loaded with
|
|
63
|
+
any `page/` file.
|
|
74
64
|
|
|
75
65
|
Full detail: `get_guideline` with `pageRule` (guards in depth, heads, MCP apps, CSR root layouts, lib pages), or
|
|
76
66
|
`ssrRule` for what may render on the server. Every stage's signature, the router's methods, Link's props and every
|
|
@@ -28,6 +28,15 @@ describe("ApiReference", () => {
|
|
|
28
28
|
expect(rendered).toMatch(/^\/\*\* .+ \*\/\nserverMode\?: "batch" \| "federation";$/m);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
+
test("says what each listed subpath holds, and lists only subpaths the package exports", async () => {
|
|
32
|
+
const exports = Object.keys((await Bun.file(path.join(akanjsDir, "package.json")).json()).exports);
|
|
33
|
+
const listed = [...rendered.matchAll(/^- `akanjs\/([^`]+)` — .+\.$/gm)].map(([, subpath]) => `./${subpath}`);
|
|
34
|
+
expect(listed).toEqual(
|
|
35
|
+
["dictionary", "document", "service", "store", "client/native", "native/desktop", "test"].map((s) => `./${s}`),
|
|
36
|
+
);
|
|
37
|
+
for (const subpath of listed) expect(exports).toContain(subpath);
|
|
38
|
+
});
|
|
39
|
+
|
|
31
40
|
test("says what Link takes beyond its own props, and names its static parts", () => {
|
|
32
41
|
expect(rendered).toContain('Every prop of `Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href">`, and:');
|
|
33
42
|
expect(rendered).toMatch(/^Link\.Back\(.+\): Element$/m);
|
package/docs/apiReference.ts
CHANGED
|
@@ -118,6 +118,16 @@ const conventionImports = [
|
|
|
118
118
|
'import { signedIn } from "@libs/shared/webkit"; // a workspace created with --libs true',
|
|
119
119
|
];
|
|
120
120
|
|
|
121
|
+
const subpathPurposes = [
|
|
122
|
+
["akanjs/dictionary", "locales, translations and the dictionaries behind labels, descriptions and `Err` keys"],
|
|
123
|
+
["akanjs/document", "database documents, filters, query builders, full-text search and persistence"],
|
|
124
|
+
["akanjs/service", "services, adapters, dependency injection and the business-logic runtime"],
|
|
125
|
+
["akanjs/store", "domain state, actions and the in-page agent's `st.tool` / `st.use` surface"],
|
|
126
|
+
["akanjs/client/native", "the native bridge and the built-in plugins of iOS, Android and desktop apps"],
|
|
127
|
+
["akanjs/native/desktop", "what an app's or a lib's own native plugin builds its desktop part from"],
|
|
128
|
+
["akanjs/test", "signal-test setup, MCP catalogue checks and sample data (`sampleOf`)"],
|
|
129
|
+
] as const;
|
|
130
|
+
|
|
121
131
|
const routeInternals = ["assertPattern", "resolveArgs", "toRouteModule"];
|
|
122
132
|
|
|
123
133
|
export class ApiReference {
|
|
@@ -160,6 +170,10 @@ export class ApiReference {
|
|
|
160
170
|
...conventionImports,
|
|
161
171
|
"```",
|
|
162
172
|
"",
|
|
173
|
+
"What these subpaths hold:",
|
|
174
|
+
"",
|
|
175
|
+
...subpathPurposes.map(([from, purpose]) => `- \`${from}\` — ${purpose}.`),
|
|
176
|
+
"",
|
|
163
177
|
...body,
|
|
164
178
|
]
|
|
165
179
|
.join("\n")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const Hex = () => <div className="bg-[#3b82f6]" />; // @flag
|
|
2
|
+
export const Rgb = () => <div className="bg-[rgb(0,0,0)]" />; // @flag
|
|
3
|
+
export const Rgba = () => <div className="bg-[rgba(0,0,0,0.5)]" />; // @flag
|
|
4
|
+
export const Hsl = () => <div className="bg-[hsl(210,100%,50%)]" />; // @flag
|
|
5
|
+
export const Hsla = () => <div className="bg-[hsla(210,100%,50%,0.5)]" />; // @flag
|
|
6
|
+
export const Oklch = () => <div className="bg-[oklch(0.5_0.1_200)]" />; // @flag
|
|
7
|
+
export const Oklab = () => <div className="bg-[oklab(0.5_0.1_0.1)]" />; // @flag
|
|
8
|
+
export const Lab = () => <div className="bg-[lab(50%_40_59)]" />; // @flag
|
|
9
|
+
export const Lch = () => <div className="bg-[lch(50%_60_40)]" />; // @flag
|
|
10
|
+
export const Hwb = () => <div className="bg-[hwb(210_10%_10%)]" />; // @flag
|
|
11
|
+
export const ColorFunction = () => <div className="bg-[color(display-p3_1_0_0)]" />; // @flag
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const SlotBgBase100 = () => <div className="bg-base-100" />; // @flag
|
|
2
|
+
export const SlotBgBase200 = () => <div className="bg-base-200" />; // @flag
|
|
3
|
+
export const SlotBgBase300 = () => <div className="bg-base-300" />; // @flag
|
|
4
|
+
export const SlotTextBaseContent = () => <div className="text-base-content" />; // @flag
|
|
5
|
+
export const SlotTextPrimaryContent = () => <div className="text-primary-content" />; // @flag
|
|
6
|
+
export const SlotTextSecondaryContent = () => <div className="text-secondary-content" />; // @flag
|
|
7
|
+
export const SlotTextAccentContent = () => <div className="text-accent-content" />; // @flag
|
|
8
|
+
export const SlotTextNeutralContent = () => <div className="text-neutral-content" />; // @flag
|
|
9
|
+
export const SlotTextInfoContent = () => <div className="text-info-content" />; // @flag
|
|
10
|
+
export const SlotTextSuccessContent = () => <div className="text-success-content" />; // @flag
|
|
11
|
+
export const SlotTextWarningContent = () => <div className="text-warning-content" />; // @flag
|
|
12
|
+
export const SlotTextErrorContent = () => <div className="text-error-content" />; // @flag
|
|
13
|
+
export const SlotBgError = () => <div className="bg-error" />; // @flag
|
|
14
|
+
export const ComponentBtnPrimary = () => <div className="btn-primary" />; // @warn
|
|
15
|
+
export const ComponentBadgeGhost = () => <div className="badge-ghost" />; // @warn
|
|
16
|
+
export const ComponentAlertInfo = () => <div className="alert-info" />; // @warn
|
|
17
|
+
export const ComponentInputBordered = () => <div className="input-bordered" />; // @warn
|
|
18
|
+
export const ComponentSelectBordered = () => <div className="select-bordered" />; // @warn
|
|
19
|
+
export const ComponentTextareaGhost = () => <div className="textarea-ghost" />; // @warn
|
|
20
|
+
export const ComponentCheckboxPrimary = () => <div className="checkbox-primary" />; // @warn
|
|
21
|
+
export const ComponentToggleAccent = () => <div className="toggle-accent" />; // @warn
|
|
22
|
+
export const ComponentLoadingSpinner = () => <div className="loading-spinner" />; // @warn
|
|
23
|
+
export const ComponentCardBody = () => <div className="card-body" />; // @warn
|
|
24
|
+
export const ComponentModalBox = () => <div className="modal-box" />; // @warn
|
|
25
|
+
export const ComponentCollapseTitle = () => <div className="collapse-title" />; // @warn
|
|
26
|
+
export const ComponentDropdownContent = () => <div className="dropdown-content" />; // @warn
|
|
27
|
+
export const ComponentStatValue = () => <div className="stat-value" />; // @warn
|
|
28
|
+
export const ComponentTabsBoxed = () => <div className="tabs-boxed" />; // @warn
|
|
29
|
+
export const ComponentTabActive = () => <div className="tab-active" />; // @warn
|
|
30
|
+
export const ComponentMenuTitle = () => <div className="menu-title" />; // @warn
|
|
31
|
+
export const ComponentStepsVertical = () => <div className="steps-vertical" />; // @warn
|
|
32
|
+
export const ComponentJoinItem = () => <div className="join-item" />; // @warn
|
|
33
|
+
export const ComponentMockupCode = () => <div className="mockup-code" />; // @warn
|
|
34
|
+
export const ComponentDrawerSide = () => <div className="drawer-side" />; // @warn
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const Hex = () => <div style={{ color: "#abc" }} />; // @flag
|
|
2
|
+
export const Rgb = () => <div style={{ color: "rgb(0,0,0)" }} />; // @flag
|
|
3
|
+
export const Rgba = () => <div style={{ color: "rgba(0,0,0,0.5)" }} />; // @flag
|
|
4
|
+
export const Hsl = () => <div style={{ color: "hsl(0 0% 0%)" }} />; // @flag
|
|
5
|
+
export const Hsla = () => <div style={{ color: "hsla(0,0%,0%,0.5)" }} />; // @flag
|
|
6
|
+
export const Oklch = () => <div style={{ color: "oklch(0.5 0.1 200)" }} />; // @flag
|
|
7
|
+
export const Oklab = () => <div style={{ color: "oklab(0.5 0.1 0.1)" }} />; // @flag
|
|
8
|
+
export const Lab = () => <div style={{ color: "lab(50% 40 59)" }} />; // @flag
|
|
9
|
+
export const Lch = () => <div style={{ color: "lch(50% 60 40)" }} />; // @flag
|
|
10
|
+
export const Hwb = () => <div style={{ color: "hwb(210 10% 10%)" }} />; // @flag
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const Slate = () => <div className="bg-slate-500" />; // @flag
|
|
2
|
+
export const Gray = () => <div className="bg-gray-500" />; // @flag
|
|
3
|
+
export const Zinc = () => <div className="bg-zinc-500" />; // @flag
|
|
4
|
+
export const Neutral = () => <div className="bg-neutral-500" />; // @flag
|
|
5
|
+
export const Stone = () => <div className="bg-stone-500" />; // @flag
|
|
6
|
+
export const Red = () => <div className="bg-red-500" />; // @flag
|
|
7
|
+
export const Orange = () => <div className="bg-orange-500" />; // @flag
|
|
8
|
+
export const Amber = () => <div className="bg-amber-500" />; // @flag
|
|
9
|
+
export const Yellow = () => <div className="bg-yellow-500" />; // @flag
|
|
10
|
+
export const Lime = () => <div className="bg-lime-500" />; // @flag
|
|
11
|
+
export const Green = () => <div className="bg-green-500" />; // @flag
|
|
12
|
+
export const Emerald = () => <div className="bg-emerald-500" />; // @flag
|
|
13
|
+
export const Teal = () => <div className="bg-teal-500" />; // @flag
|
|
14
|
+
export const Cyan = () => <div className="bg-cyan-500" />; // @flag
|
|
15
|
+
export const Sky = () => <div className="bg-sky-500" />; // @flag
|
|
16
|
+
export const Blue = () => <div className="bg-blue-500" />; // @flag
|
|
17
|
+
export const Indigo = () => <div className="bg-indigo-500" />; // @flag
|
|
18
|
+
export const Violet = () => <div className="bg-violet-500" />; // @flag
|
|
19
|
+
export const Purple = () => <div className="bg-purple-500" />; // @flag
|
|
20
|
+
export const Fuchsia = () => <div className="bg-fuchsia-500" />; // @flag
|
|
21
|
+
export const Pink = () => <div className="bg-pink-500" />; // @flag
|
|
22
|
+
export const Rose = () => <div className="bg-rose-500" />; // @flag
|
|
@@ -10,6 +10,11 @@ or {
|
|
|
10
10
|
JsStringLiteralExpression() as $s,
|
|
11
11
|
JsTemplateChunkElement() as $s
|
|
12
12
|
} where {
|
|
13
|
+
// GritQL compiles a regex anew for every node it tries, so a substring every match must contain gates it.
|
|
14
|
+
$s <: or {
|
|
15
|
+
includes "[#", includes "[rgb", includes "[hsl", includes "[ok", includes "[lab(", includes "[lch(",
|
|
16
|
+
includes "[hwb(", includes "[color("
|
|
17
|
+
},
|
|
13
18
|
$s <: r"[\s\S]*\[(?:#[0-9a-fA-F]{3,8}|(?:rgb|rgba|hsl|hsla|oklch|oklab|lab|lch|hwb|color)\([^\]]*\))\][\s\S]*",
|
|
14
19
|
register_diagnostic(
|
|
15
20
|
span = $s,
|
|
@@ -32,6 +32,8 @@ pattern st_hook_call() {
|
|
|
32
32
|
`$chain.value($args)` where { $chain <: r"st\s*\.\s*expose\s*\([\s\S]*" },
|
|
33
33
|
// Computed access (`st["use"].x()`, `st.use[key]()`) at any step, which would take a snippet per combination.
|
|
34
34
|
JsCallExpression(callee = $callee) where {
|
|
35
|
+
// GritQL compiles a regex anew for every node it tries, so a substring every match must contain gates it.
|
|
36
|
+
$callee <: or { includes "use", includes "sel", includes "ref" },
|
|
35
37
|
$callee <: or {
|
|
36
38
|
r"st\s*(?:\.\s*use|\[\s*[\x27\x22`]use[\x27\x22`]\s*\])\s*(?:\.\s*[\w$]+|\[[^\]]*\])",
|
|
37
39
|
r"st\s*(?:\.\s*slice|\[\s*[\x27\x22`]slice[\x27\x22`]\s*\])\s*(?:\.\s*[\w$]+|\[[^\]]*\])\s*(?:\.\s*use|\[\s*[\x27\x22`]use[\x27\x22`]\s*\])\s*(?:\.\s*[\w$]+|\[[^\]]*\])",
|
|
@@ -78,7 +80,9 @@ pattern passed_by_name($name) {
|
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
// GritQL copies its match state for every snippet it tries, so a substring every hook's callee contains goes first.
|
|
84
|
+
JsCallExpression(callee = $hookCallee) as $call where {
|
|
85
|
+
$hookCallee <: includes "st",
|
|
82
86
|
$call <: st_hook_call(),
|
|
83
87
|
or {
|
|
84
88
|
$call <: within JsLogicalExpression(right = $right) where { $right <: contains $call } until function_boundary(),
|
|
@@ -18,8 +18,10 @@ or {
|
|
|
18
18
|
JsStringLiteralExpression() as $s,
|
|
19
19
|
JsTemplateChunkElement() as $s
|
|
20
20
|
} where {
|
|
21
|
+
// GritQL compiles a regex anew for every node it tries, so a substring every match must contain gates each one.
|
|
21
22
|
any {
|
|
22
23
|
and {
|
|
24
|
+
$s <: or { includes "-base-", includes "-content", includes "-error" },
|
|
23
25
|
$s <: r"[\s\S]*(?:^|[\s\"'`{(\[:!])(?:bg|text|border(?:-[tblrxy])?(?:-[se])?|ring(?:-offset)?|fill|stroke|shadow|from|to|via|divide|outline|decoration|placeholder|caret|accent)-(?:base-(?:100|200|300|content)|(?:primary|secondary|accent|neutral|info|success|warning|error)-content|error)(?:[\s\"'`})\]:/!,]|$)[\s\S]*",
|
|
24
26
|
register_diagnostic(
|
|
25
27
|
span = $s,
|
|
@@ -28,6 +30,12 @@ or {
|
|
|
28
30
|
)
|
|
29
31
|
},
|
|
30
32
|
and {
|
|
33
|
+
$s <: or {
|
|
34
|
+
includes "btn-", includes "badge-", includes "alert-", includes "input-", includes "select-",
|
|
35
|
+
includes "textarea-", includes "checkbox-", includes "toggle-", includes "loading-", includes "card-",
|
|
36
|
+
includes "modal-", includes "collapse-", includes "dropdown-", includes "stat-", includes "tab",
|
|
37
|
+
includes "menu-", includes "steps-", includes "join-item", includes "mockup-", includes "drawer-"
|
|
38
|
+
},
|
|
31
39
|
$s <: r"[\s\S]*(?:^|[\s\"'`{(\[:!])(?:btn-(?:primary|secondary|accent|neutral|info|success|warning|error|ghost|link|outline|square|circle|wide|block|xs|sm|md|lg)|badge-(?:primary|secondary|accent|neutral|info|success|warning|error|ghost|outline)|alert-(?:info|success|warning|error)|input-(?:bordered|primary|secondary|accent|ghost|error)|select-(?:bordered|primary|ghost)|textarea-(?:bordered|primary|ghost)|checkbox-(?:primary|secondary|accent)|toggle-(?:primary|secondary|accent)|loading-(?:spinner|dots|ring|ball|bars|infinity)|card-(?:body|title|actions)|modal-(?:box|action|backdrop)|collapse-(?:title|content|arrow|plus)|dropdown-(?:content|end|start|hover)|stat-(?:title|value|desc)|tabs-(?:boxed|lifted|bordered)|tab-active|menu-(?:title|dropdown)|steps-(?:horizontal|vertical)|join-item|mockup-(?:code|phone|browser|window)|drawer-(?:side|content|toggle))(?:[\s\"'`})\]:/!,]|$)[\s\S]*",
|
|
32
40
|
register_diagnostic(
|
|
33
41
|
span = $s,
|
|
@@ -10,6 +10,8 @@ language js(typescript, jsx)
|
|
|
10
10
|
// write is its own node (JsStaticMemberAssignment) that the expression form does not match.
|
|
11
11
|
or {
|
|
12
12
|
JsStaticMemberExpression() as $access where {
|
|
13
|
+
// GritQL copies its match state for every snippet it tries, so a substring every match must contain goes first.
|
|
14
|
+
$access <: includes "cookie",
|
|
13
15
|
$access <: or { `document.cookie`, `window.document.cookie`, `globalThis.document.cookie`, `self.document.cookie` },
|
|
14
16
|
register_diagnostic(
|
|
15
17
|
span = $access,
|
|
@@ -18,6 +20,7 @@ or {
|
|
|
18
20
|
)
|
|
19
21
|
},
|
|
20
22
|
JsStaticMemberAssignment(object = $object, member = $member) as $access where {
|
|
23
|
+
$member <: includes "cookie",
|
|
21
24
|
$member <: `cookie`,
|
|
22
25
|
$object <: or { `document`, `window.document`, `globalThis.document`, `self.document` },
|
|
23
26
|
register_diagnostic(
|
|
@@ -11,16 +11,24 @@ language js(typescript, jsx)
|
|
|
11
11
|
// warnings, not errors, so code written before the rule reached them is not broken.
|
|
12
12
|
// The hex arm skips `url(#id)`: a paint-server id such as `#fade` is spelled in hex digits.
|
|
13
13
|
// Cases: lint/__fixtures__/no-inline-color/{bad,good}.tsx
|
|
14
|
+
|
|
15
|
+
// GritQL compiles a regex anew for every node it tries, so a substring every match must contain gates it first.
|
|
16
|
+
pattern colour_literal_text() {
|
|
17
|
+
or { includes "#", includes "rgb", includes "hsl", includes "lab(", includes "lch(", includes "hwb(" }
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
or {
|
|
15
21
|
or {
|
|
16
|
-
JsStringLiteralExpression() as $s where { $s <: within `style={$obj}` },
|
|
17
|
-
JsTemplateChunkElement() as $s where { $s <: within `<style>$body</style>` }
|
|
22
|
+
JsStringLiteralExpression() as $s where { $s <: colour_literal_text(), $s <: within `style={$obj}` },
|
|
23
|
+
JsTemplateChunkElement() as $s where { $s <: colour_literal_text(), $s <: within `<style>$body</style>` }
|
|
18
24
|
} where { $tier = "error" },
|
|
19
25
|
or {
|
|
20
26
|
or { JsxString(), JsStringLiteralExpression(), JsTemplateChunkElement() } as $s where {
|
|
27
|
+
$s <: colour_literal_text(),
|
|
21
28
|
$s <: within JsxAttribute(name = r"(?:fill|stroke|stopColor|floodColor|lightingColor|color|stop-color|flood-color|lighting-color)")
|
|
22
29
|
},
|
|
23
30
|
or { JsStringLiteralExpression(), JsTemplateChunkElement() } as $s where {
|
|
31
|
+
$s <: colour_literal_text(),
|
|
24
32
|
$s <: within or { `$el.style.$prop = $value`, `$el.style[$prop] = $value`, `$el.style.setProperty($prop, $value)` }
|
|
25
33
|
}
|
|
26
34
|
} where { $tier = "warn" }
|
|
@@ -34,6 +34,8 @@ pattern page_sort() {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
JsCallExpression(callee = $callee, arguments = JsCallArguments(args = $args)) where {
|
|
37
|
+
// GritQL copies its match state for every snippet it tries, so a substring every match must contain goes first.
|
|
38
|
+
$callee <: or { includes "fetch", includes "do" },
|
|
37
39
|
or {
|
|
38
40
|
and {
|
|
39
41
|
$callee <: `fetch.$endpoint`,
|
|
@@ -16,6 +16,13 @@ or {
|
|
|
16
16
|
JsStringLiteralExpression() as $s,
|
|
17
17
|
JsTemplateChunkElement() as $s
|
|
18
18
|
} where {
|
|
19
|
+
// GritQL compiles a regex anew for every node it tries, so a substring every match must contain gates it.
|
|
20
|
+
$s <: or {
|
|
21
|
+
includes "slate-", includes "gray-", includes "zinc-", includes "neutral-", includes "stone-", includes "red-",
|
|
22
|
+
includes "orange-", includes "amber-", includes "yellow-", includes "lime-", includes "green-", includes "emerald-",
|
|
23
|
+
includes "teal-", includes "cyan-", includes "sky-", includes "blue-", includes "indigo-", includes "violet-",
|
|
24
|
+
includes "purple-", includes "fuchsia-", includes "pink-", includes "rose-"
|
|
25
|
+
},
|
|
19
26
|
$s <: r"[\s\S]*(?:^|[\s\"'`{(\[:!])(?:bg|text|border(?:-[tblrxy])?(?:-[se])?|ring(?:-offset)?|fill|stroke|shadow|from|to|via|divide|outline|decoration|placeholder|caret|accent)-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-\d{2,3}(?:[\s\"'`})\]:/!,]|$)[\s\S]*",
|
|
20
27
|
register_diagnostic(
|
|
21
28
|
span = $s,
|
|
@@ -24,6 +24,8 @@ language js(typescript, jsx)
|
|
|
24
24
|
// bind to different text, so the metavariable cannot unify them. Under-reporting, not a false positive.
|
|
25
25
|
//
|
|
26
26
|
JsxAttribute() as $attr where {
|
|
27
|
+
// GritQL copies its match state for every node a pattern tries, so a substring the reported body needs goes first.
|
|
28
|
+
$attr <: includes "st.do.",
|
|
27
29
|
$attr <: contains JsArrowFunctionExpression() as $arrow,
|
|
28
30
|
$arrow <: `($p) => $body`,
|
|
29
31
|
// One bare parameter. A metavariable matches a whole parameter list leniently, so `(a, b)` binds the
|
|
@@ -10,6 +10,8 @@ language js(typescript, jsx)
|
|
|
10
10
|
// points, because the name is also the libs/shared model (`Notification.View`, `cnst.Notification`).
|
|
11
11
|
or {
|
|
12
12
|
JsStaticMemberExpression() as $access where {
|
|
13
|
+
// GritQL copies its match state for every snippet it tries, so a substring every match must contain goes first.
|
|
14
|
+
$access <: includes "navigator",
|
|
13
15
|
$access <: or { `navigator.share`, `navigator.canShare` },
|
|
14
16
|
register_diagnostic(
|
|
15
17
|
span = $access,
|
|
@@ -18,6 +20,7 @@ or {
|
|
|
18
20
|
)
|
|
19
21
|
},
|
|
20
22
|
JsStaticMemberExpression() as $access where {
|
|
23
|
+
$access <: or { includes "navigator", includes "Notification" },
|
|
21
24
|
$access <: or { `navigator.serviceWorker`, `Notification.requestPermission`, `Notification.permission` },
|
|
22
25
|
register_diagnostic(
|
|
23
26
|
span = $access,
|
|
@@ -26,6 +29,7 @@ or {
|
|
|
26
29
|
)
|
|
27
30
|
},
|
|
28
31
|
JsStaticMemberExpression() as $access where {
|
|
32
|
+
$access <: includes "navigator",
|
|
29
33
|
$access <: `navigator.geolocation`,
|
|
30
34
|
register_diagnostic(
|
|
31
35
|
span = $access,
|
|
@@ -34,6 +38,7 @@ or {
|
|
|
34
38
|
)
|
|
35
39
|
},
|
|
36
40
|
JsStaticMemberExpression() as $access where {
|
|
41
|
+
$access <: includes "navigator",
|
|
37
42
|
$access <: `navigator.vibrate`,
|
|
38
43
|
register_diagnostic(
|
|
39
44
|
span = $access,
|
package/lint/no-web-storage.grit
CHANGED
|
@@ -11,6 +11,8 @@ language js(typescript, jsx)
|
|
|
11
11
|
// bare snippet matches the name in any position, a field, an object key or JSX text included.
|
|
12
12
|
or {
|
|
13
13
|
JsIdentifierExpression() as $access where {
|
|
14
|
+
// GritQL copies its match state for every snippet it tries, so a substring every match must contain goes first.
|
|
15
|
+
$access <: includes "Storage",
|
|
14
16
|
$access <: or { `localStorage`, `sessionStorage` },
|
|
15
17
|
register_diagnostic(
|
|
16
18
|
span = $access,
|
|
@@ -19,6 +21,7 @@ or {
|
|
|
19
21
|
)
|
|
20
22
|
},
|
|
21
23
|
JsStaticMemberExpression(object = $root, member = $name) as $access where {
|
|
24
|
+
$name <: includes "Storage",
|
|
22
25
|
$root <: or { `window`, `globalThis`, `self` },
|
|
23
26
|
$name <: or { `localStorage`, `sessionStorage` },
|
|
24
27
|
register_diagnostic(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "3.3.0-rc.
|
|
3
|
+
"version": "3.3.0-rc.12",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"./workspace/getRelatedCnsts": "./workspace/getRelatedCnsts.ts"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@akanjs/language": "3.3.0-rc.
|
|
53
|
+
"@akanjs/language": "3.3.0-rc.12",
|
|
54
54
|
"@earendil-works/pi-agent-core": "1.5.2",
|
|
55
55
|
"@earendil-works/pi-ai": "1.5.2",
|
|
56
56
|
"@earendil-works/pi-codemode": "1.5.2",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@earendil-works/pi-tui": "1.5.2",
|
|
60
60
|
"@inquirer/prompts": "^8.7.3",
|
|
61
61
|
"@tailwindcss/node": "^4.3.3",
|
|
62
|
-
"akanjs": "3.3.0-rc.
|
|
62
|
+
"akanjs": "3.3.0-rc.12",
|
|
63
63
|
"chalk": "^6.0.1",
|
|
64
64
|
"commander": "^15.0.0",
|
|
65
65
|
"dayjs": "^1.11.23",
|