Skip to content

Commit 2685c98

Browse files
committed
chore: add eslint
1 parent 3b428b9 commit 2685c98

File tree

102 files changed

+1007
-794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1007
-794
lines changed

.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"root": true,
3+
"extends": ["react-spring"]
4+
}

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
- name: Build
4141
run: yarn build
4242

43+
- name: Lint
44+
run: yarn lint
45+
4346
- name: Typecheck
4447
run: yarn test:ts
4548

demo/.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"root": true,
3+
"extends": ["react-spring"]
4+
}

demo/custom.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
declare module 'vec-la'
22
declare module '*.scss'
3+
declare module '*.module.css'

demo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"scripts": {
1010
"dev": "vite",
1111
"clean": "rm -rf .turbo && rm -rf node_modules",
12+
"lint": "TIMING=1 eslint \"src/**/*.ts*\"",
1213
"serve": "vite preview"
1314
},
1415
"dependencies": {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module '*.module.css'

demo/src/sandboxes/draggable-list/src/App.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1-
import React, { useRef } from 'react'
1+
import * as React from 'react'
22
import { useSprings, animated } from '@react-spring/web'
33
import { useDrag } from 'react-use-gesture'
44
import clamp from 'lodash.clamp'
55
import swap from 'lodash-move'
66

77
import styles from './styles.module.css'
88

9-
const fn = (order: number[], active = false, originalIndex = 0, curIndex = 0, y = 0) => (index: number) =>
10-
active && index === originalIndex
11-
? {
12-
y: curIndex * 50 + y,
13-
scale: 1.1,
14-
zIndex: 1,
15-
shadow: 15,
16-
immediate: (key: string) => key === 'y' || key === 'zIndex',
17-
}
18-
: {
19-
y: order.indexOf(index) * 50,
20-
scale: 1,
21-
zIndex: 0,
22-
shadow: 1,
23-
immediate: false,
24-
}
9+
const fn =
10+
(order: number[], active = false, originalIndex = 0, curIndex = 0, y = 0) =>
11+
(index: number) =>
12+
active && index === originalIndex
13+
? {
14+
y: curIndex * 50 + y,
15+
scale: 1.1,
16+
zIndex: 1,
17+
shadow: 15,
18+
immediate: (key: string) => key === 'y' || key === 'zIndex',
19+
}
20+
: {
21+
y: order.indexOf(index) * 50,
22+
scale: 1,
23+
zIndex: 0,
24+
shadow: 1,
25+
immediate: false,
26+
}
2527

2628
function DraggableList({ items }: { items: string[] }) {
27-
const order = useRef(items.map((_, index) => index)) // Store indicies as a local ref, this represents the item order
29+
const order = React.useRef(items.map((_, index) => index)) // Store indicies as a local ref, this represents the item order
2830
const [springs, api] = useSprings(items.length, fn(order.current)) // Create springs, each corresponds to an item, controlling its transform, scale, etc.
2931
const bind = useDrag(({ args: [originalIndex], active, movement: [, y] }) => {
3032
const curIndex = order.current.indexOf(originalIndex)
@@ -44,9 +46,9 @@ function DraggableList({ items }: { items: string[] }) {
4446
boxShadow: shadow.to(s => `rgba(0, 0, 0, 0.15) 0px ${s}px ${2 * s}px 0px`),
4547
y,
4648
scale,
47-
}}
48-
children={items[i]}
49-
/>
49+
}}>
50+
{items[i]}
51+
</animated.div>
5052
))}
5153
</div>
5254
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module '*.module.css'

demo/src/sandboxes/exit-before-enter/src/App.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useLayoutEffect, useState } from 'react'
1+
import * as React from 'react'
22
import {
33
useSpringRef,
44
animated,
@@ -15,7 +15,7 @@ const IMAGES = [
1515
]
1616

1717
export default function App() {
18-
const [activeIndex, setActiveIndex] = useState(0)
18+
const [activeIndex, setActiveIndex] = React.useState(0)
1919
const springApi = useSpringRef()
2020

2121
const transitions = useTransition(activeIndex, {
@@ -55,9 +55,9 @@ export default function App() {
5555
ref: springApi,
5656
})
5757

58-
useLayoutEffect(() => {
58+
React.useLayoutEffect(() => {
5959
springApi.start()
60-
}, [activeIndex])
60+
}, [activeIndex, springApi])
6161

6262
return (
6363
<div className={styles.container}>

demo/src/sandboxes/floating-button/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const App = () => {
3030

3131
const [avatarSprings, avatarApi] = useSprings(
3232
COLORS.length,
33-
i => ({
33+
() => ({
3434
y: 0,
3535
}),
3636
[]
@@ -47,7 +47,7 @@ const App = () => {
4747
y: avatarRefInitialPositions.current[i],
4848
immediate: true,
4949
}))
50-
}, [])
50+
}, [avatarApi])
5151

5252
const getBounds = React.useCallback(() => {
5353
const { height, width } = containerRef.current.getBoundingClientRect()

0 commit comments

Comments
 (0)