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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { TSESTree } from "@typescript-eslint/types";
import type { RuleListener } from "@typescript-eslint/utils/ts-eslint";

import type { CamelCase } from "string-ts";
import { JsxRuntimeOptions, type RuleContext, type RuleFeature } from "@eslint-react/kit";
import { JsxRuntimeConfig, type RuleContext, type RuleFeature } from "@eslint-react/kit";
import { JsxEmit } from "typescript";
import { createRule } from "../utils";

Expand Down Expand Up @@ -30,14 +30,12 @@ export default createRule<[], MessageID>({
});

export function create(context: RuleContext<MessageID, []>): RuleListener {
const jsxRuntimeOptionsFromContext = JsxRuntimeOptions.getFromContext(context);
const jsxRuntimeOptionsFromAnnotation = JsxRuntimeOptions.getFromAnnotation(context);
const jsxRuntimeOptions = {
...jsxRuntimeOptionsFromContext,
...jsxRuntimeOptionsFromAnnotation,
const jsxRuntimeConfig = {
...JsxRuntimeConfig.getFromContext(context),
...JsxRuntimeConfig.getFromAnnotation(context),
};

const { jsx, jsxFactory, jsxFragmentFactory } = jsxRuntimeOptions;
const { jsx, jsxFactory, jsxFragmentFactory } = jsxRuntimeConfig;

if (jsx === JsxEmit.ReactJSX || jsx === JsxEmit.ReactJSXDev) return {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

***

[@eslint-react/kit](../../../README.md) / JsxRuntimeOptions
[@eslint-react/kit](../../../README.md) / JsxRuntimeConfig

# JsxRuntimeOptions
# JsxRuntimeConfig

## Type Aliases

- [JsxRuntimeOptions](type-aliases/JsxRuntimeOptions.md)
- [JsxRuntimeConfig](type-aliases/JsxRuntimeConfig.md)

## Functions

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[**@eslint-react/kit**](../../../../README.md)

***

[@eslint-react/kit](../../../../README.md) / [JsxRuntimeConfig](../README.md) / getFromAnnotation

# Function: getFromAnnotation()

> **getFromAnnotation**(`context`): [`JsxRuntimeConfig`](../type-aliases/JsxRuntimeConfig.md)

Get JsxRuntimeConfig from annotation

## Parameters

### context

[`RuleContext`](../../../../type-aliases/RuleContext.md)

The RuleContext

## Returns

[`JsxRuntimeConfig`](../type-aliases/JsxRuntimeConfig.md)

JsxRuntimeConfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

***

[@eslint-react/kit](../../../../README.md) / [JsxRuntimeOptions](../README.md) / getFromContext
[@eslint-react/kit](../../../../README.md) / [JsxRuntimeConfig](../README.md) / getFromContext

# Function: getFromContext()

> **getFromContext**(`context`): `object`

Get JsxRuntimeOptions from RuleContext
Get JsxRuntimeConfig from RuleContext

## Parameters

Expand All @@ -22,7 +22,7 @@ The RuleContext

`object`

JsxRuntimeOptions
JsxRuntimeConfig

### jsx

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[**@eslint-react/kit**](../../../../README.md)

***

[@eslint-react/kit](../../../../README.md) / [JsxRuntimeConfig](../README.md) / make

# Function: make()

> **make**(): [`JsxRuntimeConfig`](../type-aliases/JsxRuntimeConfig.md)

Create a JsxRuntimeConfig object

## Returns

[`JsxRuntimeConfig`](../type-aliases/JsxRuntimeConfig.md)

JsxRuntimeConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[**@eslint-react/kit**](../../../../README.md)

***

[@eslint-react/kit](../../../../README.md) / [JsxRuntimeConfig](../README.md) / JsxRuntimeConfig

# Type Alias: JsxRuntimeConfig

> **JsxRuntimeConfig** = [`Pick`](https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys)\<`CompilerOptions`, `"reactNamespace"` \| `"jsx"` \| `"jsxFactory"` \| `"jsxFragmentFactory"` \| `"jsxImportSource"`\>

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion packages/utilities/kit/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Namespaces

- [JsxRuntimeOptions](@eslint-react/namespaces/JsxRuntimeOptions/README.md)
- [JsxRuntimeConfig](@eslint-react/namespaces/JsxRuntimeConfig/README.md)
- [LanguagePreference](@eslint-react/namespaces/LanguagePreference/README.md)

## Type Aliases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
RE_ANNOTATION_JSX_RUNTIME,
} from "../RegExp";

export type JsxRuntimeOptions = Pick<
export type JsxRuntimeConfig = Pick<
CompilerOptions,
// Specifies the object invoked for `createElement` and `__spread` when targeting `'react'` JSX emit.
| "reactNamespace"
Expand All @@ -23,17 +23,17 @@ export type JsxRuntimeOptions = Pick<
>;

/**
* Create a JsxRuntimeOptions object
* @returns JsxRuntimeOptions
* Create a JsxRuntimeConfig object
* @returns JsxRuntimeConfig
*/
export function make(): JsxRuntimeOptions {
export function make(): JsxRuntimeConfig {
return {};
}

/**
* Get JsxRuntimeOptions from RuleContext
* Get JsxRuntimeConfig from RuleContext
* @param context The RuleContext
* @returns JsxRuntimeOptions
* @returns JsxRuntimeConfig
*/
export function getFromContext(context: RuleContext) {
const options = context.sourceCode.parserServices?.program?.getCompilerOptions() ?? {};
Expand All @@ -47,9 +47,9 @@ export function getFromContext(context: RuleContext) {
}

/**
* Get JsxRuntimeOptions from annotation
* Get JsxRuntimeConfig from annotation
* @param context The RuleContext
* @returns JsxRuntimeOptions
* @returns JsxRuntimeConfig
*/
export function getFromAnnotation(context: RuleContext) {
if (!context.sourceCode.text.includes("@jsx")) return {};
Expand Down
1 change: 1 addition & 0 deletions packages/utilities/kit/src/JsxRuntimeConfig/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./JsxRuntimeConfig";
1 change: 0 additions & 1 deletion packages/utilities/kit/src/JsxRuntimeOptions/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/utilities/kit/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * as JsxRuntimeOptions from "./JsxRuntimeOptions";
export * as JsxRuntimeConfig from "./JsxRuntimeConfig";
export * as LanguagePreference from "./LanguagePreference";
export * from "./RegExp";
export * from "./Rule";