Skip to content

Commit 2d3117c

Browse files
authored
feat: update ESLint config with @typescript-eslint/consistent-type-imports (#4746)
* update: Add type * fix: update import statement for NextApiRequest type * fix: update imports to use type for LexicalEditor and EditorState * Refactor imports to use 'import type' for type-only imports across multiple files - Updated imports in various components and API files to use 'import type' for better clarity and to optimize TypeScript's type checking. - Ensured consistent usage of type imports in files related to chat, dataset, workflow, and user management. - Improved code readability and maintainability by distinguishing between value and type imports. * refactor: remove old ESLint configuration and add new rules - Deleted the old ESLint configuration file from the app project. - Added a new ESLint configuration file with updated rules and settings. - Changed imports to use type-only imports in various files for better clarity and performance. - Updated TypeScript configuration to remove unnecessary options. - Added an ESLint ignore file to exclude build and dependency directories from linting. * fix: update imports to use 'import type' for type-only imports in schema files
1 parent 5361674 commit 2d3117c

File tree

806 files changed

+2223
-1881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

806 files changed

+2223
-1881
lines changed

.eslintignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 构建输出目录
2+
dist/
3+
build/
4+
.next/
5+
out/
6+
7+
# 依赖目录
8+
node_modules/
9+
10+
# 缓存和生成文件
11+
coverage/
12+
.coverage/
13+
.nyc_output/
14+
*.log
15+
16+
# 其他不需要检查的文件
17+
*.min.js
18+
*.config.js
19+
vitest.config.mts
20+
21+
# 特定目录
22+
bin/
23+
scripts/
24+
deploy/
25+
docSite/

.eslintrc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint"],
5+
"extends": ["next/core-web-vitals"],
6+
"rules": {
7+
"react-hooks/rules-of-hooks": 0,
8+
"@typescript-eslint/consistent-type-imports": [
9+
"error",
10+
{
11+
"prefer": "type-imports",
12+
"disallowTypeAnnotations": false
13+
}
14+
]
15+
},
16+
"ignorePatterns": ["node_modules/", "dist/", "build/", "coverage/"]
17+
}

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
"previewIcon": "node ./scripts/icon/index.js",
1414
"api:gen": "tsc ./scripts/openapi/index.ts && node ./scripts/openapi/index.js && npx @redocly/cli build-docs ./scripts/openapi/openapi.json -o ./projects/app/public/openapi/index.html",
1515
"create:i18n": "node ./scripts/i18n/index.js",
16+
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path .eslintignore",
17+
"lint:fix": "eslint \"**/*.{ts,tsx}\" --fix --ignore-path .eslintignore",
1618
"test": "vitest run",
1719
"test:workflow": "vitest run workflow"
1820
},
1921
"devDependencies": {
2022
"@chakra-ui/cli": "^2.4.1",
23+
"@typescript-eslint/eslint-plugin": "^6.21.0",
24+
"@typescript-eslint/parser": "^6.21.0",
2125
"@vitest/coverage-v8": "^3.0.9",
26+
"eslint": "^8.57.0",
27+
"eslint-config-next": "^14.1.0",
2228
"husky": "^8.0.3",
2329
"i18next": "23.16.8",
2430
"lint-staged": "^13.3.0",
@@ -31,7 +37,10 @@
3137
"zhlint": "^0.7.4"
3238
},
3339
"lint-staged": {
34-
"./**/**/*.{ts,tsx,scss}": "npm run format-code",
40+
"./**/**/*.{ts,tsx,scss}": [
41+
"npm run format-code",
42+
"npm run lint:fix"
43+
],
3544
"./docSite/**/**/*.md": "npm run format-doc && npm run gen:llms"
3645
},
3746
"resolutions": {

packages/global/common/error/code/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrType } from '../errorCode';
1+
import { type ErrType } from '../errorCode';
22
import { i18nT } from '../../../../web/i18n/utils';
33
/* dataset: 502000 */
44
export enum AppErrEnum {

packages/global/common/error/code/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrType } from '../errorCode';
1+
import { type ErrType } from '../errorCode';
22
import { i18nT } from '../../../../web/i18n/utils';
33
/* dataset: 504000 */
44
export enum ChatErrEnum {

packages/global/common/error/code/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { i18nT } from '../../../../web/i18n/utils';
2-
import { ErrType } from '../errorCode';
2+
import { type ErrType } from '../errorCode';
33

44
/* dataset: 507000 */
55
const startCode = 507000;

packages/global/common/error/code/dataset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { i18nT } from '../../../../web/i18n/utils';
2-
import { ErrType } from '../errorCode';
2+
import { type ErrType } from '../errorCode';
33

44
/* dataset: 501000 */
55
export enum DatasetErrEnum {

packages/global/common/error/code/openapi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrType } from '../errorCode';
1+
import { type ErrType } from '../errorCode';
22
import { i18nT } from '../../../../web/i18n/utils';
33
/* dataset: 506000 */
44
export enum OpenApiErrEnum {

packages/global/common/error/code/outLink.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrType } from '../errorCode';
1+
import { type ErrType } from '../errorCode';
22
import { i18nT } from '../../../../web/i18n/utils';
33
/* dataset: 505000 */
44
export enum OutLinkErrEnum {

packages/global/common/error/code/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrType } from '../errorCode';
1+
import { type ErrType } from '../errorCode';
22
import { i18nT } from '../../../../web/i18n/utils';
33
/* dataset: 508000 */
44
export enum PluginErrEnum {

0 commit comments

Comments
 (0)