🌈 style(eslint): 新增eslint规则

This commit is contained in:
xuan
2022-12-02 18:59:29 +08:00
parent c3cb46a5a7
commit d49314aa5b
217 changed files with 19491 additions and 19187 deletions
+27 -22
View File
@@ -1,14 +1,16 @@
import { ScrollView, View } from '@tarojs/components'
import React, { memo, ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react'
import styles from './index.module.scss'
import classnames from 'classnames'
import Taro, { getCurrentInstance, useReady, useRouter } from '@tarojs/taro'
import InfiniteScroll, { StatusParam } from '../infiniteScroll'
import type { ReactNode } from 'react'
import React, { memo, useEffect, useLayoutEffect, useRef, useState } from 'react'
import classnames from 'classnames'
import type { StatusParam } from '../infiniteScroll'
import InfiniteScroll from '../infiniteScroll'
import LoadingCard from '../loadingCard'
import styles from './index.module.scss'
import ProductClass from '@/pages/index/components/productClass'
import { GetClassList } from '@/api/material'
type Params = {
interface Params {
list?: any[]
defaultValue?: number | string
children?: ReactNode
@@ -38,7 +40,7 @@ export default memo(
statusMore = 0,
selectClass,
}: Params) => {
let num_half = useRef(0)
const num_half = useRef(0)
const [selected, setSelected] = useState(defaultValue)
const [tabId, setTabId] = useState('')
@@ -66,24 +68,25 @@ export default memo(
const computeSelectTab = (index) => {
if (index + 1 > num_half.current) {
let num = index + 1 - num_half.current
const num = index + 1 - num_half.current
setTabId(list[num].id.toString())
} else {
}
else {
setTabId(list[0].id.toString())
}
}
useEffect(() => {
Taro.nextTick(() => {
let query = Taro.createSelectorQuery()
const query = Taro.createSelectorQuery()
query
.select('.side_bar_select')
.boundingClientRect((rect) => {
console.log('rect::', rect)
let clientHeight = rect.height
let clientWidth = rect.width
let ratio = 750 / clientWidth
let height = clientHeight * ratio
const clientHeight = rect.height
const clientWidth = rect.width
const ratio = 750 / clientWidth
const height = clientHeight * ratio
num_half.current = Math.ceil(height / 2 / heightItem)
console.log('num_half::', num_half)
init()
@@ -92,13 +95,13 @@ export default memo(
})
}, [])
//二级面料系列分类
// 二级面料系列分类
const [openClass, setOpenClass] = useState(false)
const [classList, setClassList] = useState([])
const [classId, setClassId] = useState(-1)
const { fetchData } = GetClassList()
const getClassData = async (id) => {
let res = await fetchData({ id })
const getClassData = async(id) => {
const res = await fetchData({ id })
if (res.success) {
if (res.data?.list.length > 0) {
res.data.list = [{ id: -1, name: '全部' }, ...res.data.list]
@@ -107,7 +110,7 @@ export default memo(
}
}
useEffect(() => {
if (selected) getClassData(selected)
if (selected) { getClassData(selected) }
}, [selected])
const getSelectClass = (id) => {
@@ -118,13 +121,14 @@ export default memo(
return (
<>
<View className={classnames(styles.sideBar_main, 'side_bar_select')}>
<ScrollView scrollWithAnimation={true} style={{ height }} className={styles.sideBar_select} scrollY scrollIntoView={`tab_${tabId}`}>
<ScrollView scrollWithAnimation style={{ height }} className={styles.sideBar_select} scrollY scrollIntoView={`tab_${tabId}`}>
{list?.map((item, index) => {
return (
<View className={styles.sideBar_select_title} id={`tab_${item.id}`} key={item.id} style={{ height: `${heightItem}rpx` }}>
<View
className={classnames(styles.sideBar_select_title_item, { [styles.sideBar_select_title_select]: selected == item.id })}
onClick={() => clickEvent({ item, index })}>
onClick={() => clickEvent({ item, index })}
>
<View className={styles.title_con}>{item.name}</View>
</View>
</View>
@@ -134,7 +138,7 @@ export default memo(
<View className={styles.sideBar_con} style={{ paddingTop: classList.length > 0 ? '90rpx' : '20rpx' }}>
{classList.length > 0 && (
<View className={styles.product_class} style={{ height: openClass ? '100%' : '' }}>
<ProductClass list={classList} open={openClass} onOpenClick={(val) => setOpenClass(val)} onSelect={getSelectClass} defaultSelectId={classId} />
<ProductClass list={classList} open={openClass} onOpenClick={val => setOpenClass(val)} onSelect={getSelectClass} defaultSelectId={classId} />
</View>
)}
<InfiniteScroll
@@ -142,8 +146,9 @@ export default memo(
hasMore={hasMore}
selfonScrollToLower={() => selfOnScrolltolower?.()}
refresherTriggered={refresherTriggered}
refresherEnabled={true}
selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}>
refresherEnabled
selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}
>
{children}
</InfiniteScroll>
</View>