Skip to content

Commit 080edd9

Browse files
authored
docs: make 'strictImportCheck' setting public (#944)
1 parent 633a1bb commit 080edd9

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

apps/website/content/docs/configurations.mdx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,27 @@ This allows to specify a custom import location for React when not using the off
4141

4242
For example, if you are using `@pika/react` instead of `react`, you can set the `importSource` to `@pika/react`:
4343

44-
```tsx
44+
```ts
4545
import React from "@pika/react";
4646
```
4747

48+
### `strictImportCheck`
49+
50+
Check both the sharp and the import to determine if a API is from React before applying the rules.
51+
52+
This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
53+
54+
For example, if you set the `strictImportCheck` to `true`, then the `memo` function from `irrelevant-library` will not be recognized as React's `memo`:
55+
56+
```ts
57+
import { memo } from "irrelevant-library";
58+
59+
const NonComponentFunction = memo(() => {
60+
// ^^^^
61+
// - This will not be recognized as React's memo
62+
});
63+
```
64+
4865
### `polymorphicPropName`
4966

5067
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.
@@ -115,19 +132,19 @@ For example, if you set the `additionalHooks` to:
115132

116133
then the React Hook call:
117134

118-
```tsx
135+
```ts
119136
useIsomorphicLayoutEffect(() => { setCount(count => count + 1); }, []);
120137
```
121138

122139
will be evaluated as:
123140

124-
```tsx
141+
```ts
125142
useEffect(() => { setCount(count => count + 1); }, []);
126143
```
127144

128145
and:
129146

130-
```tsx
147+
```ts
131148
useLayoutEffect(() => { setCount(count => count + 1); }, []);
132149
```
133150

apps/website/content/docs/configurations.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ export function SettingsTypeTable() {
1818
description: <Link href="#importsource">The source where React is imported from ⤵</Link>,
1919
default: "react",
2020
},
21+
strictImportCheck: {
22+
type: "boolean",
23+
description: (
24+
<Link href="#strictimportcheck">
25+
Check both the sharp and the import to determine if a API is from React before applying the rules. ⤵
26+
</Link>
27+
),
28+
default: "false",
29+
},
2130
polymorphicPropName: {
2231
type: "string",
2332
description: (

packages/shared/src/schemas.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ export const ESLintReactSettingsSchema = object({
120120
*/
121121
strict: optional(boolean(), false),
122122
/**
123-
* @internal
123+
* Check both the sharp and the import to determine if a API is from React.
124+
* @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
125+
* @default `false`
124126
*/
125127
strictImportCheck: optional(boolean(), false),
126128
/**

0 commit comments

Comments
 (0)