Skip to content
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

add type-import lint rule #1264

Merged
merged 3 commits into from
Mar 12, 2024
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
5 changes: 5 additions & 0 deletions .changeset/fast-oranges-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"apollo-client-devtools": patch
---

Enable "@typescript-eslint/consistent-type-imports" lint rule
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ module.exports = {
"testing-library/no-node-access": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": ["warn", { ignoreRestSiblings: true }],
"@typescript-eslint/consistent-type-imports": [
"error",
{
prefer: "type-imports",
disallowTypeAnnotations: false,
fixStyle: "separate-type-imports",
},
],
},
settings: {
react: {
Expand Down
2 changes: 1 addition & 1 deletion src/@types/svg.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module "*.svg" {
import * as React from "react";
import type * as React from "react";

export const ReactComponent: React.FunctionComponent<
React.SVGProps<SVGSVGElement> & { title?: string }
Expand Down
21 changes: 10 additions & 11 deletions src/application/App.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
import { useEffect, useState, useRef } from "react";
import {
useReactiveVar,
gql,
useQuery,
makeVar,
TypedDocumentNode,
} from "@apollo/client";
import type { TypedDocumentNode } from "@apollo/client";
import { useReactiveVar, gql, useQuery, makeVar } from "@apollo/client";

import { currentScreen, Screens } from "./components/Layouts/Navigation";
import { Queries } from "./components/Queries/Queries";
import { Mutations } from "./components/Mutations/Mutations";
import { Explorer } from "./components/Explorer/Explorer";
import { Cache } from "./components/Cache/Cache";
import { GetOperationCounts, GetOperationCountsVariables } from "./types/gql";
import type {
GetOperationCounts,
GetOperationCountsVariables,
} from "./types/gql";
import { Tabs } from "./components/Tabs";
import { Button } from "./components/Button";
import IconSettings from "@apollo/icons/default/IconSettings.svg";
import IconSync from "@apollo/icons/small/IconSync.svg";
import { SettingsModal } from "./components/Layouts/SettingsModal";
import Logo from "@apollo/icons/logos/LogoSymbol.svg";
import { BannerAlert, BannerAlertConfig } from "./components/BannerAlert";
import { GetStates } from "./stateMachine";
import { DevtoolsMachine } from "./machines";
import type { BannerAlertConfig } from "./components/BannerAlert";
import { BannerAlert } from "./components/BannerAlert";
import type { GetStates } from "./stateMachine";
import type { DevtoolsMachine } from "./machines";
import { ClientNotFoundModal } from "./components/ClientNotFoundModal";
import { getPanelActor } from "../extension/devtools/panelActor";

Expand Down
2 changes: 1 addition & 1 deletion src/application/__tests__/AppProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { gql } from "@apollo/client";
import matchMediaMock from "../utilities/testing/matchMedia";
import { Mode, colorTheme } from "../theme";
import { AppProvider, getQueryData, getMutationData } from "../index";
import { QueryInfo } from "../../extension/tab/helpers";
import type { QueryInfo } from "../../extension/tab/helpers";
import { print, getIntrospectionQuery } from "graphql";

const matchMedia = matchMediaMock();
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/BannerAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import clsx from "clsx";
import { makeVar, useReactiveVar } from "@apollo/client";
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { LoadingSpinner } from "./Explorer/LoadingSpinner";
import IconCheck from "@apollo/icons/default/IconCheck.svg";
import IconError from "@apollo/icons/default/IconError.svg";
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentPropsWithoutRef, ElementType } from "react";
import type { ComponentPropsWithoutRef, ElementType } from "react";
import { clsx } from "clsx";

type NativeButtonProps = ComponentPropsWithoutRef<"button">;
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/ButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";

interface ButtonGroupProps {
children: ReactNode;
Expand Down
10 changes: 6 additions & 4 deletions src/application/components/Cache/Cache.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Fragment, useState, useMemo, ReactNode } from "react";
import { gql, useQuery, TypedDocumentNode } from "@apollo/client";
import type { ReactNode } from "react";
import { Fragment, useState, useMemo } from "react";
import type { TypedDocumentNode } from "@apollo/client";
import { gql, useQuery } from "@apollo/client";

import { SidebarLayout } from "../Layouts/SidebarLayout";
import { SearchField } from "../SearchField";
import { EntityList } from "./sidebar/EntityList";
import { Loading } from "./common/Loading";
import { GetCache, GetCacheVariables } from "../../types/gql";
import { JSONObject } from "../../types/json";
import type { GetCache, GetCacheVariables } from "../../types/gql";
import type { JSONObject } from "../../types/json";
import { JSONTreeViewer } from "../JSONTreeViewer";
import clsx from "clsx";
import { CopyButton } from "../CopyButton";
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Cache/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JSONObject } from "../../../types/json";
import type { JSONObject } from "../../../types/json";

// Return an alphabetically sorted list of all root cache ID's. ROOT_QUERY,
// ROOT_MUTATION, and ROOT_SUBSCRIPTION will be listed first (if they exist).
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Cache/sidebar/EntityList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { List } from "../../List";
import { ListItem } from "../../ListItem";

import { getRootCacheIds } from "../common/utils";
import { JSONObject } from "../../../types/json";
import type { JSONObject } from "../../../types/json";
import HighlightMatch from "../../HighlightMatch";

interface EntityListProps {
Expand Down
3 changes: 2 additions & 1 deletion src/application/components/CodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Highlight, Language, PrismTheme } from "prism-react-renderer";
import type { Language, PrismTheme } from "prism-react-renderer";
import { Highlight } from "prism-react-renderer";
import { useReactiveVar } from "@apollo/client";
import { colors } from "@apollo/brand";
import { clsx } from "clsx";
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentPropsWithoutRef } from "react";
import type { ComponentPropsWithoutRef } from "react";
import clsx from "clsx";
import CopyToClipboard from "react-copy-to-clipboard";
import { Button } from "./Button";
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Disclosure/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { Disclosure } from "@headlessui/react";
import IconChevronUp from "@apollo/icons/default/IconChevronUp.svg";
import clsx from "clsx";
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Disclosure/Disclosure.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { Disclosure as DisclosureRoot } from "@headlessui/react";
import { DisclosureButton } from "./Button";
import { DisclosurePanel } from "./Panel";
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Disclosure/Panel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { Disclosure, Transition } from "@headlessui/react";

interface DisclosurePanelProps {
Expand Down
5 changes: 2 additions & 3 deletions src/application/components/Explorer/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import type { IntrospectionQuery } from "graphql";
import { getIntrospectionQuery } from "graphql/utilities";
import { colorTheme } from "../../theme";
import { FullWidthLayout } from "../Layouts/FullWidthLayout";
import { QueryResult } from "../../../types";
import type { QueryResult } from "../../../types";
import type { JSONValue, IncomingMessageEvent } from "./postMessageHelpers";
import {
postMessageToEmbed,
EMBEDDABLE_EXPLORER_URL,
Expand All @@ -14,10 +15,8 @@ import {
EXPLORER_SUBSCRIPTION_REQUEST,
EXPLORER_SUBSCRIPTION_RESPONSE,
EXPLORER_SUBSCRIPTION_TERMINATION,
JSONValue,
SCHEMA_ERROR,
SCHEMA_RESPONSE,
IncomingMessageEvent,
} from "./postMessageHelpers";
import {
EXPLORER_LISTENING_FOR_HANDSHAKE,
Expand Down
3 changes: 2 additions & 1 deletion src/application/components/Explorer/GraphRefModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from "react";
import type React from "react";
import { useState } from "react";
import { clsx } from "clsx";
import { LoadingSpinner } from "./LoadingSpinner";
import { hasGraphRefBeenAuthenticated } from "./postMessageAuthHelpers";
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Explorer/Telescope.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import type React from "react";

interface TelescopeProps {
className?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IncomingMessageEvent, postMessageToEmbed } from "./postMessageHelpers";
import type { IncomingMessageEvent } from "./postMessageHelpers";
import { postMessageToEmbed } from "./postMessageHelpers";

export const SET_PARTIAL_AUTHENTICATION_TOKEN_FOR_PARENT =
"SetPartialAuthenticationTokenForParent";
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/GitHubIssueLink.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";

declare const VERSION: string;

Expand Down
2 changes: 1 addition & 1 deletion src/application/components/JSONTreeViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSSProperties, ComponentPropsWithoutRef } from "react";
import type { CSSProperties, ComponentPropsWithoutRef } from "react";
import { useReactiveVar } from "@apollo/client";
import { JSONTree } from "react-json-tree";
import { ColorTheme, colorTheme } from "../theme";
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Layouts/FullWidthLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { clsx } from "clsx";

interface FullWidthLayoutProps {
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Layouts/SidebarLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from "clsx";
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { PanelGroup, Panel, PanelResizeHandle } from "react-resizable-panels";

interface SidebarLayoutProps {
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/List.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentPropsWithoutRef } from "react";
import type { ComponentPropsWithoutRef } from "react";
import clsx from "clsx";

type ListProps = ComponentPropsWithoutRef<"div">;
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode, ComponentPropsWithoutRef } from "react";
import type { ReactNode, ComponentPropsWithoutRef } from "react";
import { clsx } from "clsx";

interface ListItemProps {
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Modal/Body.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { clsx } from "clsx";

interface BodyProps {
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Modal/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { clsx } from "clsx";

interface FooterProps {
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Modal/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { clsx } from "clsx";

interface HeaderProps {
Expand Down
3 changes: 2 additions & 1 deletion src/application/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Dialog, Transition } from "@headlessui/react";
import { Fragment, ReactNode } from "react";
import type { ReactNode } from "react";
import { Fragment } from "react";
import { clsx } from "clsx";

import { Body } from "./Body";
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Modal/Title.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { Dialog } from "@headlessui/react";
import { clsx } from "clsx";

Expand Down
5 changes: 3 additions & 2 deletions src/application/components/Mutations/Mutations.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Fragment, useState } from "react";
import { gql, TypedDocumentNode, useQuery } from "@apollo/client";
import type { TypedDocumentNode } from "@apollo/client";
import { gql, useQuery } from "@apollo/client";
import { List } from "../List";
import { ListItem } from "../ListItem";

import { SidebarLayout } from "../Layouts/SidebarLayout";
import { RunInExplorerButton } from "../Queries/RunInExplorerButton";
import { GetMutations, GetMutationsVariables } from "../../types/gql";
import type { GetMutations, GetMutationsVariables } from "../../types/gql";
import { JSONTreeViewer } from "../JSONTreeViewer";
import { Tabs } from "../Tabs";
import { QueryLayout } from "../QueryLayout";
Expand Down
8 changes: 6 additions & 2 deletions src/application/components/Queries/Queries.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { useState } from "react";
import { gql, useQuery, TypedDocumentNode } from "@apollo/client";
import type { TypedDocumentNode } from "@apollo/client";
import { gql, useQuery } from "@apollo/client";
import { List } from "../List";
import { ListItem } from "../ListItem";

import { SidebarLayout } from "../Layouts/SidebarLayout";
import { RunInExplorerButton } from "./RunInExplorerButton";
import { GetWatchedQueries, GetWatchedQueriesVariables } from "../../types/gql";
import type {
GetWatchedQueries,
GetWatchedQueriesVariables,
} from "../../types/gql";
import { Tabs } from "../Tabs";
import { JSONTreeViewer } from "../JSONTreeViewer";
import { QueryLayout } from "../QueryLayout";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Variables } from "../../types/scalars";
import type { Variables } from "../../types/scalars";
import {
postMessageToEmbed,
SET_OPERATION,
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/QueryLayout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";

interface HeaderProps {
children: ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/QueryLayout/QueryLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { clsx } from "clsx";

import { SidebarLayout } from "../Layouts/SidebarLayout";
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/QueryLayout/TabContent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { Tabs } from "../Tabs";

interface TabContentProps {
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/QueryLayout/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { Tabs as TabsBase } from "../Tabs";

interface TabsProps<TValue extends string> {
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/QueryLayout/Title.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";

interface TitleProps {
children: ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Tabs/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { Content as ContentBase } from "@radix-ui/react-tabs";
import clsx from "clsx";

Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Tabs/List.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { List as ListBase } from "@radix-ui/react-tabs";
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { clsx } from "clsx";

interface ListProps {
Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { Root } from "@radix-ui/react-tabs";
import clsx from "clsx";

Expand Down
2 changes: 1 addition & 1 deletion src/application/components/Tabs/Trigger.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";
import { Trigger as TriggerBase } from "@radix-ui/react-tabs";

interface TriggerProps {
Expand Down
4 changes: 2 additions & 2 deletions src/application/components/TextField.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentPropsWithoutRef } from "react";
import type { ComponentPropsWithoutRef } from "react";
import { clsx } from "clsx";

import { ExtendProps } from "../types/props";
import type { ExtendProps } from "../types/props";

type TextFieldProps = ExtendProps<
ComponentPropsWithoutRef<"input">,
Expand Down
Loading
Loading