Skip to content

Commit 39dd3f4

Browse files
authored
Add clang-format and markdownlint (#9)
1 parent 5054b8e commit 39dd3f4

7 files changed

Lines changed: 436 additions & 244 deletions

File tree

.clang-format

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# time-filter clang-format configuration
2+
3+
Language: Cpp
4+
Standard: c++20
5+
6+
# Base style
7+
BasedOnStyle: Google
8+
9+
# Indentation
10+
IndentWidth: 4
11+
TabWidth: 4
12+
UseTab: Never
13+
ContinuationIndentWidth: 4
14+
IndentCaseLabels: true
15+
IndentPPDirectives: None
16+
NamespaceIndentation: None
17+
18+
# Line width
19+
ColumnLimit: 100
20+
21+
# Braces
22+
BreakBeforeBraces: Attach
23+
Cpp11BracedListStyle: true
24+
25+
# Alignment
26+
AlignAfterOpenBracket: Align
27+
AlignConsecutiveAssignments: false
28+
AlignConsecutiveDeclarations: false
29+
AlignEscapedNewlines: Left
30+
AlignOperands: true
31+
AlignTrailingComments: true
32+
33+
# Short forms
34+
AllowShortBlocksOnASingleLine: Empty
35+
AllowShortCaseLabelsOnASingleLine: false
36+
AllowShortFunctionsOnASingleLine: Empty
37+
AllowShortIfStatementsOnASingleLine: Never
38+
AllowShortLoopsOnASingleLine: false
39+
AllowShortLambdasOnASingleLine: All
40+
41+
# Breaking
42+
AlwaysBreakAfterReturnType: None
43+
AlwaysBreakBeforeMultilineStrings: false
44+
AlwaysBreakTemplateDeclarations: Yes
45+
BinPackArguments: true
46+
BinPackParameters: true
47+
BreakBeforeBinaryOperators: None
48+
BreakBeforeTernaryOperators: true
49+
BreakConstructorInitializers: BeforeColon
50+
BreakInheritanceList: BeforeColon
51+
BreakStringLiterals: true
52+
53+
# Constructor initializers
54+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
55+
ConstructorInitializerIndentWidth: 4
56+
57+
# Spaces
58+
SpaceAfterCStyleCast: false
59+
SpaceAfterLogicalNot: false
60+
SpaceAfterTemplateKeyword: true
61+
SpaceBeforeAssignmentOperators: true
62+
SpaceBeforeCpp11BracedList: false
63+
SpaceBeforeCtorInitializerColon: true
64+
SpaceBeforeInheritanceColon: true
65+
SpaceBeforeParens: ControlStatements
66+
SpaceBeforeRangeBasedForLoopColon: true
67+
SpaceInEmptyBlock: false
68+
SpaceInEmptyParentheses: false
69+
SpacesBeforeTrailingComments: 2
70+
SpacesInAngles: false
71+
SpacesInCStyleCastParentheses: false
72+
SpacesInContainerLiterals: false
73+
SpacesInParentheses: false
74+
SpacesInSquareBrackets: false
75+
76+
# Pointer/Reference alignment
77+
DerivePointerAlignment: false
78+
PointerAlignment: Left
79+
80+
# Include sorting
81+
IncludeBlocks: Regroup
82+
IncludeCategories:
83+
# Project headers (quoted)
84+
- Regex: '^"'
85+
Priority: 1
86+
# Standard library headers
87+
- Regex: '^<[a-z_]+>'
88+
Priority: 3
89+
# Other headers
90+
- Regex: '.*'
91+
Priority: 2
92+
SortIncludes: true
93+
94+
# Other
95+
AccessModifierOffset: -4
96+
CompactNamespaces: false
97+
FixNamespaceComments: true
98+
MaxEmptyLinesToKeep: 1
99+
ReflowComments: true
100+
SortUsingDeclarations: true

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: CI
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
pre-commit:
19+
name: Pre-commit checks
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23+
24+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
25+
with:
26+
python-version: '3.12'
27+
28+
- uses: esphome/pre-commit-action@43cd1109c09c544d97196f7730ee5b2e0cc6d81e # v3.0.1 fork with pinned actions/cache
29+
30+
ci:
31+
name: CI
32+
needs: [pre-commit]
33+
runs-on: ubuntu-latest
34+
if: always()
35+
steps:
36+
- name: Verify all jobs passed
37+
run: |
38+
if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
39+
echo "One or more jobs failed or were cancelled"
40+
exit 1
41+
fi

.markdownlint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Markdownlint configuration
2+
default: true
3+
MD013: false # Disable line length limit

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
# See https://pre-commit.com for more information
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v5.0.0
7+
hooks:
8+
- id: end-of-file-fixer
9+
- id: trailing-whitespace
10+
11+
- repo: https://github.com/pre-commit/mirrors-clang-format
12+
rev: v18.1.8
13+
hooks:
14+
- id: clang-format
15+
types_or: [c, c++]
16+
# Only format our own code, not submodules or build directories
17+
files: ^cpp/
18+
exclude: (build/|\.pio/)
19+
20+
- repo: https://github.com/igorshubovych/markdownlint-cli
21+
rev: v0.42.0
22+
hooks:
23+
- id: markdownlint-fix

0 commit comments

Comments
 (0)