Skip to content

Commit bba21a6

Browse files
committed
chore: prefer use type over interface with eslint
1 parent 7b13f34 commit bba21a6

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
66
"rules": {
77
"@typescript-eslint/consistent-type-imports": "error",
8+
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
89
"@typescript-eslint/no-unused-vars": [
910
"error",
1011
{

src/parse.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import { decompress } from 'lz4js';
55
export type ParseTypeGuardFunction<T> = (obj: any) => obj is T;
66
export type ParseReviverFunction = (this: any, key: string, value: any) => any;
77

8-
export interface ParseOptions {
8+
export type ParseOptions = {
99
extended?: boolean | { enable: boolean; relaxed?: boolean };
1010
unminify?: boolean | { enable: boolean; keyMap?: Record<string, string> };
1111
decompress?: boolean | { enable: boolean };
12-
}
12+
};
1313

14-
interface _ParseOptions {
14+
type _ParseOptions = {
1515
extended: { enable: boolean; relaxed: boolean };
1616
unminify: { enable: boolean; keyMap?: Record<string, string> };
1717
decompress: { enable: boolean };
18-
}
18+
};
1919

2020
const defaultOptions: _ParseOptions = {
2121
extended: { enable: false, relaxed: true },

src/stringify.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ export type StringifyReplacerFunction = (
1414
value: any,
1515
) => any;
1616

17-
export interface StringifyOptions {
17+
export type StringifyOptions = {
1818
extended?: boolean | { enable: boolean; relaxed?: boolean };
1919
minify?: boolean | { enable: boolean; keyMap?: Record<string, string> };
2020
compress?: boolean | { enable: boolean };
21-
}
21+
};
2222

23-
interface _StringifyOptions {
23+
type _StringifyOptions = {
2424
extended: { enable: boolean; relaxed: boolean };
2525
minify: { enable: boolean; keyMap: Record<string, string> | undefined };
2626
compress: { enable: boolean };
27-
}
27+
};
2828

2929
const defaultOptions: _StringifyOptions = {
3030
extended: { enable: false, relaxed: true },

test/parse.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ describe('[parse] decompress', () => {
175175
});
176176

177177
describe('[parse] type guard', () => {
178-
interface TestObject {
178+
type TestObject = {
179179
a: number;
180180
b: string;
181-
}
181+
};
182182

183183
const typeGuard = (obj: any): obj is TestObject => {
184184
return typeof obj?.a === 'number' && typeof obj?.b === 'string';

0 commit comments

Comments
 (0)