Skip to content

Commit

Permalink
chore: update lint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo Cipolleschi committed Oct 12, 2022
1 parent 90faf0f commit 16c3646
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 68 deletions.
97 changes: 60 additions & 37 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,49 +1,54 @@
# The primary clang-format config file.
# TODO(afuller): Set these settings when they aren't broken:
# - AllowShortBlocksOnASingleLine: Empty
---
AccessModifierOffset: -1
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: false
AlignEscapedNewlines: Left
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ]
DisableFormat: false
FixNamespaceComments: true
ForEachMacros:
- FOR_EACH
- FOR_EACH_R
- FOR_EACH_RANGE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<.*\.h(pp)?>'
Priority: 1
Expand All @@ -52,40 +57,58 @@ IncludeCategories:
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentWidth: 2
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
---
Language: ObjC
ColumnLimit: 120
BreakBeforeBraces: WebKit
SpaceBeforeSquareBrackets: false
Standard: Latest
TabWidth: 8
UseCRLF: false
UseTab: Never
...
2 changes: 0 additions & 2 deletions Libraries/AppDelegate/RCTAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>


#endif

/**
Expand Down
59 changes: 30 additions & 29 deletions Libraries/Text/TextInput/RCTBaseTextInputView.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,47 @@

NS_ASSUME_NONNULL_BEGIN

@interface RCTBaseTextInputView : RCTView <RCTBackedTextInputDelegate>
@interface RCTBaseTextInputView : RCTView<RCTBackedTextInputDelegate>

- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithBridge:(RCTBridge*)bridge NS_DESIGNATED_INITIALIZER;

- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder *)decoder NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder*)decoder NS_UNAVAILABLE;
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;

@property (nonatomic, readonly) UIView<RCTBackedTextInputViewProtocol> *backedTextInputView;
@property(nonatomic, readonly)
UIView<RCTBackedTextInputViewProtocol>* backedTextInputView;

@property (nonatomic, strong, nullable) RCTTextAttributes *textAttributes;
@property (nonatomic, assign) UIEdgeInsets reactPaddingInsets;
@property (nonatomic, assign) UIEdgeInsets reactBorderInsets;
@property(nonatomic, strong, nullable) RCTTextAttributes* textAttributes;
@property(nonatomic, assign) UIEdgeInsets reactPaddingInsets;
@property(nonatomic, assign) UIEdgeInsets reactBorderInsets;

@property (nonatomic, copy, nullable) RCTDirectEventBlock onContentSizeChange;
@property (nonatomic, copy, nullable) RCTDirectEventBlock onSelectionChange;
@property (nonatomic, copy, nullable) RCTDirectEventBlock onChange;
@property (nonatomic, copy, nullable) RCTDirectEventBlock onChangeSync;
@property (nonatomic, copy, nullable) RCTDirectEventBlock onTextInput;
@property (nonatomic, copy, nullable) RCTDirectEventBlock onScroll;
@property(nonatomic, copy, nullable) RCTDirectEventBlock onContentSizeChange;
@property(nonatomic, copy, nullable) RCTDirectEventBlock onSelectionChange;
@property(nonatomic, copy, nullable) RCTDirectEventBlock onChange;
@property(nonatomic, copy, nullable) RCTDirectEventBlock onChangeSync;
@property(nonatomic, copy, nullable) RCTDirectEventBlock onTextInput;
@property(nonatomic, copy, nullable) RCTDirectEventBlock onScroll;

@property (nonatomic, assign) NSInteger mostRecentEventCount;
@property (nonatomic, assign, readonly) NSInteger nativeEventCount;
@property (nonatomic, assign) BOOL autoFocus;
@property (nonatomic, copy) NSString *submitBehavior;
@property (nonatomic, assign) BOOL selectTextOnFocus;
@property (nonatomic, assign) BOOL clearTextOnFocus;
@property (nonatomic, assign) BOOL secureTextEntry;
@property (nonatomic, copy) RCTTextSelection *selection;
@property (nonatomic, strong, nullable) NSNumber *maxLength;
@property (nonatomic, copy, nullable) NSAttributedString *attributedText;
@property (nonatomic, copy) NSString *inputAccessoryViewID;
@property (nonatomic, assign) UIKeyboardType keyboardType;
@property (nonatomic, assign) BOOL showSoftInputOnFocus;
@property(nonatomic, assign) NSInteger mostRecentEventCount;
@property(nonatomic, assign, readonly) NSInteger nativeEventCount;
@property(nonatomic, assign) BOOL autoFocus;
@property(nonatomic, copy) NSString* submitBehavior;
@property(nonatomic, assign) BOOL selectTextOnFocus;
@property(nonatomic, assign) BOOL clearTextOnFocus;
@property(nonatomic, assign) BOOL secureTextEntry;
@property(nonatomic, copy) RCTTextSelection* selection;
@property(nonatomic, strong, nullable) NSNumber* maxLength;
@property(nonatomic, copy, nullable) NSAttributedString* attributedText;
@property(nonatomic, copy) NSString* inputAccessoryViewID;
@property(nonatomic, assign) UIKeyboardType keyboardType;
@property(nonatomic, assign) BOOL showSoftInputOnFocus;

/**
Sets selection intext input if both start and end are within range of the text input.
Sets selection intext input if both start and end are within range of the text
input.
**/
- (void)setSelectionStart:(NSInteger)start
selectionEnd:(NSInteger)end;
- (void)setSelectionStart:(NSInteger)start selectionEnd:(NSInteger)end;

@end

Expand Down
18 changes: 18 additions & 0 deletions packages/react-native-bots/dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
const {danger, fail, /*message,*/ warn} = require('danger');
const includes = require('lodash.includes');
const eslint = require('@seadub/danger-plugin-eslint');
const {execSync} = require('child_process');

const isFromPhabricator =
danger.github.pr.body &&
Expand Down Expand Up @@ -110,3 +111,20 @@ if (isMergeRefStable) {
}

eslint.default();

const extensions = new Set(['h', 'cpp', 'm', 'mm']);
const clangFiles = danger.git.modified_files.filter(filename => {
const fileExt = filename.split('.').pop();
return extensions.has(fileExt);
});
if (clangFiles.length > 0) {
const dryRunCommand = `npx clang-format -n ${clangFiles.join(' ')}`;
const inPlaceCommand = `npx clang-format -i ${clangFiles.join(' ')}`;
const output = execSync(dryRunCommand);

if (output.length > 0) {
fail(`There are some C++ or Objective-C files that are malformed.
Please run the following command and amend your commit:
${inPlaceCommand}`);
}
}

0 comments on commit 16c3646

Please sign in to comment.