Skip to content

Commit 597fbf9

Browse files
authored
Merge pull request #4 from Tracktor/feat/switch-to-biome
feat: add biome configuration and update linting process
2 parents 0a3dd01 + c15161f commit 597fbf9

File tree

18 files changed

+177
-2918
lines changed

18 files changed

+177
-2918
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ node_modules
1111
dist
1212
dist-ssr
1313
*.local
14+
tsconfig.tsbuildinfo
1415

1516
# Editor directories and files
1617
.vscode/*

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# [Versions](https://github.com/Tracktor/react-utils/releases)
22

3-
## v1.24.0
4-
- **[feat]** : add util function `getObjectValue` with dot notation support
3+
## v1.24.1
4+
- **[fix]** : Change Eslint to Biome for linting

biome.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["@tracktor/biome-config-react"]
3+
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@tracktor/react-utils",
33
"description": "React data table and react data grid",
4-
"version": "1.24.0",
4+
"version": "1.24.1",
55
"private": false,
66
"license": "ISC",
77
"type": "module",
@@ -30,7 +30,8 @@
3030
"coverage": "vitest run --coverage",
3131
"dev": "vite",
3232
"build": "tsc && vite build",
33-
"lint": "eslint . --max-warnings=0 && tsc --noEmit",
33+
"lint": "biome check --diagnostic-level=error . && tsc --noEmit --incremental",
34+
"lint:fix": "biome check . --write",
3435
"preview": "vite preview",
3536
"test": "vitest",
3637
"prepare": "yarn run build && husky install"
@@ -39,10 +40,10 @@
3940
"@testing-library/jest-dom": "^5.17.0",
4041
"@testing-library/react": "^14.0.0",
4142
"@testing-library/user-event": "^14.5.1",
43+
"@tracktor/biome-config-react": "^1.1.1",
4244
"@types/react": "^18.2.28",
4345
"@types/react-dom": "^18.2.13",
4446
"@vitejs/plugin-react": "^4.1.0",
45-
"eslint-config-react-tracktor": "^1.7.0",
4647
"husky": "^8.0.3",
4748
"jsdom": "^22.1.0",
4849
"react": "^18.2.0",

src/hooks/useDebounce/useDebounce.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Delay = number;
1212
* @param value
1313
* @param delayOrOptions
1414
*/
15-
const useDebounce = <T extends any>(value: T, delayOrOptions?: Delay | Options): T => {
15+
const useDebounce = <T>(value: T, delayOrOptions?: Delay | Options): T => {
1616
const isNumberOption = typeof delayOrOptions === "number";
1717
const onDebounceRef = useRef(isNumberOption ? undefined : delayOrOptions?.onDebounce);
1818
const [debouncedValue, setDebouncedValue] = useState<T>(value);

src/hooks/useInView/useInView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, RefObject } from "react";
1+
import { RefObject, useState } from "react";
22
import useIsomorphicLayoutEffect from "@/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect";
33

44
/**

src/hooks/useLocalStorage/useLocalStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const useLocalStorage = <T>(key: string, initialValue?: T, options?: UseLocalSto
4848

4949
try {
5050
const raw = window.localStorage.getItem(key);
51-
return raw ? deserializer(raw) : initialValue ?? (null as T);
51+
return raw ? deserializer(raw) : (initialValue ?? (null as T));
5252
} catch {
5353
return initialValue ?? (null as T);
5454
}

src/hooks/useScript/useScript.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const useScript = (src: string, options?: UseScriptOptions): UseScriptStatus =>
1919

2020
useEffect(
2121
() => {
22-
if (!src || !enable) {
22+
if (!(src && enable)) {
2323
setStatus("idle");
2424
return undefined;
2525
}
@@ -28,7 +28,10 @@ const useScript = (src: string, options?: UseScriptOptions): UseScriptStatus =>
2828
// It may have been added by another instance of this hook
2929
let script: UseScriptScriptElement = document.querySelector(`script[src="${src}"]`);
3030

31-
if (!script) {
31+
if (script) {
32+
// Grab existing script status from attribute and set to state.
33+
setStatus(script.getAttribute("data-status") as UseScriptStatus);
34+
} else {
3235
// Create script
3336
script = document.createElement("script");
3437
script.src = src;
@@ -57,9 +60,6 @@ const useScript = (src: string, options?: UseScriptOptions): UseScriptStatus =>
5760

5861
script.addEventListener("load", setAttributeFromEvent);
5962
script.addEventListener("error", setAttributeFromEvent);
60-
} else {
61-
// Grab existing script status from attribute and set to state.
62-
setStatus(script.getAttribute("data-status") as UseScriptStatus);
6363
}
6464

6565
// Script event handler to update status in state

0 commit comments

Comments
 (0)