diff --git a/transforms/__tests__/scoped-jsx.js b/transforms/__tests__/scoped-jsx.js index 6ebbb62c..c0d1837f 100644 --- a/transforms/__tests__/scoped-jsx.js +++ b/transforms/__tests__/scoped-jsx.js @@ -33,7 +33,7 @@ describe("transform scoped-jsx", () => { declare const element: JSX.Element; `), ).toMatchInlineSnapshot(` - "import { type JSX } from "react"; + "import type { JSX } from "react"; declare const element: JSX.Element;" `); }); @@ -58,7 +58,7 @@ describe("transform scoped-jsx", () => { `), ).toMatchInlineSnapshot(` "import type React from 'react'; - import { type JSX } from "react"; + import type { JSX } from "react"; declare const element: JSX.Element;" `); }); @@ -71,7 +71,7 @@ describe("transform scoped-jsx", () => { `), ).toMatchInlineSnapshot(` "import * as React from 'react'; - import { type JSX } from "react"; + import type { JSX } from "react"; declare const element: JSX.Element;" `); }); @@ -84,7 +84,7 @@ describe("transform scoped-jsx", () => { `), ).toMatchInlineSnapshot(` "import type * as React from 'react'; - import { type JSX } from "react"; + import type { JSX } from "react"; declare const element: JSX.Element;" `); }); @@ -136,7 +136,7 @@ describe("transform scoped-jsx", () => { declare const element: JSX.Element; `), ).toMatchInlineSnapshot(` - "import { type JSX } from "react"; + "import type { JSX } from "react"; const React = require('react'); declare const element: JSX.Element;" `); @@ -154,7 +154,7 @@ describe("transform scoped-jsx", () => { "import {} from 'react-dom' import {} from '@testing-library/react' - import { type JSX } from "react"; + import type { JSX } from "react"; declare const element: JSX.Element;" `); @@ -170,7 +170,7 @@ describe("transform scoped-jsx", () => { ).toMatchInlineSnapshot(` "import * as React from 'react' - import { type JSX } from "react"; + import type { JSX } from "react"; declare const attributes: JSX.LibraryManagedAttributes;" `); diff --git a/transforms/scoped-jsx.js b/transforms/scoped-jsx.js index 69036cd0..f61f917b 100644 --- a/transforms/scoped-jsx.js +++ b/transforms/scoped-jsx.js @@ -39,11 +39,11 @@ const deprecatedReactChildTransform = (file, api) => { addReactTypeImport(j, reactImport); } else { const importSpecifier = j.importSpecifier(j.identifier("JSX")); - // @ts-expect-error -- Missing types in jscodeshift. Babel uses `importKind`: https://astexplorer.net/#/gist/a76bd35f28483a467fef29d3c63aac9b/0e7ba6688fc09bd11b92197349b2384bb4c94574 - importSpecifier.importKind = "type"; const jsxNamespaceImport = j.importDeclaration( [importSpecifier], j.stringLiteral("react"), + // Not using inline type import because it violates https://typescript-eslint.io/rules/no-import-type-side-effects/ + "type", ); const lastImport = ast.find(j.ImportDeclaration).at(-1);