Description
Arduino IDE 2.3.10's Auto Format feature (Ctrl/Cmd+T) uses ClangFormat under the hood. Currently the project relies on the IDE's default formatting style, which does not match the formatting rules required by The Norm Version 3 (42 School coding standard).
We need a project-local .clang-format file so that Auto Format produces Norm-compliant output for everyone working on this project, without each contributor having to change their own global IDE settings.
Goal
Create a .clang-format file, placed at the root of the sketch/project, that:
Notes / Constraints
- A custom
.clang-format file completely overrides Arduino's default configuration rather than merging with it. Any option not explicitly set will fall back to ClangFormat's own default, not Arduino's default — so double check every relevant option is set explicitly rather than assuming it inherits sane Arduino defaults.
- Since The Norm has some rules ClangFormat cannot express 1:1 (e.g. certain 42-specific naming or structural rules), those gaps should be listed explicitly in the PR description so reviewers know what still needs manual checking.
- You absolutely may use AI for completing this task, but test that the result works as intended before submitting a Pull Request.
Reference: Arduino's own default .clang-format
Use this as the starting point rather than an empty file, then adjust options to match The Norm v3:
https://raw.githubusercontent.com/arduino/tooling-project-assets/main/other/clang-format-configuration/.clang-format
Reference: Arduino default config file location on disk
For comparison / testing against what the IDE uses out of the box (embedded/global default), the relevant Arduino config and data folders are:
| OS |
Config folder (.arduinoIDE) |
Data folder (Arduino15) |
| macOS |
~/.arduinoIDE |
~/Library/Arduino15 |
| Windows |
C:\Users\<username>\.arduinoIDE |
C:\Users\<username>\AppData\Local\Arduino15 |
| Ubuntu / Linux |
~/.arduinoIDE |
~/.arduino15 |
A global .clang-format placed in either the config or data folder above is used whenever no sketch-local .clang-format is present. For this project we want the file at the sketch root, since that takes precedence over any global configuration.
Reference: Arduino tutorial
Official step-by-step guide — "Customizing the Auto Formatter Feature":
https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-customize-auto-formatter
Acceptance Criteria
.clang-format file exists at the project/sketch root
- Running Auto Format (
Ctrl/Cmd+T) on a .ino, .cpp, and .h file each produces output matching The Norm v3
- File is documented (short comment header or README note) explaining it's derived from Arduino's default and tailored to The Norm v3
Description
Arduino IDE 2.3.10's Auto Format feature (
Ctrl/Cmd+T) uses ClangFormat under the hood. Currently the project relies on the IDE's default formatting style, which does not match the formatting rules required by The Norm Version 3 (42 School coding standard).We need a project-local
.clang-formatfile so that Auto Format produces Norm-compliant output for everyone working on this project, without each contributor having to change their own global IDE settings.Goal
Create a
.clang-formatfile, placed at the root of the sketch/project, that:.inofiles.cppfiles.hfiles.clang-formattakes precedence over any global configuration)Notes / Constraints
.clang-formatfile completely overrides Arduino's default configuration rather than merging with it. Any option not explicitly set will fall back to ClangFormat's own default, not Arduino's default — so double check every relevant option is set explicitly rather than assuming it inherits sane Arduino defaults.Reference: Arduino's own default
.clang-formatUse this as the starting point rather than an empty file, then adjust options to match The Norm v3:
https://raw.githubusercontent.com/arduino/tooling-project-assets/main/other/clang-format-configuration/.clang-format
Reference: Arduino default config file location on disk
For comparison / testing against what the IDE uses out of the box (embedded/global default), the relevant Arduino config and data folders are:
.arduinoIDE)Arduino15)~/.arduinoIDE~/Library/Arduino15C:\Users\<username>\.arduinoIDEC:\Users\<username>\AppData\Local\Arduino15~/.arduinoIDE~/.arduino15A global
.clang-formatplaced in either the config or data folder above is used whenever no sketch-local.clang-formatis present. For this project we want the file at the sketch root, since that takes precedence over any global configuration.Reference: Arduino tutorial
Official step-by-step guide — "Customizing the Auto Formatter Feature":
https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-customize-auto-formatter
Acceptance Criteria
.clang-formatfile exists at the project/sketch rootCtrl/Cmd+T) on a.ino,.cpp, and.hfile each produces output matching The Norm v3