bd510d8468
* Upgrade ESLint to v9 with flat config
- Upgrade eslint from v8 to v9.18.0
- Migrate from .eslintrc.js to eslint.config.mjs (flat config)
- Upgrade typescript-eslint to v8.20.0 (unified package)
- Replace eslint-plugin-import with eslint-plugin-import-x for flat config support
- Add globals package for environment globals
- Update eslint-plugin-bsky-internal with proper meta objects for ESLint v9
- Fix deprecated context.getScope() API usage
- Update bskyembed to use flat config
- Remove deprecated --ext flag from lint scripts
- Configure rules to maintain previous behavior while using new ESLint version
* Fix varsIgnorePattern to require character after underscore
Restore the original pattern `^_.+` instead of `^_` so that lingui's
`const { _ } = useLingui()` will still be flagged when unused.
* Update ESLint rule tests for flat config format
- Update RuleTester to use flat config languageOptions instead of
eslintrc parser format
- Remove duplicate test case that ESLint v9 now detects
- Add Jest globals for test files
* update eslint package versions
* lint android a11y
* enable typechecked rules, switch them to warn
* fix yarn lock ci
* Fix CI failure
* Remove unused globals?
* Organize a bit, add quiet to main lint command
* Allow ternary
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Eric Bailey <git@esb.lol>
92 lines
2.2 KiB
TypeScript
92 lines
2.2 KiB
TypeScript
import {UITextView} from 'react-native-uitextview'
|
|
|
|
import {logger} from '#/logger'
|
|
import {atoms, useAlf, useTheme, web} from '#/alf'
|
|
import {
|
|
childHasEmoji,
|
|
normalizeTextStyles,
|
|
renderChildrenWithEmoji,
|
|
type TextProps,
|
|
} from '#/alf/typography'
|
|
|
|
export type {TextProps}
|
|
export {Text as Span} from 'react-native'
|
|
|
|
/**
|
|
* Our main text component. Use this most of the time.
|
|
*/
|
|
export function Text({
|
|
children,
|
|
emoji,
|
|
style,
|
|
selectable,
|
|
title,
|
|
dataSet,
|
|
...rest
|
|
}: TextProps) {
|
|
const {fonts, flags} = useAlf()
|
|
const t = useTheme()
|
|
const s = normalizeTextStyles([atoms.text_sm, t.atoms.text, style], {
|
|
fontScale: fonts.scaleMultiplier,
|
|
fontFamily: fonts.family,
|
|
flags,
|
|
})
|
|
|
|
if (__DEV__) {
|
|
if (!emoji && childHasEmoji(children)) {
|
|
logger.warn(
|
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-base-to-string
|
|
`Text: emoji detected but emoji not enabled: "${children}"\n\nPlease add <Text emoji />'`,
|
|
)
|
|
}
|
|
}
|
|
|
|
const shared = {
|
|
uiTextView: true,
|
|
selectable,
|
|
style: s,
|
|
dataSet: Object.assign({tooltip: title}, dataSet || {}),
|
|
...rest,
|
|
}
|
|
|
|
return (
|
|
<UITextView {...shared}>
|
|
{renderChildrenWithEmoji(children, shared, emoji ?? false)}
|
|
</UITextView>
|
|
)
|
|
}
|
|
|
|
function createHeadingElement({level}: {level: number}) {
|
|
return function HeadingElement({style, ...rest}: TextProps) {
|
|
const attr =
|
|
web({
|
|
role: 'heading',
|
|
'aria-level': level,
|
|
}) || {}
|
|
return <Text {...attr} {...rest} style={style} />
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Use semantic components when it's beneficial to the user or to a web scraper
|
|
*/
|
|
export const H1 = createHeadingElement({level: 1})
|
|
export const H2 = createHeadingElement({level: 2})
|
|
export const H3 = createHeadingElement({level: 3})
|
|
export const H4 = createHeadingElement({level: 4})
|
|
export const H5 = createHeadingElement({level: 5})
|
|
export const H6 = createHeadingElement({level: 6})
|
|
export function P({style, ...rest}: TextProps) {
|
|
const attr =
|
|
web({
|
|
role: 'paragraph',
|
|
}) || {}
|
|
return (
|
|
<Text
|
|
{...attr}
|
|
{...rest}
|
|
style={[atoms.text_md, atoms.leading_relaxed, style]}
|
|
/>
|
|
)
|
|
}
|