Skip to content

Commit

Permalink
chore: consistent type exports/imports, add eslint rules, typescript@4
Browse files Browse the repository at this point in the history
  • Loading branch information
YSMJ1994 committed Feb 21, 2024
1 parent c462f0a commit ba095bd
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
**/*.md
es/
lib/
7 changes: 6 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"extends": [
"@alifd/eslint-config-next",
"plugin:@typescript-eslint/recommended",
Expand All @@ -18,6 +21,8 @@
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "warn",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "error"
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/consistent-type-exports": "warn",
"@typescript-eslint/consistent-type-imports": "warn"
}
}
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"semantic-release": "^17.2.3",
"sinon": "^16.1.3",
"ts-jest": "^29.1.2",
"typescript": "^5.3.3"
"typescript": "^4.9.5"
},
"componentConfig": {
"name": "validate",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,5 +293,5 @@ class Schema {
}
}

export type * from './types';
export * from './types';
export default Schema;
2 changes: 1 addition & 1 deletion src/rules/format.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as util from '../util';
import { PresetValidator } from '../types';
import type { PresetValidator } from '../types';

const pattern = {
email: /[\w\u4E00-\u9FA5]+([-+.][\w\u4E00-\u9FA5]+)*@[\w\u4E00-\u9FA5]+([-.][\w\u4E00-\u9FA5]+)*\.[\w\u4E00-\u9FA5]+([-.][\w\u4E00-\u9FA5]+)*/,
Expand Down
2 changes: 1 addition & 1 deletion src/rules/length.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as util from '../util';
import { PresetValidator } from '../types';
import type { PresetValidator } from '../types';

/**
* Rule for validating minimum and maximum allowed values.
Expand Down
2 changes: 1 addition & 1 deletion src/rules/pattern.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as util from '../util';
import { PresetValidator } from '../types';
import type { PresetValidator } from '../types';

/**
* Rule for validating a regular expression pattern.
Expand Down
2 changes: 1 addition & 1 deletion src/rules/required.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as util from '../util';
import { PresetValidator } from '../types';
import type { PresetValidator } from '../types';

/**
* Rule for validating required fields.
Expand Down
2 changes: 1 addition & 1 deletion src/rules/size.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as util from '../util';
import { PresetValidator } from '../types';
import type { PresetValidator } from '../types';

/**
* Rule for validating minimum and maximum allowed values.
Expand Down
4 changes: 3 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const formatRegExp = /%[sdj%]/g;
export function format<R>(f: () => R, ...args: unknown[]): R;
export function format(f: string, ...args: unknown[]): string;
export function format<V>(f: V, ...args: unknown[]): V;
export function format(...args: [unknown, ...others: unknown[]]): unknown {
export function format(
...args: [target: unknown, ...others: unknown[]]
): unknown {
let i = 1;
const f = args[0];
const len = args.length;
Expand Down
2 changes: 1 addition & 1 deletion src/validator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
PresetOption,
PresetValidator,
Rule,
Expand Down

0 comments on commit ba095bd

Please sign in to comment.