Skip to content

Commit a5b0224

Browse files
authored
docs(website): wrap kit sections in accordions and add under-construction notice (#1850)
1 parent 8b82144 commit a5b0224

1 file changed

Lines changed: 48 additions & 35 deletions

File tree

  • apps/website/content/docs/packages

apps/website/content/docs/packages/kit.mdx

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ description: ESLint React's toolkit for building custom React rules with JavaScr
44
---
55

66
import { BskyPost } from "@/components/BskyPost";
7+
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
78

89
<Callout type="warning">
910
This module is currently in **beta**. APIs may change in future releases.
@@ -100,47 +101,51 @@ function forbidElements({ forbidden }: ForbidElementsOptions): RuleFunction {
100101
}
101102
```
102103

103-
#### Anonymous Rules
104+
<Accordions>
105+
<Accordion title="Anonymous Rules">
104106

105-
When you use an **anonymous function** (arrow function without a name) with `.use()`, a random hex string is automatically generated as the rule name:
107+
When you use an **anonymous function** (arrow function without a name) with `.use()`, a random hex string is automatically generated as the rule name:
106108

107-
```ts
108-
// Registered as `@eslint-react/kit/a1b2c3d4e5f67890`
109-
eslintReactKit().use(() => (context) => ({
110-
CallExpression(node) {
111-
// Critical check that cannot be easily disabled
112-
},
113-
}));
114-
```
109+
```ts
110+
// Registered as `@eslint-react/kit/a1b2c3d4e5f67890`
111+
eslintReactKit().use(() => (context) => ({
112+
CallExpression(node) {
113+
// Critical check that cannot be easily disabled
114+
},
115+
}));
116+
```
115117

116-
Anonymous rules are ideal for checks that are **critical to code quality or security** and should never be bypassed via disable comments:
118+
Anonymous rules are ideal for checks that are **critical to code quality or security** and should never be bypassed via disable comments:
117119

118-
```ts
119-
// This critical security check cannot be easily disabled by developers
120-
eslintReactKit().use(() => (context) => ({
121-
Property(node) {
122-
// Prevent direct construction of '__html' objects in product code
123-
if (node.key.type === "Identifier" && node.key.name === "__html") {
124-
context.report({
125-
node,
126-
message: "Do not construct '__html' objects directly. Use a sanitization library or receive them from server-side code.",
127-
});
128-
}
129-
},
130-
}));
131-
```
120+
```ts
121+
// This critical security check cannot be easily disabled by developers
122+
eslintReactKit().use(() => (context) => ({
123+
Property(node) {
124+
// Prevent direct construction of '__html' objects in product code
125+
if (node.key.type === "Identifier" && node.key.name === "__html") {
126+
context.report({
127+
node,
128+
message: "Do not construct '__html' objects directly. Use a sanitization library or receive them from server-side code.",
129+
});
130+
}
131+
},
132+
}));
133+
```
132134

133-
**Note:** Since the rule name is random and changes on every ESLint run, developers cannot use standard rules configs or disable comments like:
135+
**Note:** Since the rule name is random and changes on every ESLint run, developers cannot use standard rules configs or disable comments like:
134136

135-
```ts
136-
// This will NOT work - the rule name is random!
137-
{ rules: { "@eslint-react/kit/01KNE2WSJ8011D2HXE3A6H717C": "off" } }
137+
```ts
138+
// This will NOT work - the rule name is random!
139+
{ rules: { "@eslint-react/kit/01KNE2WSJ8011D2HXE3A6H717C": "off" } }
138140

139-
// This will NOT work - the rule name is random!
140-
// eslint-disable-next-line @eslint-react/kit/01KNE2WSJ8011D2HXE3A6H717C
141-
```
141+
// This will NOT work - the rule name is random!
142+
// eslint-disable-next-line @eslint-react/kit/01KNE2WSJ8011D2HXE3A6H717C
143+
```
144+
145+
To disable an anonymous rule, developers must modify the ESLint configuration file directly, which provides an audit trail for policy violations.
142146

143-
To disable an anonymous rule, developers must modify the ESLint configuration file directly, which provides an audit trail for policy violations.
147+
</Accordion>
148+
</Accordions>
144149

145150
### `Builder`
146151

@@ -296,7 +301,13 @@ const isCreateRefCall = is.APICall("createRef");
296301
isCreateRefCall(node);
297302
```
298303

299-
<Callout type="info" title="Why `is.API` / `is.APICall` instead of a hand-written check?">
304+
<Accordions>
305+
<Accordion title="Why `is.API` / `is.APICall` instead of a hand-written check?">
306+
307+
<Callout type="warn" title="Under Construction">
308+
This part is under construction.
309+
</Callout>
310+
300311
Consider this single statement:
301312

302313
```ts
@@ -318,7 +329,9 @@ isCreateRefCall(node);
318329
- matches on the **fully-qualified name**, so a single predicate covers both the bare `captureOwnerStack` and the namespaced `React.captureOwnerStack` (any name ending in `.captureOwnerStack`).
319330

320331
Use `is.API(name)` for the reference itself and `is.APICall(name)` for a call to it. Hand-rolling this means re-implementing unwrapping and member-expression resolution for **every** API — and breaking the moment someone adds a `?.`, an `as`, or a `React.` prefix. To additionally assert the symbol truly comes from React (and not a local same-named binding), pair it with [`is.APIFromReact`](#import-source).
321-
</Callout>
332+
333+
</Accordion>
334+
</Accordions>
322335

323336
#### Import source
324337

0 commit comments

Comments
 (0)