Commit 63d4b417 by Ryo Committed by GitHub

chore: migrate eslint config (#6895)

* chore: migrate eslint config

* submodule

* doc

* fix: copy flat eslint config in app image

* ci: use packageManager pnpm version in sandbox test

---------

Co-authored-by: archer <545436317@qq.com>
parent 5b49b4fb
# 构建输出目录
dist/
build/
.next/
out/
local/
# 依赖目录
node_modules/
# 缓存和生成文件
coverage/
.coverage/
.nyc_output/
*.log
# 其他不需要检查的文件
*.min.js
*.config.js
vitest.config.mts
# 特定目录
bin/
scripts/
deploy/
document/
projects/marketplace
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": ["next/core-web-vitals"],
"rules": {
"react-hooks/rules-of-hooks": 0,
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports",
"disallowTypeAnnotations": false
}
]
},
"ignorePatterns": ["node_modules/", "dist/", "build/", "coverage/"]
}
......@@ -19,12 +19,10 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
- uses: pnpm/action-setup@v4
with:
version: 10.33.2
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '24'
cache: 'pnpm'
- uses: actions/setup-python@v5
......
......@@ -50,6 +50,7 @@ FILE_TOKEN_KEY=
4. 第三方知识库接入钉钉知识库。
5. 增加文件解析/HTML转Markdown/文本切块 worker pool,避免并发太高导致资源耗尽,可通过环境变量调整其 pool 数量。
6. 模型思考配置。
7. S3 支持配置 CDN。
## ⚙️ 优化
......
// @ts-check
import { defineConfig, globalIgnores } from 'eslint/config';
import nextVitals from 'eslint-config-next/core-web-vitals';
import nextTs from 'eslint-config-next/typescript';
export default defineConfig([
...nextVitals,
...nextTs,
{
name: 'fastgpt/next-settings',
settings: {
next: {
rootDir: ['projects/app/', 'pro/admin/']
}
}
},
{
name: 'fastgpt/rules',
files: ['**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
disallowTypeAnnotations: false
}
],
'@next/next/no-html-link-for-pages': 'off',
'react-hooks/rules-of-hooks': 'off'
}
},
globalIgnores(
[
'**/node_modules/',
'**/dist/',
'**/build/',
'**/.next/',
'**/out/',
'**/local/',
'**/coverage/',
'**/.coverage/',
'**/.nyc_output/',
'**/*.log',
'**/*.min.js',
'**/*.config.js',
'**/vitest.config.mts',
'**/next-env.d.ts',
'**/bin/',
'**/scripts/',
'deploy/',
'document/',
'projects/marketplace/',
'lint-staged.config.mjs'
],
'fastgpt/global-ignores'
)
]);
import path from 'node:path';
const quoteFiles = (files) =>
files.map((file) => JSON.stringify(path.relative(process.cwd(), file))).join(' ');
const withoutIgnoredPaths = (files) =>
files.filter((file) => {
const relativePath = path.relative(process.cwd(), file);
return !(
relativePath.startsWith('document/') ||
relativePath.startsWith('projects/marketplace/') ||
relativePath.startsWith('deploy/') ||
relativePath.includes('/scripts/') ||
relativePath.endsWith('/next-env.d.ts')
);
});
export default {
'./document/**/**/*.mdx': (files) =>
files.length === 0
? []
: [
'pnpm -C ./document run format-doc',
'pnpm -C ./document run initDocTime',
'pnpm -C ./document run initDocToc',
'pnpm -C ./document run checkDocRefs',
'pnpm -C ./document run removeInvalidImg'
],
'**/*.{ts,tsx}': (files) => {
const lintFiles = withoutIgnoredPaths(files);
if (lintFiles.length === 0) return [];
const filenames = quoteFiles(lintFiles);
return [`eslint --fix ${filenames}`, `prettier --config ./.prettierrc.js --write ${filenames}`];
},
'**/*.scss': (files) => {
if (files.length === 0) return [];
const filenames = quoteFiles(files);
return `prettier --config ./.prettierrc.js --write ${filenames}`;
}
};
......@@ -9,7 +9,7 @@
"postinstall": "pnpm gen:theme-typings && pnpm run build:sdks",
"initIcon": "node ./scripts/icon/init.js && prettier --config \"./.prettierrc.js\" --write \"packages/web/components/common/Icon/constants.ts\"",
"previewIcon": "node ./scripts/icon/index.js",
"lint": "eslint \"**/*.{ts,tsx}\" --fix --ignore-path .eslintignore",
"lint": "turbo run lint",
"create:i18n": "node ./scripts/i18n/index.js",
"clean:unused:pro": "node --experimental-strip-types ./pro/scripts/cleanup-unused.ts",
"clean:unused:pro:write": "node --experimental-strip-types ./pro/scripts/cleanup-unused.ts --write",
......@@ -27,42 +27,24 @@
},
"devDependencies": {
"@chakra-ui/cli": "^2.4.1",
"@typescript-eslint/eslint-plugin": "catalog:",
"@typescript-eslint/parser": "catalog:",
"@vitest/coverage-v8": "catalog:",
"eslint": "catalog:",
"eslint-config-next": "catalog:",
"eslint": "catalog:eslint",
"eslint-config-next": "catalog:eslint",
"husky": "^8.0.3",
"i18next": "catalog:",
"js-yaml": "catalog:",
"lint-staged": "^13.3.0",
"lint-staged": "catalog:",
"mongodb-memory-server": "catalog:",
"next-i18next": "catalog:",
"prettier": "3.2.4",
"prettier": "catalog:",
"react-i18next": "catalog:",
"turbo": "2.9.9",
"typescript-eslint": "catalog:eslint",
"typescript": "catalog:",
"vitest": "catalog:"
},
"lint-staged": {
"./document/**/**/*.mdx": [
"pnpm -C ./document run format-doc",
"pnpm -C ./document run initDocTime",
"pnpm -C ./document run initDocToc",
"pnpm -C ./document run checkDocRefs",
"pnpm -C ./document run removeInvalidImg",
"git add ."
],
"**/*.{ts,tsx}": [
"prettier --config ./.prettierrc.js --write",
"eslint --fix --ignore-path .eslintignore"
],
"**/*.scss": [
"prettier --config ./.prettierrc.js --write"
]
},
"engines": {
"node": ">=20",
"node": ">=20.19.0",
"pnpm": "10.x"
},
"packageManager": "pnpm@10.33.4"
......
......@@ -6,7 +6,7 @@
"test:watch": "vitest -c vitest.config.ts"
},
"engines": {
"node": ">=20",
"node": ">=20.19.0",
"pnpm": "10.x"
},
"dependencies": {
......
......@@ -9,7 +9,7 @@
"test:integration:watch": "vitest -c vitest.integration.config.ts"
},
"engines": {
"node": ">=20",
"node": ">=20.19.0",
"pnpm": "10.x"
},
"dependencies": {
......
......@@ -2,7 +2,7 @@
"name": "@fastgpt/web",
"version": "1.0.0",
"engines": {
"node": ">=20",
"node": ">=20.19.0",
"pnpm": "10.x"
},
"dependencies": {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -12,6 +12,8 @@ packages:
- scripts/icon
- sdk/*
catalogMode: prefer
catalog:
"@modelcontextprotocol/sdk": ^1
"@node-rs/jieba": 2.0.1
......@@ -27,8 +29,6 @@ catalog:
"@types/react-dom": ^18
"@types/request-ip": ^0.0.38
"@types/proxy-addr": 2.0.3
"@typescript-eslint/eslint-plugin": ^6.21.0
"@typescript-eslint/parser": ^6.21.0
"@vitest/coverage-v8": ^4.1.5
"@chakra-ui/anatomy": ^2
"@chakra-ui/icons": ^2
......@@ -44,14 +44,13 @@ catalog:
chalk: ^5.6.2
date-fns: ^3.6.0
dayjs: 1.11.19
eslint: ^8.57.0
eslint-config-next: 15.5.12
express: ^4
file-type: 21.3.0
i18next: 23.16.8
js-yaml: ^4.1.1
jsonwebtoken: ^9.0.3
json5: ^2.2.3
lint-staged: ^16.4.0
lodash: 4.17.23
mime: ^4.1.0
mime-types: 3.0.2
......@@ -61,6 +60,7 @@ catalog:
nanoid: ^5.1.3
next: 16.2.4
next-i18next: 15.4.2
prettier: 3.8.3
proxy-addr: 2.0.7
proxy-agent: ^6
react: ^18
......@@ -77,6 +77,12 @@ catalog:
vitest: ^4.1.5
zod: ^4
catalogs:
eslint:
eslint: ^9
eslint-config-next: 16.2.4
typescript-eslint: ^8
onlyBuiltDependencies:
- "@parcel/watcher"
- bufferutil
......
Subproject commit ee1b1d779dfa90b36503d0693c97437fd9ba7b6a
Subproject commit ede09e6cbe630281918eebe2b3c696eb7bc58a65
......@@ -30,7 +30,7 @@ ARG proxy
ARG base_url
# copy common node_modules and one project node_modules
COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json .eslintrc.json ./
COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json eslint.config.mjs ./
COPY --from=maindeps /app/node_modules ./node_modules
COPY --from=maindeps /app/packages ./packages
COPY --from=maindeps /app/sdk ./sdk
......
......@@ -13,10 +13,11 @@
"test:watch": "vitest -c vitest.config.ts",
"build:workers": "tsx scripts/build-workers.ts",
"typecheck": "tsc --noEmit --pretty",
"lint": "eslint ./src",
"build:workers:watch": "tsx scripts/build-workers.ts --watch"
},
"engines": {
"node": ">=20",
"node": ">=20.19.0",
"pnpm": "10.x"
},
"dependencies": {
......@@ -105,12 +106,11 @@
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@types/react-syntax-highlighter": "^15.5.6",
"@typescript-eslint/eslint-plugin": "catalog:",
"@typescript-eslint/parser": "catalog:",
"eslint": "catalog:",
"eslint-config-next": "catalog:",
"eslint": "catalog:eslint",
"eslint-config-next": "catalog:eslint",
"tailwindcss": "^3",
"tsx": "catalog:",
"typescript-eslint": "catalog:eslint",
"typescript": "catalog:",
"vitest": "catalog:"
}
......
......@@ -14,7 +14,7 @@
"test:watch": "vitest"
},
"engines": {
"node": ">=20",
"node": ">=20.19.0",
"pnpm": "10.x"
},
"dependencies": {
......
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": ["next/core-web-vitals"],
"rules": {
"react-hooks/rules-of-hooks": 0,
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports",
"disallowTypeAnnotations": false
}
]
},
"ignorePatterns": ["node_modules/", "dist/", "build/", "coverage/"]
}
......@@ -5,11 +5,10 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"start": "next start"
},
"engines": {
"node": ">=20",
"node": ">=20.19.0",
"pnpm": "10.x"
},
"dependencies": {
......@@ -39,8 +38,8 @@
"@types/node": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"eslint": "catalog:",
"eslint-config-next": "catalog:",
"eslint": "catalog:eslint",
"eslint-config-next": "catalog:eslint",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "catalog:"
......
......@@ -14,7 +14,7 @@
"mcp_test": "npx @modelcontextprotocol/inspector"
},
"engines": {
"node": ">=20",
"node": ">=20.19.0",
"pnpm": "10.x"
},
"dependencies": {
......
......@@ -39,7 +39,7 @@
"access": "public"
},
"engines": {
"node": ">=20",
"node": ">=20.19.0",
"pnpm": "10.x"
},
"license": "Apache-2.0",
......
......@@ -53,7 +53,7 @@
"access": "public"
},
"engines": {
"node": ">=20",
"node": ">=20.19.0",
"pnpm": "10.x"
},
"license": "Apache-2.0",
......
......@@ -20,7 +20,7 @@
"access": "public"
},
"engines": {
"node": ">=20",
"node": ">=20.19.0",
"pnpm": "10.x"
},
"exports": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment