Skip to content

Commit

Permalink
Integrated Ruff as dev dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed Nov 28, 2024
1 parent f36c39d commit de0b093
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ updates:
schedule:
interval: daily

- package-ecosystem: pip
directory: /
schedule:
interval: daily

- package-ecosystem: npm
directory: /
schedule:
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/eslint-on-push-pr.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/lint-on-push-pr.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/sync-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
21 changes: 15 additions & 6 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -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
]
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruff>=0.8.0

0 comments on commit de0b093

Please sign in to comment.