Skip to content

Commit 48c64e5

Browse files
author
Sebastian Silbermann
committed
Stop violating no-import-type-side-effects
1 parent b5bdbae commit 48c64e5

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

transforms/__tests__/scoped-jsx.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe("transform scoped-jsx", () => {
3333
declare const element: JSX.Element;
3434
`),
3535
).toMatchInlineSnapshot(`
36-
"import { type JSX } from "react";
36+
"import type { JSX } from "react";
3737
declare const element: JSX.Element;"
3838
`);
3939
});
@@ -58,7 +58,7 @@ describe("transform scoped-jsx", () => {
5858
`),
5959
).toMatchInlineSnapshot(`
6060
"import type React from 'react';
61-
import { type JSX } from "react";
61+
import type { JSX } from "react";
6262
declare const element: JSX.Element;"
6363
`);
6464
});
@@ -71,7 +71,7 @@ describe("transform scoped-jsx", () => {
7171
`),
7272
).toMatchInlineSnapshot(`
7373
"import * as React from 'react';
74-
import { type JSX } from "react";
74+
import type { JSX } from "react";
7575
declare const element: JSX.Element;"
7676
`);
7777
});
@@ -84,7 +84,7 @@ describe("transform scoped-jsx", () => {
8484
`),
8585
).toMatchInlineSnapshot(`
8686
"import type * as React from 'react';
87-
import { type JSX } from "react";
87+
import type { JSX } from "react";
8888
declare const element: JSX.Element;"
8989
`);
9090
});
@@ -136,7 +136,7 @@ describe("transform scoped-jsx", () => {
136136
declare const element: JSX.Element;
137137
`),
138138
).toMatchInlineSnapshot(`
139-
"import { type JSX } from "react";
139+
"import type { JSX } from "react";
140140
const React = require('react');
141141
declare const element: JSX.Element;"
142142
`);
@@ -154,7 +154,7 @@ describe("transform scoped-jsx", () => {
154154
"import {} from 'react-dom'
155155
import {} from '@testing-library/react'
156156
157-
import { type JSX } from "react";
157+
import type { JSX } from "react";
158158
159159
declare const element: JSX.Element;"
160160
`);
@@ -170,7 +170,7 @@ describe("transform scoped-jsx", () => {
170170
).toMatchInlineSnapshot(`
171171
"import * as React from 'react'
172172
173-
import { type JSX } from "react";
173+
import type { JSX } from "react";
174174
175175
declare const attributes: JSX.LibraryManagedAttributes<A, B>;"
176176
`);

transforms/scoped-jsx.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ const deprecatedReactChildTransform = (file, api) => {
3939
addReactTypeImport(j, reactImport);
4040
} else {
4141
const importSpecifier = j.importSpecifier(j.identifier("JSX"));
42-
// @ts-expect-error -- Missing types in jscodeshift. Babel uses `importKind`: https://astexplorer.net/#/gist/a76bd35f28483a467fef29d3c63aac9b/0e7ba6688fc09bd11b92197349b2384bb4c94574
43-
importSpecifier.importKind = "type";
4442
const jsxNamespaceImport = j.importDeclaration(
4543
[importSpecifier],
4644
j.stringLiteral("react"),
45+
// Not using inline type import because it violates https://typescript-eslint.io/rules/no-import-type-side-effects/
46+
"type",
4747
);
4848

4949
const lastImport = ast.find(j.ImportDeclaration).at(-1);

0 commit comments

Comments
 (0)