Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix lint errors

ammarahm-edd155ae7d77dd
diff --git a/.eslintignore b/.eslintignore
index 7a35a1735..112a41025 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -11,6 +11,7 @@ resources/
# mobile
apps/mobile/native/
apps/mobile/__tests__/
+apps/mobile/e2e/
# web
apps/web/public/an.js
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
index 46d716408..a9f69c49f 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
@@ -320,15 +320,7 @@ export const useEditor = (
loadImages();
}
},
- [
- commands,
- editorId,
- isDefaultEditor,
- loadContent,
- overlay,
- postMessage,
- reset
- ]
+ [commands, isDefaultEditor, loadContent, overlay, postMessage, reset]
);
const loadImages = () => {
diff --git a/apps/mobile/app/screens/search/search-bar.js b/apps/mobile/app/screens/search/search-bar.js
index 71512f574..211cc26fc 100644
--- a/apps/mobile/app/screens/search/search-bar.js
+++ b/apps/mobile/app/screens/search/search-bar.js
@@ -21,16 +21,11 @@ import React, { useEffect, useRef, useState } from "react";
import { View } from "react-native";
import { TextInput } from "react-native-gesture-handler";
import { IconButton } from "../../components/ui/icon-button";
-import {
- eSubscribeEvent,
- eUnSubscribeEvent,
- ToastEvent
-} from "../../services/event-manager";
+import { ToastEvent } from "../../services/event-manager";
import Navigation from "../../services/navigation";
import SearchService from "../../services/search";
import { useSearchStore } from "../../stores/use-search-store";
import { useThemeStore } from "../../stores/use-theme-store";
-import { eScrollEvent } from "../../utils/events";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
export const SearchBar = () => {
@@ -55,14 +50,6 @@ export const SearchBar = () => {
});
}, []);
- const onScroll = (event) => {};
- useEffect(() => {
- eSubscribeEvent(eScrollEvent, onScroll);
- return () => {
- eUnSubscribeEvent(eScrollEvent, onScroll);
- };
- }, []);
-
const onChangeText = (value) => {
setValue(value);
search(value);
diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index ea1667638..013a902a6 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -67,13 +67,6 @@ import { SettingSection } from "./types";
import { getTimeLeft } from "./user-section";
import { getVersion } from "react-native-device-info";
-const format = (ver: number) => {
- const parts = ver.toString().split("");
- return `v${parts[0]}.${parts[1]}.${
- parts[2]?.startsWith("0") ? "" : parts[2]
- }${!parts[3] ? "" : parts[3]} `;
-};
-
export const settingsGroups: SettingSection[] = [
{
id: "account",
diff --git a/apps/mobile/app/utils/index.js b/apps/mobile/app/utils/index.js
index 6639657bc..2066a6e49 100755
--- a/apps/mobile/app/utils/index.js
+++ b/apps/mobile/app/utils/index.js
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { AppState, Dimensions, NativeModules, Platform } from "react-native";
+import { Dimensions, NativeModules, Platform } from "react-native";
import {
beginBackgroundTask,
endBackgroundTask
diff --git a/apps/mobile/share/search.js b/apps/mobile/share/search.js
index 2e3ebffd5..43e5ea6c3 100644
--- a/apps/mobile/share/search.js
+++ b/apps/mobile/share/search.js
@@ -48,7 +48,8 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {
const insets =
Platform.OS === "android"
? { top: StatusBar.currentHeight }
- : useSafeAreaInsets();
+ : // eslint-disable-next-line react-hooks/rules-of-hooks
+ useSafeAreaInsets();
const onSelectItem = async (item) => {
if (item.locked) {
diff --git a/apps/mobile/share/share.js b/apps/mobile/share/share.js
index 621f7d41c..748b12343 100644
--- a/apps/mobile/share/share.js
+++ b/apps/mobile/share/share.js
@@ -48,6 +48,7 @@ import { getElevation } from "../app/utils";
import { eOnLoadNote } from "../app/utils/events";
import { Search } from "./search";
import { useShareStore } from "./store";
+import { useCallback } from "react";
const getLinkPreview = (url) => {
return getPreviewData(url, 5000);
};
@@ -207,7 +208,8 @@ const ShareView = ({ quicknote = false }) => {
const insets =
Platform.OS === "android"
? { top: StatusBar.currentHeight }
- : useSafeAreaInsets();
+ : // eslint-disable-next-line react-hooks/rules-of-hooks
+ useSafeAreaInsets();
const [showSearch, setShowSearch] = useState(false);
const [kh, setKh] = useState(0);
const editorRef = useRef();
@@ -251,7 +253,7 @@ const ShareView = ({ quicknote = false }) => {
return note;
};
- const loadData = async () => {
+ const loadData = useCallback(async () => {
try {
defaultNote.content.data = null;
setNote({ ...defaultNote });
@@ -282,7 +284,7 @@ const ShareView = ({ quicknote = false }) => {
console.error(e);
}
setLoadingIntent(false);
- };
+ }, [onLoad]);
useEffect(() => {
(async () => {
@@ -291,7 +293,7 @@ const ShareView = ({ quicknote = false }) => {
loadData();
useShareStore.getState().restoreAppendNote();
})();
- }, []);
+ }, [loadData]);
const close = async () => {
setNote({ ...defaultNote });
@@ -304,20 +306,23 @@ const ShareView = ({ quicknote = false }) => {
}
};
- const onLoad = (editor) => {
- if (editor) {
- Storage.write("shareExtensionOpened", "opened");
- return loadData();
- }
- eSendEvent(eOnLoadNote + "shareEditor", {
- id: null,
- content: {
- type: "tiptap",
- data: noteContent.current
- },
- forced: true
- });
- };
+ const onLoad = useCallback(
+ (editor) => {
+ if (editor) {
+ Storage.write("shareExtensionOpened", "opened");
+ return loadData();
+ }
+ eSendEvent(eOnLoadNote + "shareEditor", {
+ id: null,
+ content: {
+ type: "tiptap",
+ data: noteContent.current
+ },
+ forced: true
+ });
+ },
+ [loadData]
+ );
const onPress = async () => {
setLoading(true);