Skip to content

Commit

Permalink
fix: consistent-type-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
dcharbonnier committed Dec 31, 2024
1 parent add3814 commit 415a123
Show file tree
Hide file tree
Showing 112 changed files with 341 additions and 320 deletions.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default tseslint.config(
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-parameter-properties": "off",
Expand Down
6 changes: 3 additions & 3 deletions factory/formatter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ChainTypeFormatter } from "../src/ChainTypeFormatter.js";
import { CircularReferenceTypeFormatter } from "../src/CircularReferenceTypeFormatter.js";
import { CompletedConfig } from "../src/Config.js";
import { MutableTypeFormatter } from "../src/MutableTypeFormatter.js";
import { TypeFormatter } from "../src/TypeFormatter.js";
import type { CompletedConfig } from "../src/Config.js";
import type { MutableTypeFormatter } from "../src/MutableTypeFormatter.js";
import type { TypeFormatter } from "../src/TypeFormatter.js";
import { AliasTypeFormatter } from "../src/TypeFormatter/AliasTypeFormatter.js";
import { AnnotatedTypeFormatter } from "../src/TypeFormatter/AnnotatedTypeFormatter.js";
import { AnyTypeFormatter } from "../src/TypeFormatter/AnyTypeFormatter.js";
Expand Down
3 changes: 2 additions & 1 deletion factory/generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Config, DEFAULT_CONFIG } from "../src/Config.js";
import type { Config } from "../src/Config.js";
import { DEFAULT_CONFIG } from "../src/Config.js";
import { SchemaGenerator } from "../src/SchemaGenerator.js";
import { createFormatter } from "./formatter.js";
import { createParser } from "./parser.js";
Expand Down
4 changes: 2 additions & 2 deletions src/AnnotationsReader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ts from "typescript";
import { Annotations } from "./Type/AnnotatedType.js";
import type ts from "typescript";
import type { Annotations } from "./Type/AnnotatedType.js";

export interface AnnotationsReader {
getAnnotations(node: ts.Node): Annotations | undefined;
Expand Down
6 changes: 3 additions & 3 deletions src/AnnotationsReader/BasicAnnotationsReader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json5 from "json5";
import ts from "typescript";
import { AnnotationsReader } from "../AnnotationsReader.js";
import { Annotations } from "../Type/AnnotatedType.js";
import type ts from "typescript";
import type { AnnotationsReader } from "../AnnotationsReader.js";
import type { Annotations } from "../Type/AnnotatedType.js";
import { symbolAtNode } from "../Utils/symbolAtNode.js";

export class BasicAnnotationsReader implements AnnotationsReader {
Expand Down
4 changes: 2 additions & 2 deletions src/AnnotationsReader/ExtendedAnnotationsReader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json5 from "json5";
import ts from "typescript";
import { Annotations } from "../Type/AnnotatedType.js";
import type ts from "typescript";
import type { Annotations } from "../Type/AnnotatedType.js";
import { symbolAtNode } from "../Utils/symbolAtNode.js";
import { BasicAnnotationsReader } from "./BasicAnnotationsReader.js";

Expand Down
8 changes: 4 additions & 4 deletions src/CircularReferenceNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import { Context } from "./NodeParser.js";
import { SubNodeParser } from "./SubNodeParser.js";
import { BaseType } from "./Type/BaseType.js";
import type ts from "typescript";
import type { Context } from "./NodeParser.js";
import type { SubNodeParser } from "./SubNodeParser.js";
import type { BaseType } from "./Type/BaseType.js";
import { ReferenceType } from "./Type/ReferenceType.js";
import { getKey } from "./Utils/nodeKey.js";

Expand Down
6 changes: 3 additions & 3 deletions src/CircularReferenceTypeFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Definition } from "./Schema/Definition.js";
import { SubTypeFormatter } from "./SubTypeFormatter.js";
import { BaseType } from "./Type/BaseType.js";
import type { Definition } from "./Schema/Definition.js";
import type { SubTypeFormatter } from "./SubTypeFormatter.js";
import type { BaseType } from "./Type/BaseType.js";
import { uniqueArray } from "./Utils/uniqueArray.js";

export class CircularReferenceTypeFormatter implements SubTypeFormatter {
Expand Down
8 changes: 4 additions & 4 deletions src/ExposeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ts from "typescript";
import { Context } from "./NodeParser.js";
import { SubNodeParser } from "./SubNodeParser.js";
import { BaseType } from "./Type/BaseType.js";
import type { Context } from "./NodeParser.js";
import type { SubNodeParser } from "./SubNodeParser.js";
import type { BaseType } from "./Type/BaseType.js";
import { DefinitionType } from "./Type/DefinitionType.js";
import { ReferenceType } from "./Type/ReferenceType.js";
import type { ReferenceType } from "./Type/ReferenceType.js";
import { hasJsDocTag } from "./Utils/hasJsDocTag.js";
import { symbolAtNode } from "./Utils/symbolAtNode.js";

Expand Down
4 changes: 2 additions & 2 deletions src/Interfaces/AnnotationsReader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ts from "typescript";
import { Annotations } from "../Type/AnnotatedType.js";
import type ts from "typescript";
import type { Annotations } from "../Type/AnnotatedType.js";

export interface AnnotationsReader {
getAnnotations(node: ts.Node): Annotations | undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/MutableParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SubNodeParser } from "./SubNodeParser.js";
import type { SubNodeParser } from "./SubNodeParser.js";

export interface MutableParser {
addNodeParser(parser: SubNodeParser): MutableParser;
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/MutableTypeFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SubTypeFormatter } from "./SubTypeFormatter.js";
import type { SubTypeFormatter } from "./SubTypeFormatter.js";

export interface MutableTypeFormatter {
addTypeFormatter(formatter: SubTypeFormatter): MutableTypeFormatter;
Expand Down
4 changes: 2 additions & 2 deletions src/Interfaces/SubNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ts from "typescript";
import { NodeParser } from "../NodeParser.js";
import type ts from "typescript";
import type { NodeParser } from "../NodeParser.js";

export interface SubNodeParser extends NodeParser {
supportsNode(node: ts.Node): boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/Interfaces/SubTypeFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseType } from "../Type/BaseType.js";
import { TypeFormatter } from "./TypeFormatter.js";
import type { BaseType } from "../Type/BaseType.js";
import type { TypeFormatter } from "./TypeFormatter.js";

export interface SubTypeFormatter extends TypeFormatter {
supportsType(type: BaseType): boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/Interfaces/TypeFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Definition } from "../Schema/Definition.js";
import { BaseType } from "../Type/BaseType.js";
import type { Definition } from "../Schema/Definition.js";
import type { BaseType } from "../Type/BaseType.js";

export interface TypeFormatter {
getDefinition(type: BaseType): Definition;
Expand Down
2 changes: 1 addition & 1 deletion src/MutableParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SubNodeParser } from "./SubNodeParser.js";
import type { SubNodeParser } from "./SubNodeParser.js";

export interface MutableParser {
addNodeParser(parser: SubNodeParser): MutableParser;
Expand Down
2 changes: 1 addition & 1 deletion src/MutableTypeFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SubTypeFormatter } from "./SubTypeFormatter.js";
import type { SubTypeFormatter } from "./SubTypeFormatter.js";

export interface MutableTypeFormatter {
addTypeFormatter(formatter: SubTypeFormatter): MutableTypeFormatter;
Expand Down
6 changes: 3 additions & 3 deletions src/NodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import stringify from "safe-stable-stringify";
import ts from "typescript";
import { BaseType } from "./Type/BaseType.js";
import { ReferenceType } from "./Type/ReferenceType.js";
import type ts from "typescript";
import type { BaseType } from "./Type/BaseType.js";
import type { ReferenceType } from "./Type/ReferenceType.js";
import { getKey } from "./Utils/nodeKey.js";

export class Context {
Expand Down
10 changes: 5 additions & 5 deletions src/NodeParser/AnnotatedNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import ts from "typescript";
import { AnnotationsReader } from "../AnnotationsReader.js";
import type { AnnotationsReader } from "../AnnotationsReader.js";
import { ExtendedAnnotationsReader } from "../AnnotationsReader/ExtendedAnnotationsReader.js";
import { Context } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import type { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import { AnnotatedType } from "../Type/AnnotatedType.js";
import { BaseType } from "../Type/BaseType.js";
import { ReferenceType } from "../Type/ReferenceType.js";
import type { BaseType } from "../Type/BaseType.js";
import type { ReferenceType } from "../Type/ReferenceType.js";
import { removeUndefined } from "../Utils/removeUndefined.js";
import { DefinitionType } from "../Type/DefinitionType.js";
import { UnionType } from "../Type/UnionType.js";
Expand Down
6 changes: 3 additions & 3 deletions src/NodeParser/AnyTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ts from "typescript";
import { Context } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import type { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import { AnyType } from "../Type/AnyType.js";
import { BaseType } from "../Type/BaseType.js";
import type { BaseType } from "../Type/BaseType.js";

export class AnyTypeNodeParser implements SubNodeParser {
public supportsNode(node: ts.KeywordTypeNode): boolean {
Expand Down
6 changes: 3 additions & 3 deletions src/NodeParser/ArrayLiteralExpressionNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type { Context, NodeParser } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";
import { TupleType } from "../Type/TupleType.js";

export class ArrayLiteralExpressionNodeParser implements SubNodeParser {
Expand Down
8 changes: 4 additions & 4 deletions src/NodeParser/AsExpressionNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NodeParser } from "../NodeParser.js";
import type { NodeParser } from "../NodeParser.js";
import ts from "typescript";
import { Context } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";

export class AsExpressionNodeParser implements SubNodeParser {
public constructor(protected childNodeParser: NodeParser) {}
Expand Down
6 changes: 3 additions & 3 deletions src/NodeParser/BooleanLiteralNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import { Context } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";
import { LiteralType } from "../Type/LiteralType.js";

export class BooleanLiteralNodeParser implements SubNodeParser {
Expand Down
6 changes: 3 additions & 3 deletions src/NodeParser/BooleanTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import { Context } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";
import { BooleanType } from "../Type/BooleanType.js";

export class BooleanTypeNodeParser implements SubNodeParser {
Expand Down
7 changes: 4 additions & 3 deletions src/NodeParser/CallExpressionParser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { TupleType } from "../Type/TupleType.js";
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type { NodeParser } from "../NodeParser.js";
import { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";
import { UnionType } from "../Type/UnionType.js";
import { LiteralType } from "../Type/LiteralType.js";
import { SymbolType } from "../Type/SymbolType.js";
Expand Down
7 changes: 4 additions & 3 deletions src/NodeParser/ConditionalTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type { NodeParser } from "../NodeParser.js";
import { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";
import { isAssignableTo } from "../Utils/isAssignableTo.js";
import { narrowType } from "../Utils/narrowType.js";
import { UnionType } from "../Type/UnionType.js";
Expand Down
8 changes: 4 additions & 4 deletions src/NodeParser/ConstructorNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ts from "typescript";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";
import { ConstructorType } from "../Type/ConstructorType.js";
import { FunctionOptions } from "../Config.js";
import type { FunctionOptions } from "../Config.js";
import { NeverType } from "../Type/NeverType.js";
import { Context, NodeParser } from "../NodeParser.js";
import type { Context, NodeParser } from "../NodeParser.js";
import { DefinitionType } from "../Type/DefinitionType.js";
import { getNamedArguments, getTypeName } from "./FunctionNodeParser.js";

Expand Down
9 changes: 5 additions & 4 deletions src/NodeParser/EnumNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import ts from "typescript";
import { Context } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import { EnumType, EnumValue } from "../Type/EnumType.js";
import type { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";
import type { EnumValue } from "../Type/EnumType.js";
import { EnumType } from "../Type/EnumType.js";
import { isNodeHidden } from "../Utils/isHidden.js";
import { getKey } from "../Utils/nodeKey.js";

Expand Down
7 changes: 4 additions & 3 deletions src/NodeParser/ExpressionWithTypeArgumentsNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type { NodeParser } from "../NodeParser.js";
import { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";

export class ExpressionWithTypeArgumentsNodeParser implements SubNodeParser {
public constructor(
Expand Down
8 changes: 4 additions & 4 deletions src/NodeParser/HiddenTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import { Context } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type ts from "typescript";
import type { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";
import { HiddenType } from "../Type/HiddenType.js";
import { isNodeHidden } from "../Utils/isHidden.js";

Expand Down
6 changes: 3 additions & 3 deletions src/NodeParser/InferTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type { Context, NodeParser } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";
import { InferType } from "../Type/InferType.js";

export class InferTypeNodeParser implements SubNodeParser {
Expand Down
11 changes: 6 additions & 5 deletions src/NodeParser/InterfaceAndClassNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import ts, { PropertyName } from "typescript";
import { Context, NodeParser } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import type { PropertyName } from "typescript";
import ts from "typescript";
import type { Context, NodeParser } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import { ArrayType } from "../Type/ArrayType.js";
import { BaseType } from "../Type/BaseType.js";
import type { BaseType } from "../Type/BaseType.js";
import { NeverType } from "../Type/NeverType.js";
import { ObjectProperty, ObjectType } from "../Type/ObjectType.js";
import { ReferenceType } from "../Type/ReferenceType.js";
import type { ReferenceType } from "../Type/ReferenceType.js";
import { isNodeHidden } from "../Utils/isHidden.js";
import { isPublic, isStatic } from "../Utils/modifiers.js";
import { getKey } from "../Utils/nodeKey.js";
Expand Down
6 changes: 3 additions & 3 deletions src/NodeParser/LiteralNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type { Context, NodeParser } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";

export class LiteralNodeParser implements SubNodeParser {
public constructor(protected childNodeParser: NodeParser) {}
Expand Down
10 changes: 6 additions & 4 deletions src/NodeParser/MappedTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import ts from "typescript";
import { ExpectationFailedError } from "../Error/Errors.js";
import { Context, NodeParser } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import type { NodeParser } from "../NodeParser.js";
import { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import { AnnotatedType } from "../Type/AnnotatedType.js";
import { ArrayType } from "../Type/ArrayType.js";
import { BaseType } from "../Type/BaseType.js";
import type { BaseType } from "../Type/BaseType.js";
import { DefinitionType } from "../Type/DefinitionType.js";
import { EnumType, EnumValue } from "../Type/EnumType.js";
import type { EnumValue } from "../Type/EnumType.js";
import { EnumType } from "../Type/EnumType.js";
import { LiteralType } from "../Type/LiteralType.js";
import { NeverType } from "../Type/NeverType.js";
import { NumberType } from "../Type/NumberType.js";
Expand Down
8 changes: 4 additions & 4 deletions src/NodeParser/NamedTupleMemberNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ts from "typescript";
import { Context, NodeParser } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import type { Context, NodeParser } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import { AnnotatedType } from "../Type/AnnotatedType.js";
import { ArrayType } from "../Type/ArrayType.js";
import { BaseType } from "../Type/BaseType.js";
import { ReferenceType } from "../Type/ReferenceType.js";
import type { BaseType } from "../Type/BaseType.js";
import type { ReferenceType } from "../Type/ReferenceType.js";
import { RestType } from "../Type/RestType.js";

export class NamedTupleMemberNodeParser implements SubNodeParser {
Expand Down
6 changes: 3 additions & 3 deletions src/NodeParser/NeverTypeNodeParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import { Context } from "../NodeParser.js";
import { SubNodeParser } from "../SubNodeParser.js";
import { BaseType } from "../Type/BaseType.js";
import type { Context } from "../NodeParser.js";
import type { SubNodeParser } from "../SubNodeParser.js";
import type { BaseType } from "../Type/BaseType.js";
import { NeverType } from "../Type/NeverType.js";

export class NeverTypeNodeParser implements SubNodeParser {
Expand Down
Loading

0 comments on commit 415a123

Please sign in to comment.