@kutur-kit/oxc 0.1.0-alpha.7 → 0.1.0-alpha.8

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 (139) hide show
  1. package/README.md +69 -21
  2. package/dist/app.d.ts +16 -0
  3. package/dist/app.d.ts.map +1 -0
  4. package/dist/app.js +17 -0
  5. package/dist/app.js.map +1 -0
  6. package/dist/base.d.ts.map +1 -1
  7. package/dist/base.js +5 -1
  8. package/dist/base.js.map +1 -1
  9. package/dist/effect-ui-stylex/class.d.ts +2 -0
  10. package/dist/effect-ui-stylex/class.d.ts.map +1 -0
  11. package/dist/effect-ui-stylex/class.js +109 -0
  12. package/dist/effect-ui-stylex/class.js.map +1 -0
  13. package/dist/effect-ui-stylex/components.d.ts +30 -0
  14. package/dist/effect-ui-stylex/components.d.ts.map +1 -0
  15. package/dist/effect-ui-stylex/components.js +175 -0
  16. package/dist/effect-ui-stylex/components.js.map +1 -0
  17. package/dist/effect-ui-stylex/condition-key.d.ts.map +1 -0
  18. package/dist/{foldkit-stylex → effect-ui-stylex}/condition-key.js +7 -41
  19. package/dist/effect-ui-stylex/condition-key.js.map +1 -0
  20. package/dist/effect-ui-stylex/hover-gate.d.ts.map +1 -0
  21. package/dist/effect-ui-stylex/hover-gate.js.map +1 -0
  22. package/dist/effect-ui-stylex/internal-import.d.ts +2 -0
  23. package/dist/effect-ui-stylex/internal-import.d.ts.map +1 -0
  24. package/dist/effect-ui-stylex/internal-import.js +29 -0
  25. package/dist/effect-ui-stylex/internal-import.js.map +1 -0
  26. package/dist/effect-ui-stylex/layers.d.ts +14 -0
  27. package/dist/effect-ui-stylex/layers.d.ts.map +1 -0
  28. package/dist/effect-ui-stylex/layers.js +118 -0
  29. package/dist/effect-ui-stylex/layers.js.map +1 -0
  30. package/dist/effect-ui-stylex/look-level.d.ts +2 -0
  31. package/dist/effect-ui-stylex/look-level.d.ts.map +1 -0
  32. package/dist/effect-ui-stylex/look-level.js +83 -0
  33. package/dist/effect-ui-stylex/look-level.js.map +1 -0
  34. package/dist/effect-ui-stylex/modules.d.ts +36 -0
  35. package/dist/effect-ui-stylex/modules.d.ts.map +1 -0
  36. package/dist/effect-ui-stylex/modules.js +97 -0
  37. package/dist/effect-ui-stylex/modules.js.map +1 -0
  38. package/dist/effect-ui-stylex/parts.d.ts +17 -0
  39. package/dist/effect-ui-stylex/parts.d.ts.map +1 -0
  40. package/dist/effect-ui-stylex/parts.js +66 -0
  41. package/dist/effect-ui-stylex/parts.js.map +1 -0
  42. package/dist/effect-ui-stylex/raw-part.d.ts +2 -0
  43. package/dist/effect-ui-stylex/raw-part.d.ts.map +1 -0
  44. package/dist/effect-ui-stylex/raw-part.js +90 -0
  45. package/dist/effect-ui-stylex/raw-part.js.map +1 -0
  46. package/dist/effect-ui-stylex/state-attributes.d.ts +8 -0
  47. package/dist/effect-ui-stylex/state-attributes.d.ts.map +1 -0
  48. package/dist/effect-ui-stylex/state-attributes.js +141 -0
  49. package/dist/effect-ui-stylex/state-attributes.js.map +1 -0
  50. package/dist/effect-ui-stylex/state-key.d.ts +2 -0
  51. package/dist/effect-ui-stylex/state-key.d.ts.map +1 -0
  52. package/dist/effect-ui-stylex/state-key.js +103 -0
  53. package/dist/effect-ui-stylex/state-key.js.map +1 -0
  54. package/dist/effect-ui-stylex/subpath.d.ts +10 -0
  55. package/dist/effect-ui-stylex/subpath.d.ts.map +1 -0
  56. package/dist/effect-ui-stylex/subpath.js +53 -0
  57. package/dist/effect-ui-stylex/subpath.js.map +1 -0
  58. package/dist/effect-ui-stylex.d.ts +23 -0
  59. package/dist/effect-ui-stylex.d.ts.map +1 -0
  60. package/dist/{foldkit-stylex.js → effect-ui-stylex.js} +10 -9
  61. package/dist/effect-ui-stylex.js.map +1 -0
  62. package/dist/{foldkit-stylex.json → effect-ui-stylex.json} +7 -6
  63. package/dist/plugin.d.ts.map +1 -1
  64. package/dist/plugin.js +18 -12
  65. package/dist/plugin.js.map +1 -1
  66. package/dist/rules/imports.d.ts +5 -6
  67. package/dist/rules/imports.d.ts.map +1 -1
  68. package/dist/rules/imports.js +18 -14
  69. package/dist/rules/imports.js.map +1 -1
  70. package/dist/rules/module-sources.d.ts +33 -0
  71. package/dist/rules/module-sources.d.ts.map +1 -0
  72. package/dist/rules/module-sources.js +139 -0
  73. package/dist/rules/module-sources.js.map +1 -0
  74. package/dist/rules/no-suppression-directives.js +3 -3
  75. package/dist/rules/no-suppression-directives.js.map +1 -1
  76. package/dist/rules/scope.d.ts +3 -1
  77. package/dist/rules/scope.d.ts.map +1 -1
  78. package/dist/rules/scope.js.map +1 -1
  79. package/dist/vendor/anti-slop/rules/no-runtime-typeof.js +1 -1
  80. package/dist/vendor/anti-slop/rules/no-runtime-typeof.js.map +1 -1
  81. package/package.json +11 -7
  82. package/src/app.ts +19 -0
  83. package/src/base.ts +5 -1
  84. package/src/effect-ui-stylex/class.ts +140 -0
  85. package/src/effect-ui-stylex/components.ts +184 -0
  86. package/src/{foldkit-stylex → effect-ui-stylex}/condition-key.ts +6 -52
  87. package/src/effect-ui-stylex/internal-import.ts +32 -0
  88. package/src/effect-ui-stylex/layers.ts +161 -0
  89. package/src/effect-ui-stylex/look-level.ts +99 -0
  90. package/src/effect-ui-stylex/modules.ts +115 -0
  91. package/src/effect-ui-stylex/parts.ts +89 -0
  92. package/src/effect-ui-stylex/raw-part.ts +110 -0
  93. package/src/effect-ui-stylex/state-attributes.ts +140 -0
  94. package/src/effect-ui-stylex/state-key.ts +147 -0
  95. package/src/effect-ui-stylex/subpath.ts +65 -0
  96. package/src/{foldkit-stylex.ts → effect-ui-stylex.ts} +9 -8
  97. package/src/plugin.ts +18 -12
  98. package/src/rules/imports.ts +22 -15
  99. package/src/rules/module-sources.ts +179 -0
  100. package/src/rules/no-suppression-directives.ts +3 -3
  101. package/src/rules/scope.ts +1 -1
  102. package/src/vendor/anti-slop/UPSTREAM.md +2 -0
  103. package/src/vendor/anti-slop/rules/no-runtime-typeof.ts +1 -1
  104. package/dist/foldkit-stylex/attributes.d.ts +0 -2
  105. package/dist/foldkit-stylex/attributes.d.ts.map +0 -1
  106. package/dist/foldkit-stylex/attributes.js +0 -191
  107. package/dist/foldkit-stylex/attributes.js.map +0 -1
  108. package/dist/foldkit-stylex/components.d.ts +0 -12
  109. package/dist/foldkit-stylex/components.d.ts.map +0 -1
  110. package/dist/foldkit-stylex/components.js +0 -41
  111. package/dist/foldkit-stylex/components.js.map +0 -1
  112. package/dist/foldkit-stylex/condition-key.d.ts.map +0 -1
  113. package/dist/foldkit-stylex/condition-key.js.map +0 -1
  114. package/dist/foldkit-stylex/hover-gate.d.ts.map +0 -1
  115. package/dist/foldkit-stylex/hover-gate.js.map +0 -1
  116. package/dist/foldkit-stylex/styles.d.ts +0 -2
  117. package/dist/foldkit-stylex/styles.d.ts.map +0 -1
  118. package/dist/foldkit-stylex/styles.js +0 -131
  119. package/dist/foldkit-stylex/styles.js.map +0 -1
  120. package/dist/foldkit-stylex/unstyled-view.d.ts +0 -2
  121. package/dist/foldkit-stylex/unstyled-view.d.ts.map +0 -1
  122. package/dist/foldkit-stylex/unstyled-view.js +0 -94
  123. package/dist/foldkit-stylex/unstyled-view.js.map +0 -1
  124. package/dist/foldkit-stylex/vite.d.ts +0 -2
  125. package/dist/foldkit-stylex/vite.d.ts.map +0 -1
  126. package/dist/foldkit-stylex/vite.js +0 -26
  127. package/dist/foldkit-stylex/vite.js.map +0 -1
  128. package/dist/foldkit-stylex.d.ts +0 -22
  129. package/dist/foldkit-stylex.d.ts.map +0 -1
  130. package/dist/foldkit-stylex.js.map +0 -1
  131. package/src/foldkit-stylex/attributes.ts +0 -282
  132. package/src/foldkit-stylex/components.ts +0 -41
  133. package/src/foldkit-stylex/styles.ts +0 -170
  134. package/src/foldkit-stylex/unstyled-view.ts +0 -121
  135. package/src/foldkit-stylex/vite.ts +0 -29
  136. /package/dist/{foldkit-stylex → effect-ui-stylex}/condition-key.d.ts +0 -0
  137. /package/dist/{foldkit-stylex → effect-ui-stylex}/hover-gate.d.ts +0 -0
  138. /package/dist/{foldkit-stylex → effect-ui-stylex}/hover-gate.js +0 -0
  139. /package/src/{foldkit-stylex → effect-ui-stylex}/hover-gate.ts +0 -0
@@ -0,0 +1,99 @@
1
+ import type { ESTree } from "@oxlint/plugins";
2
+
3
+ import { defineRule } from "@oxlint/plugins";
4
+
5
+ import { exportOf, type Imports, importsOf, keyOf } from "../rules/imports.ts";
6
+
7
+ const side = "Top|Right|Bottom|Left|InlineStart|InlineEnd|BlockStart|BlockEnd";
8
+
9
+ // Each family of properties that set one side or one physical axis, with the property a caller
10
+ // writes for the level above it. StyleX applies the narrower property over the wider one
11
+ // whatever the order of the styles.
12
+ const levels: ReadonlyArray<readonly [RegExp, (...groups: ReadonlyArray<string>) => string]> = [
13
+ [
14
+ /^(padding|margin|scrollPadding|scrollMargin)(Inline|Block)(?:Start|End)$/,
15
+ (box = "", axis = "") => `${box}${axis}`,
16
+ ],
17
+ [
18
+ /^(padding|margin|scrollPadding|scrollMargin)(Top|Bottom|Left|Right)$/,
19
+ (box = "", edge = "") => `${box}${edge === "Top" || edge === "Bottom" ? "Block" : "Inline"}`,
20
+ ],
21
+ [/^inset(Inline|Block)(?:Start|End)$/, (axis = "") => `inset${axis}`],
22
+ [/^(top|bottom)$/, () => "insetBlock"],
23
+ [/^(left|right)$/, () => "insetInline"],
24
+ [new RegExp(`^border(?:${side})(Width|Style|Color)$`), (kind = "") => `border${kind}`],
25
+ [
26
+ /^border(?:TopLeft|TopRight|BottomLeft|BottomRight|StartStart|StartEnd|EndStart|EndEnd)Radius$/,
27
+ () => "borderRadius",
28
+ ],
29
+ [/^(overflow|overscrollBehavior)[XY]$/, (property = "") => property],
30
+ ];
31
+
32
+ // The property of the level above `property`, or `undefined` for one that sets a whole level.
33
+ const levelAbove = (property: string) => {
34
+ for (const [pattern, above] of levels) {
35
+ const match = pattern.exec(property);
36
+
37
+ if (match !== null) return above(...match.slice(1));
38
+ }
39
+
40
+ return undefined;
41
+ };
42
+
43
+ export const lookLevel = defineRule({
44
+ meta: {
45
+ type: "problem",
46
+ docs: {
47
+ description:
48
+ "In a library of drawn elements, hold a look to the properties its style option can replace.",
49
+ },
50
+ schema: [],
51
+ messages: {
52
+ level:
53
+ "Write this look with {{above}}, or exclude {{above}} from the `style` option of the function that draws the element and say so in a comment that disables this rule for the line. StyleX applies {{property}} over a caller's {{above}} whatever the order of the styles, so the override would lose without a word.",
54
+ },
55
+ },
56
+ createOnce(context) {
57
+ let imports: Imports = new Map();
58
+
59
+ const checkStyle = (style: ESTree.Node) => {
60
+ // A dynamic style's properties are in the object its function returns.
61
+ const object = style.type === "ArrowFunctionExpression" ? style.body : style;
62
+
63
+ if (object.type !== "ObjectExpression") return;
64
+
65
+ for (const property of object.properties) {
66
+ const name = property.type === "Property" ? keyOf(property) : undefined;
67
+ const above = name === undefined ? undefined : levelAbove(name);
68
+
69
+ if (property.type === "Property" && name !== undefined && above !== undefined) {
70
+ context.report({
71
+ node: property.key,
72
+ messageId: "level",
73
+ data: { property: name, above },
74
+ });
75
+ }
76
+ }
77
+ };
78
+
79
+ return {
80
+ Program(program) {
81
+ imports = importsOf(program);
82
+ },
83
+ CallExpression(node) {
84
+ const [styles] = node.arguments;
85
+
86
+ if (
87
+ exportOf(node.callee, imports, "@stylexjs/stylex") !== "create" ||
88
+ styles?.type !== "ObjectExpression"
89
+ ) {
90
+ return;
91
+ }
92
+
93
+ for (const entry of styles.properties) {
94
+ if (entry.type === "Property") checkStyle(entry.value);
95
+ }
96
+ },
97
+ };
98
+ },
99
+ });
@@ -0,0 +1,115 @@
1
+ /** The package of the drawn components, imported by module, as `@kutur-kit/effect-ui-stylex/dialog`. */
2
+ export const library = "@kutur-kit/effect-ui-stylex";
3
+
4
+ /**
5
+ * The layers of the library's `src`. The mechanism is the StyleX plumbing in `src/mechanism`,
6
+ * which knows no look. The design is the tokens, looks and icons, each a module of `src/design`.
7
+ * A component is a module of `src/components`. `src/testing.ts` is the one module above them.
8
+ */
9
+ export type Layer = "mechanism" | "design" | "component" | "testing";
10
+
11
+ /** A module of the library: its layer and its name there, such as `component` and `button`. */
12
+ export type Place = Readonly<{ layer: Layer; name: string }>;
13
+
14
+ /** The directory of `src` that holds a layer's modules. */
15
+ export const directories = {
16
+ mechanism: "mechanism",
17
+ design: "design",
18
+ component: "components",
19
+ } as const satisfies Readonly<Record<Exclude<Layer, "testing">, string>>;
20
+
21
+ const components = [
22
+ "accordion",
23
+ "alert-dialog",
24
+ "autocomplete",
25
+ "avatar",
26
+ "button",
27
+ "calendar",
28
+ "checkbox",
29
+ "checkbox-group",
30
+ "collapsible",
31
+ "combobox",
32
+ "date-field",
33
+ "date-picker",
34
+ "dialog",
35
+ "drawer",
36
+ "drawer-provider",
37
+ "field",
38
+ "fieldset",
39
+ "file-drop",
40
+ "form",
41
+ "input",
42
+ "menu",
43
+ "menubar",
44
+ "meter",
45
+ "navigation-menu",
46
+ "number-field",
47
+ "otp-field",
48
+ "popover",
49
+ "preview-card",
50
+ "progress",
51
+ "radio-group",
52
+ "range-calendar",
53
+ "scroll-area",
54
+ "select",
55
+ "separator",
56
+ "slider",
57
+ "switch",
58
+ "tabs",
59
+ "time-field",
60
+ "toast",
61
+ "toggle",
62
+ "toggle-group",
63
+ "toolbar",
64
+ "tooltip",
65
+ "virtual-list",
66
+ ] as const;
67
+
68
+ /**
69
+ * The layer of each module the library exports, by the name an app imports it with: `button` for
70
+ * `@kutur-kit/effect-ui-stylex/button`. A test derives the table from the library's
71
+ * `package.json`, so add a module in the change that exports it.
72
+ */
73
+ export const modules: ReadonlyMap<string, Layer> = new Map<string, Layer>([
74
+ ...components.map((name) => [name, "component"] as const),
75
+ ["icons", "design"],
76
+ ["looks", "design"],
77
+ ["tokens.stylex", "design"],
78
+ ["compiled", "mechanism"],
79
+ ["reset.css", "mechanism"],
80
+ ["style", "mechanism"],
81
+ ["vite", "mechanism"],
82
+ ["testing", "testing"],
83
+ ]);
84
+
85
+ /** A file's name without the extension of a TypeScript or JavaScript module. */
86
+ export const stem = (file: string) => file.replace(/\.(?:d\.[cm]?ts|[cm]?[jt]sx?)$/, "");
87
+
88
+ /**
89
+ * The module a path under the library's `src` or `dist` is, or `undefined` for a path in no
90
+ * layer. The mechanism nests, as `mechanism/internal/dev-stylesheets.ts`. A design or component
91
+ * module is a file of its directory, so `components/internal/shared.ts` is in no layer.
92
+ */
93
+ export const placeOf = (path: string): Place | undefined => {
94
+ const [directory, ...below] = path.split("/");
95
+ const name = stem(below.join("/"));
96
+
97
+ if (below.length === 0) {
98
+ return stem(path) === "testing" ? { layer: "testing", name: "testing" } : undefined;
99
+ }
100
+
101
+ if (directory === directories.mechanism) return { layer: "mechanism", name };
102
+
103
+ if (below.length > 1) return undefined;
104
+
105
+ if (directory === directories.design) return { layer: "design", name };
106
+
107
+ return directory === directories.component ? { layer: "component", name } : undefined;
108
+ };
109
+
110
+ /** The module an app imports as `@kutur-kit/effect-ui-stylex/<name>`, if the library exports it. */
111
+ export const exportedPlace = (name: string): Place | undefined => {
112
+ const layer = modules.get(name);
113
+
114
+ return layer === undefined ? undefined : { layer, name };
115
+ };
@@ -0,0 +1,89 @@
1
+ import type { ESTree, SourceCode } from "@oxlint/plugins";
2
+
3
+ import { keyOf } from "../rules/imports.ts";
4
+ import { variableOf } from "../rules/scope.ts";
5
+
6
+ /**
7
+ * The call that hands `fn` a component's parts: `fn` is the `view` of the options the component
8
+ * takes second, as in `Dialog(h, { view: (dialog) => … })`. A component's own
9
+ * `view: (h, model) => …` is in the one argument of `make`, so it is not one.
10
+ */
11
+ const partsCallOf = (fn: ESTree.Node): ESTree.CallExpression | undefined => {
12
+ const property = fn.parent;
13
+
14
+ if (property?.type !== "Property" || property.value !== fn || keyOf(property) !== "view") {
15
+ return undefined;
16
+ }
17
+
18
+ const options = property.parent;
19
+ const call = options.parent;
20
+
21
+ return options.type === "ObjectExpression" &&
22
+ call?.type === "CallExpression" &&
23
+ call.arguments[1] === options
24
+ ? call
25
+ : undefined;
26
+ };
27
+
28
+ /**
29
+ * The component call whose `view` gets `node` as its parts object: `Dialog(h, { … })` for `dialog`
30
+ * in `view: (dialog) => dialog.trigger(h.button)`. `undefined` for anything else, a parts object
31
+ * that reached a helper function as its parameter included.
32
+ */
33
+ const ownerOf = (sourceCode: SourceCode, node: ESTree.Node): ESTree.CallExpression | undefined => {
34
+ if (node.type !== "Identifier") return undefined;
35
+
36
+ for (const { type, node: fn } of variableOf(sourceCode, node)?.defs ?? []) {
37
+ if (type === "Parameter") return partsCallOf(fn);
38
+ }
39
+
40
+ return undefined;
41
+ };
42
+
43
+ /**
44
+ * The part a call applies, with the call that draws the part's component: `trigger` and
45
+ * `Dialog(h, { … })` for `dialog.trigger(h.button)` in that call's `view`.
46
+ */
47
+ export const partOf = (
48
+ sourceCode: SourceCode,
49
+ call: ESTree.CallExpression,
50
+ ): Readonly<{ name: string; owner: ESTree.CallExpression }> | undefined => {
51
+ const { callee } = call;
52
+
53
+ if (callee.type !== "MemberExpression" || callee.computed) return undefined;
54
+
55
+ const owner = ownerOf(sourceCode, callee.object);
56
+
57
+ return owner === undefined || callee.property.type !== "Identifier"
58
+ ? undefined
59
+ : { name: callee.property.name, owner };
60
+ };
61
+
62
+ /** The `element` an options object names, as in `tabs.tab({ element: h.button, value })`. */
63
+ const elementIn = (options: ESTree.ObjectExpression) =>
64
+ options.properties.find(
65
+ (property) => property.type === "Property" && keyOf(property) === "element",
66
+ );
67
+
68
+ /**
69
+ * The builder a call draws its element on, when the call is a part or a view function: the
70
+ * argument of `dialog.trigger(h.button)`, or the `element` of `tabs.tab({ element: h.button })`
71
+ * and of `Save(h, { element: h.button })`. A part's result is that builder again, so what is
72
+ * chained on the two reaches one element.
73
+ */
74
+ export const elementOf = (
75
+ sourceCode: SourceCode,
76
+ call: ESTree.CallExpression,
77
+ ): ESTree.Node | undefined => {
78
+ const [first, second] = call.arguments;
79
+ const part = partOf(sourceCode, call);
80
+ const options = part === undefined ? second : first;
81
+
82
+ if (options?.type === "ObjectExpression") {
83
+ const element = elementIn(options);
84
+
85
+ return element?.type === "Property" ? element.value : undefined;
86
+ }
87
+
88
+ return part === undefined || first?.type === "SpreadElement" ? undefined : first;
89
+ };
@@ -0,0 +1,110 @@
1
+ import type { ESTree } from "@oxlint/plugins";
2
+
3
+ import { defineRule } from "@oxlint/plugins";
4
+
5
+ import { type Imports, importsOf } from "../rules/imports.ts";
6
+ import { variableOf } from "../rules/scope.ts";
7
+ import { drawnFunction, drawnOf, drawnParts, libraryExportOf } from "./components.ts";
8
+ import { elementOf, partOf } from "./parts.ts";
9
+
10
+ // The parts that are behaviour alone where the library has no function for them: they take any
11
+ // drawn button.
12
+ const pressable: ReadonlySet<string> = new Set(["trigger", "close"]);
13
+
14
+ // A part of that name that is no button: a context menu opens over its trigger, which is any
15
+ // area of the page.
16
+ const areas: ReadonlySet<string> = new Set(["ContextMenu.trigger"]);
17
+
18
+ export const rawPart = defineRule({
19
+ meta: {
20
+ type: "problem",
21
+ docs: {
22
+ description:
23
+ "Disallow a part of a drawn component on a bare element where a drawn function exists.",
24
+ },
25
+ schema: [],
26
+ messages: {
27
+ drawn:
28
+ "Draw this part with {{drawn}}(h, {{parts}}) from {{module}}, and chain its children on the result. On a bare element {{parts}}.{{part}}(...) has none of the component's look, and none of the CSS the part needs to work.",
29
+ button:
30
+ "Give {{parts}}.{{part}}(...) a drawn button, as {{parts}}.{{part}}(Button(h)). The part is behaviour alone, so a bare element stays unstyled.",
31
+ },
32
+ },
33
+ createOnce(context) {
34
+ let imports: Imports = new Map();
35
+
36
+ const isParameter = (node: ESTree.Node) =>
37
+ node.type === "Identifier" &&
38
+ (variableOf(context.sourceCode, node)?.defs ?? []).some(({ type }) => type === "Parameter");
39
+
40
+ // Whether a part's element is a bare builder of the view's `h`, such as `h.div`,
41
+ // `h.div.attrs(...)` or `h.button.key(id)`, under any other part applied to it. An element
42
+ // that a drawn function or the app's own function made, or a variable holds, is not one.
43
+ const isBare = (node: ESTree.Node | undefined): boolean => {
44
+ if (node === undefined) return false;
45
+
46
+ if (node.type === "MemberExpression") return isParameter(node.object);
47
+
48
+ if (node.type !== "CallExpression" || node.callee.type !== "MemberExpression") return false;
49
+
50
+ const { object } = node.callee;
51
+
52
+ if (object.type !== "Identifier") return isBare(object);
53
+
54
+ // Another component's part around the element, as `tooltip.trigger(h.button)`.
55
+ if (partOf(context.sourceCode, node) !== undefined) {
56
+ return isBare(elementOf(context.sourceCode, node));
57
+ }
58
+
59
+ // `h.div(child)`.
60
+ return isParameter(object);
61
+ };
62
+
63
+ return {
64
+ Program(program) {
65
+ imports = importsOf(program);
66
+ },
67
+ CallExpression(node) {
68
+ const part = partOf(context.sourceCode, node);
69
+
70
+ if (part === undefined || node.callee.type !== "MemberExpression") return;
71
+
72
+ const component = libraryExportOf(part.owner.callee, imports);
73
+ const drawn = component === undefined ? undefined : drawnParts.get(component.name);
74
+
75
+ if (component === undefined || drawn === undefined) return;
76
+
77
+ const element = elementOf(context.sourceCode, node);
78
+
79
+ if (
80
+ element === undefined ||
81
+ (element.type === "CallExpression" && drawnOf(element.callee, imports) !== undefined) ||
82
+ !isBare(element)
83
+ ) {
84
+ return;
85
+ }
86
+
87
+ const parts = node.callee.object.type === "Identifier" ? node.callee.object.name : "parts";
88
+
89
+ if (drawn.includes(part.name)) {
90
+ context.report({
91
+ node: node.callee.property,
92
+ messageId: "drawn",
93
+ data: {
94
+ drawn: drawnFunction(component.name, part.name),
95
+ module: component.module,
96
+ part: part.name,
97
+ parts,
98
+ },
99
+ });
100
+ } else if (pressable.has(part.name) && !areas.has(`${component.name}.${part.name}`)) {
101
+ context.report({
102
+ node: node.callee.property,
103
+ messageId: "button",
104
+ data: { part: part.name, parts },
105
+ });
106
+ }
107
+ },
108
+ };
109
+ },
110
+ });
@@ -0,0 +1,140 @@
1
+ /**
2
+ * The data attributes effect/ui/kit writes, without `data-`: every `data-*` name in the
3
+ * JavaScript it ships. `effect-ui-state-key` reports a key that selects another. A test reads the
4
+ * list again from the installed effect, so replace it with the one the test prints when a
5
+ * release adds or drops a name.
6
+ */
7
+ export const stateAttributes: ReadonlyArray<string> = [
8
+ "activation-direction",
9
+ "active",
10
+ "align",
11
+ "anchor-hidden",
12
+ "behind",
13
+ "checked",
14
+ "closed",
15
+ "combobox-blocker",
16
+ "combobox-chip",
17
+ "combobox-chips",
18
+ "combobox-group",
19
+ "combobox-input",
20
+ "combobox-inside",
21
+ "combobox-positioner",
22
+ "combobox-trigger",
23
+ "complete",
24
+ "current",
25
+ "date-picker-input",
26
+ "date-picker-trigger",
27
+ "dialog-backdrop",
28
+ "dialog-blocker",
29
+ "dialog-portal",
30
+ "dialog-trigger",
31
+ "direction",
32
+ "dirty",
33
+ "disabled",
34
+ "drag-over",
35
+ "dragging",
36
+ "drawer-backdrop",
37
+ "drawer-content",
38
+ "drawer-popup",
39
+ "drop-position",
40
+ "effect-ui-devtools",
41
+ "empty",
42
+ "ending-style",
43
+ "expanded",
44
+ "filled",
45
+ "final-focus",
46
+ "focusable",
47
+ "focused",
48
+ "has-overflow-x",
49
+ "has-overflow-y",
50
+ "has-submenu-open",
51
+ "hidden",
52
+ "highlighted",
53
+ "hovering",
54
+ "in-range",
55
+ "inactive",
56
+ "indeterminate",
57
+ "index",
58
+ "instant",
59
+ "invalid",
60
+ "key",
61
+ "limited",
62
+ "list-empty",
63
+ "menu-active",
64
+ "menu-blocker",
65
+ "menu-context",
66
+ "menu-item",
67
+ "menu-popup",
68
+ "menu-trigger",
69
+ "menu-viewport",
70
+ "menubar-trigger",
71
+ "modal",
72
+ "moving",
73
+ "multiple",
74
+ "navigation-item",
75
+ "navigation-menu",
76
+ "navigation-menu-trigger",
77
+ "nested",
78
+ "nested-dialog-open",
79
+ "nested-drawer-open",
80
+ "nested-drawer-swiping",
81
+ "open",
82
+ "orientation",
83
+ "outside-month",
84
+ "overflow-x-end",
85
+ "overflow-x-start",
86
+ "overflow-y-end",
87
+ "overflow-y-start",
88
+ "panel-open",
89
+ "parent",
90
+ "placeholder",
91
+ "popup-open",
92
+ "popup-side",
93
+ "pressed",
94
+ "preview-card-trigger",
95
+ "previous",
96
+ "progressing",
97
+ "range-end",
98
+ "range-start",
99
+ "readonly",
100
+ "required",
101
+ "scroll-area-content",
102
+ "scroll-area-corner",
103
+ "scroll-area-scrollbar-x",
104
+ "scroll-area-scrollbar-y",
105
+ "scroll-area-thumb-x",
106
+ "scroll-area-thumb-y",
107
+ "scroll-area-viewport",
108
+ "scrolling",
109
+ "scrubbing",
110
+ "select-blocker",
111
+ "select-item-text",
112
+ "select-scroll-arrow",
113
+ "select-value",
114
+ "selected",
115
+ "side",
116
+ "starting-style",
117
+ "swipe-direction",
118
+ "swipe-dismiss",
119
+ "swipe-ignore",
120
+ "swiping",
121
+ "toast-root",
122
+ "today",
123
+ "tooltip-trigger",
124
+ "touched",
125
+ "transitioning",
126
+ "trigger-disabled",
127
+ "type",
128
+ "unavailable",
129
+ "uncentered",
130
+ "unchecked",
131
+ "valid",
132
+ "virtual-grid-body",
133
+ "virtual-grid-cell",
134
+ "virtual-grid-row",
135
+ "virtual-grid-viewport",
136
+ "virtual-list-item",
137
+ "virtual-list-spacer",
138
+ "virtual-list-viewport",
139
+ "visible",
140
+ ];