Skip to content

fix: fixed named export 'JsxEmit' not found, closes #1095 #1096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
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
14 changes: 7 additions & 7 deletions .pkgs/configs/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ export const typescript = tseslint.config({
"no-mixed-operators": "warn",
"no-undef": "off",
"prefer-object-has-own": "error",
// "no-restricted-syntax": [
// "error",
// {
// message: "no optional",
// selector: "TSPropertySignature[optional=true]",
// },
// ],
"no-restricted-syntax": [
"error",
{
message: "no typescript named import",
selector: "ImportDeclaration[source.value='typescript'] ImportSpecifier",
},
],
"@typescript-eslint/ban-ts-comment": [
"error",
{
Expand Down
14 changes: 7 additions & 7 deletions .pkgs/configs/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ export const typescript: ConfigArray = tseslint.config(
"no-undef": "off",
"prefer-object-has-own": "error",

// "no-restricted-syntax": [
// "error",
// {
// message: "no optional",
// selector: "TSPropertySignature[optional=true]",
// },
// ],
"no-restricted-syntax": [
"error",
{
message: "no typescript named import",
selector: "ImportDeclaration[source.value='typescript'] ImportSpecifier",
},
],

"@typescript-eslint/ban-ts-comment": [
"error",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { JsxConfig } from "@eslint-react/kit";
import { RuleTester } from "@typescript-eslint/rule-tester";

import tsx from "dedent";

import { JsxEmit } from "typescript";
import { defaultLanguageOptionsWithTypes, getProjectForJsxEmit } from "../../../../../test";

import { stringify } from "../utils";
import rule, { RULE_NAME } from "./jsx";

Expand All @@ -12,7 +12,7 @@ const ruleTester = new RuleTester({
...defaultLanguageOptionsWithTypes,
parserOptions: {
...defaultLanguageOptionsWithTypes.parserOptions,
project: getProjectForJsxEmit(JsxEmit.ReactJSX),
project: getProjectForJsxEmit(JsxConfig.JsxEmit.ReactJSX),
projectService: false,
},
},
Expand Down
3 changes: 2 additions & 1 deletion packages/plugins/eslint-plugin-react-debug/src/rules/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { flow } from "@eslint-react/eff";
import { JsxConfig, Reporter as RPT, type RuleContext, type RuleFeature } from "@eslint-react/kit";
import { AST_NODE_TYPES as T, type TSESTree } from "@typescript-eslint/types";
import { match, P } from "ts-pattern";
import { JsxEmit } from "typescript";
import { createRule, stringify } from "../utils";

const { JsxEmit } = JsxConfig;

export const RULE_NAME = "jsx";

export const RULE_FEATURES = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { JsxConfig } from "@eslint-react/kit";
import { RuleTester } from "@typescript-eslint/rule-tester";
import tsx from "dedent";

import { JsxEmit } from "typescript";
import tsx from "dedent";
import { defaultLanguageOptionsWithTypes, getProjectForJsxEmit } from "../../../../../test";
import rule, { RULE_NAME } from "./jsx-uses-react";

Expand All @@ -10,7 +10,7 @@ const ruleTester = new RuleTester({
...defaultLanguageOptionsWithTypes,
parserOptions: {
...defaultLanguageOptionsWithTypes.parserOptions,
project: getProjectForJsxEmit(JsxEmit.React),
project: getProjectForJsxEmit(JsxConfig.JsxEmit.React),
projectService: false,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import type { RuleListener } from "@typescript-eslint/utils/ts-eslint";

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

const { JsxEmit } = JsxConfig;

export const RULE_NAME = "jsx-uses-react";

export const RULE_FEATURES = [] as const satisfies RuleFeature[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

# JsxConfig

## Type Aliases
## Interfaces

- [JsxConfig](type-aliases/JsxConfig.md)
- [JsxConfig](interfaces/JsxConfig.md)

## Variables

- [JsxEmit](variables/JsxEmit.md)

## Functions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Function: getFromAnnotation()

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

Get JsxConfig from annotation

Expand All @@ -20,6 +20,6 @@ The RuleContext

## Returns

[`JsxConfig`](../type-aliases/JsxConfig.md)
[`JsxConfig`](../interfaces/JsxConfig.md)

JsxConfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ JsxConfig

### jsx

> **jsx**: `JsxEmit`
> **jsx**: `4` \| `JsxEmit`

### jsxFactory

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

# Function: make()

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

Create a JsxConfig object

## Returns

[`JsxConfig`](../type-aliases/JsxConfig.md)
[`JsxConfig`](../interfaces/JsxConfig.md)

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

***

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

# Interface: JsxConfig

## Properties

### jsx?

> `optional` **jsx**: `number`

***

### jsxFactory?

> `optional` **jsxFactory**: `string`

***

### jsxFragmentFactory?

> `optional` **jsxFragmentFactory**: `string`

***

### jsxImportSource?

> `optional` **jsxImportSource**: `string`

This file was deleted.

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

***

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

# Variable: JsxEmit

> `const` **JsxEmit**: `object`

## Type declaration

### None

> `readonly` **None**: `0` = `0`

### Preserve

> `readonly` **Preserve**: `1` = `1`

### React

> `readonly` **React**: `2` = `2`

### ReactJSX

> `readonly` **ReactJSX**: `4` = `4`

### ReactJSXDev

> `readonly` **ReactJSXDev**: `5` = `5`

### ReactNative

> `readonly` **ReactNative**: `3` = `3`
26 changes: 16 additions & 10 deletions packages/utilities/kit/src/JsxConfig/JsxConfig.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
/* eslint-disable perfectionist/sort-objects */
import type { RuleContext } from "../types";
import { getOrElseUpdate } from "@eslint-react/eff";
import { type CompilerOptions, JsxEmit } from "typescript";
import * as RE from "../RegExp";

export type JsxConfig = Pick<
CompilerOptions,
// Specifies the object invoked for `createElement` and `__spread` when targeting `'react'` JSX emit.
| "reactNamespace"
export const JsxEmit = {
None: 0,
Preserve: 1,
React: 2,
ReactNative: 3,
ReactJSX: 4,
ReactJSXDev: 5,
} as const;

export interface JsxConfig {
// Specifies what JSX code is generated.
| "jsx"
jsx?: number;
// Specifies the JSX factory function to use when targeting React JSX emit, e.g. `React.createElement` or `h`.
| "jsxFactory"
jsxFactory?: string;
// Specifies the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.
| "jsxFragmentFactory"
jsxFragmentFactory?: string;
// Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.
| "jsxImportSource"
>;
jsxImportSource?: string;
}

/**
* Create a JsxConfig object
Expand Down
16 changes: 8 additions & 8 deletions test/rule-tester.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RuleTester, type RuleTesterConfig } from "@typescript-eslint/rule-tester";
import * as vitest from "vitest";
import { getFixturesRootDir } from "./helpers";
import { JsxEmit } from "typescript";
import ts from "typescript";

RuleTester.it = vitest.it;
RuleTester.itOnly = vitest.it.only;
Expand Down Expand Up @@ -39,17 +39,17 @@ export const ruleTesterWithTypes = new RuleTester({
languageOptions: defaultLanguageOptionsWithTypes,
});

export function getProjectForJsxEmit(jsxEmit: JsxEmit) {
export function getProjectForJsxEmit(jsxEmit: ts.JsxEmit) {
switch (jsxEmit) {
case JsxEmit.None:
case JsxEmit.ReactJSX:
case JsxEmit.ReactJSXDev:
case ts.JsxEmit.None:
case ts.JsxEmit.ReactJSX:
case ts.JsxEmit.ReactJSXDev:
return "tsconfig.json";
case JsxEmit.React:
case ts.JsxEmit.React:
return "tsconfig.jsx-react.json";
case JsxEmit.ReactNative:
case ts.JsxEmit.ReactNative:
return "tsconfig.jsx-react-native.json";
case JsxEmit.Preserve:
case ts.JsxEmit.Preserve:
return "tsconfig.jsx-preserve.json";
}
}