Skip to content

Commit

Permalink
Bulk detect/correct (most of the) typos and misspells in RN core code
Browse files Browse the repository at this point in the history
Summary:
## Changelog:
[Internal] -

While merging a Contributor PR in D43816768, I got curious whether such things as detecting/fixing typos could be automated.

There is a tool called [typos](https://github.com/crate-ci/typos), which, as it turns out, works very well on source code files.

The amount of false positives was minimal, most of the suggestions were valid ones.

And the total amount of typos found and fixed was **more than 300**, which is... quite a bit :)

### Methodology

* Run `typos` separately on `ReactCommon`, `Libraries`, `React`, `ReactAndroid` and `scripts` folders inside `packages/react-native`, e.g.:
```
$ typos -w --config ~/tmp/_typos.toml ~/fbsource/xplat/js/react-native-github/packages/react-native/ReactAndroid
```

Contents of the `_typos.toml` config file:
```
[default.extend-words]
collapsable = "collapsable"
NDK = "NDK"
inout = "inout"
```

(yeah, it really didn't like the "collapsable" word, for some reason ;))
* Inspect all the changes manually and revert false positives (as mentioned, their amount was minimal)

Note that most of the changes are inside things like comments and error messages, however there are a few among identifier name fixes (`typos` is actually quite smart at understanding naming conventions in code) - I kept the suggestions in cases that are local and not part of a public API. There are also misspelled file name changes in a couple of cases.

Reviewed By: NickGerleman

Differential Revision: D44172494

fbshipit-source-id: 86e27edbbb99e09135e3cdd5d7cea8ffeb8307f4
  • Loading branch information
rshest authored and facebook-github-bot committed Mar 20, 2023
1 parent 9678900 commit b9c64f3
Show file tree
Hide file tree
Showing 119 changed files with 186 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,8 @@ export default {
assertNativeAnimatedModule,
shouldUseNativeDriver,
transformDataType,
// $FlowExpectedError[unsafe-getters-setters] - unsafe getter lint suppresion
// $FlowExpectedError[missing-type-arg] - unsafe getter lint suppresion
// $FlowExpectedError[unsafe-getters-setters] - unsafe getter lint suppression
// $FlowExpectedError[missing-type-arg] - unsafe getter lint suppression
get nativeEventEmitter(): NativeEventEmitter {
if (!nativeEventEmitter) {
// $FlowFixMe[underconstrained-implicit-instantiation]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('Native Animated', () => {
);
});

it('shoud map AnimatedValueXY', () => {
it('should map AnimatedValueXY', () => {
const value = new Animated.ValueXY({x: 0, y: 0});
value.__makeNative();
const event = Animated.event([{nativeEvent: {state: value}}], {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
// 2) Update `onUpdateRef`.
// 3) Update listeners for `AnimatedEvent` props.
//
// Ideally, each of these would be separat "effects" so that they are not
// Ideally, each of these would be separate "effects" so that they are not
// unnecessarily re-run when irrelevant dependencies change. For example, we
// should be able to hoist all `AnimatedEvent` props and only do #3 if either
// the `AnimatedEvent` props change or `instance` changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @end
* ```
*
* All the methods implemented by the RCTAppDelegate can be overriden by your AppDelegate if you need to provide a
* All the methods implemented by the RCTAppDelegate can be overridden by your AppDelegate if you need to provide a
custom implementation.
* If you need to customize the default implementation, you can invoke `[super <method_name>]` and use the returned
object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

/**
* Interface for NativeModules which allows to augment NativeModules with type informations.
* Interface for NativeModules which allows to augment NativeModules with type information.
* See react-native-sensor-manager for example.
*/
interface NativeModulesStatic {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ type Props = $ReadOnly<{|
*/
unstable_pressDelay?: ?number,
/**
* Web to Native Accessibilty props
* Web to Native Accessibility props
* https://github.com/facebook/react-native/issues/34424
*/
'aria-label'?: ?string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ export type Props = $ReadOnly<{|
* On Android devices manufactured by Xiaomi with Android Q,
* when keyboardType equals 'email-address'this will be set
* in native to 'true' to prevent a system related crash. This
* will cause cursor to be diabled as a side-effect.
* will cause cursor to be disabled as a side-effect.
*
*/
caretHidden?: ?boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ export type Props = $ReadOnly<{|
* On Android devices manufactured by Xiaomi with Android Q,
* when keyboardType equals 'email-address'this will be set
* in native to 'true' to prevent a system related crash. This
* will cause cursor to be diabled as a side-effect.
* will cause cursor to be disabled as a side-effect.
*
*/
caretHidden?: ?boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {GestureResponderEvent} from '../../Types/CoreEventTypes';

/**
* //FIXME: need to find documentation on which component is a TTouchable and can implement that interface
* @see React.DOMAtributes
* @see React.DOMAttributes
*/
export interface Touchable {
onTouchStart?: ((event: GestureResponderEvent) => void) | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ let devToolsAgent: ?Agent;

export default function TraceUpdateOverlay(): React.Node {
const [overlayDisabled, setOverlayDisabled] = useState(false);
// This effect is designed to be explictly shown here to avoid re-subscribe from the same
// This effect is designed to be explicitly shown here to avoid re-subscribe from the same
// overlay component.
useEffect(() => {
if (!isNativeComponentReady) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export interface AccessibilityPropsIOS {
accessibilityViewIsModal?: boolean | undefined;

/**
* When accessibile is true, the system will invoke this function when the user performs the escape gesture (scrub with two fingers).
* When accessible is true, the system will invoke this function when the user performs the escape gesture (scrub with two fingers).
* @platform ios
*/
onAccessibilityEscape?: (() => void) | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
let resolvedPromise;

/**
* Polyfill for the microtask queuening API defined by WHATWG HTMP spec.
* Polyfill for the microtask queueing API defined by WHATWG HTML spec.
* https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask
*
* The method must queue a microtask to invoke @param {function} callback, and
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Core/setUpTimers.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if (global.RN$Bridgeless !== true) {
* as the Promise.
*/
if (hasPromiseQueuedToJSVM) {
// When promise queues to the JSVM microtasks queue, we shim the immedaite
// When promise queues to the JSVM microtasks queue, we shim the immediate
// APIs via `queueMicrotask` to maintain the backward compatibility.
polyfillGlobal(
'setImmediate',
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Image/RCTImageCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@interface RCTImageCache : NSObject <RCTImageCache>

RCT_EXTERN void RCTSetImageCacheLimits(
NSUInteger maxCachableDecodedImageSizeInBytes,
NSUInteger maxCacheableDecodedImageSizeInBytes,
NSUInteger imageCacheTotalCostLimit);

@end
8 changes: 4 additions & 4 deletions packages/react-native/Libraries/Image/RCTImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

#import <React/RCTImageUtils.h>

static NSUInteger RCTMaxCachableDecodedImageSizeInBytes = 2 * 1024 * 1024;
static NSUInteger RCTMaxCacheableDecodedImageSizeInBytes = 2 * 1024 * 1024;
static NSUInteger RCTImageCacheTotalCostLimit = 20 * 1024 * 1024;

void RCTSetImageCacheLimits(NSUInteger maxCachableDecodedImageSizeInBytes, NSUInteger imageCacheTotalCostLimit)
void RCTSetImageCacheLimits(NSUInteger maxCacheableDecodedImageSizeInBytes, NSUInteger imageCacheTotalCostLimit)
{
RCTMaxCachableDecodedImageSizeInBytes = maxCachableDecodedImageSizeInBytes;
RCTMaxCacheableDecodedImageSizeInBytes = maxCacheableDecodedImageSizeInBytes;
RCTImageCacheTotalCostLimit = imageCacheTotalCostLimit;
}

Expand Down Expand Up @@ -73,7 +73,7 @@ - (void)addImageToCache:(UIImage *)image forKey:(NSString *)cacheKey
return;
}
NSInteger bytes = image.reactDecodedImageBytes;
if (bytes <= RCTMaxCachableDecodedImageSizeInBytes) {
if (bytes <= RCTMaxCacheableDecodedImageSizeInBytes) {
[self->_decodedImageCache setObject:image forKey:cacheKey cost:bytes];
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Image/RCTImageView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ - (void)updateWithImage:(UIImage *)image
image = [image resizableImageWithCapInsets:_capInsets resizingMode:UIImageResizingModeStretch];
}

// Apply trilinear filtering to smooth out mis-sized images
// Apply trilinear filtering to smooth out missized images
_imageView.layer.minificationFilter = kCAFilterTrilinear;
_imageView.layer.magnificationFilter = kCAFilterTrilinear;

Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/Libraries/Inspector/DevtoolsOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default function DevtoolsOverlay({
[findViewForLocation],
);

const shouldSetResponser = useCallback(
const shouldSetResponder = useCallback(
(e: PressEvent): boolean => {
onResponderMove(e);
return true;
Expand All @@ -193,7 +193,7 @@ export default function DevtoolsOverlay({
onPointerUp: stopInspecting,
}
: {
onStartShouldSetResponder: shouldSetResponser,
onStartShouldSetResponder: shouldSetResponder,
onResponderMove: onResponderMove,
onResponderRelease: stopInspecting,
};
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/Libraries/Inspector/InspectorOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class InspectorOverlay extends React.Component<Props> {
this.props.onTouchPoint(locationX, locationY);
};

shouldSetResponser: (e: PressEvent) => boolean = (e: PressEvent): boolean => {
shouldSetResponder: (e: PressEvent) => boolean = (e: PressEvent): boolean => {
this.findViewForTouchEvent(e);
return true;
};
Expand All @@ -54,7 +54,7 @@ class InspectorOverlay extends React.Component<Props> {

return (
<View
onStartShouldSetResponder={this.shouldSetResponser}
onStartShouldSetResponder={this.shouldSetResponder}
onResponderMove={this.findViewForTouchEvent}
nativeID="inspectorOverlay" /* TODO: T68258846. */
style={[styles.inspector, {height: Dimensions.get('window').height}]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Handler = {
* other events from being processed in a timely manner.
*
* The "stall" time is defined as the amount of time in access of the acceptable
* threshold, which is typically around 100-200ms. So if the treshold is set to
* threshold, which is typically around 100-200ms. So if the threshold is set to
* 100 and a timer fires 150 ms later than it was scheduled because the event
* loop was tied up, that would be considered a 50ms stall.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Lists/FlatList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {

/**
* An array (or array-like list) of items to render. Other data types can be
* used by targetting VirtualizedList directly.
* used by targeting VirtualizedList directly.
*/
data: ArrayLike<ItemT> | null | undefined;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const React = require('react');
type RequiredProps<ItemT> = {|
/**
* An array (or array-like list) of items to render. Other data types can be
* used by targetting VirtualizedList directly.
* used by targeting VirtualizedList directly.
*/
data: ?$ArrayLike<ItemT>,
|};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ describe('LogBoxData', () => {
flushToObservers();
expect(observer.mock.calls.length).toBe(2);

// We expect observers to recieve the same Set object in sequential updates
// We expect observers to receive the same Set object in sequential updates
// so that it doesn't break memoization for components observing state.
expect(observer.mock.calls[0][0].logs).toBe(observer.mock.calls[1][0].logs);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export function parseLogBoxException(
}
// Most `console.error` calls won't have a componentStack. We parse them like
// regular logs which have the component stack burried in the message.
// regular logs which have the component stack buried in the message.
return {
level: 'error',
stack: error.stack,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/Libraries/LogBox/UI/LogBoxMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ function LogBoxMessage(props: Props): React.Node {
createUnderLength(key, prevPart);
}

const substititionPart = content.substr(
const substitutionPart = content.substr(
substitution.offset,
substitution.length,
);

createUnderLength(key + '.5', substititionPart, substitutionStyle);
createUnderLength(key + '.5', substitutionPart, substitutionStyle);
return substitution.offset + substitution.length;
}, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('LogBox', () => {
jest.mock('../Data/LogBoxData');
const mockError = new Error('Simulated error');

// Picking a random implemention detail to simulate throwing.
// Picking a random implementation detail to simulate throwing.
(LogBoxData.isMessageIgnored: any).mockImplementation(() => {
throw mockError;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ - (void)restoreDefaultValues
{
if (_managedByFabric) {
// Restoring to default values causes render of inconsistent state
// to the user because it isn't synchonised with Fabric's UIManager.
// to the user because it isn't synchronised with Fabric's UIManager.
return;
}
// Restore the default value for all props that were modified by this node.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let componentNameToExists: Map<string, boolean> = new Map();
* Unstable API. Do not use!
*
* This method returns if the component with name received as a parameter
* is registed in the native platform.
* is registered in the native platform.
*/
export function unstable_hasComponent(name: string): boolean {
let hasNativeComponent = componentNameToExists.get(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ - (void)scaleFontSizeToFitSize:(CGSize)size
while (true) {
[self scaleFontSizeWithRatio:ratio minimumFontSize:minimumFontSize maximumFontSize:maximumFontSize];

RCTTextSizeComparisonOptions comparsion = [self compareToSize:size thresholdRatio:0.01];
RCTTextSizeComparisonOptions comparison = [self compareToSize:size thresholdRatio:0.01];

if ((comparsion & RCTTextSizeComparisonWithinRange) && (comparsion & RCTTextSizeComparisonSmaller)) {
if ((comparison & RCTTextSizeComparisonWithinRange) && (comparison & RCTTextSizeComparisonSmaller)) {
return;
} else if (comparsion & RCTTextSizeComparisonSmaller) {
} else if (comparison & RCTTextSizeComparisonSmaller) {
bottomRatio = ratio;
lastRatioWhichFits = ratio;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ - (CGSize)contentSize
{
CGSize contentSize = super.contentSize;
CGSize placeholderSize = _placeholderView.isHidden ? CGSizeZero : self.placeholderSize;
// When a text input is empty, it actually displays a placehoder.
// When a text input is empty, it actually displays a placeholder.
// So, we have to consider `placeholderSize` as a minimum `contentSize`.
// Returning size DOES contain `textContainerInset` (aka `padding`).
return CGSizeMake(MAX(contentSize.width, placeholderSize.width), MAX(contentSize.height, placeholderSize.height));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@implementation RCTBaseTextInputView {
__weak RCTBridge *_bridge;
__weak id<RCTEventDispatcherProtocol> _eventDispatcher;
BOOL _hasInputAccesoryView;
BOOL _hasInputAccessoryView;
NSString *_Nullable _predictedText;
BOOL _didMoveToWindow;
}
Expand Down Expand Up @@ -626,18 +626,18 @@ - (void)setDefaultInputAccessoryView

// These keyboard types (all are number pads) don't have a "Done" button by default,
// so we create an `inputAccessoryView` with this button for them.
BOOL shouldHaveInputAccesoryView =
BOOL shouldHaveInputAccessoryView =
(keyboardType == UIKeyboardTypeNumberPad || keyboardType == UIKeyboardTypePhonePad ||
keyboardType == UIKeyboardTypeDecimalPad || keyboardType == UIKeyboardTypeASCIICapableNumberPad) &&
textInputView.returnKeyType == UIReturnKeyDone;

if (_hasInputAccesoryView == shouldHaveInputAccesoryView) {
if (_hasInputAccessoryView == shouldHaveInputAccessoryView) {
return;
}

_hasInputAccesoryView = shouldHaveInputAccesoryView;
_hasInputAccessoryView = shouldHaveInputAccessoryView;

if (shouldHaveInputAccesoryView) {
if (shouldHaveInputAccessoryView) {
UIToolbar *toolbarView = [UIToolbar new];
[toolbarView sizeToFit];
UIBarButtonItem *flexibleSpace =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ declare class EventSubscriptionVendor {
* Removes a bulk set of the subscriptions.
*
* @param eventType - Optional name of the event type whose
* registered supscriptions to remove, if null remove all subscriptions.
* registered subscriptions to remove, if null remove all subscriptions.
*/
removeAllSubscriptions(eventType?: string): void;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/Base/RCTBridge+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ RCT_EXTERN void RCTRegisterModule(Class);
- (void)registerModuleForFrameUpdates:(id<RCTBridgeModule>)module withModuleData:(RCTModuleData *)moduleData;

/**
* Dispatch work to a module's queue - this is also suports the fake RCTJSThread
* Dispatch work to a module's queue - this is also supports the fake RCTJSThread
* queue. Exposed for the RCTProfiler
*/
- (void)dispatchBlock:(dispatch_block_t)block queue:(dispatch_queue_t)queue;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/React/Base/RCTBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ RCT_EXTERN void RCTSetTurboModuleCleanupMode(RCTTurboModuleCleanupMode mode);
*
* All the interaction with the JavaScript context should be done using the bridge
* instance of the RCTBridgeModules. Modules will be automatically instantiated
* using the default contructor, but you can optionally pass in an array of
* using the default constructor, but you can optionally pass in an array of
* pre-initialized module instances if they require additional init parameters
* or configuration.
*/
Expand All @@ -87,7 +87,7 @@ RCT_EXTERN void RCTSetTurboModuleCleanupMode(RCTTurboModuleCleanupMode mode);
* The designated initializer. This creates a new bridge on top of the specified
* executor. The bridge should then be used for all subsequent communication
* with the JavaScript code running in the executor. Modules will be automatically
* instantiated using the default contructor, but you can optionally pass in an
* instantiated using the default constructor, but you can optionally pass in an
* array of pre-initialized module instances if they require additional init
* parameters or configuration.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@class RCTViewRegistry;

/**
RCTBridgeModuleDecorator contains instances that can be intialized with @synthesize
RCTBridgeModuleDecorator contains instances that can be initialized with @synthesize
in RCTBridgeModules. For the Fabric interop layer.
In Bridgeless, @synthesize ivars are passed from RCTBridgeModuleDecorator.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/Base/RCTRootContentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
- (instancetype)initWithFrame:(CGRect)frame
bridge:(RCTBridge *)bridge
reactTag:(NSNumber *)reactTag
sizeFlexiblity:(RCTRootViewSizeFlexibility)sizeFlexibility NS_DESIGNATED_INITIALIZER;
sizeFlexibility:(RCTRootViewSizeFlexibility)sizeFlexibility NS_DESIGNATED_INITIALIZER;

@end
Loading

0 comments on commit b9c64f3

Please sign in to comment.