mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-03 22:32:42 +00:00
* 🔧 chore: Update ESLint config, add import sorting script, Test Sharding, Bump `@librechat/agents`
* Change 'no-nested-ternary' rule from 'warn' to 'error' in ESLint config
* Add new scripts for sorting imports in the project
* Update lint-staged configuration to include import sorting
* Modify GitHub Actions workflows to support sharding for unit tests
* chore: remove nested ternary expressions
* refactor: Extract scale multiplier logic into a separate function in CircleRender component
* refactor: Simplify auto-refill rendering logic in Balance component for better readability
* refactor: Improve width style handling in DataTable components for clarity and maintainability
* chore: remove CircleRender component
* delete: Remove CircleRender component as it is no longer needed in the project
* chore: Bump @librechat/agents to version 3.2.31 and update Node.js engine requirement
* Update @librechat/agents dependency from 3.2.2 to 3.2.31 in package-lock.json, api/package.json, and packages/api/package.json
* Change Node.js engine requirement from >=20.0.0 to >=24.0.0 in @librechat/agents
* chore: Add import sorting check to ESLint CI workflow
* Implement a new job in the GitHub Actions workflow to verify import ordering on changed files.
* The job checks for changes in specific file types and reports any import order drift, providing instructions for local fixes.
124 lines
4.5 KiB
YAML
124 lines
4.5 KiB
YAML
name: ESLint Code Quality Checks
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- dev
|
|
- dev-staging
|
|
- release/*
|
|
paths:
|
|
- 'api/**'
|
|
- 'client/**'
|
|
- 'packages/**'
|
|
- '.github/workflows/eslint-ci.yml'
|
|
|
|
jobs:
|
|
eslint_checks:
|
|
name: Run ESLint Linting
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
security-events: write
|
|
actions: read
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Node.js 24.16.0
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24.16.0'
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
# Run ESLint on changed files within the api/, client/, and packages/ directories.
|
|
- name: Run ESLint on changed files
|
|
run: |
|
|
# Extract the base commit SHA from the pull_request event payload.
|
|
BASE_SHA=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
|
|
echo "Base commit SHA: $BASE_SHA"
|
|
|
|
# Get changed files (only JS/TS files in api/, client/, or packages/)
|
|
mapfile -d '' -t CHANGED_FILES < <(
|
|
git diff -z --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD |
|
|
grep -zE '^(api|client|packages)/.*\.(js|jsx|ts|tsx)$' || true
|
|
)
|
|
|
|
# Debug output
|
|
echo "Changed files:"
|
|
printf '%s\n' "${CHANGED_FILES[@]}"
|
|
|
|
# Ensure there are files to lint before running ESLint
|
|
if [[ ${#CHANGED_FILES[@]} -eq 0 ]]; then
|
|
echo "No matching files changed. Skipping ESLint."
|
|
exit 0
|
|
fi
|
|
|
|
# Run ESLint
|
|
npx eslint --no-error-on-unmatched-pattern \
|
|
--config eslint.config.mjs \
|
|
--max-warnings=0 \
|
|
-- "${CHANGED_FILES[@]}"
|
|
|
|
# Run Prettier --check on the same set of changed files to catch
|
|
# formatting drift in PRs that bypassed the local pre-commit hook
|
|
# (e.g. GitHub UI edit-and-merge, `git commit --no-verify`).
|
|
- name: Run Prettier --check on changed files
|
|
run: |
|
|
BASE_SHA=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
|
|
mapfile -d '' -t CHANGED_FILES < <(
|
|
git diff -z --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD |
|
|
grep -zE '^(api|client|packages)/.*\.(js|jsx|ts|tsx)$' || true
|
|
)
|
|
|
|
if [[ ${#CHANGED_FILES[@]} -eq 0 ]]; then
|
|
echo "No matching files changed. Skipping Prettier."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Files to check:"
|
|
printf '%s\n' "${CHANGED_FILES[@]}"
|
|
|
|
# `prettier --check` exits non-zero if any file would be reformatted.
|
|
# Suggest the local fix in the failure message so contributors aren't
|
|
# left guessing how to resolve.
|
|
if ! npx prettier --check --no-error-on-unmatched-pattern -- "${CHANGED_FILES[@]}"; then
|
|
echo ""
|
|
echo "::error::Prettier formatting drift detected. Fix locally with:"
|
|
echo "::error:: npx prettier --write <files>"
|
|
echo "::error::Or rely on the lint-staged pre-commit hook (do not bypass with --no-verify)."
|
|
exit 1
|
|
fi
|
|
|
|
# Verify import ordering on the same set of changed files. The script
|
|
# only sorts files under known source roots, so unrelated changed files
|
|
# (configs, etc.) are ignored. Matches the lint-staged pre-commit hook.
|
|
- name: Check import sorting on changed files
|
|
run: |
|
|
BASE_SHA=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
|
|
mapfile -d '' -t CHANGED_FILES < <(
|
|
git diff -z --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD |
|
|
grep -zE '^(api|client|packages)/.*\.(js|jsx|ts|tsx)$' || true
|
|
)
|
|
|
|
if [[ ${#CHANGED_FILES[@]} -eq 0 ]]; then
|
|
echo "No matching files changed. Skipping import-sort check."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Files to check:"
|
|
printf '%s\n' "${CHANGED_FILES[@]}"
|
|
|
|
# `--check` lists offending files and exits non-zero without writing.
|
|
if ! node scripts/sort-imports.mts --check "${CHANGED_FILES[@]}"; then
|
|
echo ""
|
|
echo "::error::Import order drift detected. Fix locally with:"
|
|
echo "::error:: npm run sort-imports"
|
|
echo "::error::Or rely on the lint-staged pre-commit hook (do not bypass with --no-verify)."
|
|
exit 1
|
|
fi
|