🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore(eslint): Make `no-style-props` catch prefixed props (#16699)
Ben Bachem5cda0d28214e
diff --git a/packages/eslint-plugin/src/rules/no-style-props.test.ts b/packages/eslint-plugin/src/rules/no-style-props.test.tsindex 3cc92782a8..d74d4be57a 100644--- a/packages/eslint-plugin/src/rules/no-style-props.test.ts+++ b/packages/eslint-plugin/src/rules/no-style-props.test.ts@@ -68,6 +68,8 @@ ruleTester.run("no-style-props", rule, {`interface BaseProps { variant?: "primary"; }interface ButtonProps extends BaseProps { size?: "sm"; }const Button = (props: ButtonProps) => <div />;`,+ `type ButtonProps = { classNames?: Record<string, string>; stylesheet?: string; classifier?: string };+ function Button(props: ButtonProps) { return <div />; }`,],invalid: [{@@ -391,5 +393,52 @@ ruleTester.run("no-style-props", rule, {{ messageId: "unexpectedProp", data: { propName: "className" } },],},+ {+ code: `type BadgeProps = { badgeClassName?: string };+ function Badge(props: BadgeProps) { return <div />; }`,+ errors: [+ {+ messageId: "unexpectedProp",+ data: { propName: "badgeClassName" },+ },+ ],+ },+ {+ code: `function Trigger({ triggerClassName }: { triggerClassName?: string }) { return <div />; }`,+ errors: [+ {+ messageId: "unexpectedProp",+ data: { propName: "triggerClassName" },+ },+ {+ messageId: "unexpectedProp",+ data: { propName: "triggerClassName" },+ },+ ],+ },+ {+ code: `interface DialogProps { "overlayClassName"?: string; }+ function Dialog(props: DialogProps) { return <div />; }`,+ errors: [+ {+ messageId: "unexpectedProp",+ data: { propName: "overlayClassName" },+ },+ ],+ },+ {+ code: `type TooltipProps = { contentStyle?: React.CSSProperties };+ function Tooltip(props: TooltipProps) { return <div />; }`,+ errors: [+ { messageId: "unexpectedProp", data: { propName: "contentStyle" } },+ ],+ },+ {+ code: `function Panel({ wrapperStyle }: { wrapperStyle?: React.CSSProperties }) { return <div />; }`,+ errors: [+ { messageId: "unexpectedProp", data: { propName: "wrapperStyle" } },+ { messageId: "unexpectedProp", data: { propName: "wrapperStyle" } },+ ],+ },],});diff --git a/packages/eslint-plugin/src/rules/no-style-props.ts b/packages/eslint-plugin/src/rules/no-style-props.tsindex 71a89d226f..623683f7a3 100644--- a/packages/eslint-plugin/src/rules/no-style-props.ts+++ b/packages/eslint-plugin/src/rules/no-style-props.ts@@ -2,8 +2,6 @@ import { AST_NODE_TYPES, type TSESTree } from "@typescript-eslint/utils";import { createComponentPropTypeVisitors } from "../react-components.js";import { createRule } from "../util.js";-const FORBIDDEN_PROP_NAMES = new Set(["className", "style"]);-function getPropertyName(key: TSESTree.PropertyName | TSESTree.PrivateIdentifier,): string | null {@@ -14,6 +12,15 @@ function getPropertyName(return null;}+function isForbiddenStyleProp(propName: string): boolean {+ return (+ propName === "className" ||+ propName === "style" ||+ propName.endsWith("ClassName") ||+ propName.endsWith("Style")+ );+}+const rule = createRule({name: "no-style-props",meta: {@@ -33,7 +40,7 @@ const rule = createRule({node: TSESTree.Node,propName: string | null,): void {- if (!propName || !FORBIDDEN_PROP_NAMES.has(propName)) return;+ if (!propName || !isForbiddenStyleProp(propName)) return;context.report({node,messageId: "unexpectedProp",diff --git a/web/eslint.config.mjs b/web/eslint.config.mjsindex 34ce1a7c83..1141d6568e 100644--- a/web/eslint.config.mjs+++ b/web/eslint.config.mjs@@ -139,9 +139,10 @@ export default [},},- // Component APIs should expose explicit variants instead of className or style- // escape hatches. New file-level overrides are only acceptable for headless- // components that do not apply any internal styling themselves.+ // Component APIs should expose explicit variants instead of className, style,+ // or prefixed variants such as badgeClassName. New file-level overrides are+ // only acceptable for headless components that do not apply any internal+ // styling themselves.{name: "langfuse/web/no-style-props",files: ["src/**/*.{ts,tsx}"],diff --git a/web/src/components/grouped-score-badge.tsx b/web/src/components/grouped-score-badge.tsxindex 4224386224..401c2bfecf 100644--- a/web/src/components/grouped-score-badge.tsx+++ b/web/src/components/grouped-score-badge.tsx@@ -1,3 +1,4 @@+/* eslint-disable @repo/no-style-props */import { useState } from "react";import { Badge, badgeVariants } from "@/src/components/ui/badge";import {diff --git a/web/src/components/session/index.tsx b/web/src/components/session/index.tsxindex 484eca7267..3bc263b801 100644--- a/web/src/components/session/index.tsx+++ b/web/src/components/session/index.tsx@@ -1,3 +1,4 @@+/* eslint-disable @repo/no-style-props */import { cn } from "@/src/utils/tailwind";import { GroupedScoreBadges } from "@/src/components/grouped-score-badge";import { ErrorPage } from "@/src/components/error-page";diff --git a/web/src/components/ui/multi-select-combobox.tsx b/web/src/components/ui/multi-select-combobox.tsxindex ef19dac7e5..a753025679 100644--- a/web/src/components/ui/multi-select-combobox.tsx+++ b/web/src/components/ui/multi-select-combobox.tsx@@ -1,3 +1,4 @@+/* eslint-disable @repo/no-style-props */import { useState, useEffect, useRef, type ReactNode } from "react";import { Input } from "@/src/components/ui/input";import { Button } from "@/src/components/ui/button";diff --git a/web/src/features/evals/components/default-eval-model-setup.tsx b/web/src/features/evals/components/default-eval-model-setup.tsxindex be7e79aa80..eb8e4d7f82 100644--- a/web/src/features/evals/components/default-eval-model-setup.tsx+++ b/web/src/features/evals/components/default-eval-model-setup.tsx@@ -1,4 +1,4 @@-/* eslint-disable @repo/no-abstracted-overlay-trigger */+/* eslint-disable @repo/no-abstracted-overlay-trigger, @repo/no-style-props */import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { ModelParameters } from "@/src/components/ModelParameters";import { CardContent, Card } from "@/src/components/ui/card";diff --git a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsx b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsxindex f91b316ff5..a9ad6fd785 100644--- a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsx+++ b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsx@@ -1,3 +1,4 @@+/* eslint-disable @repo/no-style-props */import { useCallback, useMemo, useState, type UIEvent } from "react";import { EyeOff, FlaskConical, ListTree, Sparkles, Wrench } from "lucide-react";import {diff --git a/web/src/features/experiments/components/table/ExperimentGridCell.tsx b/web/src/features/experiments/components/table/ExperimentGridCell.tsxindex 75c554ad6a..f93769f80d 100644--- a/web/src/features/experiments/components/table/ExperimentGridCell.tsx+++ b/web/src/features/experiments/components/table/ExperimentGridCell.tsx@@ -1,3 +1,4 @@+/* eslint-disable @repo/no-style-props */import { MemoizedIOTableCell } from "@/src/components/ui/IOTableCell";import { Badge } from "@/src/components/ui/badge";import {diff --git a/web/src/features/score-analytics/components/charts/HeatmapCell.tsx b/web/src/features/score-analytics/components/charts/HeatmapCell.tsxindex 71502d2b6b..677f77c71e 100644--- a/web/src/features/score-analytics/components/charts/HeatmapCell.tsx+++ b/web/src/features/score-analytics/components/charts/HeatmapCell.tsx@@ -1,3 +1,4 @@+/* eslint-disable @repo/no-style-props */import { type HeatmapCell } from "@/src/features/score-analytics/lib/heatmap-utils";import { getContrastColor } from "@/src/features/score-analytics/lib/color-scales";import {diff --git a/web/src/features/v4-migration/apiMigrationGuidance.ts b/web/src/features/v4-migration/apiMigrationGuidance.tsindex fc1e509e2a..8e57629f72 100644--- a/web/src/features/v4-migration/apiMigrationGuidance.ts+++ b/web/src/features/v4-migration/apiMigrationGuidance.ts@@ -213,8 +213,7 @@ const genericReplacements: Record<string, string> = {"GET /api/public/generations":"GET /api/public/v2/observations?type=GENERATION","GET /api/public/scores": "GET /api/public/v3/scores",- "GET /api/public/metrics/daily":- "GET /api/public/v2/metrics?query=<URL-encoded JSON with view, metrics, fromTimestamp, and toTimestamp>",+ "GET /api/public/metrics/daily": "GET /api/public/v2/metrics",};const isVersionBefore = (version: string, minimum: string): boolean => {