Fix the ESLint findings in the Floating UI code and the markup-classes gate

This commit is contained in:
Bartek committed 2026-10-02 12:33:38 +02:00
1 parent ad80ded69d
commit 763d7a369d
4 files changed
+8 -8

No files matched your search

+2 -2
View File
@@ -30,7 +30,7 @@ const CLASS_SELECTOR = new RegExp(String.raw`\.(-?(?:${ESCAPE}|[_a-zA-Z\u00a0-\u
const decodeIdent = (ident: string): string => ident.replace(/\\([0-9a-fA-F]{1,6})[ \t\r\n\f]?|\\(.)/g, (_, hex: string | undefined, char: string | undefined) => (hex === undefined ? char! : String.fromCodePoint(parseInt(hex, 16))))
const classNamesIn = (css: string): string[] => [...css.matchAll(CLASS_SELECTOR)].map((m) => decodeIdent(m[1]!))
const classNamesIn = (css: string): string[] => [...css.matchAll(CLASS_SELECTOR)].map((m) => decodeIdent(m[1]))
const args = process.argv.slice(2)
const htmlTargets: string[] = []
@@ -84,7 +84,7 @@ const main = async () => {
pageCount++
// Page-level <style> blocks define classes too (demo pages style their own markup).
const inline = new Set<string>()
for (const block of html.matchAll(/<style[^>]*>([\s\S]*?)<\/style>/g)) for (const cls of classNamesIn(block[1]!)) inline.add(cls)
for (const block of html.matchAll(/<style[^>]*>([\s\S]*?)<\/style>/g)) for (const cls of classNamesIn(block[1])) inline.add(cls)
for (const m of html.matchAll(/class="([^"]*)"/g)) {
for (const cls of m[1].split(/\s+/).filter(Boolean)) {
if (defined.has(cls) || inline.has(cls)) continue
+2 -2
View File
@@ -20,7 +20,7 @@ type FloatingConfigFunction = (defaultConfig: FloatingConfig) => Partial<Floatin
type ComponentConfig = {
autoClose: boolean | 'inside' | 'outside'
// A string is Popper's `clippingParents`, kept for v5 markup and mapped to `clippingAncestors`.
boundary: Boundary | string
boundary: Exclude<Boundary, string> | string
display: 'dynamic' | 'static'
offset: number[] | string | ((state: MiddlewareState, element: HTMLElement) => number[])
popperConfig: Partial<FloatingConfig> | FloatingConfigFunction | null
@@ -210,7 +210,7 @@ class Dropdown extends BaseComponent {
_getConfig(config?: ComponentConfigInput): ComponentConfig {
const merged = super._getConfig(config) as ComponentConfig
if (typeof merged.reference === 'object' && !isElement(merged.reference) && typeof (merged.reference as VirtualElement).getBoundingClientRect !== 'function') {
if (typeof merged.reference === 'object' && !isElement(merged.reference) && typeof merged.reference.getBoundingClientRect !== 'function') {
throw new TypeError(`${NAME.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`)
}
+1 -1
View File
@@ -61,7 +61,7 @@ export type TooltipConfig = {
allowList: AllowList
animation: boolean
// A string is Popper's `clippingParents`, kept for v5 markup and mapped to `clippingAncestors`.
boundary: Boundary | string
boundary: Exclude<Boundary, string> | string
container: HTMLElement | string | false
customClass: string | ((this: HTMLElement, element: HTMLElement) => string)
delay: TooltipDelay
+3 -3
View File
@@ -118,7 +118,7 @@ class FloatingUi {
}
if (isElement(reference)) {
return getElement(reference as HTMLElement | string)!
return getElement(reference)!
}
if (typeof reference === 'object' && reference !== null) {
@@ -166,12 +166,12 @@ function normalizeOffset(value: unknown): OffsetValue {
}
if (Array.isArray(raw)) {
const [crossAxis = 0, mainAxis = 0] = raw
const [crossAxis = 0, mainAxis = 0] = raw as number[]
return { mainAxis, crossAxis }
}
if (typeof raw === 'number' || (typeof raw === 'object' && raw !== null)) {
return raw as OffsetValue
return raw
}
return 0