Linting and Formatting
The Education Benchmarking and Insights platform is a monorepo consisting of multiple modules written in different languages. To maintain code quality and consistency across these diverse stacks, we employ several language-specific linting and formatting tools.
This document serves as the single source of truth for code style enforcement.
Centralized Enforcement (Pre-commit Hooks & CI)
Most of our code style rules are enforced automatically using pre-commit hooks and our central Azure DevOps CI pipelines (specifically the pr-compliance-checks workflow).
If a formatting check fails during a Pull Request build, check the pipeline logs to see which tool flagged the issue and apply the required fixes locally before pushing again.
Markdown (All Modules)
We use markdownlint-cli2 to ensure consistent formatting across all documentation and README files in the repository.
- Configuration: The rules are centrally defined in the root
.markdownlint-cli2.jsoncfile. This configures exceptions (like allowing inline HTML where necessary) and ignores certain directories (likenode_modulesandterraform). - Enforcement: Run automatically via the
markdownlint-cli2pre-commit hook. - Manual Execution: Run
pre-commit run markdownlint-cli2 --all-filesfrom the repository root, or runnpx markdownlint-cli2 "**/*.md". - IDE Integration (Recommended):
- VS Code: Install the
DavidAnson.vscode-markdownlintextension. This will automatically highlight markdown violations in your editor as you type based on the root configuration file.
- VS Code: Install the
C# (.NET Backend & Infrastructure)
For the web, platform, and core-infrastructure modules, we use standard .NET formatting tools.
- Configuration: Formatting rules are governed by standard
.editorconfigfiles located in the respective module roots (e.g.,web/.editorconfig,platform/.editorconfig). - Enforcement: Enforced in the CI pipelines via the
dotnet formatcommand. - Manual Execution: Run
dotnet formatfrom the respective module root directory (web/,platform/, orcore-infrastructure/). - IDE Integration (Recommended):
- Rider / Visual Studio: Both natively support
.editorconfig. Formatting on save or using the built-in “Reformat Code” shortcut will automatically apply these rules. - See Rider Configuration for more details.
- Rider / Visual Studio: Both natively support
TypeScript & JavaScript (Front-end Components & Web)
For the Vue.js (Web module) and React (Front-end Components module) front-end code bases, we use ESLint and Prettier.
- Configuration:
- ESLint configuration can be found in
front-end-components/eslint.config.mjsandweb/src/Web.App/package.json(or ESLint config files). - Prettier rules are defined locally to the projects.
- ESLint configuration can be found in
- Enforcement: Run locally using NPM scripts. Ensure your code passes
npm run lintbefore committing. - Manual Execution: Run the following commands from
front-end-components/orweb/src/Web.App/:npm run lintto check for issues.npm run lint:fixto automatically fix issues.
- IDE Integration (Recommended):
- VS Code: Install the
dbaeumer.vscode-eslintandesbenp.prettier-vscodeextensions. Configure VS Code to format on save using Prettier as the default formatter.
- VS Code: Install the
Python (Data Pipeline)
For the data engineering components in the data-pipeline module, we use Black and isort.
- Enforcement: Black formatting is executed automatically via pre-commit hooks. Note that our pre-commit hook is configured with the
--checkflag. This means it will fail the commit if formatting is incorrect rather than silently modifying your files, encouraging developers to run the formatter themselves. isort is available for manual execution. - Manual Execution: Run the following commands from the
data-pipeline/directory:make lintto automatically format files using Black and isort.make lint-checkto verify formatting without modifying files.
- IDE Integration (Recommended):
- VS Code: Install the
ms-python.black-formatterandms-python.isortextensions. - PyCharm / IntelliJ: Configure Black as an external tool or use the native Black integration to format on save.
- VS Code: Install the
Terraform (Infrastructure)
For our Infrastructure as Code, we use the built-in Terraform formatting tools.
- Enforcement: Enforced in CI pipelines.
- Manual Execution: Run
terraform fmt -recursivefrom the root of the repository or within any specific module containing Terraform files (e.g.,core-infrastructure/terraform/).