diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000000..0972d86083276c --- /dev/null +++ b/.clang-format @@ -0,0 +1,111 @@ +# # Defines the Google C++ style for automatic reformatting. +# # http://clang.llvm.org/docs/ClangFormatStyleOptions.html +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: InlineOnly +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 79 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeCategories: + - Regex: '^' + Priority: 2 + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakAssignment: 10 +PenaltyBreakBeforeFirstCallParameter: 20 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Auto +TabWidth: 8 +UseTab: Never +# ... + diff --git a/.gitignore b/.gitignore index 922ef6733e6816..9d13ba4647b1ff 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ !.mailmap !.nycrc !.remarkrc +!.clang-format core vgcore.* diff --git a/Makefile b/Makefile index 4e974903a93ebd..fe3e512f426e58 100644 --- a/Makefile +++ b/Makefile @@ -949,6 +949,18 @@ bench: bench-net bench-http bench-fs bench-tls bench-ci: bench +CLANG_FORMAT = $(NODE) ./node_modules/.bin/clang-format -style=file -i + +format: + mkdir -p node_modules + if [ ! -d node_modules/clang-format ]; then \ + ./node ./deps/npm install clang-format --no-save --no-package-lock; fi + $(CLANG_FORMAT) --glob=src/**/*.cc + $(CLANG_FORMAT) --glob=src/**/*.h + # $(CLANG_FORMAT) --glob=test/**/*.cc + # $(CLANG_FORMAT) --glob=test/**/*.c + # $(CLANG_FORMAT) --glob=test/**/*.h + lint-md-clean: $(RM) -r tools/remark-cli/node_modules $(RM) -r tools/remark-preset-lint-node/node_modules diff --git a/src/node_root_certs.h b/src/node_root_certs.h index 22f48e03fdf0e9..3b47f9b2db5450 100644 --- a/src/node_root_certs.h +++ b/src/node_root_certs.h @@ -1,3 +1,4 @@ +// clang-format off #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS /* GlobalSign Root CA */ @@ -3944,3 +3945,4 @@ "8W0jq5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=\n" "-----END CERTIFICATE-----\n", #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS +// clang-format on