Skip to content

Commit e857c62

Browse files
committed
style: prefer type import
1 parent 7982ab9 commit e857c62

File tree

15 files changed

+37
-41
lines changed

15 files changed

+37
-41
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ module.exports = {
2222
rules: {
2323
'@typescript-eslint/ban-ts-comment': 'warn',
2424
'@typescript-eslint/no-explicit-any': 'off',
25+
'@typescript-eslint/consistent-type-imports': 'error',
2526
},
2627
};

src/bin/cli.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import chalk from 'chalk';
33
import { program } from 'commander';
44

5-
import { GenerateServiceProps, generateService } from '../index';
5+
import type { GenerateServiceProps } from '../index';
6+
import { generateService } from '../index';
67
import { readConfig } from '../readConfig';
78

89
program

src/bin/openapi.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { pickBy } from 'lodash';
44
import { join } from 'path';
55

66
import * as pkg from '../../package.json';
7-
import { GenerateServiceProps, generateService } from '../index';
7+
import type { GenerateServiceProps } from '../index';
8+
import { generateService } from '../index';
89
import { logError } from '../log';
910
import { readConfig } from '../readConfig';
10-
import { IPriorityRule, IReactQueryMode } from '../type';
11+
import type { IPriorityRule, IReactQueryMode } from '../type';
1112

1213
const params = program
1314
.name('openapi')

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IReactQueryMode } from './type';
1+
import type { IReactQueryMode } from './type';
22

33
export enum SchemaObjectFormat {
44
int32 = 'int32',

src/generator/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Dictionary } from 'lodash';
1+
import type { Dictionary } from 'lodash';
22

3-
import { IReactQueryMode, ParameterObject, SchemaObject } from '../type';
3+
import type { IReactQueryMode, ParameterObject, SchemaObject } from '../type';
44

55
export const serviceEntryFileName = 'index';
66

src/generator/mockGenarator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import fs from 'fs';
2-
import { Dictionary, forEach, includes, isUndefined, keys } from 'lodash';
2+
import type { Dictionary } from 'lodash';
3+
import { forEach, includes, isUndefined, keys } from 'lodash';
34
import Mock from 'mockjs';
45
import { dirname, join } from 'path';
56
import pinyin from 'tiny-pinyin';
67

78
import log from '../log';
89
import OpenAPIParserMock from '../parser-mock/index';
910
import { getRandomInt } from '../parser-mock/util';
10-
import {
11+
import type {
1112
OpenAPIObject,
1213
OperationObject,
1314
ParameterObject,

src/generator/patchSchema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import type { Dictionary } from 'lodash';
12
import {
2-
Dictionary,
33
forEach,
44
has,
55
isEmpty,
@@ -12,7 +12,7 @@ import {
1212
uniq,
1313
} from 'lodash';
1414

15-
import { ComponentsObject, ISchemaObject, SchemaObject } from '../type';
15+
import type { ComponentsObject, ISchemaObject, SchemaObject } from '../type';
1616
import {
1717
isArraySchemaObject,
1818
isNonArraySchemaObject,

src/generator/serviceGenarator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { existsSync, readFileSync } from 'fs';
22
import { globSync } from 'glob';
3+
import type { Dictionary } from 'lodash';
34
import {
4-
Dictionary,
55
// camelCase,
66
entries,
77
filter,
@@ -27,7 +27,7 @@ import {
2727
} from '../config';
2828
import type { GenerateServiceProps } from '../index';
2929
import log from '../log';
30-
import {
30+
import type {
3131
ArraySchemaObject,
3232
ContentObject,
3333
ISchemaObject,
@@ -62,7 +62,7 @@ import {
6262
import { writeFile } from './file';
6363
import { Merger } from './merge';
6464
import { patchSchema } from './patchSchema';
65-
import {
65+
import type {
6666
APIDataType,
6767
ControllerType,
6868
ICustomParameterObject,
@@ -72,9 +72,9 @@ import {
7272
IServiceControllerPayload,
7373
ITypeItem,
7474
ITypescriptFileType,
75-
type MergeOption,
7675
TagAPIDataType,
7776
} from './type';
77+
import { type MergeOption } from './type';
7878
import {
7979
capitalizeFirstLetter,
8080
genDefaultFunctionName,

src/generator/type.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import type { ProjectOptions } from 'ts-morph';
22

3-
import {
4-
type MutuallyExclusive,
5-
OperationObject,
6-
ParameterObject,
7-
SchemaObject,
8-
} from '../type';
9-
import { TypescriptFileType } from './config';
3+
import type { OperationObject, ParameterObject, SchemaObject } from '../type';
4+
import { type MutuallyExclusive } from '../type';
5+
import type { TypescriptFileType } from './config';
106

117
export type ITypescriptFileType = keyof typeof TypescriptFileType;
128

src/generator/util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import type { Dictionary } from 'lodash';
12
import {
2-
Dictionary,
33
countBy,
44
every,
55
filter,
@@ -20,7 +20,7 @@ import pinyin from 'tiny-pinyin';
2020

2121
import { SchemaObjectType } from '../config';
2222
import log from '../log';
23-
import {
23+
import type {
2424
ArraySchemaObject,
2525
BinaryArraySchemaObject,
2626
ComponentsObject,
@@ -32,7 +32,7 @@ import {
3232
SchemaObject,
3333
} from '../type';
3434
import { numberEnum } from './config';
35-
import { ICustomSchemaObject, ITypeItem } from './type';
35+
import type { ICustomSchemaObject, ITypeItem } from './type';
3636

3737
export function stripDot(str: string) {
3838
return str.replace(/[-_ .](\w)/g, (_all, letter: string) =>

0 commit comments

Comments
 (0)