Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"effect": "^3.17.9",
"fumadocs-core": "15.7.3",
"fumadocs-core": "15.7.5",
"fumadocs-docgen": "3.0.0",
"fumadocs-mdx": "11.8.1",
"fumadocs-twoslash": "3.1.6",
"fumadocs-twoslash": "3.1.7",
"fumadocs-typescript": "4.0.6",
"fumadocs-ui": "15.7.3",
"fumadocs-ui": "15.7.5",
"lucide-react": "^0.542.0",
"next": "^15.5.2",
"next-view-transitions": "^0.3.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import type { CustomComponentNormalized, CustomComponentPropNormalized } from "@eslint-react/shared";

/**
* Finds a custom component by name from the provided array of components.
*
* @param name - The name of the component to find
* @param components - Array of normalized custom components to search through
* @returns The matching component if found, undefined otherwise
*/
export function findCustomComponent(name: string, components: CustomComponentNormalized[]) {
return components
.findLast((c) => c.name === name || c.re.test(name));
}

/**
* Finds a custom component prop by its "as" name.
*
* @param name - The name to match against the prop's "as" property
* @param props - Array of normalized custom component props to search through
* @returns The matching prop if found, undefined otherwise
*/
export function findCustomComponentProp(name: string, props: CustomComponentPropNormalized[]) {
return props
.findLast((a) => a.as === name);
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/docs/functions/coerceESLintSettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@

> **coerceESLintSettings**(`settings`): `PartialDeep`\<`undefined` \| \{ `react-x?`: `unknown`; \}\>

Coerces unknown input to ESLintSettings type

## Parameters

### settings

`unknown`

The settings object to coerce

## Returns

`PartialDeep`\<`undefined` \| \{ `react-x?`: `unknown`; \}\>
53 changes: 24 additions & 29 deletions packages/shared/docs/functions/coerceSettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,41 @@

> **coerceSettings**(`settings`): `object`

Coerces unknown input to ESLintReactSettings type

## Parameters

### settings

`unknown`

The settings object to coerce

## Returns

### additionalComponents?

> `optional` **additionalComponents**: `object`[]

An array of user-defined components

#### Description

This is used to inform the ESLint React plugins how to treat these components during checks.
User-defined components configuration
Informs ESLint React how to treat these components during validation

#### Example

```ts
`[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }] }]
```

### additionalHooks?

> `optional` **additionalHooks**: `object`

A object to define additional hooks that are equivalent to the built-in React Hooks.

#### Description

ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
Custom hooks that should be treated as equivalent to built-in React Hooks

#### Example

```ts
`{ useEffect: ["useIsomorphicLayoutEffect"] }`
{ useEffect: ["useIsomorphicLayoutEffect"] }
```

#### additionalHooks.use?
Expand Down Expand Up @@ -128,51 +125,49 @@ ESLint React will recognize these aliases as equivalent to the built-in hooks in

> `optional` **importSource**: `string`

The source where React is imported from.

#### Description

This allows to specify a custom import location for React when not using the official distribution.
The source where React is imported from
Allows specifying a custom import location for React

#### Default

`"react"`
```ts
"react"
```

#### Example

```ts
`"@pika/react"`
"@pika/react"
```

### polymorphicPropName?

> `optional` **polymorphicPropName**: `string`

The name of the prop that is used for polymorphic components.

#### Description

This is used to determine the type of the component.
The prop name used for polymorphic components
Used to determine the component's type

#### Example

```ts
`"as"`
"as"
```

### version?

> `optional` **version**: `string`

React version to use, "detect" means auto detect React version from the project's dependencies.
If `importSource` is specified, an equivalent version of React should be provided here.
React version to use
"detect" means auto-detect React version from project dependencies

#### Example

```ts
`"18.3.1"`
"18.3.1"
```

#### Default

`"detect"`
```ts
"detect"
```
4 changes: 4 additions & 0 deletions packages/shared/docs/functions/decodeESLintSettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@

> **decodeESLintSettings**(`settings`): `undefined` \| \{ `react-x?`: `unknown`; \}

Decodes and validates ESLint settings, using defaults if invalid

## Parameters

### settings

`unknown`

The settings object to decode

## Returns

`undefined` \| \{ `react-x?`: `unknown`; \}
53 changes: 24 additions & 29 deletions packages/shared/docs/functions/decodeSettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,41 @@

> **decodeSettings**(`settings`): `object`

Decodes and validates ESLint React settings, using defaults if invalid

## Parameters

### settings

`unknown`

The settings object to decode

## Returns

### additionalComponents?

> `optional` **additionalComponents**: `object`[]

An array of user-defined components

#### Description

This is used to inform the ESLint React plugins how to treat these components during checks.
User-defined components configuration
Informs ESLint React how to treat these components during validation

#### Example

```ts
`[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }] }]
```

### additionalHooks?

> `optional` **additionalHooks**: `object`

A object to define additional hooks that are equivalent to the built-in React Hooks.

#### Description

ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
Custom hooks that should be treated as equivalent to built-in React Hooks

#### Example

```ts
`{ useEffect: ["useIsomorphicLayoutEffect"] }`
{ useEffect: ["useIsomorphicLayoutEffect"] }
```

#### additionalHooks.use?
Expand Down Expand Up @@ -128,51 +125,49 @@ ESLint React will recognize these aliases as equivalent to the built-in hooks in

> `optional` **importSource**: `string`

The source where React is imported from.

#### Description

This allows to specify a custom import location for React when not using the official distribution.
The source where React is imported from
Allows specifying a custom import location for React

#### Default

`"react"`
```ts
"react"
```

#### Example

```ts
`"@pika/react"`
"@pika/react"
```

### polymorphicPropName?

> `optional` **polymorphicPropName**: `string`

The name of the prop that is used for polymorphic components.

#### Description

This is used to determine the type of the component.
The prop name used for polymorphic components
Used to determine the component's type

#### Example

```ts
`"as"`
"as"
```

### version?

> `optional` **version**: `string`

React version to use, "detect" means auto detect React version from the project's dependencies.
If `importSource` is specified, an equivalent version of React should be provided here.
React version to use
"detect" means auto-detect React version from project dependencies

#### Example

```ts
`"18.3.1"`
"18.3.1"
```

#### Default

`"detect"`
```ts
"detect"
```
5 changes: 5 additions & 0 deletions packages/shared/docs/functions/getSettingsFromContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@

> **getSettingsFromContext**(`context`): [`ESLintReactSettingsNormalized`](../interfaces/ESLintReactSettingsNormalized.md)

Retrieves normalized ESLint React settings from the rule context
Uses caching for performance optimization

## Parameters

### context

`RuleContext`

The ESLint rule context

## Returns

[`ESLintReactSettingsNormalized`](../interfaces/ESLintReactSettingsNormalized.md)
4 changes: 4 additions & 0 deletions packages/shared/docs/functions/isESLintReactSettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@

> **isESLintReactSettings**(`settings`): `settings is { additionalComponents?: { as?: string; attributes?: { as?: string; defaultValue?: string; name: string }[]; name: string }[]; additionalHooks?: { use?: string[]; useActionState?: string[]; useCallback?: string[]; useContext?: string[]; useDebugValue?: string[]; useDeferredValue?: string[]; useEffect?: string[]; useFormStatus?: string[]; useId?: string[]; useImperativeHandle?: string[]; useInsertionEffect?: string[]; useLayoutEffect?: string[]; useMemo?: string[]; useOptimistic?: string[]; useReducer?: string[]; useRef?: string[]; useState?: string[]; useSyncExternalStore?: string[]; useTransition?: string[] }; importSource?: string; polymorphicPropName?: string; version?: string }`

Checks if the provided settings conform to ESLintReactSettings schema

## Parameters

### settings

`unknown`

The settings object to validate

## Returns

`settings is { additionalComponents?: { as?: string; attributes?: { as?: string; defaultValue?: string; name: string }[]; name: string }[]; additionalHooks?: { use?: string[]; useActionState?: string[]; useCallback?: string[]; useContext?: string[]; useDebugValue?: string[]; useDeferredValue?: string[]; useEffect?: string[]; useFormStatus?: string[]; useId?: string[]; useImperativeHandle?: string[]; useInsertionEffect?: string[]; useLayoutEffect?: string[]; useMemo?: string[]; useOptimistic?: string[]; useReducer?: string[]; useRef?: string[]; useState?: string[]; useSyncExternalStore?: string[]; useTransition?: string[] }; importSource?: string; polymorphicPropName?: string; version?: string }`
4 changes: 4 additions & 0 deletions packages/shared/docs/functions/isESLintSettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@

> **isESLintSettings**(`settings`): settings is undefined \| \{ react-x?: unknown \}

Checks if the provided settings conform to ESLintSettings schema

## Parameters

### settings

`unknown`

The settings object to validate

## Returns

settings is undefined \| \{ react-x?: unknown \}
Loading