From d709d34c4d332db7a2d70f4aba8295c179414f74 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Thu, 14 Mar 2024 09:12:29 -0700 Subject: [PATCH] [lint] Add clang-format rule for header sorting --- .clang-format | 74 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 8 deletions(-) diff --git a/.clang-format b/.clang-format index 59e5058c91260..a92f0626b1ed0 100644 --- a/.clang-format +++ b/.clang-format @@ -53,14 +53,72 @@ ForEachMacros: [ foreach, Q_FOREACH ] # Sort headers by main include file (implicit priority 0), # then project and private includes, then system headers IncludeCategories: - - Regex: '^<([a-z|_]+)>' # standard library headers - Priority: 1 - - Regex: '^(<[A-z]+)' # dependency headers - Priority: 2 - - Regex: '^(<|")dart/' # DART headers - Priority: 3 - - Regex: '^".*' # headers relative to this project - Priority: 4 + - Regex: '^".*\.h(pp)?"$' # headers relative to this project + Priority: 1 + + # DART headers + - Regex: '^$' + Priority: 10 + - Regex: '^$' + Priority: 20 + - Regex: '^$' + Priority: 21 + - Regex: '^$' + Priority: 22 + - Regex: '^$' + Priority: 23 + - Regex: '^$' + Priority: 24 + - Regex: '^$' + Priority: 25 + - Regex: '^$' + Priority: 26 + - Regex: '^$' + Priority: 27 + - Regex: '^$' + Priority: 28 + - Regex: '^$' + Priority: 29 + - Regex: '^$' + Priority: 30 + - Regex: '^$' + Priority: 31 + - Regex: '^$' + Priority: 32 + - Regex: '^$' + Priority: 33 + - Regex: '^$' + Priority: 34 + + # 3rd-party headers + - Regex: '^<.*\.h(pp)?>$' + Priority: 50 + - Regex: '^<.*\/.*>$' + Priority: 50 + + # C++ standard library headers, then C + # TODO(JS): Add when new C++ STL header begins with "c" is found + - Regex: "^$" + Priority: 100 + - Regex: "^$" + Priority: 100 + - Regex: "^$" + Priority: 100 + - Regex: "^$" + Priority: 100 + - Regex: "^$" + Priority: 100 + - Regex: "^$" + Priority: 100 + - Regex: "^$" + Priority: 100 + - Regex: "^$" # C standard library headers + Priority: 110 + - Regex: "^<([a-z|_]+)>$" + Priority: 100 + + - Regex: ".*" + Priority: 999 IndentCaseLabels: true IndentPPDirectives: BeforeHash IndentFunctionDeclarationAfterType: false