build: enable consistent type imports eslint rule (#7992)

* build: enable consistent type imports eslint rule

* change to warn

* fix the warning in example and excalidraw-app

* fix packages

* enable type annotations and throw error for the rule
This commit is contained in:
Aakansha Doshi 2024-05-08 14:21:50 +05:30 committed by GitHub
parent c1926f33bb
commit 1ed53b153c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
240 changed files with 635 additions and 611 deletions

View file

@ -1,5 +1,5 @@
import { EDITOR_LS_KEYS } from "../constants";
import { JSONValue } from "../types";
import type { EDITOR_LS_KEYS } from "../constants";
import type { JSONValue } from "../types";
export class EditorLocalStorage {
static has(key: typeof EDITOR_LS_KEYS[keyof typeof EDITOR_LS_KEYS]) {

View file

@ -2,16 +2,17 @@ import { nanoid } from "nanoid";
import { cleanAppStateForExport } from "../appState";
import { IMAGE_MIME_TYPES, MIME_TYPES } from "../constants";
import { clearElementsForExport } from "../element";
import { ExcalidrawElement, FileId } from "../element/types";
import type { ExcalidrawElement, FileId } from "../element/types";
import { CanvasError, ImageSceneDataError } from "../errors";
import { calculateScrollCenter } from "../scene";
import { AppState, DataURL, LibraryItem } from "../types";
import { ValueOf } from "../utility-types";
import type { AppState, DataURL, LibraryItem } from "../types";
import type { ValueOf } from "../utility-types";
import { bytesToHexString, isPromiseLike } from "../utils";
import { FileSystemHandle, nativeFileSystemSupported } from "./filesystem";
import type { FileSystemHandle } from "./filesystem";
import { nativeFileSystemSupported } from "./filesystem";
import { isValidExcalidrawData, isValidLibrary } from "./json";
import { restore, restoreLibraryItems } from "./restore";
import { ImportedLibraryData } from "./types";
import type { ImportedLibraryData } from "./types";
const parseFileContents = async (blob: Blob | File) => {
let contents: string;

View file

@ -1,7 +1,7 @@
import type { FileSystemHandle } from "browser-fs-access";
import {
fileOpen as _fileOpen,
fileSave as _fileSave,
FileSystemHandle,
supported as nativeFileSystemSupported,
} from "browser-fs-access";
import { EVENT, MIME_TYPES } from "../constants";

View file

@ -10,7 +10,7 @@ import {
} from "../constants";
import { getNonDeletedElements } from "../element";
import { isFrameLikeElement } from "../element/typeChecks";
import {
import type {
ExcalidrawElement,
ExcalidrawFrameLikeElement,
NonDeletedExcalidrawElement,
@ -18,11 +18,12 @@ import {
import { t } from "../i18n";
import { isSomeElementSelected, getSelectedElements } from "../scene";
import { exportToCanvas, exportToSvg } from "../scene/export";
import { ExportType } from "../scene/types";
import { AppState, BinaryFiles } from "../types";
import type { ExportType } from "../scene/types";
import type { AppState, BinaryFiles } from "../types";
import { cloneJSON } from "../utils";
import { canvasToBlob } from "./blob";
import { fileSave, FileSystemHandle } from "./filesystem";
import type { FileSystemHandle } from "./filesystem";
import { fileSave } from "./filesystem";
import { serializeAsJSON } from "./json";
import { getElementsOverlappingFrame } from "../frame";

View file

@ -8,11 +8,11 @@ import {
VERSIONS,
} from "../constants";
import { clearElementsForDatabase, clearElementsForExport } from "../element";
import { ExcalidrawElement } from "../element/types";
import { AppState, BinaryFiles, LibraryItems } from "../types";
import type { ExcalidrawElement } from "../element/types";
import type { AppState, BinaryFiles, LibraryItems } from "../types";
import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob";
import {
import type {
ExportedDataState,
ImportedDataState,
ExportedLibraryData,

View file

@ -1,5 +1,5 @@
import { loadLibraryFromBlob } from "./blob";
import {
import type {
LibraryItems,
LibraryItem,
ExcalidrawImperativeAPI,
@ -10,7 +10,7 @@ import { restoreLibraryItems } from "./restore";
import type App from "../components/App";
import { atom } from "jotai";
import { jotaiStore } from "../jotai";
import { ExcalidrawElement } from "../element/types";
import type { ExcalidrawElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds";
import { AbortError } from "../errors";
import { t } from "../i18n";
@ -31,7 +31,7 @@ import {
promiseTry,
resolvablePromise,
} from "../utils";
import { MaybePromise } from "../utility-types";
import type { MaybePromise } from "../utility-types";
import { Emitter } from "../emitter";
import { Queue } from "../queue";
import { hashElementsVersion, hashString } from "../element";

View file

@ -1,7 +1,7 @@
import { THEME } from "../constants";
import { Theme } from "../element/types";
import { DataURL } from "../types";
import { OpenAIInput, OpenAIOutput } from "./ai/types";
import type { Theme } from "../element/types";
import type { DataURL } from "../types";
import type { OpenAIInput, OpenAIOutput } from "./ai/types";
export type MagicCacheData =
| {

View file

@ -1,7 +1,7 @@
import { OrderedExcalidrawElement } from "../element/types";
import type { OrderedExcalidrawElement } from "../element/types";
import { orderByFractionalIndex, syncInvalidIndices } from "../fractionalIndex";
import { AppState } from "../types";
import { MakeBrand } from "../utility-types";
import type { AppState } from "../types";
import type { MakeBrand } from "../utility-types";
import { arrayToMap } from "../utils";
export type ReconciledExcalidrawElement = OrderedExcalidrawElement &

View file

@ -1,5 +1,5 @@
import { ExcalidrawElement } from "../element/types";
import { AppState, BinaryFiles } from "../types";
import type { ExcalidrawElement } from "../element/types";
import type { AppState, BinaryFiles } from "../types";
import { exportCanvas, prepareElementsForExport } from ".";
import { getFileHandleType, isImageFileHandleType } from "./blob";

View file

@ -1,4 +1,4 @@
import {
import type {
ExcalidrawElement,
ExcalidrawElementType,
ExcalidrawSelectionElement,
@ -8,13 +8,13 @@ import {
PointBinding,
StrokeRoundness,
} from "../element/types";
import {
import type {
AppState,
BinaryFiles,
LibraryItem,
NormalizedZoomValue,
} from "../types";
import { ImportedDataState, LegacyAppState } from "./types";
import type { ImportedDataState, LegacyAppState } from "./types";
import {
getNonDeletedElements,
getNormalizedDimensions,
@ -37,7 +37,7 @@ import { LinearElementEditor } from "../element/linearElementEditor";
import { bumpVersion } from "../element/mutateElement";
import { getUpdatedTimestamp, updateActiveTool } from "../utils";
import { arrayToMap } from "../utils";
import { MarkOptional, Mutable } from "../utility-types";
import type { MarkOptional, Mutable } from "../utility-types";
import {
detectLineHeight,
getContainerElement,

View file

@ -1,9 +1,7 @@
import { vi } from "vitest";
import {
ExcalidrawElementSkeleton,
convertToExcalidrawElements,
} from "./transform";
import { ExcalidrawArrowElement } from "../element/types";
import type { ExcalidrawElementSkeleton } from "./transform";
import { convertToExcalidrawElements } from "./transform";
import type { ExcalidrawArrowElement } from "../element/types";
const opts = { regenerateIds: false };

View file

@ -11,8 +11,8 @@ import {
redrawTextBoundingBox,
} from "../element";
import { bindLinearElement } from "../element/binding";
import type { ElementConstructorOpts } from "../element/newElement";
import {
ElementConstructorOpts,
newFrameElement,
newImageElement,
newMagicFrameElement,
@ -23,7 +23,7 @@ import {
measureText,
normalizeText,
} from "../element/textElement";
import {
import type {
ElementsMap,
ExcalidrawArrowElement,
ExcalidrawBindableElement,
@ -43,7 +43,7 @@ import {
TextAlign,
VerticalAlign,
} from "../element/types";
import { MarkOptional } from "../utility-types";
import type { MarkOptional } from "../utility-types";
import {
arrayToMap,
assertNever,

View file

@ -1,12 +1,12 @@
import { ExcalidrawElement } from "../element/types";
import {
import type { ExcalidrawElement } from "../element/types";
import type {
AppState,
BinaryFiles,
LibraryItems,
LibraryItems_anyVersion,
} from "../types";
import type { cleanAppStateForExport } from "../appState";
import { VERSIONS } from "../constants";
import type { VERSIONS } from "../constants";
export interface ExportedDataState {
type: string;