Skip to content

Commit b408e30

Browse files
committed
docs: update configurations documentation
1 parent 8182809 commit b408e30

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

website/pages/docs/configurations.mdx

+29-17
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ ESLint React provides the following configurations:
1212

1313
React version to use, `"detect"` means auto detect React version from the project's dependencies.
1414

15+
### `importSource`
16+
17+
(type: `string`, default: `"react"`)
18+
19+
The source where React is imported from.\
20+
This allows to specify a custom import location for React when not using the official distribution.\
21+
If `importSource` is specified, an equivalent version of React should be provided to the [`version`](#version) setting.
22+
23+
(e.g. `@pika/react`, etc)
24+
1525
### `polymorphicPropName`
1626

1727
(type: `string`)
@@ -24,37 +34,39 @@ For example, if you set the `polymorphicPropName` setting to `as` then this elem
2434

2535
will be evaluated as an `h3`. If no `polymorphicPropName` is set, then the component will be evaluated as `Box`.
2636

27-
### `additionalHooks`
37+
### `additionalComponents`
2838

29-
(type: `[key: string]: string[]`)
39+
(type: `{ name: string; as: string; attributes: { name: string; as?: string; defaultValue?: string }[] }[]`)
3040

31-
<Callout type="warning">This is intended to cover edge cases. We suggest to use this option very sparingly, if at all.</Callout>
41+
<Callout type="info">Before using `additionalComponents`, consider whether `polymorphicPropName` can be used instead, as it simpler and more efficient.</Callout>
3242

33-
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.
43+
<Callout type="warning">This is an experimental feature that can be unstable and lacks documentation.</Callout>
3444

35-
(e.g. `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`)
45+
An array of components and its attributes mapping. It allows the related rules to do even more comprehensive analysis. You can also provide default values for attributes here, that will be used when that attribute is not present in the component.
3646

37-
### `additionalComponents`
47+
For example, if you set the `additionalComponents` to `[{ name: "EmbedContent", as: "iframe", attributes: [{ name: "sandbox", defaultValue: "" }] }]` then this element:
3848

39-
(type: `{ name: string; as: string; attributes: { name: string; as?: string; defaultValue?: string }[] }[]`)
49+
`<EmbedContent src="https://eslint-react.xyz" />`
4050

41-
<Callout type="info">Before using `additionalComponents`, consider whether `polymorphicPropName` can be used instead, as it simpler and more efficient.</Callout>
51+
will be evaluated as an `<iframe src="https://eslint-react.xyz" sandbox="" />`
4252

43-
<Callout type="warning">This is an experimental feature that can be unstable and lacks documentation.</Callout>
53+
So that both the `dom/no-missing-iframe-sandbox` and `dom/no-unsafe-iframe-sandbox` rules can perform checks on it.
4454

45-
An array of components and its attributes mapping. It allows the related rules to do even more comprehensive analysis on them than just using the `polymorphicPropName` setting. You can also provide default values for attributes here, that will be used when that attribute is not present in the component.
55+
### `additionalHooks`
4656

47-
(e.g. The `[{ name: "EmbedContent", as: "iframe", attributes: [{ name: "sandbox", defaultValue: "" }] }]` demystifies an `<EmbedContent src="https://eslint-react.xyz" />` as an `<iframe src="https://eslint-react.xyz" sandbox="" />`, so that both the `dom/no-missing-iframe-sandbox` and `dom/no-unsafe-iframe-sandbox` rules can perform checks on it)
57+
(type: `[key: string]: string[]`)
4858

49-
### `importSource`
59+
<Callout type="warning">This is intended to cover edge cases. We suggest to use this option very sparingly, if at all.</Callout>
5060

51-
(type: `string`, default: `"react"`)
61+
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.
5262

53-
The source where React is imported from.\
54-
This allows to specify a custom import location for React when not using the official distribution.\
55-
If `importSource` is specified, an equivalent version of React should be provided to the [`version`](#version) setting.
63+
For example, if you set the `additionalHooks` to `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }` then the React Hook in this code:
5664

57-
(e.g. `@pika/react`, etc)
65+
`useIsomorphicLayoutEffect(() => { setCount(count + 1); }, [count]);`
66+
67+
will be evaluated as a `useLayoutEffect` hook
68+
69+
So that the `hooks-extra/no-direct-set-state-in-use-layout-effect` rule can perform checks on it.
5870

5971
## Examples
6072

0 commit comments

Comments
 (0)