Skip to content

πŸ™Œ OpenHands: AI-Driven Development

chore(lint): stage inline-style warnings (#18275)

Engel Nyst864db17a7d0c
diff --git a/.agents/skills/frontend-development/references/guide.md b/.agents/skills/frontend-development/references/guide.md
index 76ff3fb8f5..8307431432 100644
--- a/.agents/skills/frontend-development/references/guide.md
+++ b/.agents/skills/frontend-development/references/guide.md
@@ -1,3 +1,16 @@
+## Inline-style rollout
+
+`shadcn/no-inline-styles` runs at warning severity across source, including UI
+primitive implementations. Numeric CSS custom properties and semantic token
+references pass; hardcoded variable colors and style elements still warn.
+Do not add a blanket property allowance or blindly replace measured dimensions,
+portal coordinates, or renderer-library styles with static classes. Review the
+value's owner before moving it to classes or CSS variables.
+
+`src/components/providers/agent-server-ui-root.tsx` is the exact exception: its
+public `style` / `styleOverrides` API forwards caller-owned styles, so the
+implementation must accept an opaque object. Other lint policies keep their scope.
+
## Skill Loading
Public skills are loaded from the `@openhands/extensions` npm package at build time through `SKILLS_CATALOG` from `@openhands/extensions/skills`. `SkillsService` maps catalog entries to `SkillInfo` and merges them with user and project skills fetched from the Agent Server using `load_public: false`.
diff --git a/__tests__/scripts/inline-styles-lint.test.ts b/__tests__/scripts/inline-styles-lint.test.ts
new file mode 100644
index 0000000000..b9e4ed9cef
--- /dev/null
+++ b/__tests__/scripts/inline-styles-lint.test.ts
@@ -0,0 +1,53 @@
+// @vitest-environment node
+import { ESLint } from "eslint";
+import { describe, expect, it } from "vitest";
+
+const eslint = new ESLint({
+ overrideConfig: [
+ {
+ languageOptions: { parserOptions: { project: null } },
+ rules: { "@typescript-eslint/prefer-optional-chain": "off" },
+ },
+ ],
+});
+
+const cases = [
+ { jsx: '<div style={{ "--progress": width }} />', warning: false },
+ {
+ jsx: '<div style={{ "--ink": "var(--oh-foreground)" }} />',
+ warning: false,
+ },
+ { jsx: "<div style={{ width }} />", warning: true },
+ { jsx: "<div style={forwardedStyle} />", warning: true },
+ { jsx: '<div style={{ "--ink": "#ff0000" }} />', warning: true },
+ { jsx: '<style>{".probe { color: red; }"}</style>', warning: true },
+];
+const probe = `export function Probe({ width, forwardedStyle }) { return <>\n${cases.map(({ jsx }) => jsx).join("\n")}\n</>; }`;
+
+describe("Canvas inline-style warning policy", () => {
+ it("warns about inline styling while accepting dynamic variables and semantic tokens", async () => {
+ const [result] = await eslint.lintText(probe, {
+ filePath: "src/routes/inline-style-probe.tsx",
+ });
+ expect(result.fatalErrorCount).toBe(0);
+ const findings = result.messages.filter(
+ ({ ruleId }) => ruleId === "shadcn/no-inline-styles",
+ );
+ expect(new Set(findings.map(({ line }) => line - 2))).toEqual(
+ new Set(cases.flatMap(({ warning }, index) => (warning ? [index] : []))),
+ );
+ expect(findings.every(({ severity }) => severity === 1)).toBe(true);
+ });
+
+ it("preserves the embedding root's caller-owned style API", async () => {
+ const [result] = await eslint.lintText(probe, {
+ filePath: "src/components/providers/agent-server-ui-root.tsx",
+ });
+ expect(result.fatalErrorCount).toBe(0);
+ expect(
+ result.messages.filter(
+ ({ ruleId }) => ruleId === "shadcn/no-inline-styles",
+ ),
+ ).toEqual([]);
+ });
+});
diff --git a/eslint.config.js b/eslint.config.js
index e7c9c382cd..a8909b30de 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -451,7 +451,10 @@ export default [
],
},
],
- "shadcn/no-inline-styles": "off",
+ // Warning-only while measured layout, portal placement, accessibility
+ // helpers and renderer interfaces are reviewed by their owners. The rule
+ // permits CSS variables itself; no broad property/color exception is needed.
+ "shadcn/no-inline-styles": "warn",
"shadcn/require-static-classes": [
"error",
{ componentImports: ["^#/ui(/|$)"] },
@@ -478,4 +481,10 @@ export default [
"shadcn/require-static-classes": "off",
},
},
+ {
+ // Public embedding API: this owner must forward arbitrary caller styles.
+ // Its opaque object cannot be converted to custom-properties-only styles.
+ files: ["src/components/providers/agent-server-ui-root.tsx"],
+ rules: { "shadcn/no-inline-styles": "off" },
+ },
];