Skip to content

Commit

Permalink
Add eslint-plugin-react-google-translate --save-dev to posthog app
Browse files Browse the repository at this point in the history
  • Loading branch information
havenbarnes committed Jan 14, 2025
1 parent cb7547d commit 7c9ddc2
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = {
'simple-import-sort',
'import',
'unused-imports',
'react-google-translate',
],
rules: {
'react-hooks/rules-of-hooks': 'error',
Expand Down Expand Up @@ -273,6 +274,8 @@ module.exports = {
},
],
'no-else-return': 'warn',
'react-google-translate/no-conditional-text-nodes-with-siblings': 'warn',
'react-google-translate/no-return-text-nodes': 'error',
},
overrides: [
{
Expand Down
9 changes: 2 additions & 7 deletions frontend/src/lib/lemon-ui/LemonBanner/LemonBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './LemonBanner.scss'

import { IconInfo, IconWarning, IconX } from '@posthog/icons'
import { IconX } from '@posthog/icons'
import clsx from 'clsx'
import { useActions, useValues } from 'kea'
import { LemonButton, SideAction } from 'lib/lemon-ui/LemonButton'
Expand Down Expand Up @@ -60,12 +60,7 @@ export function LemonBanner({
)}
>
<div className="flex items-center gap-2 grow @md:px-1">
{!hideIcon &&
(type === 'warning' || type === 'error' ? (
<IconWarning className="LemonBanner__icon hidden @md:block" />
) : (
<IconInfo className="LemonBanner__icon hidden @md:block" />
))}
{!hideIcon && (type === 'warning' || type === 'error' ? 'Foo' : 'Bar')}
<div className="grow overflow-hidden">{children}</div>
{action && <LemonButton className="hidden @md:flex" type="secondary" {...action} />}
{showCloseButton && <LemonButton size="small" icon={<IconX />} onClick={_onClose} aria-label="close" />}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/scenes/feature-flags/FeatureFlag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ export function FeatureFlag({ id }: { id?: string } = {}): JSX.Element {
: null
}
>
{featureFlag.deleted ? 'Restore' : 'Delete'} feature flag
<span>{featureFlag.deleted ? 'Restore' : 'Delete'}</span>{' '}
<span>feature flag</span>
</LemonButton>
</>
}
Expand Down Expand Up @@ -924,7 +925,7 @@ function FeatureFlagRollout({ readOnly }: { readOnly?: boolean }): JSX.Element {
<code>true</code>
</strong>
)}{' '}
if they match one or more release condition groups.
<span>if they match one or more release condition groups.</span>
</div>
</div>
)}
Expand Down
46 changes: 27 additions & 19 deletions frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { LemonField } from 'lib/lemon-ui/LemonField'
import { LemonSlider } from 'lib/lemon-ui/LemonSlider'
import { LemonTag } from 'lib/lemon-ui/LemonTag/LemonTag'
import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'
import { capitalizeFirstLetter, dateFilterToText, dateStringToComponents, humanFriendlyNumber } from 'lib/utils'
import { capitalizeFirstLetter, dateStringToComponents, humanFriendlyNumber } from 'lib/utils'
import { urls } from 'scenes/urls'

import { cohortsModel } from '~/models/cohortsModel'
Expand Down Expand Up @@ -203,21 +203,27 @@ export function FeatureFlagReleaseConditions({
(val, idx) => (
<LemonSnack key={idx}>
{val}
{isPropertyFilterWithOperator(property) &&
['is_date_before', 'is_date_after'].includes(property.operator) &&
dateStringToComponents(String(val)) // check it's a relative date
? ` ( ${dateFilterToText(
String(val),
undefined,
'',
[],
false,
String(val).slice(-1) === 'h'
? 'MMMM D, YYYY HH:mm:ss'
: 'MMMM D, YYYY',
true
)} )`
: ''}
<span>
{isPropertyFilterWithOperator(property) &&
['is_date_before', 'is_date_after'].includes(
property.operator
) &&
dateStringToComponents(String(val)) // check it's a relative date
? ` ( $
{dateFilterToText(
String(val),
undefined,
'',
[],
false,
String(val).slice(-1) === 'h'
? 'MMMM D, YYYY HH:mm:ss'
: 'MMMM D, YYYY',
true
)}{' '}
)`
: ''}
</span>
</LemonSnack>
)
)
Expand Down Expand Up @@ -279,8 +285,10 @@ export function FeatureFlagReleaseConditions({
>
<div className="text-sm ">
Rolled out to{' '}
<b>{group.rollout_percentage != null ? group.rollout_percentage : 100}%</b> of{' '}
<b>{aggregationTargetName}</b> in this set.{' '}
{group.rollout_percentage != null ? <b>{group.rollout_percentage}</b> : <b>100</b>}
<b>%</b>
<span>of</span>
<b>{aggregationTargetName}</b> <span>in this set.</span>
</div>
</LemonTag>
) : (
Expand Down Expand Up @@ -344,7 +352,7 @@ export function FeatureFlagReleaseConditions({
}
return ''
})()}{' '}
of total {aggregationTargetName}.
<span>of total {aggregationTargetName}.</span>
</div>
</div>
)}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-posthog": "link:./eslint-rules",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-google-translate": "^0.0.114",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-storybook": "^0.6.15",
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7c9ddc2

Please sign in to comment.