Skip to content

chore: Centralize linting and formatting tooling (ESLint, Prettier, Ruff, Dart)

Jérôme Revillard requested to merge align-tooling into main

Summary

Centralize and modernize linting/formatting configuration across the entire monorepo: ESLint 10 + Prettier 3 for JavaScript/Vue, Ruff for Python (OPEA services), Flutter/Dart for mobile, and Claude Code hooks for automatic enforcement.

Changes

1. ESLint 10 + Prettier 3 (JavaScript/Vue)

  • Migrate all 4 JS components to ESLint 10 flat config (eslint.config.js)
  • Add eslint-config-prettier as last config entry (disables formatting rules that conflict with Prettier)
  • Add eslint-plugin-vue with flat/recommended preset for frontend
  • Centralize Prettier config at repo root (.prettierrc)
  • Extract shared ESLint rules in components/shared/eslint-rules-base.js
  • Add .editorconfig for IDE-level consistency
  • Remove deprecated .eslintignore files (migrated into eslint.config.js ignores)
  • Remove per-component .prettierrc files (conflicted with root config)
  • Add globals package for Jest globals in test files
  • Add root-level orchestration scripts (lint, lint:fix, format, format:check)

Components covered: gov-chat-frontend, gov-chat-backend, document-repository, shared/lib

2. Ruff (Python — OPEA services)

  • Add genie-ai-overlay/pyproject.toml with Ruff configuration
    • Target: Python 3.10 (matches lowest runtime version across Dockerfiles)
    • Line length: 120, double quotes
    • Rules: E, F, I, UP, B, SIM (pycodestyle, pyflakes, isort, pyupgrade, bugbear, simplify)
    • Ignores: E402 (OPEA os.getenv()-before-import pattern), E741 (ML variable names)
  • Add Python lint/format scripts to root package.json (lint:py, lint:py:fix, format:py, format:py:check)
  • Update documentation: black/flake8 references replaced with ruff

Components covered: genie-ai-overlay/ (chatqna, dataprep, retriever, reranker, core)

3. Flutter/Dart (Mobile)

  • Add lint/format scripts to root package.json (lint:dart, format:dart, format:dart:check)
  • Add PostToolUse hook for dart analyze on .dart files (timeout 60s)
  • Update CLAUDE.md linting section with Dart commands
  • Existing analysis_options.yaml with flutter_lints already in place

Components covered: mobile/genie_ai_mobile/

4. Claude Code integration

  • Add .claude/settings.json with PostToolUse hooks:
    • ESLint on .js/.vue files (walks up to find nearest eslint.config.js)
    • Ruff on .py files (uses ruff via PATH — cross-platform)
    • dart analyze on .dart files (uses dart via PATH — cross-platform)
  • Update CLAUDE.md linting section with complete JS + Python + Dart commands

Files changed

File Change
.prettierrc, .prettierignore, .editorconfig New — centralized config
components/shared/eslint-rules-base.js New — shared ESLint rules
components/*/eslint.config.js (x4) New — ESLint 10 flat config
components/*/package.json (x4) Updated — ESLint 10 deps, lint scripts
components/*/.eslintignore (x3) Deleted — migrated to flat config
components/*/.prettierrc (x3) Deleted — centralized to root
genie-ai-overlay/pyproject.toml New — Ruff config
package.json Updated — root orchestration scripts (JS + Python + Dart)
.claude/settings.json New — PostToolUse hooks (ESLint + Ruff + Dart)
CLAUDE.md, STANDARDS.md, project-context.md Updated — tooling references

Test plan

  • npm run lint — ESLint runs on all 4 JS components (~328 existing errors, not config issues)
  • npm run format:check — Prettier checks pass on all 4 JS components
  • npm run lint:py — Ruff checks Python code (92 existing errors)
  • npm run format:py:check — Ruff format checks Python code (14 files to reformat)
  • npm run lint:dartdart analyze runs on Flutter project (3908 issues, mostly missing deps)
  • npm run format:dart:checkdart format checks (64 files to reformat)
  • Hook ESLint on .js — pipe-tested, fires correctly
  • Hook Ruff on .py — pipe-tested, fires correctly
  • Hook Dart on .dart — pipe-tested, fires correctly

Note

Existing lint errors (~328 JS, 4.RAG_System Python, 3908 Dart) are not fixed in this MR — only tooling configuration is committed. Lint error fixes will be addressed in separate MRs.

Closes #412 (closed) Closes #449 (closed) Closes #493 (closed)

Edited by Jérôme Revillard

Merge request reports

Loading