mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Statsig] Typecheck gates (#3467)

* Typecheck gates

* Lint against untyped useGate()

* Alphabetic

authored by danabra.mov and committed by

GitHub 427f3a84 bf974b14

+45 -6
+1
.eslintrc.js
··· 31 31 }, 32 32 }, 33 33 ], 34 + 'bsky-internal/use-typed-gates': 'error', 34 35 'simple-import-sort/imports': [ 35 36 'warn', 36 37 {
+1
eslint/index.js
··· 3 3 module.exports = { 4 4 rules: { 5 5 'avoid-unwrapped-text': require('./avoid-unwrapped-text'), 6 + 'use-typed-gates': require('./use-typed-gates'), 6 7 }, 7 8 }
+31
eslint/use-typed-gates.js
··· 1 + 'use strict' 2 + 3 + exports.create = function create(context) { 4 + return { 5 + ImportSpecifier(node) { 6 + if ( 7 + !node.local || 8 + node.local.type !== 'Identifier' || 9 + node.local.name !== 'useGate' 10 + ) { 11 + return 12 + } 13 + if ( 14 + node.parent.type !== 'ImportDeclaration' || 15 + !node.parent.source || 16 + node.parent.source.type !== 'Literal' 17 + ) { 18 + return 19 + } 20 + const source = node.parent.source.value 21 + if (source.startsWith('.') || source.startsWith('#')) { 22 + return 23 + } 24 + context.report({ 25 + node, 26 + message: 27 + "Use useGate() from '#/lib/statsig/statsig' instead of the one on npm.", 28 + }) 29 + }, 30 + } 31 + }
+8 -3
src/lib/statsig/gates.ts
··· 1 - import {useGate} from './statsig' 2 - 3 - export const useNewSearchGate = () => useGate('new_search') 1 + export type Gate = 2 + // Keep this alphabetic please. 3 + | 'autoexpand_suggestions_on_profile_follow' 4 + | 'disable_min_shell_on_foregrounding' 5 + | 'disable_poll_on_discover' 6 + | 'new_search' 7 + | 'show_follow_back_label' 8 + | 'start_session_with_following'
+2 -1
src/lib/statsig/statsig.tsx
··· 11 11 import {logger} from '#/logger' 12 12 import {useSession} from '../../state/session' 13 13 import {LogEvents} from './events' 14 + import {Gate} from './gates' 14 15 15 16 export type {LogEvents} 16 17 ··· 69 70 } 70 71 } 71 72 72 - export function useGate(gateName: string) { 73 + export function useGate(gateName: Gate): boolean { 73 74 const {isLoading, value} = useStatsigGate(gateName) 74 75 if (isLoading) { 75 76 // This should not happen because of waitForInitialization={true}.
+2 -2
src/view/screens/Search/Search.tsx
··· 22 22 import {usePalette} from '#/lib/hooks/usePalette' 23 23 import {MagnifyingGlassIcon} from '#/lib/icons' 24 24 import {NavigationProp} from '#/lib/routes/types' 25 - import {useNewSearchGate} from '#/lib/statsig/gates' 25 + import {useGate} from '#/lib/statsig/statsig' 26 26 import {augmentSearchQuery} from '#/lib/strings/helpers' 27 27 import {s} from '#/lib/styles' 28 28 import {logger} from '#/logger' ··· 337 337 const {isDesktop} = useWebMediaQueries() 338 338 const {_} = useLingui() 339 339 340 - const isNewSearch = useNewSearchGate() 340 + const isNewSearch = useGate('new_search') 341 341 342 342 const onPageSelected = React.useCallback( 343 343 (index: number) => {