Skip to content

Commit da0e0e9

Browse files
committed
docs: minor improvements
1 parent 4652967 commit da0e0e9

File tree

3 files changed

+59
-33
lines changed

3 files changed

+59
-33
lines changed

pnpm-lock.yaml

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/content/docs/configurations.mdx

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,68 @@
22
title: Configurations
33
---
44

5+
import { TypeTable } from 'fumadocs-ui/components/type-table';
6+
import { REACT_BUILD_IN_HOOKS } from "@eslint-react/shared";
7+
import { Link } from "next-view-transitions"
8+
59
ESLint React provides the following configurations:
610

7-
## Settings
11+
## Properties
812

9-
### `version`
13+
<TypeTable
14+
type={{
15+
version: {
16+
description: <Link href="#version">React version to perform the analysis.</Link>,
17+
type: "string",
18+
default: "detect",
19+
},
20+
importSource: {
21+
description: <Link href="#importsource">The source where React is imported from.</Link>,
22+
type: "string",
23+
default: "react",
24+
},
25+
polymorphicPropName: {
26+
description: <Link href="#polymorphicpropname">The prop your code uses to create polymorphic components.</Link>,
27+
type: "string",
28+
default: "as",
29+
},
30+
additionalComponents: {
31+
description: <Link href="#additionalcomponents">An array of components and its attributes mapping.</Link>,
32+
type: "CustomComponent[]",
33+
typeDescription: `
34+
type CustomComponent = {
35+
name: string;
36+
as?: string;
37+
attributes?: {
38+
name: string;
39+
as?: string;
40+
defaultValue?: string;
41+
}[]
42+
}
43+
`,
44+
default: "[]",
45+
},
46+
additionalHooks: {
47+
description: <Link href="#additionalhooks">An object of aliases for React built-in Hooks.</Link>,
48+
type: "Record<ReactBuiltInHookName, string[]>",
49+
typeDescription: `
50+
type ReactBuiltInHookName = ${REACT_BUILD_IN_HOOKS.map(n => '"' + n + '"').join(" | ")}
51+
`,
52+
default: "{}",
53+
},
54+
}}
55+
/>
1056

11-
```ts
12-
const version = "detect"
13-
```
57+
## Descriptions
58+
59+
### `version`
1460

1561
React version to perform the analysis, `"detect"` means auto detect React version from the project's dependencies.
1662

1763
If failed to detect, it will use the `19.0.0` version.
1864

1965
### `importSource`
2066

21-
```ts
22-
const importSource = "react"
23-
```
24-
2567
<Callout type="info">If `importSource` is specified, an equivalent version of React should be provided to the [`version`](#version) setting.</Callout>
2668

2769
The source where React is imported from.
@@ -36,10 +78,6 @@ import React from "@pika/react";
3678

3779
### `polymorphicPropName`
3880

39-
```ts
40-
const polymorphicPropName = "as"
41-
```
42-
4381
You can optionally use the `polymorphicPropName` setting to define the prop your code uses to create polymorphic components. This setting will be used determine the element type in rules that require semantic context.
4482

4583
For example, if you set the `polymorphicPropName` setting to `as` then this element:
@@ -54,18 +92,6 @@ If no `polymorphicPropName` is set, then the component will be evaluated as `Box
5492

5593
### `additionalComponents`
5694

57-
```ts
58-
const additionalComponents = [] satisfies {
59-
name: string;
60-
as?: string;
61-
attributes?: {
62-
name: string;
63-
as?: string;
64-
defaultValue?: string;
65-
}[]
66-
}[]
67-
```
68-
6995
<Callout type="info">Before using `additionalComponents`, consider whether `polymorphicPropName` can be used instead, as it simpler and more efficient.</Callout>
7096

7197
<Callout type="warn">This is an experimental feature that can be unstable and lacks documentation.</Callout>
@@ -105,13 +131,6 @@ So that both the `dom/no-missing-iframe-sandbox` and `dom/no-unsafe-iframe-sandb
105131

106132
### `additionalHooks`
107133

108-
```ts
109-
const additionalHooks = {
110-
useLayoutEffect: ["useIsomorphicLayoutEffect"]
111-
// ...
112-
}
113-
```
114-
115134
<Callout type="warn">This is intended to cover edge cases. We suggest using the built-in React Hooks whenever possible.</Callout>
116135

117136
A object of aliases for React built-in Hooks. ESLint React will recognize these aliases as equivalent to the built-in Hooks in all its rules.

website/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"fumadocs-docgen": "^1.3.5",
1616
"fumadocs-mdx": "11.3.1",
1717
"fumadocs-twoslash": "^2.0.3",
18+
"fumadocs-typescript": "^3.0.3",
1819
"fumadocs-ui": "14.7.7",
1920
"next": "15.1.5",
2021
"next-view-transitions": "^0.3.4",
@@ -24,6 +25,7 @@
2425
},
2526
"devDependencies": {
2627
"@eslint-react/eslint-plugin": "workspace:*",
28+
"@eslint-react/shared": "workspace:*",
2729
"@eslint/js": "^9.19.0",
2830
"@eslint/markdown": "^6.2.2",
2931
"@mdx-js/mdx": "^3.1.0",

0 commit comments

Comments
 (0)