Skip to content

Commit 05bc152

Browse files
authored
Run eslint and add :initial fallback from el.props (#52)
1 parent 0523a90 commit 05bc152

22 files changed

+92
-85
lines changed

scripts/watch.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ const rootDir = resolve(__dirname, '..')
99
const src = resolve(__dirname, '../src')
1010

1111
// Package build promise
12-
const tryBuild = async () => {
12+
const tryBuild = async() => {
1313
try {
1414
await build(rootDir, false)
15-
} catch (e) {
15+
}
16+
catch (e) {
1617
consola.log(e)
17-
} finally {
18+
}
19+
finally {
1820
consola.info('Waiting for changes...')
1921
}
2022
}

src/directive/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ export const directive = (
6161
bind: register,
6262
unbind: unregister,
6363
// Vue 3 SSR
64-
getSSRProps(binding) {
65-
const { initial = {} } = binding.value
64+
getSSRProps(binding, el) {
65+
const { initial } = binding.value || el.props || {}
6666

6767
// No initial
6868
if (!initial || Object.keys(initial).length === 0) return

src/features/eventListeners.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export function registerEventListeners<T extends MotionVariants>({
134134
const _stopSync = watch(computedProperties, apply)
135135

136136
const stop = () => {
137-
_eventListeners.forEach((stopFn) => stopFn())
137+
_eventListeners.forEach(stopFn => stopFn())
138138
_stopSync()
139139
}
140140

src/motionValue.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ export class MotionValue<V = any> {
134134
// These casts could be avoided if parseFloat would be typed better
135135
return this.canTrackVelocity
136136
? velocityPerSecond(
137-
parseFloat(this.current as any) - parseFloat(this.prev as any),
138-
this.timeDelta,
139-
)
137+
parseFloat(this.current as any) - parseFloat(this.prev as any),
138+
this.timeDelta,
139+
)
140140
: 0
141141
}
142142

src/reactiveTransform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export function reactiveTransform(
4949
// Loop on defined TransformProperties state keys
5050
for (const [key, value] of Object.entries(newVal)) {
5151
if (
52-
enableHardwareAcceleration &&
53-
(key === 'x' || key === 'y' || key === 'z')
52+
enableHardwareAcceleration
53+
&& (key === 'x' || key === 'y' || key === 'z')
5454
)
5555
continue
5656

src/types/variants.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ export interface TransformProperties {
4848
*/
4949
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
5050
export type StyleProperties = Omit<
51-
CSSProperties,
52-
| 'transition'
53-
| 'rotate'
54-
| 'scale'
55-
| 'perspective'
56-
| 'transform'
57-
| 'transformBox'
58-
| 'transformOrigin'
59-
| 'transformStyle'
51+
CSSProperties,
52+
| 'transition'
53+
| 'rotate'
54+
| 'scale'
55+
| 'perspective'
56+
| 'transform'
57+
| 'transformBox'
58+
| 'transformOrigin'
59+
| 'transformStyle'
6060
>
6161

6262
/**
@@ -72,7 +72,7 @@ export type MotionProperties =
7272
* Permissive properties for useSpring
7373
*/
7474
export type PermissiveMotionProperties = MotionProperties &
75-
Record<string, ResolvedSingleTarget>
75+
Record<string, ResolvedSingleTarget>
7676

7777
/**
7878
* Variant

src/useElementStyle.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export function useElementStyle(
3333
// Loop on style keys
3434
for (const key of Object.keys(valueTypes)) {
3535
if (
36-
el.style[key] === null ||
37-
el.style[key] === '' ||
38-
isTransformProp(key) ||
39-
isTransformOriginProp(key)
36+
el.style[key] === null
37+
|| el.style[key] === ''
38+
|| isTransformProp(key)
39+
|| isTransformOriginProp(key)
4040
)
4141
continue
4242

src/useMotion.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export function useMotion<T extends MotionVariants>(
2727
options?: UseMotionOptions,
2828
) {
2929
// Reactive styling and transform
30-
const { motionProperties, stop: stopMotionProperties } =
31-
useMotionProperties(target)
30+
const { motionProperties, stop: stopMotionProperties }
31+
= useMotionProperties(target)
3232

3333
// Variants manager
3434
const { variant, state } = useMotionVariants<T>(variants)
@@ -67,7 +67,8 @@ export function useMotion<T extends MotionVariants>(
6767
_stop()
6868
}
6969
})
70-
} else {
70+
}
71+
else {
7172
_stop()
7273
}
7374
}

src/useMotionControls.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export function useMotionControls<T extends MotionVariants>(
3434
motionValues,
3535
(newVal) => {
3636
// Go through every motion value, and check if any is animating
37-
isAnimating.value =
38-
Object.values(newVal).filter((value) => value.isAnimating()).length > 0
37+
isAnimating.value
38+
= Object.values(newVal).filter(value => value.isAnimating()).length > 0
3939
},
4040
{
4141
immediate: true,
@@ -66,8 +66,8 @@ export function useMotionControls<T extends MotionVariants>(
6666
key as keyof MotionProperties,
6767
value,
6868
motionProperties,
69-
(variant as Variant).transition ||
70-
getDefaultTransition(key, variant[key]),
69+
(variant as Variant).transition
70+
|| getDefaultTransition(key, variant[key]),
7171
resolve,
7272
)
7373
})
@@ -91,7 +91,7 @@ export function useMotionControls<T extends MotionVariants>(
9191
})
9292
}
9393

94-
const leave = async (done: () => void) => {
94+
const leave = async(done: () => void) => {
9595
let leaveVariant: Variant | undefined
9696

9797
if (_variants) {

src/useMotionFeatures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function useMotionFeatures<T extends MotionVariants>(
5757
}
5858

5959
// Stop all the registered features
60-
const stop = () => toStop.value.forEach((_stop) => _stop())
60+
const stop = () => toStop.value.forEach(_stop => _stop())
6161

6262
// Enforce cleanup on unmounted
6363
tryOnUnmounted(stop)

0 commit comments

Comments
 (0)