eslint-plugin-nextfriday 4.3.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,99 +0,0 @@
1
- # react-props-destructure
2
-
3
- Enforce destructuring props inside React component body instead of parameters.
4
-
5
- ## Rule Details
6
-
7
- This rule enforces a consistent pattern for handling props in React components by requiring destructuring to be done inside the component body rather than in the parameter list. This promotes better code readability and makes prop usage more explicit.
8
-
9
- ## Examples
10
-
11
- ### Incorrect
12
-
13
- ```jsx
14
- const Component = ({ children }) => <div>{children}</div>;
15
-
16
- const Component = ({ title, children, onClick }) => (
17
- <div onClick={onClick}>
18
- <h1>{title}</h1>
19
- {children}
20
- </div>
21
- );
22
-
23
- function Component({ children }) {
24
- return <div>{children}</div>;
25
- }
26
-
27
- const Component = function ({ children }) {
28
- return <div>{children}</div>;
29
- };
30
-
31
- // Also applies to conditional returns
32
- const Component = ({ show, children }) => {
33
- return show ? <div>{children}</div> : null;
34
- };
35
-
36
- // And logical operators
37
- const Component = ({ show, children }) => {
38
- return show && <div>{children}</div>;
39
- };
40
- ```
41
-
42
- ### Correct
43
-
44
- ```jsx
45
- const Component = (props) => {
46
- const { children } = props;
47
- return <div>{children}</div>;
48
- };
49
-
50
- const Component = (props) => {
51
- const { title, children, onClick } = props;
52
-
53
- return (
54
- <div onClick={onClick}>
55
- <h1>{title}</h1>
56
- {children}
57
- </div>
58
- );
59
- };
60
-
61
- function Component(props) {
62
- const { children } = props;
63
- return <div>{children}</div>;
64
- }
65
-
66
- const Component = function (props) {
67
- const { children } = props;
68
- return <div>{children}</div>;
69
- };
70
-
71
- // Multiple parameters are allowed
72
- const Component = (props, ref) => {
73
- return <div>{props.children}</div>;
74
- };
75
-
76
- // No parameters is allowed
77
- const Component = () => {
78
- return <div>Hello</div>;
79
- };
80
-
81
- // Already using props parameter (no destructuring) is allowed
82
- const Component = (props) => {
83
- return <div>{props.children}</div>;
84
- };
85
-
86
- // Non-React functions are ignored
87
- const helper = ({ value }) => {
88
- return value * 2;
89
- };
90
-
91
- const regularFunction = ({ data }) => {
92
- return data.map((item) => item.id);
93
- };
94
- ```
95
-
96
- ## When Not To Use It
97
-
98
- - If you prefer parameter destructuring for brevity
99
- - When working on a codebase that already consistently uses parameter destructuring