Principle:MarketSquare Robotframework browser Code Quality Enforcement
Overview
The robotframework-browser project enforces code quality across three languages -- Python, TypeScript, and Robot Framework -- using automated linting, formatting, and type-checking tools. Both check mode (for CI validation) and fix mode (for developer convenience) are supported, ensuring that code quality standards are maintained consistently across the entire codebase.
Core Concept
In a polyglot project, code quality enforcement must cover all languages involved. A single inv lint command runs all quality checks in sequence, and individual language-specific tasks are available for targeted checking. The tools operate in two modes:
- Check mode (default) -- Reports violations without modifying files; used in CI to gate merges
- Fix mode (explicit) -- Automatically corrects violations where possible; used during development
Python Quality Tools
Python code quality is enforced by three complementary tools:
Ruff (Format + Lint)
Ruff is a fast Python linter and formatter (written in Rust) that replaces traditional tools like flake8, isort, and black:
ruff format-- Enforces consistent code formatting (indentation, line length, quote style, etc.)- In check mode:
ruff format --checkreports formatting violations - In fix mode:
ruff formatauto-formats files
- In check mode:
ruff check-- Checks for code quality issues (unused imports, style violations, potential bugs)- In fix mode:
ruff check --fixauto-fixes simple violations
- In fix mode:
Both commands use configuration from pyproject.toml and target:
Browser/(main library source)bootstrap.py(bootstrap script)tasks.py(build tasks)utest/(unit tests)browser_batteries/(BrowserBatteries package)
Mypy (Type Checking)
Mypy performs static type checking on Python code:
- Configured via
Browser/mypy.ini - Targets
Browser/,bootstrap.py, andbrowser_batteries/ - Excludes the
.venv/directory - Catches type errors, missing return types, incompatible assignments, and other type-related issues
TypeScript Quality Tools
ESLint
ESLint checks TypeScript code in the Node.js portion of the project:
- Runs via
npm run lint - Targets
.tsfiles in thenode/directory - Supports incremental linting: skips if no
.tsfiles have changed since last lint (tracked via timestamp file) - Can be forced with
--forceflag
Robot Framework Quality Tools
Robocop
Robocop is a formatter for Robot Framework test files:
- Runs with
robocop formatcommand - Configured via
pyproject.toml - Targets the
atest/directory - In CI mode: adds
--check --diffflags to report violations without modifying files - Excludes specific files that are intentionally non-standard (e.g., tidy-transformer test files)
Composite Lint Task
The lint task is a composite that depends on all three language-specific tasks:
lint
├── lint_python (ruff format + ruff check + mypy)
├── lint_node (eslint via npm run lint)
└── lint_robot (robocop format)
Running inv lint executes all three in dependency order.
CI Integration
In CI environments (detected via the GITHUB_WORKFLOW environment variable):
- Ruff runs in check mode (no auto-fixing)
- Robocop runs with
--check --diff(reports violations and shows diffs) - ESLint runs normally (always in check mode)
- Any failure causes the CI pipeline to fail
Domains
- Code_Quality -- The primary purpose is maintaining code quality standards
- Development_Tooling -- These are developer productivity tools integrated into the build system
Implemented By
Related Topics
- MarketSquare_Robotframework_browser_Inv_Lint -- Implementation details of the lint tasks
- MarketSquare_Robotframework_browser_Test_Execution -- Testing complements linting for quality assurance
- MarketSquare_Robotframework_browser_Project_Build_Pipeline -- Linting is part of the overall development workflow