@flamingo-stack/openframe-frontend-core 0.0.694-2513.7695.1 → 0.0.694-2513.7700.1
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/eslint-config/README.md
CHANGED
|
@@ -71,6 +71,19 @@ Two rules are deliberately **absent** from the base and belong in a repo's local
|
|
|
71
71
|
- `@typescript-eslint/naming-convention` — Biome's equivalent produced 1 715 findings in
|
|
72
72
|
multi-platform-hub alone and was never enforced.
|
|
73
73
|
|
|
74
|
+
## WebKit performance rules
|
|
75
|
+
|
|
76
|
+
`base` carries two rules from `./webview-performance.js` for patterns that are cheap in Chrome and
|
|
77
|
+
expensive in WebKit (Safari, and the WKWebView the desktop and iOS shells run in). They are not
|
|
78
|
+
applied to tests or stories.
|
|
79
|
+
|
|
80
|
+
- `flamingo/no-inline-style-element`: no `<style>` element in JSX. React rewrites its text on
|
|
81
|
+
re-render, and each rewrite makes WebKit restyle and relayout the whole document.
|
|
82
|
+
- `flamingo/no-whole-store-subscription`: a `use…Store` hook called with no selector, or with
|
|
83
|
+
`s => s`, re-renders on every write to the store. The rule goes by the name, so a `use…Store`
|
|
84
|
+
hook that is not a zustand subscription (a context getter, say) is a false positive: carry it in
|
|
85
|
+
a named `files:` block.
|
|
86
|
+
|
|
74
87
|
## Why not ESLint 10
|
|
75
88
|
|
|
76
89
|
ESLint 10 is out, and `eslint@9` is marked deprecated on npm. It still does not work here:
|
package/eslint-config/base.js
CHANGED
|
@@ -6,6 +6,7 @@ import globals from 'globals';
|
|
|
6
6
|
import tseslint from 'typescript-eslint';
|
|
7
7
|
|
|
8
8
|
import { ignores } from './ignores.js';
|
|
9
|
+
import { webviewPerformancePlugin } from './webview-performance.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Promote every `warn` in a third-party config to `error`.
|
|
@@ -291,6 +292,20 @@ export const base = [
|
|
|
291
292
|
languageOptions: { parserOptions: { jsxPragma: null } },
|
|
292
293
|
},
|
|
293
294
|
|
|
295
|
+
// Patterns measured to be cheap in Chrome and expensive in WebKit (Safari and
|
|
296
|
+
// the desktop/iOS shells' WKWebView) — see ./webview-performance.js. Tests and
|
|
297
|
+
// stories are not render paths users sit on.
|
|
298
|
+
{
|
|
299
|
+
name: 'flamingo/base/webview-performance',
|
|
300
|
+
files: ['**/*.{js,mjs,jsx,ts,mts,tsx}'],
|
|
301
|
+
ignores: ['**/*.{test,spec}.{js,mjs,jsx,ts,mts,tsx}', '**/__tests__/**', '**/*.stories.{js,jsx,ts,tsx,mdx}'],
|
|
302
|
+
plugins: { flamingo: webviewPerformancePlugin },
|
|
303
|
+
rules: {
|
|
304
|
+
'flamingo/no-inline-style-element': 'error',
|
|
305
|
+
'flamingo/no-whole-store-subscription': 'error',
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
|
|
294
309
|
// Type declaration files describe other people's shapes; most of the base
|
|
295
310
|
// rules are noise there.
|
|
296
311
|
{
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules for render-path patterns that cost little in Chrome and a lot in
|
|
3
|
+
* WebKit (Safari, and the WKWebView the desktop and iOS shells run in). Each
|
|
4
|
+
* one was measured on the Mingo chat in 2026-10 (openframe-oss-lib#2513); the
|
|
5
|
+
* numbers are in the rule messages so a finding explains itself.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** A `<style>` element in JSX: its text is replaced whenever React re-renders
|
|
9
|
+
* it, and every replacement makes WebKit restyle and relayout the document. */
|
|
10
|
+
const noInlineStyleElement = {
|
|
11
|
+
meta: {
|
|
12
|
+
type: 'problem',
|
|
13
|
+
docs: { description: 'Disallow <style> elements rendered from components' },
|
|
14
|
+
schema: [],
|
|
15
|
+
messages: {
|
|
16
|
+
inlineStyle:
|
|
17
|
+
'Do not render a <style> element: React rewrites it on re-render and each rewrite makes WebKit ' +
|
|
18
|
+
'restyle and relayout the whole document (Mingo streaming: 15ms -> 1ms per chunk once removed). ' +
|
|
19
|
+
'Put keyframes in the Tailwind preset and other CSS in a stylesheet.',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
create(context) {
|
|
23
|
+
return {
|
|
24
|
+
JSXOpeningElement(node) {
|
|
25
|
+
if (node.name.type === 'JSXIdentifier' && node.name.name === 'style') {
|
|
26
|
+
context.report({ node, messageId: 'inlineStyle' });
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** zustand-style store hooks are `use<Name>Store`. */
|
|
34
|
+
const STORE_HOOK = /^use[A-Z]\w*Store$/;
|
|
35
|
+
|
|
36
|
+
/** `useXStore()` / `useXStore(s => s)`: the component re-renders on every
|
|
37
|
+
* write to any field of the store, not just the ones it reads. */
|
|
38
|
+
const noWholeStoreSubscription = {
|
|
39
|
+
meta: {
|
|
40
|
+
type: 'problem',
|
|
41
|
+
docs: { description: 'Require a selector when subscribing to a store hook' },
|
|
42
|
+
schema: [],
|
|
43
|
+
messages: {
|
|
44
|
+
wholeStore:
|
|
45
|
+
'{{name}} without a field selector subscribes to the whole store, so every write to any field re-renders this component ' +
|
|
46
|
+
'(Mingo chat: 4 renders per streamed frame -> 1 with selectors). Select the fields you read: ' +
|
|
47
|
+
'{{name}}(s => s.field), or useShallow(s => ({ ... })) for several.',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
create(context) {
|
|
51
|
+
return {
|
|
52
|
+
CallExpression(node) {
|
|
53
|
+
if (node.callee.type !== 'Identifier' || !STORE_HOOK.test(node.callee.name)) return;
|
|
54
|
+
const [selector] = node.arguments;
|
|
55
|
+
const identity =
|
|
56
|
+
selector?.type === 'ArrowFunctionExpression' &&
|
|
57
|
+
selector.params.length === 1 &&
|
|
58
|
+
selector.params[0].type === 'Identifier' &&
|
|
59
|
+
selector.body.type === 'Identifier' &&
|
|
60
|
+
selector.body.name === selector.params[0].name;
|
|
61
|
+
if (!selector || identity) {
|
|
62
|
+
context.report({ node, messageId: 'wholeStore', data: { name: node.callee.name } });
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const webviewPerformancePlugin = {
|
|
70
|
+
meta: { name: 'flamingo-webview-performance' },
|
|
71
|
+
rules: {
|
|
72
|
+
'no-inline-style-element': noInlineStyleElement,
|
|
73
|
+
'no-whole-store-subscription': noWholeStoreSubscription,
|
|
74
|
+
},
|
|
75
|
+
};
|
package/package.json
CHANGED