eslint-plugin-nextfriday 4.3.1 → 4.4.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.
- package/CHANGELOG.md +16 -0
- package/README.md +7 -9
- package/docs/rules/PREFER_PROPS_WITH_CHILDREN.md +17 -35
- package/lib/index.cjs +80 -117
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +0 -42
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.ts +0 -42
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +80 -117
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/docs/rules/PREFER_INLINE_TYPE_EXPORT.md +0 -64
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# eslint-plugin-nextfriday
|
|
2
2
|
|
|
3
|
+
## 4.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#134](https://github.com/next-friday/eslint-plugin-nextfriday/pull/134) [`ae95cb8`](https://github.com/next-friday/eslint-plugin-nextfriday/commit/ae95cb840eb5e1a2f342e58958e0a44a94d4ae3d) Thanks [@joetakara](https://github.com/joetakara)! - remove `prefer-inline-type-export` rule
|
|
8
|
+
|
|
9
|
+
fix `prefer-import-type` incorrectly converting namespace imports used as JSX member expressions (e.g. `<Avatar.Root>`) to `import type`
|
|
10
|
+
|
|
11
|
+
update `prefer-props-with-children` to only flag optional `children?: ReactNode` — required `children: ReactNode` is no longer reported
|
|
12
|
+
|
|
13
|
+
## 4.3.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#132](https://github.com/next-friday/eslint-plugin-nextfriday/pull/132) [`5b2cb71`](https://github.com/next-friday/eslint-plugin-nextfriday/commit/5b2cb713b126917b1205fd54c6a1143d50aef7aa) Thanks [@joetakara](https://github.com/joetakara)! - fix 18 rules missing internal filename guards. `no-helper-function-in-hook` and `no-helper-function-in-test` now self-skip on non-matching files and are included in all presets — no consumer configuration required. all jsx rules now guard against non-jsx files using `isJsxFile()`, consistent with the established codebase pattern.
|
|
18
|
+
|
|
3
19
|
## 4.3.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -451,7 +451,6 @@ In practice: turn the high tier on as `"error"` first, leave the medium tier as
|
|
|
451
451
|
| [no-nested-interface-declaration](docs/rules/NO_NESTED_INTERFACE_DECLARATION.md) | Disallow inline object types in interface/type properties | ❌ |
|
|
452
452
|
| [prefer-named-param-types](docs/rules/PREFER_NAMED_PARAM_TYPES.md) | Enforce named types for function parameters with object types | ❌ |
|
|
453
453
|
| [prefer-inline-literal-union](docs/rules/PREFER_INLINE_LITERAL_UNION.md) | Enforce inlining literal union types for better IDE hover info | ✅ |
|
|
454
|
-
| [prefer-inline-type-export](docs/rules/PREFER_INLINE_TYPE_EXPORT.md) | Require type/interface exports inline at the declaration | ✅ |
|
|
455
454
|
| [prefer-interface-for-component-props](docs/rules/PREFER_INTERFACE_FOR_COMPONENT_PROPS.md) | Enforce interface over type alias for component prop declarations | ✅ |
|
|
456
455
|
| [prefer-interface-over-inline-types](docs/rules/PREFER_INTERFACE_OVER_INLINE_TYPES.md) | Enforce interface declarations over inline types for React props | ❌ |
|
|
457
456
|
| [sort-type-alphabetically](docs/rules/SORT_TYPE_ALPHABETICALLY.md) | Enforce A-Z sorting of properties within type groups | ✅ |
|
|
@@ -489,16 +488,16 @@ In practice: turn the high tier on as `"error"` first, leave the medium tier as
|
|
|
489
488
|
|
|
490
489
|
| Preset | Severity | Base Rules | JSX Rules | Total Rules |
|
|
491
490
|
| -------------------- | -------- | ---------- | --------- | ----------- |
|
|
492
|
-
| `base` | warn |
|
|
493
|
-
| `base/recommended` | error |
|
|
494
|
-
| `react` | warn |
|
|
495
|
-
| `react/recommended` | error |
|
|
496
|
-
| `nextjs` | warn |
|
|
497
|
-
| `nextjs/recommended` | error |
|
|
491
|
+
| `base` | warn | 43 | 0 | 43 |
|
|
492
|
+
| `base/recommended` | error | 43 | 0 | 43 |
|
|
493
|
+
| `react` | warn | 43 | 23 | 66 |
|
|
494
|
+
| `react/recommended` | error | 43 | 23 | 66 |
|
|
495
|
+
| `nextjs` | warn | 43 | 23 | 66 |
|
|
496
|
+
| `nextjs/recommended` | error | 43 | 23 | 66 |
|
|
498
497
|
|
|
499
498
|
The `nextjs` and `nextjs/recommended` presets currently share the same rule set as `react` and `react/recommended`; they are kept as named aliases for ergonomics.
|
|
500
499
|
|
|
501
|
-
### Base Configuration Rules (
|
|
500
|
+
### Base Configuration Rules (43 rules)
|
|
502
501
|
|
|
503
502
|
Included in `base`, `base/recommended`, and all other presets:
|
|
504
503
|
|
|
@@ -536,7 +535,6 @@ Included in `base`, `base/recommended`, and all other presets:
|
|
|
536
535
|
- `nextfriday/prefer-guard-clause`
|
|
537
536
|
- `nextfriday/prefer-import-type`
|
|
538
537
|
- `nextfriday/prefer-inline-literal-union`
|
|
539
|
-
- `nextfriday/prefer-inline-type-export`
|
|
540
538
|
- `nextfriday/prefer-named-param-types`
|
|
541
539
|
- `nextfriday/prefer-react-import-types`
|
|
542
540
|
- `nextfriday/require-explicit-return-type`
|
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
# prefer-props-with-children
|
|
2
2
|
|
|
3
|
-
Prefer `PropsWithChildren<T>` over manually declaring `children
|
|
3
|
+
Prefer `PropsWithChildren<T>` over manually declaring `children?: ReactNode` in component props.
|
|
4
4
|
|
|
5
5
|
## Rule Details
|
|
6
6
|
|
|
7
|
-
This rule reports interfaces, type aliases, and inline parameter types that declare
|
|
7
|
+
This rule reports interfaces, type aliases, and inline parameter types that declare an **optional** `children` field typed as `ReactNode` (or `React.ReactNode`). `PropsWithChildren<T>` already provides exactly this — an optional `children: ReactNode` — so the manual declaration is redundant.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Required `children: ReactNode` (without `?`) is intentional and is not flagged, because `PropsWithChildren` cannot express required children.
|
|
10
|
+
|
|
11
|
+
The rule only flags `children?` whose type is exactly `ReactNode`. Other shapes such as `ReactElement`, render-prop functions, or unions like `ReactNode | string` are left alone.
|
|
10
12
|
|
|
11
13
|
### Why?
|
|
12
14
|
|
|
13
|
-
- `PropsWithChildren<T>` is the canonical type for components that accept children, making intent obvious at a glance.
|
|
14
|
-
-
|
|
15
|
-
- It keeps the surrounding props focused on what is unique to the component.
|
|
15
|
+
- `PropsWithChildren<T>` is the canonical type for components that optionally accept children, making intent obvious at a glance.
|
|
16
|
+
- Required `children: ReactNode` (no `?`) cannot be replaced by `PropsWithChildren` — that case is intentional and not flagged.
|
|
16
17
|
|
|
17
18
|
## Examples
|
|
18
19
|
|
|
19
20
|
### Incorrect
|
|
20
21
|
|
|
21
|
-
```tsx
|
|
22
|
-
interface LayoutProps {
|
|
23
|
-
children: ReactNode;
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
```tsx
|
|
28
|
-
interface CardProps {
|
|
29
|
-
title: string;
|
|
30
|
-
children: ReactNode;
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
22
|
```tsx
|
|
35
23
|
interface OptionalChildrenProps {
|
|
36
24
|
children?: ReactNode;
|
|
@@ -39,25 +27,22 @@ interface OptionalChildrenProps {
|
|
|
39
27
|
```
|
|
40
28
|
|
|
41
29
|
```tsx
|
|
42
|
-
interface
|
|
43
|
-
children
|
|
30
|
+
interface LayoutProps {
|
|
31
|
+
children?: ReactNode;
|
|
44
32
|
}
|
|
45
33
|
```
|
|
46
34
|
|
|
47
35
|
```tsx
|
|
48
36
|
type WrapperProps = {
|
|
49
|
-
children
|
|
37
|
+
children?: ReactNode;
|
|
50
38
|
className: string;
|
|
51
39
|
};
|
|
52
40
|
```
|
|
53
41
|
|
|
54
42
|
```tsx
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{label}
|
|
59
|
-
</div>
|
|
60
|
-
);
|
|
43
|
+
interface ReactNamespaceProps {
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
}
|
|
61
46
|
```
|
|
62
47
|
|
|
63
48
|
### Correct
|
|
@@ -79,12 +64,9 @@ type WrapperProps = PropsWithChildren<{
|
|
|
79
64
|
```
|
|
80
65
|
|
|
81
66
|
```tsx
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{props.label}
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
67
|
+
interface RequiredChildrenProps {
|
|
68
|
+
children: ReactNode;
|
|
69
|
+
}
|
|
88
70
|
```
|
|
89
71
|
|
|
90
72
|
```tsx
|
|
@@ -103,7 +85,7 @@ interface SlotProps {
|
|
|
103
85
|
|
|
104
86
|
This rule should not be used if:
|
|
105
87
|
|
|
106
|
-
- Your project intentionally avoids `PropsWithChildren` and prefers explicit `children
|
|
88
|
+
- Your project intentionally avoids `PropsWithChildren` and prefers explicit `children?` declarations.
|
|
107
89
|
- You frequently use children types other than `ReactNode` (this rule already skips those cases).
|
|
108
90
|
|
|
109
91
|
## Related Rules
|