-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: run biome check on src files #556
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", | ||
"files": { | ||
"include": ["src/**/*.ts", "src/**/*.tsx"], | ||
"ignore": ["example", "expo-example", "docs", "plugin", "lib"] | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"indentStyle": "tab" | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"suspicious": { | ||
"noEmptyInterface": "off", | ||
"noExplicitAny": "off" | ||
}, | ||
"complexity": { | ||
"noForEach": "off", | ||
"noUselessSwitchCase": "off", | ||
"noBannedTypes": "off" | ||
}, | ||
"correctness": { | ||
"useExhaustiveDependencies": "off" | ||
} | ||
} | ||
}, | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"enabled": true, | ||
"quoteStyle": "single", | ||
"jsxQuoteStyle": "double", | ||
"trailingCommas": "all", | ||
"semicolons": "asNeeded", | ||
"arrowParentheses": "asNeeded", | ||
"indentStyle": "tab", | ||
"indentWidth": 4, | ||
"lineWidth": 120 | ||
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", | ||
"files": { | ||
"include": ["src/**/*.ts", "src/**/*.tsx"], | ||
"ignore": ["example", "expo-example", "docs", "plugin", "lib"] | ||
}, | ||
"globals": [], | ||
"jsxRuntime": "reactClassic" | ||
}, | ||
"json": { | ||
"formatter": { | ||
"enabled": true, | ||
"indentWidth": 2, | ||
"indentStyle": "tab", | ||
"lineWidth": 120 | ||
"enabled": true, | ||
"indentStyle": "space" | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"suspicious": { | ||
"noEmptyInterface": "off", | ||
"noExplicitAny": "off" | ||
}, | ||
"complexity": { | ||
"noForEach": "off", | ||
"noUselessSwitchCase": "off", | ||
"noBannedTypes": "off" | ||
}, | ||
"correctness": { | ||
"useExhaustiveDependencies": "off" | ||
} | ||
} | ||
}, | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"enabled": true, | ||
"quoteStyle": "single", | ||
"jsxQuoteStyle": "double", | ||
"trailingCommas": "all", | ||
"semicolons": "asNeeded", | ||
"arrowParentheses": "asNeeded", | ||
"indentStyle": "space", | ||
"indentWidth": 4, | ||
"lineWidth": 120 | ||
}, | ||
"globals": [], | ||
"jsxRuntime": "reactClassic" | ||
}, | ||
"json": { | ||
"formatter": { | ||
"enabled": true, | ||
"indentWidth": 4, | ||
"indentStyle": "space", | ||
"lineWidth": 120 | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import React from 'react' | ||
import { ImageBackground as NativeImageBackground } from 'react-native' | ||
import { forwardRef } from 'react' | ||
import type { UnistylesValues } from '../../types' | ||
import { ImageBackground as NativeImageBackground } from 'react-native' | ||
import { getClassName } from '../../core' | ||
import { isServer } from '../../web/utils' | ||
import { UnistylesShadowRegistry } from '../../web' | ||
import type { UnistylesValues } from '../../types' | ||
import { copyComponentProperties } from '../../utils' | ||
import { UnistylesShadowRegistry } from '../../web' | ||
import { isServer } from '../../web/utils' | ||
|
||
type Props = { | ||
style?: UnistylesValues | ||
|
@@ -24,34 +24,42 @@ const UnistylesImageBackground = forwardRef<unknown, Props>((props, forwardedRef | |
{...props} | ||
style={styleClassNames} | ||
imageStyle={imageClassNames} | ||
ref={isServer() ? undefined : ref => { | ||
if (!ref) { | ||
// @ts-expect-error hidden from TS | ||
UnistylesShadowRegistry.remove(storedRef, styleClassNames?.hash) | ||
} | ||
|
||
storedRef = ref | ||
// @ts-expect-error hidden from TS | ||
UnistylesShadowRegistry.add(ref, styleClassNames?.hash) | ||
|
||
if (typeof forwardedRef === 'function') { | ||
return forwardedRef(ref) | ||
} | ||
|
||
if (forwardedRef) { | ||
forwardedRef.current = ref | ||
} | ||
}} | ||
imageRef={isServer() ? undefined : ref => { | ||
if (!ref) { | ||
// @ts-expect-error hidden from TS | ||
UnistylesShadowRegistry.remove(storedImageRef, imageClassNames?.hash) | ||
} | ||
|
||
storedImageRef = ref | ||
// @ts-expect-error hidden from TS | ||
UnistylesShadowRegistry.add(ref, imageClassNames?.hash) | ||
}} | ||
ref={ | ||
isServer() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about it ? Can we tweak it? Looks bad There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as comment below, related to ternary formatting biomejs/biome#2388 |
||
? undefined | ||
: ref => { | ||
if (!ref) { | ||
// @ts-expect-error hidden from TS | ||
UnistylesShadowRegistry.remove(storedRef, styleClassNames?.hash) | ||
} | ||
|
||
storedRef = ref | ||
// @ts-expect-error hidden from TS | ||
UnistylesShadowRegistry.add(ref, styleClassNames?.hash) | ||
|
||
if (typeof forwardedRef === 'function') { | ||
return forwardedRef(ref) | ||
} | ||
|
||
if (forwardedRef) { | ||
forwardedRef.current = ref | ||
} | ||
} | ||
} | ||
imageRef={ | ||
isServer() | ||
? undefined | ||
: ref => { | ||
if (!ref) { | ||
// @ts-expect-error hidden from TS | ||
UnistylesShadowRegistry.remove(storedImageRef, imageClassNames?.hash) | ||
} | ||
|
||
storedImageRef = ref | ||
// @ts-expect-error hidden from TS | ||
UnistylesShadowRegistry.add(ref, imageClassNames?.hash) | ||
} | ||
} | ||
/> | ||
) | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
import React, { forwardRef, useLayoutEffect, useRef } from 'react' | ||
import { Pressable as NativePressableReactNative } from 'react-native' | ||
import type { PressableProps as Props, View } from 'react-native' | ||
import { UnistylesShadowRegistry } from '../../specs' | ||
import { passForwardedRef } from '../../core' | ||
import { UnistylesShadowRegistry } from '../../specs' | ||
|
||
type PressableProps = Props & { | ||
variants?: Record<string, string | boolean> | ||
} | ||
|
||
const getStyles = (styleProps: Record<string, any> = {}) => { | ||
const unistyleKey = Object | ||
.keys(styleProps) | ||
.find(key => key.startsWith('unistyles-')) | ||
const unistyleKey = Object.keys(styleProps).find(key => key.startsWith('unistyles-')) | ||
|
||
if (!unistyleKey) { | ||
return styleProps | ||
|
@@ -20,7 +18,7 @@ const getStyles = (styleProps: Record<string, any> = {}) => { | |
return { | ||
// styles without C++ state | ||
...styleProps[unistyleKey].uni__getStyles(), | ||
[unistyleKey]: styleProps[unistyleKey].uni__getStyles() | ||
[unistyleKey]: styleProps[unistyleKey].uni__getStyles(), | ||
} | ||
} | ||
|
||
|
@@ -40,9 +38,7 @@ export const Pressable = forwardRef<View, PressableProps>(({ variants, style, .. | |
<NativePressableReactNative | ||
{...props} | ||
ref={ref => { | ||
const unistyles = typeof style === 'function' | ||
? style({ pressed: false }) | ||
: style | ||
const unistyles = typeof style === 'function' ? style({ pressed: false }) : style | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why it's once in multiple lines and sometimes in single line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the default Biome's formatting for ternary, there is a discussion opened about it but no away at the moment to configure it |
||
|
||
// @ts-expect-error - this is hidden from TS | ||
UnistylesShadowRegistry.add(ref, unistyles) | ||
|
@@ -54,9 +50,8 @@ export const Pressable = forwardRef<View, PressableProps>(({ variants, style, .. | |
return passForwardedRef(props, ref, forwardedRef) | ||
}} | ||
style={state => { | ||
const unistyles = typeof style === 'function' | ||
? style(state) | ||
: getStyles(style as unknown as Record<string, any>) | ||
const unistyles = | ||
typeof style === 'function' ? style(state) : getStyles(style as unknown as Record<string, any>) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we increase line width? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I increased it to |
||
|
||
if (!storedRef.current) { | ||
return unistyles | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import React, { forwardRef } from 'react' | ||
import { Pressable as NativePressableReactNative } from 'react-native' | ||
import type { PressableProps as Props, View } from 'react-native' | ||
import { getClassName } from '../../core' | ||
import { UnistylesShadowRegistry } from '../../specs' | ||
import type { UnistylesValues } from '../../types' | ||
import { getClassName } from '../../core' | ||
import { isServer } from '../../web/utils' | ||
|
||
type Variants = Record<string, string | boolean | undefined> | ||
type WebPressableState = { | ||
pressed: boolean, | ||
hovered: boolean, | ||
pressed: boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did change |
||
hovered: boolean | ||
focused: boolean | ||
} | ||
|
||
type WebPressableStyle = ((state: WebPressableState) => UnistylesValues) | UnistylesValues | ||
|
||
type PressableProps = Props & { | ||
variants?: Variants | ||
style?: WebPressableStyle, | ||
style?: WebPressableStyle | ||
} | ||
|
||
export const Pressable = forwardRef<View, PressableProps>(({ style, ...props }, forwardedRef) => { | ||
|
@@ -28,23 +28,25 @@ export const Pressable = forwardRef<View, PressableProps>(({ style, ...props }, | |
return ( | ||
<NativePressableReactNative | ||
{...props} | ||
ref={isServer() ? undefined : ref => { | ||
storedRef = ref as unknown as HTMLElement | ||
// @ts-expect-error hidden from TS | ||
UnistylesShadowRegistry.add(storedRef, classNames?.hash) | ||
ref={ | ||
isServer() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
? undefined | ||
: ref => { | ||
storedRef = ref as unknown as HTMLElement | ||
// @ts-expect-error hidden from TS | ||
UnistylesShadowRegistry.add(storedRef, classNames?.hash) | ||
|
||
if (typeof forwardedRef === 'function') { | ||
return forwardedRef(ref) | ||
} | ||
if (typeof forwardedRef === 'function') { | ||
return forwardedRef(ref) | ||
} | ||
|
||
if (forwardedRef) { | ||
forwardedRef.current = ref | ||
} | ||
}} | ||
if (forwardedRef) { | ||
forwardedRef.current = ref | ||
} | ||
} | ||
} | ||
style={state => { | ||
const styleResult = typeof style === 'function' | ||
? style(state as WebPressableState) | ||
: style | ||
const styleResult = typeof style === 'function' ? style(state as WebPressableState) : style | ||
const previousScopedTheme = UnistylesShadowRegistry.getScopedTheme() | ||
|
||
UnistylesShadowRegistry.setScopedTheme(scopedTheme) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only line where I fixed a biome lint warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we force <React.Fragment>, I'm not a big fan of
<></>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, in this case the warning was because the fragment was unnecessary so I removed it