Skip to content

Commit a57273c

Browse files
committed
add husky and lint-staged
1 parent 3151cfd commit a57273c

File tree

6 files changed

+297
-19
lines changed

6 files changed

+297
-19
lines changed

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

lib/components/Picker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface PickerValue {
1616

1717
export interface PickerRootProps extends Omit<HTMLProps<HTMLDivElement>, 'value' | 'onChange'> {
1818
value: PickerValue
19-
onChange(value: PickerValue, key: string): void
19+
onChange: (value: PickerValue, key: string) => void
2020
height?: number
2121
itemHeight?: number
2222
wheelMode?: 'off' | 'natural' | 'normal'
@@ -135,7 +135,7 @@ function PickerRoot(props: PickerRootProps) {
135135

136136
const pickerData = useMemo(
137137
() => ({ height, itemHeight, wheelMode, value, optionGroups }),
138-
[height, itemHeight, value, optionGroups]
138+
[height, itemHeight, value, optionGroups, wheelMode]
139139
)
140140

141141
const triggerChange = useCallback((key: string, nextValue: string) => {

lib/components/PickerColumn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function PickerColumn({
154154

155155
const nextScrollerTranslate = scrollerTranslate + delta
156156
updateScrollerWhileMoving(nextScrollerTranslate)
157-
}, [itemHeight, scrollerTranslate, updateScrollerWhileMoving])
157+
}, [itemHeight, scrollerTranslate, updateScrollerWhileMoving, wheelMode])
158158

159159
const handleWheelEnd = useCallback(() => {
160160
handleScrollerTranslateSettled()

lib/components/PickerItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export interface PickerItemProps extends Omit<HTMLProps<HTMLDivElement>, 'value'
1212
value: string
1313
}
1414

15-
function isFunction(functionToCheck: any): functionToCheck is Function {
15+
// eslint-disable-next-line
16+
function isFunction(functionToCheck: any): boolean {
1617
return typeof functionToCheck === 'function'
1718
}
1819

package.json

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,41 @@
22
"name": "react-mobile-picker",
33
"version": "1.0.0",
44
"description": "An iOS like select box component for React",
5+
"type": "module",
6+
"files": [
7+
"dist",
8+
"README.md"
9+
],
10+
"main": "./dist/react-mobile-picker.umd.cjs",
11+
"module": "./dist/react-mobile-picker.js",
12+
"typings": "./dist/react-mobile-picker.d.ts",
13+
"exports": {
14+
".": {
15+
"import": "./dist/react-mobile-picker.js",
16+
"require": "./dist/react-mobile-picker.umd.cjs"
17+
}
18+
},
19+
"repository": "https://github.com/adcentury/react-mobile-picker",
20+
"license": "MIT",
521
"scripts": {
622
"dev": "vite",
723
"build:lib": "tsc && vite build",
824
"build:examples": "tsc && vite build --config vite.config.examples.ts",
925
"lint": "eslint lib examples --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10-
"preview": "vite preview"
26+
"preview": "vite preview",
27+
"prepare": "husky install"
28+
},
29+
"lint-staged": {
30+
"lib/**/*.{ts,tsx}": [
31+
"eslint --fix"
32+
],
33+
"examples/**/*.{ts,tsx}": [
34+
"eslint --fix"
35+
]
1136
},
1237
"peerDependencies": {
13-
"react": "^18",
14-
"react-dom": "^18"
38+
"react": "^16 || ^17 || ^18",
39+
"react-dom": "^16 || ^17 || ^18"
1540
},
1641
"devDependencies": {
1742
"@headlessui/react": "^1.7.17",
@@ -26,25 +51,15 @@
2651
"eslint": "^8.44.0",
2752
"eslint-plugin-react-hooks": "^4.6.0",
2853
"eslint-plugin-react-refresh": "^0.4.1",
54+
"husky": "^8.0.3",
2955
"less": "^4.1.3",
56+
"lint-staged": "^14.0.1",
3057
"postcss": "^8.4.26",
3158
"react": "^18.2.0",
3259
"react-dom": "^18.2.0",
3360
"tailwindcss": "^3.3.3",
3461
"typescript": "^5.0.2",
3562
"vite": "^4.4.0",
3663
"vite-plugin-dts": "^3.3.1"
37-
},
38-
"type": "module",
39-
"files": [
40-
"dist"
41-
],
42-
"main": "./dist/react-mobile-picker.umd.cjs",
43-
"module": "./dist/react-mobile-picker.js",
44-
"exports": {
45-
".": {
46-
"import": "./dist/react-mobile-picker.js",
47-
"require": "./dist/react-mobile-picker.umd.cjs"
48-
}
4964
}
5065
}

0 commit comments

Comments
 (0)