diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index de29e17b..00000000 --- a/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -typings -node_modules -example/android-bundle.js -example/ios-bundle.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 187894b6..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - root: true, - extends: '@react-native', -}; diff --git a/.flowconfig b/.flowconfig deleted file mode 100644 index 6aa8762f..00000000 --- a/.flowconfig +++ /dev/null @@ -1,81 +0,0 @@ -[ignore] -; We fork some components by platform -.*/*[.]android.js - -; Ignore "BUCK" generated dirs -/\.buckd/ - -; Ignore polyfills -node_modules/react-native/Libraries/polyfills/.* - -; These should not be required directly -; require from fbjs/lib instead: require('fbjs/lib/warning') -node_modules/warning/.* - -; Flow doesn't support platforms -.*/Libraries/Utilities/LoadingView.js - -; Ignore example folder -.*/example/.* - - -[untyped] -.*/node_modules/@react-native-community/cli/.*/.* - -[include] - -[libs] -node_modules/react-native/Libraries/react-native/react-native-interface.js -node_modules/react-native/flow/ - -[options] -emoji=true - -esproposal.optional_chaining=enable -esproposal.nullish_coalescing=enable - -module.file_ext=.js -module.file_ext=.json -module.file_ext=.ios.js - -munge_underscores=true - -module.name_mapper='^react-native$' -> '/node_modules/react-native/Libraries/react-native/react-native-implementation' -module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' -module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' - -suppress_type=$FlowIssue -suppress_type=$FlowFixMe -suppress_type=$FlowFixMeProps -suppress_type=$FlowFixMeState - -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ -suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError - -server.max_workers=4 - -[lints] -sketchy-null-number=warn -sketchy-null-mixed=warn -sketchy-number=warn -untyped-type-import=warn -nonstrict-import=warn -deprecated-type=warn -unsafe-getters-setters=warn -inexact-spread=warn -unnecessary-invariant=warn -signature-verification-failure=warn -deprecated-utility=error - -[strict] -deprecated-type -nonstrict-import -sketchy-null -unclear-type -unsafe-getters-setters -untyped-import -untyped-type-import - -[version] -^0.105.0 diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index 6e29914c..00000000 --- a/.prettierrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - bracketSpacing: false, - jsxBracketSameLine: true, - singleQuote: true, - trailingComma: 'all', -}; \ No newline at end of file diff --git a/__tests__/mock.test.js b/__tests__/mock.test.js index ced42a3e..f7885d46 100644 --- a/__tests__/mock.test.js +++ b/__tests__/mock.test.js @@ -1,19 +1,19 @@ -const mockClipboard = require('../jest/clipboard-mock'); +const mockClipboard = require("../jest/clipboard-mock"); -jest.mock('../dist/index.js', () => mockClipboard); +jest.mock("../dist/index.js", () => mockClipboard); -describe('mockClipboard', () => { - const {getString, useClipboard} = require('../dist/index.js'); +describe("mockClipboard", () => { + const { getString, useClipboard } = require("../dist/index.js"); - it('can get mock string', async () => { - const result = await getString(); - const expected = 'mockString'; - expect(result).toBe(expected); - }); + it("can get mock string", async () => { + const result = await getString(); + const expected = "mockString"; + expect(result).toBe(expected); + }); - it('can get useClipboardHook', async () => { - const [result] = useClipboard(); - const expected = 'mockString'; - expect(result).toBe(expected); - }); + it("can get useClipboardHook", async () => { + const [result] = useClipboard(); + const expected = "mockString"; + expect(result).toBe(expected); + }); }); diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..7734e11e --- /dev/null +++ b/biome.json @@ -0,0 +1,30 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", + "vcs": { + "enabled": false, + "clientKind": "git", + "useIgnoreFile": false + }, + "files": { + "ignoreUnknown": false, + "ignore": ["dist", "example/ios", "example/android"] + }, + "formatter": { + "enabled": true, + "indentStyle": "tab" + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + }, + "javascript": { + "formatter": { + "quoteStyle": "double" + } + } +} diff --git a/example/App.tsx b/example/App.tsx index 2efc608e..d537ec8e 100644 --- a/example/App.tsx +++ b/example/App.tsx @@ -1,171 +1,172 @@ -import React, {useEffect, useState} from 'react'; +import type React from "react"; +import { useCallback, useEffect, useState } from "react"; import { - StyleSheet, - Text, - View, - Button, - TextInput, - Alert, - SafeAreaView, - Platform, - Image, -} from 'react-native'; -import Clipboard, {useClipboard} from '../src'; + StyleSheet, + Text, + View, + Button, + TextInput, + Alert, + SafeAreaView, + Platform, + Image, +} from "react-native"; +import Clipboard, { useClipboard } from "../src"; // Small icon of a plus for demo purposes const TEST_IMAGE = - 'iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg=='; + "iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg=="; const changeListener = () => { - console.warn('Clipboard changed!'); + console.warn("Clipboard changed!"); }; const App: React.FC = () => { - const [text, setText] = useState(''); - const [isURL, setIsURL] = useState(false); - const [data, setString] = useClipboard(); - const [image, setImage] = useState(null); - const [imageString, setImageString] = useState(''); + const [text, setText] = useState(""); + const [isURL, setIsURL] = useState(false); + const [data, setString] = useClipboard(); + const [image, setImage] = useState(null); + const [imageString, setImageString] = useState(""); - const checkStringType = async () => { - const checkClipboard = await Clipboard.hasURL(); - setIsURL(checkClipboard); - }; + const checkStringType = useCallback(async () => { + const checkClipboard = await Clipboard.hasURL(); + setIsURL(checkClipboard); + }, []); - const pasteImageAndroid = async () => { - const base64 = await Clipboard.getImage(); - setImageString(base64); - }; + const pasteImageAndroid = async () => { + const base64 = await Clipboard.getImage(); + setImageString(base64); + }; - useEffect(() => { - checkStringType(); - }, [data]); + useEffect(() => { + checkStringType(); + }, [checkStringType]); - useEffect(() => { - if (Platform.OS === 'ios' || Platform.OS === 'android') { - const listener = Clipboard.addListener(changeListener); + useEffect(() => { + if (Platform.OS === "ios" || Platform.OS === "android") { + const listener = Clipboard.addListener(changeListener); - return () => { - listener.remove(); - }; - } - }, []); + return () => { + listener.remove(); + }; + } + }, []); - const writeToClipboard = async () => { - setString(text); - Alert.alert(`Copied to clipboard: ${text}`); - }; + const writeToClipboard = async () => { + setString(text); + Alert.alert(`Copied to clipboard: ${text}`); + }; - const writeImageToClipboard = async () => { - Clipboard.setImage(TEST_IMAGE); - Alert.alert(`Copied Image to clipboard`); - }; + const writeImageToClipboard = async () => { + Clipboard.setImage(TEST_IMAGE); + Alert.alert("Copied Image to clipboard"); + }; - const getImage = async () => { - if (await Clipboard.hasImage()) { - const image = await Clipboard.getImagePNG(); - setImage(image); - } else { - console.warn('No image in clipboard'); - } - }; + const getImage = async () => { + if (await Clipboard.hasImage()) { + const image = await Clipboard.getImagePNG(); + setImage(image); + } else { + console.warn("No image in clipboard"); + } + }; - return ( - - Clipboard Module - - Clipboard Contents: - {data} - Content is URL: - {JSON.stringify(isURL)} - Content is IMAGE: - {image && } - - setText(input)} - value={text} - placeholder="Type here..." - /> -