Skip to content

Commit 172ca46

Browse files
authored
feat(devin-ai): add Lifeguard rules (#3949)
1 parent 7b5ebe5 commit 172ca46

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

devin_lifeguard.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
rules:
2+
- name: localize-messages
3+
trigger: >-
4+
when adding user-facing text or aria-label attributes, ensure the
5+
strings are localized
6+
7+
for example: aria-label="Expand" should instead use formatMessage(...)
8+
solution: >-
9+
wrap any user-visible string in formatMessage from useIntl so that it can
10+
be properly localized
11+
12+
e.g. aria-label={formatMessage(messages.someLabel)}
13+
- name: use-intl-hook
14+
trigger: >-
15+
when a component imports or uses injectIntl from 'react-intl' instead of
16+
using useIntl
17+
solution: >-
18+
remove injectIntl usage and refactor the component to use useIntl
19+
directly. for example:
20+
21+
import { useIntl } from 'react-intl';
22+
23+
const { formatMessage } = useIntl();
24+
- name: use-blueprint-tokens
25+
trigger: >-
26+
when adding or modifying styles, if numeric px values are used, prefer
27+
blueprint tokens
28+
solution: |-
29+
avoid hard-coded px. use blueprint tokens (e.g. $space-2, $space-3) or
30+
existing scss variables for consistent theming
31+
- name: testing-literal-strings
32+
trigger: >-
33+
when writing tests for localized text, if the code checks against a
34+
variable reference or message ID, the test won't fail if the translation
35+
changes.
36+
solution: >-
37+
use the literal translated string in the test assertion so that the test
38+
accurately fails when the copy changes, for example getByRole('button', {
39+
name: 'Choose' }) instead of referencing a variable or ID.
40+
- name: match-peer-and-dev-deps
41+
trigger: >-
42+
mismatch in version constraints for peerDependencies and devDependencies
43+
for the same library
44+
solution: >-
45+
ensure that the peerDependencies version matches devDependencies version
46+
to avoid unexpected version conflicts
47+
- name: avoid-data-testid
48+
trigger: >-
49+
when writing tests, if there's a role or accessible label or text
50+
available, data-testid should be avoided to ensure we test the actual
51+
accessibility.
52+
solution: >-
53+
use queries like getByRole, getByLabelText, or getByText with the actual
54+
user-facing string or aria-label. Only use test IDs as a last resort.

0 commit comments

Comments
 (0)