Skip to content

Commit b3f00fc

Browse files
docs(ar): translate eslint-plugin-react-hooks, react-dom hooks/static, legacy
Made-with: Cursor
1 parent 952cdec commit b3f00fc

21 files changed

Lines changed: 497 additions & 497 deletions

src/content/reference/eslint-plugin-react-hooks/index.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@ version: rc
55

66
<Intro>
77

8-
`eslint-plugin-react-hooks` provides ESLint rules to enforce the [Rules of React](/reference/rules).
8+
`eslint-plugin-react-hooks` يوفّر قواعد ESLint لتطبيق [قواعد React](/reference/rules).
99

1010
</Intro>
1111

12-
This plugin helps you catch violations of React's rules at build time, ensuring your components and hooks follow React's rules for correctness and performance. The lints cover both fundamental React patterns (exhaustive-deps and rules-of-hooks) and issues flagged by React Compiler. React Compiler diagnostics are automatically surfaced by this ESLint plugin, and can be used even if your app hasn't adopted the compiler yet.
12+
تساعدك الإضافة على اكتشاف مخالفات قواعد React وقت البناء، لتلتزم المكوّنات والـ hooks بقواعد الصحة والأداء. تغطي التحذيرات أنماط React الأساسية (مثل exhaustive-deps وrules-of-hooks) ومسائل يبلّغ عنها React Compiler. تُعرَض تشخيصات المُصرّف تلقائياً عبر هذه الإضافة، ويمكن استخدامها حتى إن لم يكن المُصرّف مفعّلاً في تطبيقك بعد.
1313

1414
<Note>
15-
When the compiler reports a diagnostic, it means that the compiler was able to statically detect a pattern that is not supported or breaks the Rules of React. When it detects this, it **automatically** skips over those components and hooks, while keeping the rest of your app compiled. This ensures optimal coverage of safe optimizations that won't break your app.
15+
عندما يبلّغ المُصرّف عن تشخيص، يعني أنه استطاع اكتشاف نمط غير مدعوم أو يخالف قواعد React. عندها **يتخطّى** تلقائياً تلك المكوّنات والـ hooks مع الإبقاء على بقية التطبيق مُجمَّعاً، لأقصى تغطية آمنة من التحسينات دون كسر التطبيق.
1616

17-
What this means for linting, is that you don’t need to fix all violations immediately. Address them at your own pace to gradually increase the number of optimized components.
17+
بالنسبة للـ lint، لا يلزمك إصلاح كل المخالفات فوراً. عالجها بوتيرتك لزيادة عدد المكوّنات المُحسَّنة تدريجياً.
1818
</Note>
1919

20-
## Recommended Rules {/*recommended*/}
21-
22-
These rules are included in the `recommended` preset in `eslint-plugin-react-hooks`:
23-
24-
* [`exhaustive-deps`](/reference/eslint-plugin-react-hooks/lints/exhaustive-deps) - Validates that dependency arrays for React hooks contain all necessary dependencies
25-
* [`rules-of-hooks`](/reference/eslint-plugin-react-hooks/lints/rules-of-hooks) - Validates that components and hooks follow the Rules of Hooks
26-
* [`component-hook-factories`](/reference/eslint-plugin-react-hooks/lints/component-hook-factories) - Validates higher order functions defining nested components or hooks
27-
* [`config`](/reference/eslint-plugin-react-hooks/lints/config) - Validates the compiler configuration options
28-
* [`error-boundaries`](/reference/eslint-plugin-react-hooks/lints/error-boundaries) - Validates usage of Error Boundaries instead of try/catch for child errors
29-
* [`gating`](/reference/eslint-plugin-react-hooks/lints/gating) - Validates configuration of gating mode
30-
* [`globals`](/reference/eslint-plugin-react-hooks/lints/globals) - Validates against assignment/mutation of globals during render
31-
* [`immutability`](/reference/eslint-plugin-react-hooks/lints/immutability) - Validates against mutating props, state, and other immutable values
32-
* [`incompatible-library`](/reference/eslint-plugin-react-hooks/lints/incompatible-library) - Validates against usage of libraries which are incompatible with memoization
33-
* [`preserve-manual-memoization`](/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization) - Validates that existing manual memoization is preserved by the compiler
34-
* [`purity`](/reference/eslint-plugin-react-hooks/lints/purity) - Validates that components/hooks are pure by checking known-impure functions
35-
* [`refs`](/reference/eslint-plugin-react-hooks/lints/refs) - Validates correct usage of refs, not reading/writing during render
36-
* [`set-state-in-effect`](/reference/eslint-plugin-react-hooks/lints/set-state-in-effect) - Validates against calling setState synchronously in an effect
37-
* [`set-state-in-render`](/reference/eslint-plugin-react-hooks/lints/set-state-in-render) - Validates against setting state during render
38-
* [`static-components`](/reference/eslint-plugin-react-hooks/lints/static-components) - Validates that components are static, not recreated every render
39-
* [`unsupported-syntax`](/reference/eslint-plugin-react-hooks/lints/unsupported-syntax) - Validates against syntax that React Compiler does not support
40-
* [`use-memo`](/reference/eslint-plugin-react-hooks/lints/use-memo) - Validates usage of the `useMemo` hook without a return value
20+
## القواعد الموصى بها {/*recommended*/}
21+
22+
هذه القواعد ضمن الإعداد `recommended` في `eslint-plugin-react-hooks`:
23+
24+
* [`exhaustive-deps`](/reference/eslint-plugin-react-hooks/lints/exhaustive-deps) — يتحقق أن مصفوفات تبعيات الـ hooks تتضمّن كل التبعيات اللازمة
25+
* [`rules-of-hooks`](/reference/eslint-plugin-react-hooks/lints/rules-of-hooks) — يتحقق أن المكوّنات والـ hooks تتبع Rules of Hooks
26+
* [`component-hook-factories`](/reference/eslint-plugin-react-hooks/lints/component-hook-factories) — دوال رتبة أعلى تُعرّف مكوّنات أو hooks متداخلة
27+
* [`config`](/reference/eslint-plugin-react-hooks/lints/config) — صحة خيارات إعداد المُصرّف
28+
* [`error-boundaries`](/reference/eslint-plugin-react-hooks/lints/error-boundaries) — استخدام Error Boundaries بدلاً من try/ccatch لأخطاء الأبناء
29+
* [`gating`](/reference/eslint-plugin-react-hooks/lints/gating) — ضبط وضع gating
30+
* [`globals`](/reference/eslint-plugin-react-hooks/lints/globals) — تجنّب إسناد/تعديل عامات أثناء التصيير
31+
* [`immutability`](/reference/eslint-plugin-react-hooks/lints/immutability) — عدم تعديل props أو state أو قيم غير قابلة للتغيير
32+
* [`incompatible-library`](/reference/eslint-plugin-react-hooks/lints/incompatible-library) — مكتبات غير متوافقة مع التذكّر
33+
* [`preserve-manual-memoization`](/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization) — الإبقاء على التذكّر اليدوي عند المُصرّف
34+
* [`purity`](/reference/eslint-plugin-react-hooks/lints/purity) — نقاء المكوّنات/الـ hooks عبر دوال معروفة بعدم النقاء
35+
* [`refs`](/reference/eslint-plugin-react-hooks/lints/refs) — استخدام صحيح للـ refs دون قراءة/كتابة أثناء التصيير
36+
* [`set-state-in-effect`](/reference/eslint-plugin-react-hooks/lints/set-state-in-effect) — عدم استدعاء setState متزامناً داخل effect
37+
* [`set-state-in-render`](/reference/eslint-plugin-react-hooks/lints/set-state-in-render) — عدم ضبط الحالة أثناء التصيير
38+
* [`static-components`](/reference/eslint-plugin-react-hooks/lints/static-components) — مكوّنات ثابتة لا تُعاد إنشاؤها كل تصيير
39+
* [`unsupported-syntax`](/reference/eslint-plugin-react-hooks/lints/unsupported-syntax) — صياغة لا يدعمها React Compiler
40+
* [`use-memo`](/reference/eslint-plugin-react-hooks/lints/use-memo) — استخدام `useMemo` دون قيمة مُرجَعة

src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ title: component-hook-factories
44

55
<Intro>
66

7-
Validates against higher order functions defining nested components or hooks. Components and hooks should be defined at the module level.
7+
يتحقق من عدم استخدام دوال رتبة أعلى تعرّف مكوّنات أو hooks متداخلة. يجب تعريف المكوّنات والـ hooks على مستوى الوحدة.
88

99
</Intro>
1010

11-
## Rule Details {/*rule-details*/}
11+
## تفاصيل القاعدة {/*rule-details*/}
1212

13-
Defining components or hooks inside other functions creates new instances on every call. React treats each as a completely different component, destroying and recreating the entire component tree, losing all state, and causing performance problems.
13+
تعريف مكوّنات أو hooks داخل دوال أخرى ينشئ نسخاً جديدة كل استدعاء. يعامل React كل نسخة كمكوّن مختلف تماماً، فيدمّر ويعيد إنشاء شجرة المكوّن بالكامل، يفقد كل الحالة، ويسبب مشاكل أداء.
1414

15-
### Invalid {/*invalid*/}
15+
### غير صالح {/*invalid*/}
1616

17-
Examples of incorrect code for this rule:
17+
أمثلة لشيفرة غير صحيحة لهذه القاعدة:
1818

1919
```js {expectedErrors: {'react-compiler': [14]}}
20-
//Factory function creating components
20+
//دالة مصنع تُنشئ مكوّنات
2121
function createComponent(defaultValue) {
2222
return function Component() {
2323
// ...
2424
};
2525
}
2626

27-
//Component defined inside component
27+
//مكوّن معرّف داخل مكوّن
2828
function Parent() {
2929
function Child() {
3030
// ...
@@ -33,38 +33,38 @@ function Parent() {
3333
return <Child />;
3434
}
3535

36-
//Hook factory function
36+
//دالة مصنع لـ hook
3737
function createCustomHook(endpoint) {
3838
return function useData() {
3939
// ...
4040
};
4141
}
4242
```
4343

44-
### Valid {/*valid*/}
44+
### صالح {/*valid*/}
4545

46-
Examples of correct code for this rule:
46+
أمثلة لشيفرة صحيحة لهذه القاعدة:
4747

4848
```js
49-
//Component defined at module level
49+
//مكوّن معرّف على مستوى الوحدة
5050
function Component({ defaultValue }) {
5151
// ...
5252
}
5353

54-
//Custom hook at module level
54+
// ✅ hook مخصّص على مستوى الوحدة
5555
function useData(endpoint) {
5656
// ...
5757
}
5858
```
5959

60-
## Troubleshooting {/*troubleshooting*/}
60+
## استكشاف الأعطال {/*troubleshooting*/}
6161

62-
### I need dynamic component behavior {/*dynamic-behavior*/}
62+
### أحتاج سلوكاً ديناميكياً للمكوّن {/*dynamic-behavior*/}
6363

64-
You might think you need a factory to create customized components:
64+
قد تظن أنك تحتاج مصنعاً لإنشاء مكوّنات مخصّصة:
6565

6666
```js
67-
//Wrong: Factory pattern
67+
//خطأ: نمط مصنع
6868
function makeButton(color) {
6969
return function Button({children}) {
7070
return (
@@ -79,10 +79,10 @@ const RedButton = makeButton('red');
7979
const BlueButton = makeButton('blue');
8080
```
8181

82-
Pass [JSX as children](/learn/passing-props-to-a-component#passing-jsx-as-children) instead:
82+
مرّر [JSX كأبناء](/learn/passing-props-to-a-component#passing-jsx-as-children) بدلاً من ذلك:
8383

8484
```js
85-
//Better: Pass JSX as children
85+
//أفضل: مرّر JSX كأبناء
8686
function Button({color, children}) {
8787
return (
8888
<button style={{backgroundColor: color}}>

src/content/reference/eslint-plugin-react-hooks/lints/config.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,44 @@ title: config
44

55
<Intro>
66

7-
Validates the compiler [configuration options](/reference/react-compiler/configuration).
7+
يتحقق من [خيارات إعداد](/reference/react-compiler/configuration) المُصرّف.
88

99
</Intro>
1010

11-
## Rule Details {/*rule-details*/}
11+
## تفاصيل القاعدة {/*rule-details*/}
1212

13-
React Compiler accepts various [configuration options](/reference/react-compiler/configuration) to control its behavior. This rule validates that your configuration uses correct option names and value types, preventing silent failures from typos or incorrect settings.
13+
يقبل React Compiler عدة [خيارات إعداد](/reference/react-compiler/configuration) للتحكّم في سلوكه. تتحقق هذه القاعدة من أن إعدادك يستخدم أسماء خيارات صحيحة وأنواع قيم صحيحة، لتجنّب فشل صامت بسبب أخطاء مطبعية أو إعدادات خاطئة.
1414

15-
### Invalid {/*invalid*/}
15+
### غير صالح {/*invalid*/}
1616

17-
Examples of incorrect code for this rule:
17+
أمثلة لشيفرة غير صحيحة لهذه القاعدة:
1818

1919
```js
20-
//Unknown option name
20+
//اسم خيار غير معروف
2121
module.exports = {
2222
plugins: [
2323
['babel-plugin-react-compiler', {
24-
compileMode: 'all' // Typo: should be compilationMode
24+
compileMode: 'all' // خطأ مطبعي: يجب أن يكون compilationMode
2525
}]
2626
]
2727
};
2828

29-
//Invalid option value
29+
//قيمة خيار غير صالحة
3030
module.exports = {
3131
plugins: [
3232
['babel-plugin-react-compiler', {
33-
compilationMode: 'everything' // Invalid: use 'all' or 'infer'
33+
compilationMode: 'everything' // غير صالح: استخدم 'all' أو 'infer'
3434
}]
3535
]
3636
};
3737
```
3838

39-
### Valid {/*valid*/}
39+
### صالح {/*valid*/}
4040

41-
Examples of correct code for this rule:
41+
أمثلة لشيفرة صحيحة لهذه القاعدة:
4242

4343
```js
44-
//Valid compiler configuration
44+
//إعداد مُصرّف صالح
4545
module.exports = {
4646
plugins: [
4747
['babel-plugin-react-compiler', {
@@ -52,38 +52,38 @@ module.exports = {
5252
};
5353
```
5454

55-
## Troubleshooting {/*troubleshooting*/}
55+
## استكشاف الأعطال {/*troubleshooting*/}
5656

57-
### Configuration not working as expected {/*config-not-working*/}
57+
### الإعداد لا يعمل كما تتوقع {/*config-not-working*/}
5858

59-
Your compiler configuration might have typos or incorrect values:
59+
قد يحتوي إعداد المُصرّف على أخطاء مطبعية أو قيم خاطئة:
6060

6161
```js
62-
//Wrong: Common configuration mistakes
62+
//خطأ: أخطاء إعداد شائعة
6363
module.exports = {
6464
plugins: [
6565
['babel-plugin-react-compiler', {
66-
// Typo in option name
66+
// خطأ مطبعي في اسم الخيار
6767
compilationMod: 'all',
68-
// Wrong value type
68+
// نوع قيمة خاطئ
6969
panicThreshold: true,
70-
// Unknown option
70+
// خيار غير معروف
7171
optimizationLevel: 'max'
7272
}]
7373
]
7474
};
7575
```
7676

77-
Check the [configuration documentation](/reference/react-compiler/configuration) for valid options:
77+
راجع [توثيق الإعداد](/reference/react-compiler/configuration) للخيارات الصالحة:
7878

7979
```js
80-
//Better: Valid configuration
80+
//أفضل: إعداد صالح
8181
module.exports = {
8282
plugins: [
8383
['babel-plugin-react-compiler', {
84-
compilationMode: 'all', // or 'infer'
85-
panicThreshold: 'none', // or 'critical_errors', 'all_errors'
86-
// Only use documented options
84+
compilationMode: 'all', // أو 'infer'
85+
panicThreshold: 'none', // أو 'critical_errors' أو 'all_errors'
86+
// استخدم فقط الخيارات الموثّقة
8787
}]
8888
]
8989
};

src/content/reference/eslint-plugin-react-hooks/lints/error-boundaries.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,35 @@ title: error-boundaries
44

55
<Intro>
66

7-
Validates usage of Error Boundaries instead of try/catch for errors in child components.
7+
يتحقق من استخدام Error Boundaries بدلاً من try/catch لأخطاء المكوّنات الفرعية.
88

99
</Intro>
1010

11-
## Rule Details {/*rule-details*/}
11+
## تفاصيل القاعدة {/*rule-details*/}
1212

13-
Try/catch blocks can't catch errors that happen during React's rendering process. Errors thrown in rendering methods or hooks bubble up through the component tree. Only [Error Boundaries](/reference/react/Component#catching-rendering-errors-with-an-error-boundary) can catch these errors.
13+
لا تستطيع كتل try/catch التقاط أخطاء تحدث أثناء عملية التصيير في React. الأخطاء المرمية في دوال التصيير أو الـ hooks تنتقل عبر شجرة المكوّنات. فقط [Error Boundaries](/reference/react/Component#catching-rendering-errors-with-an-error-boundary) يمكنها التقاط هذه الأخطاء.
1414

15-
### Invalid {/*invalid*/}
15+
### غير صالح {/*invalid*/}
1616

17-
Examples of incorrect code for this rule:
17+
أمثلة لشيفرة غير صحيحة لهذه القاعدة:
1818

1919
```js {expectedErrors: {'react-compiler': [4]}}
20-
//Try/catch won't catch render errors
20+
//try/catch لن يلتقط أخطاء التصيير
2121
function Parent() {
2222
try {
23-
return <ChildComponent />; // If this throws, catch won't help
23+
return <ChildComponent />; // إذا رُمي خطأ هنا، catch لن يفيد
2424
} catch (error) {
2525
return <div>Error occurred</div>;
2626
}
2727
}
2828
```
2929

30-
### Valid {/*valid*/}
30+
### صالح {/*valid*/}
3131

32-
Examples of correct code for this rule:
32+
أمثلة لشيفرة صحيحة لهذه القاعدة:
3333

3434
```js
35-
//Using error boundary
35+
//استخدام Error Boundary
3636
function Parent() {
3737
return (
3838
<ErrorBoundary>
@@ -42,24 +42,24 @@ function Parent() {
4242
}
4343
```
4444

45-
## Troubleshooting {/*troubleshooting*/}
45+
## استكشاف الأعطال {/*troubleshooting*/}
4646

47-
### Why is the linter telling me not to wrap `use` in `try`/`catch`? {/*why-is-the-linter-telling-me-not-to-wrap-use-in-trycatch*/}
47+
### لماذا يطلب مني الـ linter عدم لفّ `use` داخل `try`/`catch`؟ {/*why-is-the-linter-telling-me-not-to-wrap-use-in-trycatch*/}
4848

49-
The `use` hook doesn't throw errors in the traditional sense, it suspends component execution. When `use` encounters a pending promise, it suspends the component and lets React show a fallback. Only Suspense and Error Boundaries can handle these cases. The linter warns against `try`/`catch` around `use` to prevent confusion as the `catch` block would never run.
49+
لا يرمي الـ hook `use` أخطاء بالمعنى التقليدي؛ بل يعلّق تنفيذ المكوّن. عندما يصادف `use` وعداً معلّقاً، يعلّق المكوّن ويترك لـ React عرض حالة بديلة. فقط Suspense وError Boundaries يمكنها التعامل مع هذه الحالات. يحذّر الـ linter من `try`/`catch` حول `use` لتجنّب الالتباس لأن كتلة `catch` لن تعمل أبداً.
5050

5151
```js {expectedErrors: {'react-compiler': [5]}}
52-
//Try/catch around `use` hook
52+
//try/catch حول hook `use`
5353
function Component({promise}) {
5454
try {
55-
const data = use(promise); // Won't catch - `use` suspends, not throws
55+
const data = use(promise); // لن يلتقط — `use` يعلّق لا يرمي
5656
return <div>{data}</div>;
5757
} catch (error) {
58-
return <div>Failed to load</div>; // Unreachable
58+
return <div>Failed to load</div>; // لا يُنفَّذ
5959
}
6060
}
6161

62-
// ✅ Error boundary catches `use` errors
62+
// ✅ Error boundary تلتقط أخطاء `use`
6363
function App() {
6464
return (
6565
<ErrorBoundary fallback={<div>Failed to load</div>}>
@@ -69,4 +69,4 @@ function App() {
6969
</ErrorBoundary>
7070
);
7171
}
72-
```
72+
```

0 commit comments

Comments
 (0)