mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🧹 chore: Migrate to Flat ESLint Config & Update Prettier Settings (#5737)
* chore: migrated eslint v8 to v9 * chore: migrated eslint v8 to v9 * ESLint only checks the files that have changed in the pull request. * fix: ESLint only checks the files that have changed in the pull request. * refactor: eslint only on changed files * refactor: eslint only on changed files or added files * refactor: eslint only on changed files or added files * refactor: eslint only on changed files or added files but only include files that are not deleted (ACMRTUXB: A, C, M, R, T, U, X, B). * whoops missed something
This commit is contained in:
parent
aae413cc71
commit
86134415e9
10 changed files with 2710 additions and 1738 deletions
9
.github/workflows/backend-review.yml
vendored
9
.github/workflows/backend-review.yml
vendored
|
|
@ -38,7 +38,7 @@ jobs:
|
|||
|
||||
- name: Install MCP Package
|
||||
run: npm run build:mcp
|
||||
|
||||
|
||||
- name: Create empty auth.json file
|
||||
run: |
|
||||
mkdir -p api/data
|
||||
|
|
@ -61,9 +61,4 @@ jobs:
|
|||
run: cd api && npm run test:ci
|
||||
|
||||
- name: Run librechat-data-provider unit tests
|
||||
run: cd packages/data-provider && npm run test:ci
|
||||
|
||||
- name: Run linters
|
||||
uses: wearerequired/lint-action@v2
|
||||
with:
|
||||
eslint: true
|
||||
run: cd packages/data-provider && npm run test:ci
|
||||
96
.github/workflows/eslint-ci.yml
vendored
Normal file
96
.github/workflows/eslint-ci.yml
vendored
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
name: ESLint Code Quality Checks
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
- release/*
|
||||
|
||||
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 20.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
# Use a paths filter (v3) to detect changes in JavaScript/TypeScript files,
|
||||
# but only consider files that are added or modified (ignoring deleted files).
|
||||
- name: Filter changed files for ESLint
|
||||
id: file_filter
|
||||
uses: dorny/paths-filter@v3
|
||||
with:
|
||||
filters: |
|
||||
eslint:
|
||||
- added|modified: '**/*.js'
|
||||
- added|modified: '**/*.jsx'
|
||||
- added|modified: '**/*.ts'
|
||||
- added|modified: '**/*.tsx'
|
||||
|
||||
# Run ESLint only if relevant files have been added or modified.
|
||||
- name: Run ESLint on changed files
|
||||
if: steps.file_filter.outputs.eslint == 'true'
|
||||
env:
|
||||
SARIF_ESLINT_IGNORE_SUPPRESSED: "true"
|
||||
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"
|
||||
|
||||
# List files changed between the base commit and current HEAD,
|
||||
# but only include files that are not deleted (ACMRTUXB: A, C, M, R, T, U, X, B).
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD | grep -E '\.(js|jsx|ts|tsx)$')
|
||||
echo "Files to lint:"
|
||||
echo "$CHANGED_FILES"
|
||||
|
||||
# Run ESLint on the changed files.
|
||||
npx eslint --no-error-on-unmatched-pattern \
|
||||
--config eslint.config.mjs \
|
||||
--format @microsoft/eslint-formatter-sarif \
|
||||
--output-file eslint-results.sarif $CHANGED_FILES || true
|
||||
|
||||
# If no JavaScript/TypeScript files were added or modified,
|
||||
# create a valid (non-empty) SARIF file containing one run.
|
||||
- name: Create empty SARIF results file
|
||||
if: steps.file_filter.outputs.eslint != 'true'
|
||||
run: |
|
||||
cat << 'EOF' > eslint-results.sarif
|
||||
{
|
||||
"version": "2.1.0",
|
||||
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
|
||||
"runs": [
|
||||
{
|
||||
"tool": {
|
||||
"driver": {
|
||||
"name": "ESLint",
|
||||
"informationUri": "https://eslint.org",
|
||||
"version": "0.0.0",
|
||||
"rules": []
|
||||
}
|
||||
},
|
||||
"results": []
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
|
||||
- name: Upload analysis results to GitHub
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
with:
|
||||
sarif_file: eslint-results.sarif
|
||||
wait-for-processing: true
|
||||
Loading…
Add table
Add a link
Reference in a new issue