Skip to content

Commit

Permalink
add husky and lint-staged
Browse files Browse the repository at this point in the history
  • Loading branch information
adcentury committed Aug 23, 2023
1 parent 3151cfd commit a57273c
Show file tree
Hide file tree
Showing 6 changed files with 297 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
4 changes: 2 additions & 2 deletions lib/components/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface PickerValue {

export interface PickerRootProps extends Omit<HTMLProps<HTMLDivElement>, 'value' | 'onChange'> {
value: PickerValue
onChange(value: PickerValue, key: string): void
onChange: (value: PickerValue, key: string) => void
height?: number
itemHeight?: number
wheelMode?: 'off' | 'natural' | 'normal'
Expand Down Expand Up @@ -135,7 +135,7 @@ function PickerRoot(props: PickerRootProps) {

const pickerData = useMemo(
() => ({ height, itemHeight, wheelMode, value, optionGroups }),
[height, itemHeight, value, optionGroups]
[height, itemHeight, value, optionGroups, wheelMode]
)

const triggerChange = useCallback((key: string, nextValue: string) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/PickerColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function PickerColumn({

const nextScrollerTranslate = scrollerTranslate + delta
updateScrollerWhileMoving(nextScrollerTranslate)
}, [itemHeight, scrollerTranslate, updateScrollerWhileMoving])
}, [itemHeight, scrollerTranslate, updateScrollerWhileMoving, wheelMode])

const handleWheelEnd = useCallback(() => {
handleScrollerTranslateSettled()
Expand Down
3 changes: 2 additions & 1 deletion lib/components/PickerItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export interface PickerItemProps extends Omit<HTMLProps<HTMLDivElement>, 'value'
value: string
}

function isFunction(functionToCheck: any): functionToCheck is Function {
// eslint-disable-next-line
function isFunction(functionToCheck: any): boolean {
return typeof functionToCheck === 'function'
}

Expand Down
45 changes: 30 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,41 @@
"name": "react-mobile-picker",
"version": "1.0.0",
"description": "An iOS like select box component for React",
"type": "module",
"files": [
"dist",
"README.md"
],
"main": "./dist/react-mobile-picker.umd.cjs",
"module": "./dist/react-mobile-picker.js",
"typings": "./dist/react-mobile-picker.d.ts",
"exports": {
".": {
"import": "./dist/react-mobile-picker.js",
"require": "./dist/react-mobile-picker.umd.cjs"
}
},
"repository": "https://github.com/adcentury/react-mobile-picker",
"license": "MIT",
"scripts": {
"dev": "vite",
"build:lib": "tsc && vite build",
"build:examples": "tsc && vite build --config vite.config.examples.ts",
"lint": "eslint lib examples --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
"preview": "vite preview",
"prepare": "husky install"
},
"lint-staged": {
"lib/**/*.{ts,tsx}": [
"eslint --fix"
],
"examples/**/*.{ts,tsx}": [
"eslint --fix"
]
},
"peerDependencies": {
"react": "^18",
"react-dom": "^18"
"react": "^16 || ^17 || ^18",
"react-dom": "^16 || ^17 || ^18"
},
"devDependencies": {
"@headlessui/react": "^1.7.17",
Expand All @@ -26,25 +51,15 @@
"eslint": "^8.44.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.1",
"husky": "^8.0.3",
"less": "^4.1.3",
"lint-staged": "^14.0.1",
"postcss": "^8.4.26",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwindcss": "^3.3.3",
"typescript": "^5.0.2",
"vite": "^4.4.0",
"vite-plugin-dts": "^3.3.1"
},
"type": "module",
"files": [
"dist"
],
"main": "./dist/react-mobile-picker.umd.cjs",
"module": "./dist/react-mobile-picker.js",
"exports": {
".": {
"import": "./dist/react-mobile-picker.js",
"require": "./dist/react-mobile-picker.umd.cjs"
}
}
}
Loading

0 comments on commit a57273c

Please sign in to comment.