Skip to content

Commit 7300a6b

Browse files
committed
docs: add 'Advanced Configuration' to Configuration
1 parent cc4fe2b commit 7300a6b

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

website/pages/docs/configuration.mdx

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,74 @@ A Record of aliases for React's built-in Hooks. ESLint React will recognize thes
4242
This is intended to cover edge cases. We suggest to use this option very sparingly, if at all.\
4343
(e.g. `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`).
4444

45+
### `additionalComponents` (experimental)
46+
47+
A Array of aliases for built-in components. ESLint React will recognize these aliases as equivalent to the built-in components in all its rules.\
48+
This is an experimental feature that can be unstable and lacks comprehensive documentation.\
49+
4550
## Examples
4651

52+
### Basic Configuration
53+
54+
<ESLintConfig>
55+
56+
<Config>
57+
58+
```ts twoslash filename="eslint.config.js"
59+
// ...
60+
import react from "@eslint-react/eslint-plugin";
61+
62+
// ...
63+
export default [
64+
// ...
65+
{
66+
files: ["**/*.{ts,tsx}"],
67+
...react.configs.recommended,
68+
settings: {
69+
"react-x": {
70+
importSource: "react",
71+
jsxPragma: "createElement",
72+
jsxPragmaFrag: "Fragment",
73+
additionalHooks: {
74+
useLayoutEffect: ["useIsomorphicLayoutEffect"],
75+
// ...
76+
},
77+
version: "detect",
78+
},
79+
},
80+
},
81+
];
82+
```
83+
84+
</Config>
85+
86+
<Config>
87+
88+
```js filename=".eslintrc.js"
89+
// ...
90+
module.exports = {
91+
// ...
92+
settings: {
93+
"react-x": {
94+
importSource: "react",
95+
jsxPragma: "createElement",
96+
jsxPragmaFrag: "Fragment",
97+
additionalHooks: {
98+
useLayoutEffect: ["useIsomorphicLayoutEffect"],
99+
// ...
100+
},
101+
version: "detect",
102+
},
103+
},
104+
};
105+
```
106+
107+
</Config>
108+
109+
</ESLintConfig>
110+
111+
### Advanced Configuration
112+
47113
<ESLintConfig>
48114

49115
<Config>
@@ -67,6 +133,17 @@ export default [
67133
useLayoutEffect: ["useIsomorphicLayoutEffect"],
68134
// ...
69135
},
136+
additionalComponents: [
137+
{
138+
name: "Link",
139+
as: "a",
140+
attributes: [
141+
{ name: "to", as: "href" },
142+
{ name: "rel", as: "rel", defaultValue: "noopener noreferrer" },
143+
],
144+
},
145+
// ...
146+
],
70147
version: "detect",
71148
},
72149
},
@@ -92,6 +169,17 @@ module.exports = {
92169
useLayoutEffect: ["useIsomorphicLayoutEffect"],
93170
// ...
94171
},
172+
additionalComponents: [
173+
{
174+
name: "Link",
175+
as: "a",
176+
attributes: [
177+
{ name: "to", as: "href" },
178+
{ name: "rel", as: "rel", defaultValue: "noopener noreferrer" },
179+
],
180+
},
181+
// ...
182+
],
95183
version: "detect",
96184
},
97185
},

0 commit comments

Comments
 (0)