hass.tibber_prices/scripts/format
Julian Pawlowski b2d63c2b6d chore(scripts): add explicit format/fix/check modes for all file types
Split lint workflow into three clearly separated modes:

- scripts/format: Python-only formatting (Ruff format)
- scripts/lint-fix: Python-only lint auto-fixes (Ruff check --fix)
- scripts/lint: convenience wrapper (delegates to format + lint-fix)

Add all-in-one scripts covering Python and non-Python files (Prettier for
JSON/JSONC/Markdown/YAML, shfmt for shell scripts):

- scripts/format-all: format all file types
- scripts/check-all: check-only for all file types (CI/CD parity)
- scripts/lint-all: format-all + lint-fix in one command

Release-Notes: skip
User-Impact: none
2026-04-12 12:11:38 +00:00

33 lines
725 B
Bash
Executable file

#!/bin/bash
# script/format: Format code with Ruff formatter
#
# Runs Ruff format and applies formatting changes. Automatically cleans up any
# accidental package installations after running.
#
# Usage:
# ./scripts/format
#
# Examples:
# ./scripts/format
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR/.."
# shellcheck source=scripts/.lib/output.sh
source "$SCRIPT_DIR/.lib/output.sh"
if [[ -z ${VIRTUAL_ENV:-} ]]; then
# shellcheck source=/dev/null
source "$HOME/.venv/bin/activate"
fi
log_header "Running Ruff format"
uv run --active ruff format .
# Clean up any accidental package installation from uv run
"$SCRIPT_DIR/clean" --minimal
log_success "Formatting completed"