diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c1f9df13..ac2cc2ea 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,6 +6,11 @@ updates: schedule: interval: daily + - package-ecosystem: pip + directory: / + schedule: + interval: daily + - package-ecosystem: npm directory: / schedule: diff --git a/.github/workflows/eslint-on-push-pr.yml b/.github/workflows/eslint-on-push-pr.yml deleted file mode 100644 index 2e9ea10f..00000000 --- a/.github/workflows/eslint-on-push-pr.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Lint pushes/PRs - -on: [push, pull_request] - -jobs: - eslint: - runs-on: ubuntu-latest - steps: - - - name: Checkout repository code - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 'lts/*' - - - name: Install dependencies - run: npm ci # instead of install to ensure consistency and determinism in CI/CD workflow - - - name: Run ESLint - run: npm run lint diff --git a/.github/workflows/lint-on-push-pr.yml b/.github/workflows/lint-on-push-pr.yml new file mode 100644 index 00000000..15973f6e --- /dev/null +++ b/.github/workflows/lint-on-push-pr.yml @@ -0,0 +1,34 @@ +name: Lint pushes + PRs +on: [push, pull_request] + +jobs: + + js-json-md-yaml-lint: + name: JavaScript + JSON + Markdown + YAML + runs-on: ubuntu-latest + steps: + + - name: Checkout repository code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + + - name: Install dependencies + run: npm ci + + - name: Run ESLint + run: npx eslint . --cache + + python-lint: + name: Python + runs-on: ubuntu-latest + steps: + + - name: Checkout repository code + uses: actions/checkout@v4 + + - name: Run Ruff + uses: chartboost/ruff-action@v1 diff --git a/.github/workflows/sync-changes.yml b/.github/workflows/sync-changes.yml index 47330ff2..1930f5ac 100644 --- a/.github/workflows/sync-changes.yml +++ b/.github/workflows/sync-changes.yml @@ -66,7 +66,7 @@ jobs: - name: Sync ** to adamlui/ai-apps/chatgpt-auto-continue/ run: | - rsync -avhr --delete --exclude={'.*','eslint*','package*.json'} \ + rsync -avhr --delete --exclude={'.*','eslint*','package*.json','requirements*.txt'} \ ${{ github.workspace }}/adamlui/chatgpt-auto-continue/ \ ${{ github.workspace }}/adamlui/ai-apps/chatgpt-auto-continue/ diff --git a/.husky/pre-commit b/.husky/pre-commit index 585d8319..74fd1057 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,15 +1,24 @@ #!/bin/bash -RED="\033[1;31m" ; NC="\033[0m" +# Init UI colors +NC="\033[0m" # no color +BR="\033[1;91m" # bright red +BY="\033[1;33m" # bright yellow -if npm ls -g eslint &> /dev/null || npm ls eslint &> /dev/null ; then - npm run lint +# Run ESLint for JavaScript + JSON + Markdown + YAML +echo -e "\n${BY}Running ESLint...${NC}" +npx eslint . --cache + +# Run Ruff for Python +echo -e "${BY}Running Ruff...${NC}" +if command -v ruff &> /dev/null ; then + ruff check . else PROJECT_ROOT=$( cd "$(dirname "$0")/.." && # nav to root [ "$OSTYPE" == "msys" ] && pwd -W || pwd # get absolute path ) - echo -e "\n${RED}Warning: eslint not installed${NC}" - echo -e " To add missing dependencies, run 'npm install' from" - echo -e " $PROJECT_ROOT\n" + echo -e "\n${BR}Warning: Ruff not installed${NC}" + echo -e "To add missing Python dependencies, run 'pip install -r requirements-dev.txt' from" + echo -e "$PROJECT_ROOT\n" fi diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 00000000..ab190c72 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,7 @@ +lint.ignore = [ + "E401", # allow multiple imports on one line + "E402", # allow module level import at top of file + "E701", # allow multiple statements on one line (colon) + "E702", # allow multiple statements on one line (semicolon) + "E722" # allow bare exceptions +] diff --git a/package.json b/package.json index ad855e83..186225c1 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,10 @@ ], "scripts": { "prepare": "husky", - "lint": "eslint . --cache", - "lint:all": "eslint .", - "lint:fix": "eslint . --fix --cache", - "lint:fix-all": "eslint . --fix", + "lint": "eslint . --cache && ruff check", + "lint:all": "eslint . && ruff check", + "lint:fix": "eslint . --fix --cache && ruff check --fix", + "lint:fix-all": "eslint . --fix && ruff check --fix", "bump": "bash utils/bump.sh", "bump:chrome": "bash utils/bump.sh --chrome", "bump:chromium": "bash utils/bump.sh --chrome", diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..fe6faaf5 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1 @@ +ruff>=0.8.0