Skip to content

Commit 8de6a10

Browse files
committed
docs: minor improvements
1 parent a8d1e1b commit 8de6a10

File tree

9 files changed

+23
-17
lines changed

9 files changed

+23
-17
lines changed

packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-direct-set-state-in-use-effect.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ ruleTester.run(RULE_NAME, rule, {
657657
const [data, setData] = useState(() => 0);
658658
useEffect(() => {
659659
void async function () {
660-
const ret = await fetch("https://example.com");
660+
const ret = await fetch("https://eslint-react.xyz");
661661
setData(ret);
662662
}()
663663
}, []);

packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-direct-set-state-in-use-layout-effect.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ ruleTester.run(RULE_NAME, rule, {
680680
const [data, setData] = useState(() => 0);
681681
useLayoutEffect(() => {
682682
void async function () {
683-
const ret = await fetch("https://example.com");
683+
const ret = await fetch("https://eslint-react.xyz");
684684
setData(ret);
685685
}()
686686
}, []);

packages/plugins/eslint-plugin-react-x/src/rules/no-comment-textnodes.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ruleTester.run(RULE_NAME, rule, {
5151
valid: [
5252
...allValid,
5353
"<App foo='test'>{/* valid */}</App>",
54-
"<strong>&nbsp;https://www.example.com/attachment/download/1</strong>",
54+
"<strong>&nbsp;https://www.eslint-react.xyz/attachment/download/1</strong>",
5555
"<App /* valid */ placeholder={'foo'}/>",
5656
"</* valid */></>",
5757
],

website/pages/docs/configurations.mdx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ ESLint React provides the following configurations:
1111
(type: `string`, default: `"react"`)
1212

1313
The source where React is imported from.\
14-
This allows to specify a custom import location for React when not using the official distribution (e.g. `@pika/react`, etc).
14+
This allows to specify a custom import location for React when not using the official distribution.
15+
16+
(e.g. `@pika/react`, etc)
1517

1618
### `jsxPragma`
1719

@@ -56,17 +58,21 @@ will be evaluated as an `h3`. If no `polymorphicPropName` is set, then the compo
5658

5759
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.
5860

59-
(e.g. `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`).
61+
(e.g. `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`)
6062

6163
### `additionalComponents`
6264

6365
(type: `{ name: string; as: string; attributes: { name: string; as?: string; defaultValue?: string }[] }[]`)
6466

65-
<Callout type="warning">This is an experimental feature that can be unstable and lacks comprehensive documentation.</Callout>
67+
<Callout type="info">If `polymorphicPropName` meets the requirements, always consider using it instead of this setting, as it is simpler and more efficient.</Callout>
68+
69+
<Callout type="warning">This is an experimental feature that can be unstable and lacks documentation.</Callout>
70+
71+
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.
6672

67-
An array of user-defined components, used to inform the ESLint React plugins how to treat these components during checks.
73+
(e.g. The `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }] }]` demystifies a `<Link to="https://eslint-react.xyz" />` as an `<a href="https://eslint-react.xyz" />` so that the `dom/no-unsafe-target-blank` rule can perform checks on it)
6874

69-
This can be incredibly helpful for rules to understand the semantics of user-defined components and their props (e.g. `<Link to="/home" />`, `<Box as="form" />`, `<Button component="a" />`).
75+
(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-sandbox` and `dom/no-unsafe-sandbox` rules can perform checks on it)
7076

7177
## Examples
7278

website/pages/docs/rules/dom-no-missing-iframe-sandbox.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ This rule checks all React iframe elements and verifies that there is sandbox at
3939
import React from "react";
4040

4141
function MyComponent() {
42-
return <iframe src="https://example.com" />;
43-
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42+
return <iframe src="https://eslint-react.xyz" />;
43+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4444
// - Missing 'sandbox' attribute on iframe component.
4545
}
4646
```
@@ -51,7 +51,7 @@ function MyComponent() {
5151
import React from "react";
5252

5353
function MyComponent() {
54-
return <iframe src="https://example.com" sandbox="allow-popups" />;
54+
return <iframe src="https://eslint-react.xyz" sandbox="allow-popups" />;
5555
}
5656
```
5757

website/pages/docs/rules/dom-no-unsafe-iframe-sandbox.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import React from "react";
4141
function MyComponent() {
4242
return (
4343
<iframe
44-
src="https://example.com"
44+
src="https://eslint-react.xyz"
4545
sandbox="allow-scripts allow-same-origin"
4646
/>
4747
);
@@ -54,7 +54,7 @@ function MyComponent() {
5454
import React from "react";
5555

5656
function MyComponent() {
57-
return <iframe src="https://example.com" sandbox="allow-popups" />;
57+
return <iframe src="https://eslint-react.xyz" sandbox="allow-popups" />;
5858
}
5959
```
6060

website/pages/docs/rules/dom-no-unsafe-target-blank.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import React from "react";
3636

3737
function MyComponent() {
3838
return (
39-
<a href="https://example.com" target="_blank">
39+
<a href="https://eslint-react.xyz" target="_blank">
4040
Example
4141
</a>
4242
);
@@ -50,7 +50,7 @@ import React from "react";
5050

5151
function MyComponent() {
5252
return (
53-
<a href="https://example.com" target="_blank" rel="noreferrer noopener">
53+
<a href="https://eslint-react.xyz" target="_blank" rel="noreferrer noopener">
5454
Example
5555
</a>
5656
);

website/pages/docs/rules/hooks-extra-no-direct-set-state-in-use-effect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default function RemoteContent() {
7979

8080
useEffect(() => {
8181
let discarded = false;
82-
fetch("https://example.com/content")
82+
fetch("https://eslint-react.xyz/content")
8383
.then(resp => resp.text())
8484
.then(text => {
8585
if (discarded) return;

website/pages/docs/rules/hooks-extra-no-direct-set-state-in-use-layout-effect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default function RemoteContent() {
7373

7474
useLayoutEffect(() => {
7575
let discarded = false;
76-
fetch("https://example.com/content")
76+
fetch("https://eslint-react.xyz/content")
7777
.then(resp => resp.text())
7878
.then(text => {
7979
if (discarded) return;

0 commit comments

Comments
 (0)