From 93c35d22a90b7b0378158f6e2b824751ab4ddc2b Mon Sep 17 00:00:00 2001 From: ukorvl Date: Sat, 21 Oct 2023 15:22:36 +0400 Subject: [PATCH 1/3] add biomejs #14 --- .vscode/settings.json | 14 +- rome.json => biome.json | 7 +- package-lock.json | 334 +++++++++++++++++++++------------------- package.json | 7 +- 4 files changed, 195 insertions(+), 167 deletions(-) rename rome.json => biome.json (72%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 5588c73..3d7f03e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,14 @@ { - "editor.defaultFormatter": "rome.rome", - "editor.formatOnSave": true + "[typescript]": { + "editor.defaultFormatter": "biomejs.biome" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "biomejs.biome" + }, + "editor.formatOnSave": true, + "editor.formatOnPaste": true, + "editor.formatOnType": true, + "editor.codeActionsOnSave": { + "quickfix.biome": true + } } diff --git a/rome.json b/biome.json similarity index 72% rename from rome.json rename to biome.json index 6f37fab..dab84e2 100644 --- a/rome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://docs.rome.tools/schemas/12.1.3/schema.json", + "$schema": "https://biomejs.dev/schemas/1.0.0/schema.json", "organizeImports": { "enabled": false }, @@ -19,10 +19,5 @@ }, "files": { "ignore": ["node_modules/*", "build/*"] - }, - "javascript": { - "formatter": { - "quoteStyle": "single" - } } } diff --git a/package-lock.json b/package-lock.json index 802b405..ad50882 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "hoist-non-react-statics": "^3.3.2" }, "devDependencies": { + "@biomejs/biome": "^1.3.1", "@rollup/plugin-commonjs": "^24.0.1", "@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-replace": "^5.0.2", @@ -32,7 +33,6 @@ "rollup-plugin-dts": "^4.2.3", "rollup-plugin-esbuild": "^5.0.0", "rollup-plugin-filesize": "^10.0.0", - "rome": "12.1.3", "size-limit": "^9.0.0", "ts-jest": "^29.0.3", "typescript": "4.7" @@ -724,6 +724,127 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, + "node_modules/@biomejs/biome": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.3.1.tgz", + "integrity": "sha512-ufGCBj8ZNbF+vZDZscqvvLIGsh8M4BduQoJ1X3nm8c9Dupp8gzAKibZSWDLLcgnsAVeKEmWwY6r3Wv/JIa0LgA==", + "dev": true, + "hasInstallScript": true, + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.*" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "1.3.1", + "@biomejs/cli-darwin-x64": "1.3.1", + "@biomejs/cli-linux-arm64": "1.3.1", + "@biomejs/cli-linux-x64": "1.3.1", + "@biomejs/cli-win32-arm64": "1.3.1", + "@biomejs/cli-win32-x64": "1.3.1" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.3.1.tgz", + "integrity": "sha512-m3cBroQftLFYFh3to6RO4ooLqZsE2K9yf5xOlDjm6D4Vrgq85XFwDOxjjJyGGDjDPQ55xGunm80qmGr8jTjiyA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.3.1.tgz", + "integrity": "sha512-i2yDivc/HHBRFJMoRUUPsFs9pKK0NnS/8tQg/uqNsAkLMF9OKZCCxtUJPmpUBHpdQ2f39An1cVpFmCIEv0uYJQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.3.1.tgz", + "integrity": "sha512-H56MB7Mf59snzG+nLpfS2j3jXsJ+a6aQOBeRiT0rgn44FZ63yI9jWNIgN1+Xylsa8shmwtquOkoxLS/4KKt0Qg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.3.1.tgz", + "integrity": "sha512-8ENayCpYXXC77a7AxDNjC+pPKMYteLzysxhkCCZ7Gd2sWtrH8iMM45JL8wQJhoHz5NT3+qgsfGafiNuxeVAVlg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.3.1.tgz", + "integrity": "sha512-gAx/E949/1/jQDwG9nTspVtjikBI/y7RbbUwwBVABF1bcAUC63VhrHfKJRbM7VTXMlZ7n9YrxkyMww8vf40qcQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.3.1.tgz", + "integrity": "sha512-+08eKmEdVM7d4UxY/tff2aPXbeUNNp6wwH7v0FbrE+25mH9lhELgylEk4+k6OLXOcDT7KDAduzP2f9CuM/Aj9w==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.*" + } + }, "node_modules/@esbuild/android-arm": { "version": "0.19.5", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.5.tgz", @@ -2028,84 +2149,6 @@ } } }, - "node_modules/@rometools/cli-darwin-arm64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-12.1.3.tgz", - "integrity": "sha512-AmFTUDYjBuEGQp/Wwps+2cqUr+qhR7gyXAUnkL5psCuNCz3807TrUq/ecOoct5MIavGJTH6R4aaSL6+f+VlBEg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rometools/cli-darwin-x64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-12.1.3.tgz", - "integrity": "sha512-k8MbWna8q4LRlb005N2X+JS1UQ+s3ZLBBvwk4fP8TBxlAJXUz17jLLu/Fi+7DTTEmMhM84TWj4FDKW+rNar28g==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rometools/cli-linux-arm64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-12.1.3.tgz", - "integrity": "sha512-X/uLhJ2/FNA3nu5TiyeNPqiD3OZoFfNfRvw6a3ut0jEREPvEn72NI7WPijH/gxSz55znfQ7UQ6iM4DZumUknJg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rometools/cli-linux-x64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-12.1.3.tgz", - "integrity": "sha512-csP17q1eWiUXx9z6Jr/JJPibkplyKIwiWPYNzvPCGE8pHlKhwZj3YHRuu7Dm/4EOqx0XFIuqqWZUYm9bkIC8xg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rometools/cli-win32-arm64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-12.1.3.tgz", - "integrity": "sha512-RymHWeod57EBOJY4P636CgUwYA6BQdkQjh56XKk4pLEHO6X1bFyMet2XL7KlHw5qOTalzuzf5jJqUs+vf3jdXQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rometools/cli-win32-x64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-12.1.3.tgz", - "integrity": "sha512-yHSKYidqJMV9nADqg78GYA+cZ0hS1twANAjiFibQdXj9aGzD+s/IzIFEIi/U/OBLvWYg/SCw0QVozi2vTlKFDQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, "node_modules/@sigstore/protobuf-specs": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@sigstore/protobuf-specs/-/protobuf-specs-0.1.0.tgz", @@ -7280,27 +7323,6 @@ "node": ">=16.0.0" } }, - "node_modules/rome": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/rome/-/rome-12.1.3.tgz", - "integrity": "sha512-e+ff72hxDpe/t5/Us7YRBVw3PBET7SeczTQNn6tvrWdrCaAw3qOukQQ+tDCkyFtS4yGsnhjrJbm43ctNbz27Yg==", - "dev": true, - "hasInstallScript": true, - "bin": { - "rome": "bin/rome" - }, - "engines": { - "node": ">=14.*" - }, - "optionalDependencies": { - "@rometools/cli-darwin-arm64": "12.1.3", - "@rometools/cli-darwin-x64": "12.1.3", - "@rometools/cli-linux-arm64": "12.1.3", - "@rometools/cli-linux-x64": "12.1.3", - "@rometools/cli-win32-arm64": "12.1.3", - "@rometools/cli-win32-x64": "12.1.3" - } - }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -8959,6 +8981,62 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, + "@biomejs/biome": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.3.1.tgz", + "integrity": "sha512-ufGCBj8ZNbF+vZDZscqvvLIGsh8M4BduQoJ1X3nm8c9Dupp8gzAKibZSWDLLcgnsAVeKEmWwY6r3Wv/JIa0LgA==", + "dev": true, + "requires": { + "@biomejs/cli-darwin-arm64": "1.3.1", + "@biomejs/cli-darwin-x64": "1.3.1", + "@biomejs/cli-linux-arm64": "1.3.1", + "@biomejs/cli-linux-x64": "1.3.1", + "@biomejs/cli-win32-arm64": "1.3.1", + "@biomejs/cli-win32-x64": "1.3.1" + } + }, + "@biomejs/cli-darwin-arm64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.3.1.tgz", + "integrity": "sha512-m3cBroQftLFYFh3to6RO4ooLqZsE2K9yf5xOlDjm6D4Vrgq85XFwDOxjjJyGGDjDPQ55xGunm80qmGr8jTjiyA==", + "dev": true, + "optional": true + }, + "@biomejs/cli-darwin-x64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.3.1.tgz", + "integrity": "sha512-i2yDivc/HHBRFJMoRUUPsFs9pKK0NnS/8tQg/uqNsAkLMF9OKZCCxtUJPmpUBHpdQ2f39An1cVpFmCIEv0uYJQ==", + "dev": true, + "optional": true + }, + "@biomejs/cli-linux-arm64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.3.1.tgz", + "integrity": "sha512-H56MB7Mf59snzG+nLpfS2j3jXsJ+a6aQOBeRiT0rgn44FZ63yI9jWNIgN1+Xylsa8shmwtquOkoxLS/4KKt0Qg==", + "dev": true, + "optional": true + }, + "@biomejs/cli-linux-x64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.3.1.tgz", + "integrity": "sha512-8ENayCpYXXC77a7AxDNjC+pPKMYteLzysxhkCCZ7Gd2sWtrH8iMM45JL8wQJhoHz5NT3+qgsfGafiNuxeVAVlg==", + "dev": true, + "optional": true + }, + "@biomejs/cli-win32-arm64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.3.1.tgz", + "integrity": "sha512-gAx/E949/1/jQDwG9nTspVtjikBI/y7RbbUwwBVABF1bcAUC63VhrHfKJRbM7VTXMlZ7n9YrxkyMww8vf40qcQ==", + "dev": true, + "optional": true + }, + "@biomejs/cli-win32-x64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.3.1.tgz", + "integrity": "sha512-+08eKmEdVM7d4UxY/tff2aPXbeUNNp6wwH7v0FbrE+25mH9lhELgylEk4+k6OLXOcDT7KDAduzP2f9CuM/Aj9w==", + "dev": true, + "optional": true + }, "@esbuild/android-arm": { "version": "0.19.5", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.5.tgz", @@ -9823,48 +9901,6 @@ "picomatch": "^2.3.1" } }, - "@rometools/cli-darwin-arm64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-12.1.3.tgz", - "integrity": "sha512-AmFTUDYjBuEGQp/Wwps+2cqUr+qhR7gyXAUnkL5psCuNCz3807TrUq/ecOoct5MIavGJTH6R4aaSL6+f+VlBEg==", - "dev": true, - "optional": true - }, - "@rometools/cli-darwin-x64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-12.1.3.tgz", - "integrity": "sha512-k8MbWna8q4LRlb005N2X+JS1UQ+s3ZLBBvwk4fP8TBxlAJXUz17jLLu/Fi+7DTTEmMhM84TWj4FDKW+rNar28g==", - "dev": true, - "optional": true - }, - "@rometools/cli-linux-arm64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-12.1.3.tgz", - "integrity": "sha512-X/uLhJ2/FNA3nu5TiyeNPqiD3OZoFfNfRvw6a3ut0jEREPvEn72NI7WPijH/gxSz55znfQ7UQ6iM4DZumUknJg==", - "dev": true, - "optional": true - }, - "@rometools/cli-linux-x64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-12.1.3.tgz", - "integrity": "sha512-csP17q1eWiUXx9z6Jr/JJPibkplyKIwiWPYNzvPCGE8pHlKhwZj3YHRuu7Dm/4EOqx0XFIuqqWZUYm9bkIC8xg==", - "dev": true, - "optional": true - }, - "@rometools/cli-win32-arm64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-12.1.3.tgz", - "integrity": "sha512-RymHWeod57EBOJY4P636CgUwYA6BQdkQjh56XKk4pLEHO6X1bFyMet2XL7KlHw5qOTalzuzf5jJqUs+vf3jdXQ==", - "dev": true, - "optional": true - }, - "@rometools/cli-win32-x64": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-12.1.3.tgz", - "integrity": "sha512-yHSKYidqJMV9nADqg78GYA+cZ0hS1twANAjiFibQdXj9aGzD+s/IzIFEIi/U/OBLvWYg/SCw0QVozi2vTlKFDQ==", - "dev": true, - "optional": true - }, "@sigstore/protobuf-specs": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@sigstore/protobuf-specs/-/protobuf-specs-0.1.0.tgz", @@ -13776,20 +13812,6 @@ "terser": "^5.6.0" } }, - "rome": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/rome/-/rome-12.1.3.tgz", - "integrity": "sha512-e+ff72hxDpe/t5/Us7YRBVw3PBET7SeczTQNn6tvrWdrCaAw3qOukQQ+tDCkyFtS4yGsnhjrJbm43ctNbz27Yg==", - "dev": true, - "requires": { - "@rometools/cli-darwin-arm64": "12.1.3", - "@rometools/cli-darwin-x64": "12.1.3", - "@rometools/cli-linux-arm64": "12.1.3", - "@rometools/cli-linux-x64": "12.1.3", - "@rometools/cli-win32-arm64": "12.1.3", - "@rometools/cli-win32-x64": "12.1.3" - } - }, "run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", diff --git a/package.json b/package.json index a025e18..64ea426 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "prebuild": "rimraf build", "build": "rollup -c", "test": "jest", - "lint": "rome check .", + "lint": "biome lint ./lib", + "format": "biome format --write", "prepare": "husky install" }, "keywords": [ @@ -35,6 +36,7 @@ "hoist-non-react-statics": "^3.3.2" }, "devDependencies": { + "@biomejs/biome": "^1.3.1", "@rollup/plugin-commonjs": "^24.0.1", "@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-replace": "^5.0.2", @@ -55,7 +57,6 @@ "rollup-plugin-dts": "^4.2.3", "rollup-plugin-esbuild": "^5.0.0", "rollup-plugin-filesize": "^10.0.0", - "rome": "12.1.3", "size-limit": "^9.0.0", "ts-jest": "^29.0.3", "typescript": "4.7" @@ -64,7 +65,7 @@ "access": "public" }, "lint-staged": { - "*.{js,ts,tsx}": "rome format --write" + "*.{js,ts,tsx}": "npm run format" }, "jest": { "roots": [ From 08df5b7427c196dbcd54117b2a4a21c1acfc27ba Mon Sep 17 00:00:00 2001 From: ukorvl Date: Sat, 21 Oct 2023 15:30:42 +0400 Subject: [PATCH 2/3] apply linter #14 --- biome.json | 2 +- lib/OnScreen.tsx | 8 ++++---- lib/internal/assignRefs.ts | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/biome.json b/biome.json index dab84e2..2a401d3 100644 --- a/biome.json +++ b/biome.json @@ -14,7 +14,7 @@ "formatter": { "indentStyle": "space", "lineWidth": 100, - "indentSize": 2, + "indentWidth": 2, "formatWithErrors": false }, "files": { diff --git a/lib/OnScreen.tsx b/lib/OnScreen.tsx index ae4a77b..2c9e6dc 100644 --- a/lib/OnScreen.tsx +++ b/lib/OnScreen.tsx @@ -6,8 +6,8 @@ import React, { ReactElement, ElementType, ComponentProps, -} from 'react'; -import { UseOnScreenParameters, useOnScreen } from './useOnScreen'; +} from "react"; +import { UseOnScreenParameters, useOnScreen } from "./useOnScreen"; /** * OnScreen component own props. @@ -21,7 +21,7 @@ type OnScreenOwnProps, 'ref'>; +} & Omit, "ref">; /** * OnScreen component props with generic element props. @@ -65,7 +65,7 @@ export const OnScreen = Children.only(children({ ref, ...useOnScreenData })), - [useOnScreenData, children, ref], + [useOnScreenData, children], ); if (Component !== undefined) { diff --git a/lib/internal/assignRefs.ts b/lib/internal/assignRefs.ts index 86c759a..3248102 100644 --- a/lib/internal/assignRefs.ts +++ b/lib/internal/assignRefs.ts @@ -1,4 +1,4 @@ -import { MutableRefObject, Ref } from 'react'; +import { MutableRefObject, Ref } from "react"; /** * Takes both ref objects and ref functions and returns assigned ref function. @@ -7,12 +7,12 @@ import { MutableRefObject, Ref } from 'react'; */ export const assignRefs = (...refs: Ref[]) => { return (node: T | null) => { - refs.forEach((r) => { - if (typeof r === 'function') { - r(node); - } else if (r) { - (r as MutableRefObject).current = node; + for (const ref of refs) { + if (typeof ref === "function") { + ref(node); + } else if (ref) { + (ref as MutableRefObject).current = node; } - }); + } }; }; From 6bb2add9e702db3d923839ccdc5dfe6b1df89dfa Mon Sep 17 00:00:00 2001 From: ukorvl Date: Sat, 21 Oct 2023 15:32:56 +0400 Subject: [PATCH 3/3] apply formatter #14 --- lib/__tests__/OnScreen.test.tsx | 16 ++++++++-------- lib/__tests__/testUtils.ts | 14 +++++++------- lib/__tests__/useOnScreen.test.tsx | 18 +++++++++--------- lib/__tests__/withOnScreen.test.tsx | 18 +++++++++--------- lib/index.ts | 12 ++++++------ lib/internal/index.ts | 2 +- lib/useOnScreen.tsx | 2 +- lib/withOnScreen.tsx | 12 ++++++------ package.json | 4 ++-- 9 files changed, 49 insertions(+), 49 deletions(-) diff --git a/lib/__tests__/OnScreen.test.tsx b/lib/__tests__/OnScreen.test.tsx index fda70b3..1ea0992 100644 --- a/lib/__tests__/OnScreen.test.tsx +++ b/lib/__tests__/OnScreen.test.tsx @@ -1,24 +1,24 @@ -import React from 'react'; -import { OnScreen } from '../OnScreen'; +import React from "react"; +import { OnScreen } from "../OnScreen"; import { ComponentRenderer, createIsOnScreenValueTest, createOnceParameterTest, createRenderTest, -} from './testUtils'; +} from "./testUtils"; const renderComponent: ComponentRenderer = (settings) => ( {...settings}> {({ ref, isOnScreen }) => ( -
+
)} ); -describe('OnScreen', () => { - it('OnScreen component renders', createRenderTest(renderComponent)); +describe("OnScreen", () => { + it("OnScreen component renders", createRenderTest(renderComponent)); - it('isOnScreen value changes', createIsOnScreenValueTest(renderComponent)); + it("isOnScreen value changes", createIsOnScreenValueTest(renderComponent)); - it('Once prop is working as expected', createOnceParameterTest(renderComponent)); + it("Once prop is working as expected", createOnceParameterTest(renderComponent)); }); diff --git a/lib/__tests__/testUtils.ts b/lib/__tests__/testUtils.ts index eab6595..15264bf 100644 --- a/lib/__tests__/testUtils.ts +++ b/lib/__tests__/testUtils.ts @@ -1,16 +1,16 @@ /*global expect*/ -import { act, render } from '@testing-library/react'; -import { mockIntersectionObserver } from 'jsdom-testing-mocks'; -import { ReactElement } from 'react'; -import { UseOnScreenParameters } from '../useOnScreen'; +import { act, render } from "@testing-library/react"; +import { mockIntersectionObserver } from "jsdom-testing-mocks"; +import { ReactElement } from "react"; +import { UseOnScreenParameters } from "../useOnScreen"; /** * Renders component. */ -export type ComponentRenderer = (settings?: Pick) => ReactElement; +export type ComponentRenderer = (settings?: Pick) => ReactElement; -const targetTestId = 'target'; -const targetIsOnScreenTestId = 'target-isOnScreen'; +const targetTestId = "target"; +const targetIsOnScreenTestId = "target-isOnScreen"; const io = mockIntersectionObserver(); diff --git a/lib/__tests__/useOnScreen.test.tsx b/lib/__tests__/useOnScreen.test.tsx index 675d6b7..9c592c9 100644 --- a/lib/__tests__/useOnScreen.test.tsx +++ b/lib/__tests__/useOnScreen.test.tsx @@ -1,25 +1,25 @@ -import React, { useRef } from 'react'; -import { useOnScreen, UseOnScreenParameters } from '../useOnScreen'; +import React, { useRef } from "react"; +import { useOnScreen, UseOnScreenParameters } from "../useOnScreen"; import { ComponentRenderer, createIsOnScreenValueTest, createOnceParameterTest, createRenderTest, -} from './testUtils'; +} from "./testUtils"; -const ComponentTemplate = (props: Pick) => { +const ComponentTemplate = (props: Pick) => { const ref = useRef(null); const { isOnScreen } = useOnScreen({ ref, ...props }); - return
; + return
; }; const renderComponent: ComponentRenderer = (settings) => ; -describe('useOnScreen', () => { - it('useOnScreen component renders', createRenderTest(renderComponent)); +describe("useOnScreen", () => { + it("useOnScreen component renders", createRenderTest(renderComponent)); - it('isOnScreen value changes', createIsOnScreenValueTest(renderComponent)); + it("isOnScreen value changes", createIsOnScreenValueTest(renderComponent)); - it('Once prop is working as expected', createOnceParameterTest(renderComponent)); + it("Once prop is working as expected", createOnceParameterTest(renderComponent)); }); diff --git a/lib/__tests__/withOnScreen.test.tsx b/lib/__tests__/withOnScreen.test.tsx index cc6daa4..8022a76 100644 --- a/lib/__tests__/withOnScreen.test.tsx +++ b/lib/__tests__/withOnScreen.test.tsx @@ -1,16 +1,16 @@ -import React, { forwardRef } from 'react'; -import { useOnScreen } from '../useOnScreen'; -import { withOnScreen } from '../withOnScreen'; +import React, { forwardRef } from "react"; +import { useOnScreen } from "../useOnScreen"; +import { withOnScreen } from "../withOnScreen"; import { ComponentRenderer, createIsOnScreenValueTest, createOnceParameterTest, createRenderTest, -} from './testUtils'; +} from "./testUtils"; const ComponentTemplate = forwardRef>( function ComponentTemplate({ isOnScreen }, ref) { - return
; + return
; }, ); @@ -19,10 +19,10 @@ const renderComponent: ComponentRenderer = (settings) => { return ; }; -describe('withOnScreen', () => { - it('withOnScreen component renders', createRenderTest(renderComponent)); +describe("withOnScreen", () => { + it("withOnScreen component renders", createRenderTest(renderComponent)); - it('isOnScreen value changes', createIsOnScreenValueTest(renderComponent)); + it("isOnScreen value changes", createIsOnScreenValueTest(renderComponent)); - it('Once prop is working as expected', createOnceParameterTest(renderComponent)); + it("Once prop is working as expected", createOnceParameterTest(renderComponent)); }); diff --git a/lib/index.ts b/lib/index.ts index 1041931..3eaa616 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,6 +1,6 @@ -export { useOnScreen } from './useOnScreen'; -export type { UseOnScreenParameters } from './useOnScreen'; -export { OnScreen } from './OnScreen'; -export type { OnScreenProps } from './OnScreen'; -export { withOnScreen } from './withOnScreen'; -export type { WithOnScreenWrappedComponent } from './withOnScreen'; +export { useOnScreen } from "./useOnScreen"; +export type { UseOnScreenParameters } from "./useOnScreen"; +export { OnScreen } from "./OnScreen"; +export type { OnScreenProps } from "./OnScreen"; +export { withOnScreen } from "./withOnScreen"; +export type { WithOnScreenWrappedComponent } from "./withOnScreen"; diff --git a/lib/internal/index.ts b/lib/internal/index.ts index 92702d5..13b376c 100644 --- a/lib/internal/index.ts +++ b/lib/internal/index.ts @@ -1 +1 @@ -export * from './assignRefs'; +export * from "./assignRefs"; diff --git a/lib/useOnScreen.tsx b/lib/useOnScreen.tsx index dadc1ef..b127a6d 100644 --- a/lib/useOnScreen.tsx +++ b/lib/useOnScreen.tsx @@ -1,4 +1,4 @@ -import { RefObject, useEffect, useState } from 'react'; +import { RefObject, useEffect, useState } from "react"; /** * UseOnScreen hook settings. diff --git a/lib/withOnScreen.tsx b/lib/withOnScreen.tsx index 0e25926..1e0c3d6 100644 --- a/lib/withOnScreen.tsx +++ b/lib/withOnScreen.tsx @@ -1,7 +1,7 @@ -import React, { useRef, ComponentType, forwardRef, ForwardedRef } from 'react'; -import hoistNonReactStatics from 'hoist-non-react-statics'; -import { UseOnScreenParameters, useOnScreen } from './useOnScreen'; -import { assignRefs } from './internal'; +import React, { useRef, ComponentType, forwardRef, ForwardedRef } from "react"; +import hoistNonReactStatics from "hoist-non-react-statics"; +import { UseOnScreenParameters, useOnScreen } from "./useOnScreen"; +import { assignRefs } from "./internal"; /** * WithOnScreen wrapped component with injected props. @@ -30,7 +30,7 @@ export type WithOnScreenWrappedComponent,> */ export const withOnScreen =

, T extends HTMLElement>( WrappedComponent: WithOnScreenWrappedComponent

, - settings?: Omit, 'ref'>, + settings?: Omit, "ref">, ) => { const WithOnScreen = (props: P, forwardedRef: ForwardedRef) => { const ref = useRef(null); @@ -42,7 +42,7 @@ export const withOnScreen =

, T extends HTMLEl hoistNonReactStatics(WithOnScreen, WrappedComponent); WithOnScreen.displayName = `WithOnScreen(${ - WrappedComponent.displayName || WrappedComponent.name || 'Component' + WrappedComponent.displayName || WrappedComponent.name || "Component" })`; return forwardRef(WithOnScreen); diff --git a/package.json b/package.json index 64ea426..4b9c77c 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "build": "rollup -c", "test": "jest", "lint": "biome lint ./lib", - "format": "biome format --write", + "format": "biome format --write ./lib", "prepare": "husky install" }, "keywords": [ @@ -65,7 +65,7 @@ "access": "public" }, "lint-staged": { - "*.{js,ts,tsx}": "npm run format" + "*.{js,ts,tsx}": "biome format --write" }, "jest": { "roots": [