Skip to content

Commit

Permalink
feat: spellcheck integration (#428)
Browse files Browse the repository at this point in the history
## 📜 Description

Added spellcheck to CI to exclude any spells in a project.

## 💡 Motivation and Context

I used spellcheck locally before, but just discovered a CI action and
thought it could be useful to add to CI to be sure that external
contributions are validated as well.

## 📢 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### CI

- added a job to detect spellchecks in the code base;

## 🤔 How Has This Been Tested?

Tested on CI 🙂 

## 📸 Screenshots (if appropriate):

<img width="1943" alt="image"
src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/fb386904-0880-4e1a-b030-eb042ad2110f">

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
  • Loading branch information
kirillzyusko authored Apr 26, 2024
1 parent 6ffa49d commit 64b2e21
Show file tree
Hide file tree
Showing 53 changed files with 278 additions and 73 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 🧙 Check spell

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
spellcheck:
runs-on: ubuntu-latest
name: 🔍 spellcheck
steps:
- uses: actions/checkout@v4
- uses: streetsidesoftware/cspell-action@v6
with:
files: "**/*"
root: "."
config: "./cspell.json"
inline: error
strict: true
use_cspell_files: false
incremental_files_only: false
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ - (void)testRendersWelcomeScreen
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
BOOL foundElement = NO;

__block NSString *redboxError = nil;
__block NSString *redBoxError = nil;
#ifdef DEBUG
RCTSetLogFunction(
^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
if (level >= RCTLogLevelError) {
redboxError = message;
redBoxError = message;
}
});
#endif

while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
while ([date timeIntervalSinceNow] > 0 && !foundElement && !redBoxError) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];

Expand All @@ -59,7 +59,7 @@ - (void)testRendersWelcomeScreen
RCTSetLogFunction(RCTDefaultLogFunction);
#endif

XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
XCTAssertNil(redBoxError, @"RedBox error: %@", redBoxError);
XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
}

Expand Down
4 changes: 2 additions & 2 deletions FabricExample/src/components/Message/data.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { MessageProps } from "./types";

export const history: MessageProps[] = [
{ text: "Hmmmm🤔" },
{ text: "It looks like it still will be laggy..." },
{ text: "Hmmm🤔" },
{ text: "It looks like it still will be choppy..." },
{ text: "But I don't know what should I try next" },
{ text: "Reanimated?", sender: true },
{ text: "A little bit disappointed 😔" },
Expand Down
2 changes: 1 addition & 1 deletion FabricExample/src/constants/screenNames.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export enum ScreenNames {
ANIMATED_EXAMPLE = "ANIMATED_EXAMPLE",
REANIMATED_CHAT = "REANIMATED_CHAT",
REANIMATED_CHAT_FLATLIST = "REANIMATED_CHAT_FLATLIST",
REANIMATED_CHAT_FLAT_LIST = "REANIMATED_CHAT_FLAT_LIST",
EVENTS = "EVENTS",
AWARE_SCROLL_VIEW = "AWARE_SCROLL_VIEW",
AWARE_SCROLL_VIEW_STICKY_FOOTER = "AWARE_SCROLL_VIEW_STICKY_FOOTER",
Expand Down
12 changes: 6 additions & 6 deletions FabricExample/src/navigation/ExamplesStack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import KeyboardAvoidingViewExample from "../../screens/Examples/KeyboardAvoiding
import LottieAnimation from "../../screens/Examples/Lottie";
import NonUIProps from "../../screens/Examples/NonUIProps";
import ReanimatedChat from "../../screens/Examples/ReanimatedChat";
import ReanimatedChatFlatlist from "../../screens/Examples/ReanimatedChatFlatlist";
import ReanimatedChatFlatList from "../../screens/Examples/ReanimatedChatFlatList";
import StatusBar from "../../screens/Examples/StatusBar";
import ToolbarExample from "../../screens/Examples/Toolbar";
import NativeStack from "../NestedStack";

export type ExamplesStackParamList = {
[ScreenNames.ANIMATED_EXAMPLE]: undefined;
[ScreenNames.REANIMATED_CHAT]: undefined;
[ScreenNames.REANIMATED_CHAT_FLATLIST]: undefined;
[ScreenNames.REANIMATED_CHAT_FLAT_LIST]: undefined;
[ScreenNames.EVENTS]: undefined;
[ScreenNames.AWARE_SCROLL_VIEW]: undefined;
[ScreenNames.AWARE_SCROLL_VIEW_STICKY_FOOTER]: undefined;
Expand All @@ -47,8 +47,8 @@ const options = {
[ScreenNames.REANIMATED_CHAT]: {
title: "Chat",
},
[ScreenNames.REANIMATED_CHAT_FLATLIST]: {
title: "Chat Flatlist",
[ScreenNames.REANIMATED_CHAT_FLAT_LIST]: {
title: "Chat FlatList",
},
[ScreenNames.EVENTS]: {
title: "Events",
Expand Down Expand Up @@ -105,8 +105,8 @@ const ExamplesStack = () => (
options={options[ScreenNames.REANIMATED_CHAT]}
/>
<Stack.Screen
name={ScreenNames.REANIMATED_CHAT_FLATLIST}
component={ReanimatedChatFlatlist}
name={ScreenNames.REANIMATED_CHAT_FLAT_LIST}
component={ReanimatedChatFlatList}
options={options[ScreenNames.REANIMATED_CHAT]}
/>
<Stack.Screen
Expand Down
6 changes: 3 additions & 3 deletions FabricExample/src/screens/Examples/Main/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const examples: Example[] = [
icons: "💬",
},
{
title: "Chat flatlist",
testID: "reanimated_chat_flatlist",
info: ScreenNames.REANIMATED_CHAT_FLATLIST,
title: "Chat FlatList",
testID: "reanimated_chat_flat_list",
info: ScreenNames.REANIMATED_CHAT_FLAT_LIST,
icons: "💬",
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const RenderItem: ListRenderItem<MessageProps> = ({ item, index }) => {
return <Message key={index} {...item} />;
};

function ReanimatedChatFlatlist() {
function ReanimatedChatFlatList() {
const { height } = useReanimatedKeyboardAnimation();

const fakeView = useAnimatedStyle(
Expand All @@ -42,4 +42,4 @@ function ReanimatedChatFlatlist() {
);
}

export default ReanimatedChatFlatlist;
export default ReanimatedChatFlatList;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const RenderItem: ListRenderItem<MessageProps> = ({ item, index }) => {
return <Message key={index} {...item} />;
};

function ReanimatedChatFlatlist() {
function ReanimatedChatFlatList() {
const { height } = useReanimatedKeyboardAnimation();

const fakeView = useAnimatedStyle(
Expand All @@ -42,4 +42,4 @@ function ReanimatedChatFlatlist() {
);
}

export default ReanimatedChatFlatlist;
export default ReanimatedChatFlatList;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import android.view.View
import androidx.annotation.RequiresApi

/**
* Call this everytime when using [ViewCompat.setOnApplyWindowInsetsListener]
* Call this every time when using [ViewCompat.setOnApplyWindowInsetsListener]
* to ensure that insets are always received.
* @see https://stackoverflow.com/a/61909205/9272042
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class IosInterpolator : Interpolator {
keyboardPosition: Int,
): Int {
if (
absoluteFingerPosition <= keyboardPosition || // user overscrolled keyboard
absoluteFingerPosition <= keyboardPosition || // user over scrolled keyboard
dy <= 0 // user scrolls up
) {
return dy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class KeyboardAnimationCallback(
// imitate iOS behavior and send two instant start/end events containing an info about new tag
// 1. onStart/onMove/onEnd can be still dispatched after, if keyboard change size (numeric -> alphabetic type)
// 2. event should be send only when keyboard is visible, since this event arrives earlier -> `tag` will be
// 100% included in onStart/onMove/onEnd lifecycles, but triggering onStart/onEnd several time
// 100% included in onStart/onMove/onEnd life cycles, but triggering onStart/onEnd several time
// can bring breaking changes
context.dispatchEvent(
view.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EdgeToEdgeReactViewGroup(private val reactContext: ThemedReactContext) : R
private var wasMounted = false
private var callback: KeyboardAnimationCallback? = null

// region View lifecycles
// region View life cycles
override fun onAttachedToWindow() {
super.onAttachedToWindow()

Expand Down
122 changes: 122 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"language": "en",
"words": [
"codegen",
"worklet",
"worklets",
"reactnativekeyboardcontroller",
"subview",
"subviews",
"superview",
"Kiryl",
"kirill",
"Ziusko",
"Zyusko",
"kirillzyusko",
"gorhom",
"Vladyslav",
"Hirbod",
"Rahman",
"Tawil",
"buildscript",
"uimanager",
"compat",
"keyboardcontroller",
"lateinit",
"robolectric",
"instancetype",
"androidx",
"swiftlint",
"detekt",
"docsearch",
"searchbox",
"oninteractive",
"classpath",
"keyboardcontrollerfabricexample",
"proguard",
"dynamicanimation",
"appcompat",
"viewmanagers",
"KITKAT",
"Millis",
"pixelmatch",
"systemui",
"loglevel",
"pngjs",
"swiperefreshlayout",
"cleartext",
"textinput",
"hermesc",
"workletized",
"workletization",
"RCTUI",
"XCUI",
"endregion",
"autoreleasepool",
"jsbundle",
"cocoapods",
"dimen",
"mtrl",
"mipmap",
"BROWSABLE",
"armeabi",
"NSURL",
"turbomodule",
"hhmm",
"sysui",
"unmock",
"gradlew",
"gifs",
"Werror",
"alloc",
"metaspace",
"rootproject",
"allprojects",
"infima",
"argb",
"dists",
"stdlib",
"inputmethod",
"unavatar",
"unfocus",
"soloader",
"iname",
"Srcs",
"xcconfig",
"ifdef",
"apks",
"Iframes",
"androiddebugkey",
"rnkcexample",
"jvmargs",
"autoskip",
"Preact",
"APPL",
"armv",
"BNDL",
"rnkcfabricexample",
"podspec",
"LIBCPP",
"CPLUSPLUSFLAGS",
"xcconfig",
"DKEYBOARD",
"DRCT",
"DFOLLY",
"upto",
"clazz",
"xcworkspace"
],
"ignorePaths": [
"node_modules",
"e2e/apks/",
"**/gradlew",
"**/gradlew.bat",
"**/*.pbxproj",
"**/*.xcscheme",
"**/*.xcworkspacedata",
"**/*.svg",
"**/*.storyboard",
"cspell.json"
],
"useGitignore": true
}
2 changes: 1 addition & 1 deletion docs/blog/2023-09-08-components/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The enhanced `KeyboardAvoidingView` offers smoother and more natural animations

### Backward Compatible and Seamless Integration

I understand the importance of maintaining compatibility with existing codebases and providing a smooth transition for React Native developers. With enhanced `KeyboardAvoidingView`, I've put compatibility at the forefront of design principles.
I understand the importance of maintaining compatibility with existing code bases and providing a smooth transition for React Native developers. With enhanced `KeyboardAvoidingView`, I've put compatibility at the forefront of design principles.

The `KeyboardAvoidingView` is crafted to seamlessly integrate with your existing React Native projects. It's a **drop-in** replacement for the default React Native `KeyboardAvoidingView` component. This means that you can start using an enhanced version without the need for extensive code modifications or rewrites.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const onInteractiveCode = (
<span>
If finger is released and keyboard animates to its final destination, then
the standard <code>onStart</code>/<code>onMove</code>/<code>onEnd</code>{" "}
lifecycles will be triggered.
life cycles will be triggered.
</span>
<div className="desktop">{onInteractiveCode}</div>

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/keyboard-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ keywords: [react-native-keyboard-controller, KeyboardProvider]

# KeyboardProvider

`KeyboardProvider` should wrap your app. Underhood it works with `KeyboardControllerView` to receive events during keyboard movements, maps these events to `Animated`/`Reanimated` values and store them in `context`.
`KeyboardProvider` should wrap your app. Under the hood it works with `KeyboardControllerView` to receive events during keyboard movements, maps these events to `Animated`/`Reanimated` values and store them in `context`.

## Props

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/recipes/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This library requires to wrap an app with `KeyboardProvider` component. It's nee
Library exposes `KeyboardControllerView` with `onKeyboardMove` method. This method is fired when keyboard frame is changed. `KeyboardProvider` automatically maps these events to `Animated.Value` and `Reanimated.SharedValue` and stores it in `context`.

:::info
Underhood `KeyboardControllerView` is a simple `View` with one additional `onKeyboardMove` callback method, so it inherits all props from plain `View`, such as `style`, etc.
Under the hood `KeyboardControllerView` is a simple `View` with one additional `onKeyboardMove` callback method, so it inherits all props from plain `View`, such as `style`, etc.
:::

Thus we have a single source of truth about keyboard position. Since values are stored in `context` we can use it in any component where we need them. Moreover, we can consume `context` values in class components as well as in hooks.
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"https": "HTTPS=true SSL_CRT_FILE=localhost.pem SSL_KEY_FILE=localhost-key.pem docusaurus start",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc"
"typescript": "tsc"
},
"dependencies": {
"@docusaurus/core": "3.1.1",
Expand Down
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-1.0.0/api/keyboard-provider.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# KeyboardProvider

`KeyboardProvider` should wrap your app. Underhood it works with `KeyboardControllerView` to receive events during keyboard movements, maps these events to `Animated`/`Reanimated` values and store them in `context`.
`KeyboardProvider` should wrap your app. Under the hood it works with `KeyboardControllerView` to receive events during keyboard movements, maps these events to `Animated`/`Reanimated` values and store them in `context`.

## Props

Expand Down
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-1.0.0/recipes/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This library requires to wrap an app with `KeyboardProvider` component. It's nee
Library exposes `KeyboardControllerView` with `onKeyboardMove` method. This method is fired when keyboard frame is changed. `KeyboardProvider` automatically maps these events to `Animated.Value` and `Reanimated.SharedValue` and stores it in `context`.

:::info
Underhood `KeyboardControllerView` is a simple `View` with one additional `onKeyboardMove` callback method, so it inherits all props from plain `View`, such as `style`, etc.
Under the hood `KeyboardControllerView` is a simple `View` with one additional `onKeyboardMove` callback method, so it inherits all props from plain `View`, such as `style`, etc.
:::

Thus we have a single source of truth about keyboard position. Since values are stored in `context` we can use it in any component where we need them. Moreover, we can consume `context` values in class components as well as in hooks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const onInteractiveCode = (
<span>
If finger is released and keyboard animates to its final destination, then
the standard <code>onStart</code>/<code>onMove</code>/<code>onEnd</code>{" "}
lifecycles will be triggered.
life cycles will be triggered.
</span>
<div className="desktop">{onInteractiveCode}</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ keywords: [react-native-keyboard-controller, KeyboardProvider]

# KeyboardProvider

`KeyboardProvider` should wrap your app. Underhood it works with `KeyboardControllerView` to receive events during keyboard movements, maps these events to `Animated`/`Reanimated` values and store them in `context`.
`KeyboardProvider` should wrap your app. Under the hood it works with `KeyboardControllerView` to receive events during keyboard movements, maps these events to `Animated`/`Reanimated` values and store them in `context`.

## Props

Expand Down
Loading

0 comments on commit 64b2e21

Please sign in to comment.