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

chore: consistent type imports eslint rule #325

Merged
merged 1 commit into from
Oct 24, 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
7 changes: 7 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
"ignoreRestSiblings": true
}
],
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports",
"fixStyle": "separate-type-imports"
}
],
"@typescript-eslint/naming-convention": [
"error",
{
Expand Down
2 changes: 1 addition & 1 deletion packages/2d/src/editor/NodeInspectorConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {useComputed} from '@preact/signals';
import type {PluginInspectorConfig} from '@revideo/ui';
import {
AutoField,
Button,
Group,
Label,
Pane,
PluginInspectorConfig,
Separator,
UnknownField,
findAndOpenFirstUserFile,
Expand Down
4 changes: 2 additions & 2 deletions packages/2d/src/editor/PreviewOverlayConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {Vector2} from '@revideo/core';
import type {PluginOverlayConfig} from '@revideo/ui';
import {
MouseButton,
OverlayWrapper,
PluginOverlayConfig,
useViewportContext,
useViewportMatrix,
} from '@revideo/ui';
import {ComponentChildren} from 'preact';
import type {ComponentChildren} from 'preact';
import {usePluginState} from './Provider';

function Component({children}: {children?: ComponentChildren}) {
Expand Down
14 changes: 5 additions & 9 deletions packages/2d/src/editor/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import {
ReadonlySignal,
Signal,
computed,
signal,
useSignalEffect,
} from '@preact/signals';
import {Scene2D} from '@revideo/2d';
import type {ReadonlySignal, Signal} from '@preact/signals';
import {computed, signal, useSignalEffect} from '@preact/signals';
import type {Scene2D} from '@revideo/2d';
import {SceneRenderEvent} from '@revideo/core';
import {useApplication, useCurrentScene} from '@revideo/ui';
import {ComponentChildren, createContext} from 'preact';
import type {ComponentChildren} from 'preact';
import {createContext} from 'preact';
import {useContext, useMemo} from 'preact/hooks';

export interface PluginState {
Expand Down
3 changes: 1 addition & 2 deletions packages/2d/src/editor/SceneGraphTabConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type {PluginTabConfig, PluginTabProps} from '@revideo/ui';
import {
AccountTree,
emphasize,
Pane,
PluginTabConfig,
PluginTabProps,
Tab,
useApplication,
usePanels,
Expand Down
2 changes: 1 addition & 1 deletion packages/2d/src/editor/icons/IconMap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */

import {FunctionComponent} from 'preact';
import type {FunctionComponent} from 'preact';
import {CircleIcon} from './CircleIcon';
import {CodeBlockIcon} from './CodeBlockIcon';
import {CurveIcon} from './CurveIcon';
Expand Down
3 changes: 2 additions & 1 deletion packages/2d/src/editor/tree/NodeElement.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useComputed, useSignal, useSignalEffect} from '@preact/signals';
import {NODE_NAME, Node} from '@revideo/2d';
import type {Node} from '@revideo/2d';
import {NODE_NAME} from '@revideo/2d';
import {useRef} from 'preact/hooks';
import {usePluginState} from '../Provider';
import {IconMap} from '../icons/IconMap';
Expand Down
6 changes: 3 additions & 3 deletions packages/2d/src/editor/tree/TreeElement.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Signal} from '@preact/signals';
import type {Signal} from '@preact/signals';
import {Collapse, Toggle} from '@revideo/ui';
import {clsx} from 'clsx';
import {ComponentChildren, JSX} from 'preact';
import {Ref} from 'preact/hooks';
import type {ComponentChildren, JSX} from 'preact';
import type {Ref} from 'preact/hooks';
import styles from './index.module.scss';

const DEPTH_VAR = '--depth';
Expand Down
2 changes: 1 addition & 1 deletion packages/2d/src/editor/tree/TreeRoot.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {clsx} from 'clsx';
import {JSX} from 'preact';
import type {JSX} from 'preact';
import styles from './index.module.scss';

export function TreeRoot({
Expand Down
24 changes: 10 additions & 14 deletions packages/2d/src/lib/code/CodeCursor.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import {
clampRemap,
Color,
map,
SerializedVector2,
unwrap,
Vector2,
} from '@revideo/core';
import {Code} from '../components';
import {CodeFragment, parseCodeFragment} from './CodeFragment';
import {CodeHighlighter} from './CodeHighlighter';
import {CodeMetrics} from './CodeMetrics';
import {CodePoint, CodeRange} from './CodeRange';
import {CodeScope, isCodeScope} from './CodeScope';
import type {SerializedVector2} from '@revideo/core';
import {clampRemap, Color, map, unwrap, Vector2} from '@revideo/core';
import type {Code} from '../components';
import type {CodeFragment} from './CodeFragment';
import {parseCodeFragment} from './CodeFragment';
import type {CodeHighlighter} from './CodeHighlighter';
import type {CodeMetrics} from './CodeMetrics';
import type {CodePoint, CodeRange} from './CodeRange';
import type {CodeScope} from './CodeScope';
import {isCodeScope} from './CodeScope';
import {isPointInCodeSelection} from './CodeSelection';

export interface CodeFragmentDrawingInfo {
Expand Down
5 changes: 3 additions & 2 deletions packages/2d/src/lib/code/CodeDiffer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {CodeScope, CodeTag, resolveScope} from './CodeScope';
import {CodeTokenizer} from './CodeTokenizer';
import type {CodeScope, CodeTag} from './CodeScope';
import {resolveScope} from './CodeScope';
import type {CodeTokenizer} from './CodeTokenizer';
import {patienceDiff} from './diff';

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/2d/src/lib/code/CodeFragment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {CodeMetrics, isCodeMetrics, measureString} from './CodeMetrics';
import type {CodeMetrics} from './CodeMetrics';
import {isCodeMetrics, measureString} from './CodeMetrics';

export interface CodeFragment {
before: CodeMetrics;
Expand Down
5 changes: 3 additions & 2 deletions packages/2d/src/lib/code/CodeScope.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {SignalValue, unwrap} from '@revideo/core';
import {PossibleCodeFragment} from './CodeFragment';
import type {SignalValue} from '@revideo/core';
import {unwrap} from '@revideo/core';
import type {PossibleCodeFragment} from './CodeFragment';
import {isCodeMetrics} from './CodeMetrics';

export interface CodeScope {
Expand Down
8 changes: 2 additions & 6 deletions packages/2d/src/lib/code/CodeSelection.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
CodePoint,
CodeRange,
isCodeRange,
isPointInCodeRange,
} from './CodeRange';
import type {CodePoint, CodeRange} from './CodeRange';
import {isCodeRange, isPointInCodeRange} from './CodeRange';

export type CodeSelection = CodeRange[];
export type PossibleCodeSelection = CodeRange | CodeRange[];
Expand Down
28 changes: 10 additions & 18 deletions packages/2d/src/lib/code/CodeSignal.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
import type {
Signal,
SignalValue,
ThreadGenerator,
TimingFunction,
} from '@revideo/core';
import {
createSignal,
deepLerp,
DependencyContext,
Signal,
SignalContext,
SignalValue,
ThreadGenerator,
TimingFunction,
unwrap,
} from '@revideo/core';
import {Code} from '../components';
import {addInitializer, getPropertyMetaOrCreate} from '../decorators';
import {defaultDiffer} from './CodeDiffer';
import {insert, replace} from './CodeFragment';
import {CodeHighlighter} from './CodeHighlighter';
import {CodePoint, CodeRange} from './CodeRange';
import {
CODE,
CodeScope,
CodeTag,
parseCodeScope,
PossibleCodeScope,
resolveCodeTag,
} from './CodeScope';
import type {CodeHighlighter} from './CodeHighlighter';
import type {CodePoint, CodeRange} from './CodeRange';
import type {CodeScope, CodeTag, PossibleCodeScope} from './CodeScope';
import {CODE, parseCodeScope, resolveCodeTag} from './CodeScope';
import {defaultTokenize} from './CodeTokenizer';
import {extractRange} from './extractRange';

Expand Down Expand Up @@ -81,9 +76,6 @@ export class CodeSignalContext<TOwner>
private readonly highlighter?: SignalValue<CodeHighlighter | null>,
) {
super(initial, deepLerp, owner);
if (owner instanceof Code) {
this.highlighter ??= owner.highlighter;
}
Object.defineProperty(this.invokable, 'edit', {
value: this.edit.bind(this),
});
Expand Down
6 changes: 3 additions & 3 deletions packages/2d/src/lib/code/LezerHighlighter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {HighlightStyle} from '@codemirror/language';
import {Parser, SyntaxNode, Tree} from '@lezer/common';
import type {HighlightStyle} from '@codemirror/language';
import type {Parser, SyntaxNode, Tree} from '@lezer/common';
import {highlightTree} from '@lezer/highlight';
import {CodeHighlighter, HighlightResult} from './CodeHighlighter';
import type {CodeHighlighter, HighlightResult} from './CodeHighlighter';
import {DefaultHighlightStyle} from './DefaultHighlightStyle';

interface LezerCache {
Expand Down
5 changes: 3 additions & 2 deletions packages/2d/src/lib/code/extractRange.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {CodeRange} from './CodeRange';
import {CodeTag, resolveCodeTag} from './CodeScope';
import type {CodeRange} from './CodeRange';
import type {CodeTag} from './CodeScope';
import {resolveCodeTag} from './CodeScope';

/**
* Transform the fragments to isolate the given range into its own fragment.
Expand Down
3 changes: 2 additions & 1 deletion packages/2d/src/lib/components/Audio.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {DependencyContext, PlaybackState} from '@revideo/core';
import {computed, nodeName} from '../decorators';
import {Media, MediaProps} from './Media';
import type {MediaProps} from './Media';
import {Media} from './Media';

@nodeName('Audio')
export class Audio extends Media {
Expand Down
9 changes: 5 additions & 4 deletions packages/2d/src/lib/components/Bezier.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {BBox, SerializedVector2, Vector2} from '@revideo/core';
import {CurveProfile} from '../curves';
import {PolynomialSegment} from '../curves/PolynomialSegment';
import type {SerializedVector2, Vector2} from '@revideo/core';
import {BBox} from '@revideo/core';
import type {CurveProfile} from '../curves';
import type {PolynomialSegment} from '../curves/PolynomialSegment';
import {computed} from '../decorators';
import {DesiredLength} from '../partials';
import type {DesiredLength} from '../partials';
import {arc, drawLine, drawPivot, moveTo} from '../utils';
import {Curve} from './Curve';

Expand Down
17 changes: 7 additions & 10 deletions packages/2d/src/lib/components/Circle.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import {
BBox,
DEG2RAD,
SerializedVector2,
SignalValue,
SimpleSignal,
} from '@revideo/core';
import {CurveProfile, getCircleProfile} from '../curves';
import type {SerializedVector2, SignalValue, SimpleSignal} from '@revideo/core';
import {BBox, DEG2RAD} from '@revideo/core';
import type {CurveProfile} from '../curves';
import {getCircleProfile} from '../curves';
import {computed, initial, nodeName, signal} from '../decorators';
import {DesiredLength} from '../partials';
import {Curve, CurveProps} from './Curve';
import type {DesiredLength} from '../partials';
import type {CurveProps} from './Curve';
import {Curve} from './Curve';

export interface CircleProps extends CurveProps {
/**
Expand Down
29 changes: 17 additions & 12 deletions packages/2d/src/lib/components/Code.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
import {
BBox,
createSignal,
experimentalLog,
map,
import type {
SerializedVector2,
Signal,
SignalValue,
SimpleSignal,
ThreadGenerator,
TimingFunction,
Vector2,
} from '@revideo/core';
import {
BBox,
createSignal,
experimentalLog,
map,
unwrap,
useLogger,
useScene,
Vector2,
} from '@revideo/core';
import {
CodeCursor,
import type {
CodeFragmentDrawingInfo,
CodeHighlighter,
CodePoint,
CodeRange,
CodeSelection,
CodeSignal,
PossibleCodeScope,
PossibleCodeSelection,
} from '../code';
import {
CodeCursor,
codeSignal,
CodeSignalContext,
findAllCodeRanges,
isPointInCodeSelection,
lines,
parseCodeSelection,
PossibleCodeScope,
PossibleCodeSelection,
resolveScope,
} from '../code';
import {computed, initial, nodeName, parser, signal} from '../decorators';
import {DesiredLength} from '../partials';
import {Shape, ShapeProps} from './Shape';
import type {DesiredLength} from '../partials';
import type {ShapeProps} from './Shape';
import {Shape} from './Shape';

export interface DrawTokenHook {
(
Expand Down
21 changes: 8 additions & 13 deletions packages/2d/src/lib/components/CodeBlock.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {
import type {
SerializedVector2,
Signal,
SignalValue,
SimpleSignal,
ThreadGenerator,
TimingFunction,
} from '@revideo/core';
import {
Vector2,
clampRemap,
createComputedAsync,
Expand All @@ -17,19 +19,12 @@ import {
useLogger,
waitFor,
} from '@revideo/core';
import {
Code,
CodeStyle,
CodeTree,
MorphToken,
Token,
diff,
parse,
ready,
} from 'code-fns';
import type {Code, CodeStyle, CodeTree, MorphToken, Token} from 'code-fns';
import {diff, parse, ready} from 'code-fns';
import {computed, initial, nodeName, parser, signal} from '../decorators';
import {DesiredLength} from '../partials';
import {Shape, ShapeProps} from './Shape';
import type {DesiredLength} from '../partials';
import type {ShapeProps} from './Shape';
import {Shape} from './Shape';

type CodePoint = [number, number];
type CodeRange = [CodePoint, CodePoint];
Expand Down
9 changes: 5 additions & 4 deletions packages/2d/src/lib/components/CubicBezier.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {PossibleVector2, SignalValue, Vector2Signal} from '@revideo/core';
import type {PossibleVector2, SignalValue, Vector2Signal} from '@revideo/core';
import {CubicBezierSegment} from '../curves';
import {PolynomialSegment} from '../curves/PolynomialSegment';
import type {PolynomialSegment} from '../curves/PolynomialSegment';
import {computed, vector2Signal} from '../decorators';
import {bezierCurveTo, lineTo, moveTo} from '../utils';
import {Bezier, BezierOverlayInfo} from './Bezier';
import {CurveProps} from './Curve';
import type {BezierOverlayInfo} from './Bezier';
import {Bezier} from './Bezier';
import type {CurveProps} from './Curve';

export interface CubicBezierProps extends CurveProps {
p0?: SignalValue<PossibleVector2>;
Expand Down
Loading