diff --git a/lefthook.yml b/lefthook.yml index 4b751e9b6e..edf804a1f5 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -77,38 +77,39 @@ pre-commit: - name: web-deps glob: "web/**/*.{css,less,json,js,jsx,ts,tsx}" run: | - # Ensure web/node_modules includes the tooling needed by the hook jobs. - # CI runners don't run `npm install` before lefthook, and `npx` without - # local node_modules fetches the latest packages from the registry - which - # breaks because the pinned prettier plugins - # (prettier-plugin-organize-imports, prettier-plugin-packagejson) aren't - # auto-resolved and ESLint 10 requires eslint.config.js. - if [ ! -f web/node_modules/.package-lock.json ] \ - || [ ! -d web/node_modules/prettier-plugin-organize-imports ] \ - || [ ! -d web/node_modules/@typescript-eslint/eslint-plugin ]; then - echo '==> web/node_modules missing required hook dependencies; running npm ci --prefix web --include=dev' - rm -rf web/node_modules - npm ci --prefix web --include=dev --no-audit --no-fund + # Install ONLY oxfmt + oxlint (prebuilt Rust binaries) into an isolated + # dir inside web/node_modules. This skips the full React dev-toolchain + # `npm ci`, which was the dominant CI cost of the old prettier/eslint + # setup. oxfmt/oxlint read web/.oxfmtrc.json / web/.oxlintrc.json from cwd. + HOOKBIN=web/node_modules/.hookbin + if [ ! -x "$HOOKBIN/node_modules/.bin/oxfmt" ] \ + || [ ! -x "$HOOKBIN/node_modules/.bin/oxlint" ]; then + echo '==> installing oxfmt + oxlint only (no full web toolchain)' + mkdir -p "$HOOKBIN" + [ -f "$HOOKBIN/package.json" ] \ + || printf '{"name":"hookbin","version":"1.0.0","private":true}\n' > "$HOOKBIN/package.json" + npm install --prefix "$HOOKBIN" --no-audit --no-fund --save-dev oxfmt oxlint fi - - name: web-prettier + - name: web-oxfmt glob: "web/**/*.{css,less,json,js,jsx,ts,tsx}" + exclude: ["web/**/*.min.js", "web/**/*.min.css"] root: "web/" stage_fixed: true run: | if [ "${LEFTHOOK_CHECK_ONLY:-}" = "1" ]; then - npx prettier --check --ignore-unknown {staged_files} + node_modules/.hookbin/node_modules/.bin/oxfmt --check {staged_files} else - npx prettier --write --ignore-unknown {staged_files} + node_modules/.hookbin/node_modules/.bin/oxfmt {staged_files} fi - - name: web-eslint + - name: web-oxlint glob: "web/**/*.{js,jsx,ts,tsx}" root: "web/" stage_fixed: true run: | if [ "${LEFTHOOK_CHECK_ONLY:-}" = "1" ]; then - npx eslint {staged_files} + node_modules/.hookbin/node_modules/.bin/oxlint {staged_files} else - npx eslint --fix {staged_files} + node_modules/.hookbin/node_modules/.bin/oxlint --fix {staged_files} fi - name: check-yaml run: python3 tools/hooks/check_files.py yaml diff --git a/web/.eslintrc.cjs b/web/.eslintrc.cjs deleted file mode 100644 index bf1cf54727..0000000000 --- a/web/.eslintrc.cjs +++ /dev/null @@ -1,81 +0,0 @@ -module.exports = { - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:react/recommended', - 'plugin:react-hooks/recommended', - ], - plugins: ['@typescript-eslint', 'react', 'react-refresh', 'check-file'], - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 'latest', - sourceType: 'module', - ecmaFeatures: { - jsx: true, - }, - }, - settings: { - react: { - version: 'detect', - }, - }, - env: { - browser: true, - es2021: true, - node: true, - }, - rules: { - '@typescript-eslint/no-use-before-define': [ - 'warn', - { - functions: false, - variables: true, - }, - ], - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/ban-ts-comment': 'off', - '@typescript-eslint/no-empty-function': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - 'react/prop-types': 'off', - 'react/react-in-jsx-scope': 'off', - 'react/no-unescaped-entities': [ - 'warn', - { - forbid: [ - { - char: "'", - alternatives: [''', '''], - }, - { - char: '"', - alternatives: ['"', '"'], - }, - ], - }, - ], - 'react-refresh/only-export-components': 'off', - 'no-console': ['warn', { allow: ['warn', 'error'] }], - 'check-file/filename-naming-convention': [ - 'error', - { - '**/*.{jsx,tsx}': '[a-z0-9.-]*', - '**/*.{js,ts}': '[a-z0-9.-]*', - }, - ], - 'check-file/folder-naming-convention': [ - 'error', - { - 'src/**/': 'KEBAB_CASE', - 'mocks/*/': 'KEBAB_CASE', - }, - ], - }, - overrides: [ - { - files: ['**/__tests__/**'], - rules: { - 'check-file/folder-naming-convention': 'off', - }, - }, - ], -}; diff --git a/web/.prettierrc b/web/.oxfmtrc.json similarity index 55% rename from web/.prettierrc rename to web/.oxfmtrc.json index ea51f06ac9..d7484ee1fc 100644 --- a/web/.prettierrc +++ b/web/.oxfmtrc.json @@ -1,9 +1,7 @@ { - "printWidth": 80, "singleQuote": true, + "printWidth": 80, "trailingComma": "all", "proseWrap": "never", - "overrides": [{ "files": ".prettierrc", "options": { "parser": "json" } }], - "plugins": [], "endOfLine": "lf" } diff --git a/web/.oxlintrc.json b/web/.oxlintrc.json new file mode 100644 index 0000000000..ebea8f787e --- /dev/null +++ b/web/.oxlintrc.json @@ -0,0 +1,29 @@ +{ + "env": { + "browser": true, + "es2021": true, + "node": true + }, + "plugins": ["@typescript-eslint", "react", "react-hooks"], + "settings": { + "react": { + "version": "18.2.0" + } + }, + "rules": { + "@typescript-eslint/no-use-before-define": [ + "warn", + { + "functions": false, + "variables": true + } + ], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/no-non-null-assertion": "off", + "react/react-in-jsx-scope": "off", + "react/no-unescaped-entities": "warn", + "no-console": ["warn", { "allow": ["warn", "error"] }] + } +} diff --git a/web/.prettierignore b/web/.prettierignore deleted file mode 100644 index 5892e28be3..0000000000 --- a/web/.prettierignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -.umi -.umi-production diff --git a/web/README.md b/web/README.md index edf78d19f8..4f13441ae6 100644 --- a/web/README.md +++ b/web/README.md @@ -1,45 +1,43 @@ ## Install front-end dependencies - ```bash - npm install - ``` +```bash +npm install +``` ## Launch front-end - ```bash - npm run dev - ``` +```bash +npm run dev +``` - _The following output confirms a successful launch of the system:_ +_The following output confirms a successful launch of the system:_ -  + ## Login to RAGFlow web UI - Open your browser and navigate to: +Open your browser and navigate to: - ```bash - http://localhost:9222 or http://[YOUR_MACHINE_IP]:9222 - ``` - - _Replace `[YOUR_MACHINE_IP]` with your actual machine IP address (e.g., `http://192.168.1.49:9222`)._ +```bash +http://localhost:9222 or http://[YOUR_MACHINE_IP]:9222 +``` +_Replace `[YOUR_MACHINE_IP]` with your actual machine IP address (e.g., `http://192.168.1.49:9222`)._ ## Login to RAGFlow web admin UI - Open your browser and navigate to: +Open your browser and navigate to: - ```bash - http://localhost:9222/admin or http://[YOUR_MACHINE_IP]:9222/admin - ``` - - _Replace `[YOUR_MACHINE_IP]` with your actual machine IP address (e.g., `http://192.168.1.49:9222/admin`)._ +```bash +http://localhost:9222/admin or http://[YOUR_MACHINE_IP]:9222/admin +``` +_Replace `[YOUR_MACHINE_IP]` with your actual machine IP address (e.g., `http://192.168.1.49:9222/admin`)._ ## Shutdown front-end - Ctrl + C or +Ctrl + C or - ```bash - kill -f "umi dev" - ``` \ No newline at end of file +```bash +kill -f "umi dev" +``` diff --git a/web/index.html b/web/index.html index 5aea7c664b..d847756afa 100644 --- a/web/index.html +++ b/web/index.html @@ -1,4 +1,4 @@ - +
@@ -11,4 +11,4 @@ - \ No newline at end of file +