Skip to content

Commit 0a20aa6

Browse files
style: format code with Prettier and StandardJS
This commit fixes the style issues introduced in be1b8d4 according to the output from Prettier and StandardJS. Details: None
1 parent be1b8d4 commit 0a20aa6

File tree

38 files changed

+754
-734
lines changed

38 files changed

+754
-734
lines changed

babel.config.cjs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const plugins = [
33
['@babel/plugin-proposal-decorators', { legacy: true }],
44
['@babel/plugin-transform-runtime'],
55
['@babel/plugin-transform-object-rest-spread'],
6-
['babel-plugin-react-compiler'],
6+
['babel-plugin-react-compiler']
77
]
88

99
module.exports = {
@@ -12,27 +12,30 @@ module.exports = {
1212
'@babel/preset-env',
1313
{
1414
targets: {
15-
browsers: ['> 1%', 'last 2 versions', 'not ie <= 8'],
15+
browsers: ['> 1%', 'last 2 versions', 'not ie <= 8']
1616
},
1717
modules: false,
1818
useBuiltIns: 'entry',
19-
corejs: 3,
20-
},
19+
corejs: 3
20+
}
2121
],
2222
[
2323
'@babel/preset-react',
2424
{
25-
runtime: 'automatic',
26-
},
25+
runtime: 'automatic'
26+
}
2727
],
28-
'@babel/preset-typescript',
28+
'@babel/preset-typescript'
2929
],
3030
compact: true,
3131
comments: true,
32-
plugins: process.env.NODE_ENV === 'production' ? [...plugins, 'transform-remove-console', 'transform-remove-debugger'] : plugins,
32+
plugins:
33+
process.env.NODE_ENV === 'production'
34+
? [...plugins, 'transform-remove-console', 'transform-remove-debugger']
35+
: plugins,
3336
env: {
3437
development: {
35-
plugins: ['react-refresh/babel'],
36-
},
37-
},
38+
plugins: ['react-refresh/babel']
39+
}
40+
}
3841
}

jest.config.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ module.exports = {
22
testEnvironment: 'jsdom',
33
collectCoverage: true,
44
transform: {
5-
'^.+\\.(t|j)sx?$': 'esbuild-jest',
5+
'^.+\\.(t|j)sx?$': 'esbuild-jest'
66
},
77
// When the package is ESM ("type": "module"), treat these extensions as ESM for Jest
88
extensionsToTreatAsEsm: ['.ts', '.tsx', '.jsx'],
99
// esbuild-jest does not need babel-jest globals
1010
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
1111
moduleNameMapper: {
1212
'\\.(css|less|scss)$': '<rootDir>/jest/styleMock.js',
13-
'^@\\/(.*)$': '<rootDir>/src/$1',
13+
'^@\\/(.*)$': '<rootDir>/src/$1'
1414
},
1515
// Ignore built/distribution files to avoid haste name collisions
1616
modulePathIgnorePatterns: ['<rootDir>/dist-lib/'],
1717
testPathIgnorePatterns: ['/tests/e2e/'],
18-
setupFilesAfterEnv: ['<rootDir>/jest/setupTests.js'],
18+
setupFilesAfterEnv: ['<rootDir>/jest/setupTests.js']
1919
}

src/app-hooks/proTabsContext/index.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const defaultValue = {
88
setActiveKey: () => {},
99
panes: [],
1010
setPanes: () => {},
11-
removeTab: () => {},
11+
removeTab: () => {}
1212
}
1313

1414
const initialPanes = [
@@ -18,8 +18,8 @@ const initialPanes = [
1818
key: '/',
1919
content: <Home />,
2020
closable: false,
21-
path: '/',
22-
},
21+
path: '/'
22+
}
2323
]
2424

2525
const ProTabContext = createContext(defaultValue)
@@ -62,7 +62,7 @@ const ProTabProvider = ({ children }) => {
6262
setActiveKey,
6363
panes,
6464
setPanes,
65-
removeTab,
65+
removeTab
6666
}),
6767
[activeKey, setActiveKey, panes, setPanes, removeTab]
6868
)

src/components/KeepAlive/index.jsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,16 @@ const createKeepAliveManager = () => {
8585
// set global options: { deactivateDelay, keepInactiveCount, limit }
8686
setOptions: (opts = {}) => {
8787
if (typeof opts.deactivateDelay === 'number') deactivateDelay = opts.deactivateDelay
88-
if (typeof opts.keepInactiveCount === 'number')
88+
if (typeof opts.keepInactiveCount === 'number') {
8989
keepInactiveCount = Math.max(0, Math.floor(opts.keepInactiveCount))
90+
}
9091
if (typeof opts.limit === 'number') limit = Math.max(0, Math.floor(opts.limit))
9192
},
9293
register: (id, opts) => {
9394
// opts: { setShouldRender, persistOnUnmount }
9495
instances.set(id, {
9596
setShouldRender: opts.setShouldRender,
96-
persistOnUnmount: !!opts.persistOnUnmount,
97+
persistOnUnmount: !!opts.persistOnUnmount
9798
})
9899
},
99100
unregister: (id) => {
@@ -193,7 +194,7 @@ const createKeepAliveManager = () => {
193194
instances.delete(id)
194195
activeMap.delete(id)
195196
keys = keys.filter((k) => k !== id)
196-
},
197+
}
197198
}
198199
}
199200

@@ -236,7 +237,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
236237
const effectivePersist = ActivityComponent ? true : persistOnUnmount
237238
keepAliveManager.register(id, {
238239
setShouldRender,
239-
persistOnUnmount: effectivePersist,
240+
persistOnUnmount: effectivePersist
240241
})
241242
}
242243
return () => {
@@ -329,14 +330,14 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
329330
if (!active) return
330331
scrollPos.current.set(e.target, {
331332
left: e.target.scrollLeft,
332-
top: e.target.scrollTop,
333+
top: e.target.scrollTop
333334
})
334335
}
335336

336337
// Capture scroll events to record positions
337338
target.addEventListener('scroll', onScroll, {
338339
capture: true,
339-
passive: true,
340+
passive: true
340341
})
341342

342343
return () => {
@@ -390,7 +391,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
390391
// 在移动 DOM 之前,发送自定义事件通知子组件,然后同步移动到占位符下。
391392
// 之前使用短延迟的异步移动会导致渲染滞后和大量定时器/帧回调,移到同步移动以提升响应性。
392393
const event = new CustomEvent('keepalive-dom-move', {
393-
detail: { from: container.parentNode, to: placeholder },
394+
detail: { from: container.parentNode, to: placeholder }
394395
})
395396

396397
let dispatchError = null
@@ -405,7 +406,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
405406
console.debug('[KeepAlive] appending container to placeholder', id, {
406407
from: container.parentNode,
407408
to: placeholder,
408-
dispatchError,
409+
dispatchError
409410
})
410411
} catch (e) {}
411412
}
@@ -428,7 +429,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
428429
id,
429430
note: 'no-children-after-append',
430431
childElementCount: container.childElementCount,
431-
time: Date.now(),
432+
time: Date.now()
432433
})
433434
try {
434435
document.body.dataset.keepaliveIssue = 'no-children'
@@ -454,7 +455,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
454455
childElementCount: container.childElementCount,
455456
appended,
456457
dispatchError,
457-
time: Date.now(),
458+
time: Date.now()
458459
})
459460
}
460461
} catch (e) {}
@@ -492,7 +493,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
492493
note: 'cleared-inline-display-none',
493494
clearedCount: cleared.length,
494495
clearedTagsSample: cleared.slice(0, 5),
495-
time: Date.now(),
496+
time: Date.now()
496497
})
497498
}
498499
} catch (e) {}
@@ -523,7 +524,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
523524
window.__keepalive_debug_details.push({
524525
id,
525526
note: 'force-visible-root',
526-
time: Date.now(),
527+
time: Date.now()
527528
})
528529
}
529530
}
@@ -555,7 +556,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
555556
shouldRender,
556557
containerNode: !!containerNode,
557558
childrenType: typeof children,
558-
time: Date.now(),
559+
time: Date.now()
559560
})
560561
} catch (e) {}
561562
}, [shouldRender, active, containerNode, id, children])
@@ -613,7 +614,7 @@ KeepAlive.propTypes = {
613614
active: PropTypes.bool,
614615
children: PropTypes.node,
615616
persistOnUnmount: PropTypes.bool,
616-
cacheLimit: PropTypes.number,
617+
cacheLimit: PropTypes.number
617618
}
618619

619620
export default KeepAlive

src/components/hooks/useInViewport/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const useInViewport = (triggerOnce = false, threshold = 0, rootMargin = '0px') =
3535

3636
return {
3737
inViewRef,
38-
inViewport,
38+
inViewport
3939
}
4040
}
4141

src/components/hooks/useScrollIntoView/index.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ const useScrollIntoView = ({ offset = 0 }) => {
2626
if (shouldScrollY) {
2727
window.scrollTo({
2828
top: shouldScrollY ? adjustedTop : scrollTop,
29-
behavior: 'smooth',
29+
behavior: 'smooth'
3030
})
3131
}
3232

3333
if (shouldScrollX) {
3434
window.scrollTo({
3535
left: shouldScrollX ? adjustedLeft : scrollLeft,
36-
behavior: 'smooth',
36+
behavior: 'smooth'
3737
})
3838
}
3939

@@ -50,7 +50,7 @@ const useScrollIntoView = ({ offset = 0 }) => {
5050

5151
return {
5252
scrollIntoView,
53-
targetRef,
53+
targetRef
5454
}
5555
}
5656

src/components/hooks/useTable/index.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const useTable = (props) => {
2626
}
2727
dataInterface({
2828
...(isPagination ? { pageNum: page, pageSize } : {}),
29-
...other,
29+
...other
3030
}).then((resp) => {
3131
if (resp && resp.status === 1) {
3232
setPage(page)
@@ -73,7 +73,7 @@ const useTable = (props) => {
7373
setCachePayload({ ...safePayload })
7474
getTableList(dataInterface || props.dataInterface, {
7575
...cachePayload,
76-
...safePayload,
76+
...safePayload
7777
})
7878
}
7979

@@ -99,16 +99,16 @@ const useTable = (props) => {
9999
showQuickJumper: true,
100100
showSizeChanger: true,
101101
hideOnSinglePage: false,
102-
showTotal: (total) => <span>{`共计 ${total} 条记录 第${page}/${Math.ceil(total / pageSize)}页`}</span>,
102+
showTotal: (total) => <span>{`共计 ${total} 条记录 第${page}/${Math.ceil(total / pageSize)}页`}</span>
103103
}
104104
: false,
105-
scroll: dataSource.length ? { scrollToFirstRowOnChange: true, x: 'max-content' } : false,
105+
scroll: dataSource.length ? { scrollToFirstRowOnChange: true, x: 'max-content' } : false
106106
},
107107
page,
108108
pageSize,
109109
rawData,
110110
updateTable,
111-
resetTable,
111+
resetTable
112112
}
113113
}
114114
export default useTable

src/components/stateful/TreeList/index.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Index = forwardRef((props, ref) => {
1313
selectedKeys, // 选中的节点
1414
setSelectedKeys, // 选中外传函数
1515
selectable = false, // 父级节点是否可以选中
16-
params = {}, // 额外的参数
16+
params = {} // 额外的参数
1717
} = props
1818
const [treeList, setTreeList] = useState([]) // 全量数据源列表
1919
const [treeData, setTreeData] = useState([])
@@ -87,7 +87,7 @@ const Index = forwardRef((props, ref) => {
8787
return {
8888
...item,
8989
key: itemPath,
90-
...(item.children?.length ? { children: setPath(item.children, itemPath) } : {}),
90+
...(item.children?.length ? { children: setPath(item.children, itemPath) } : {})
9191
}
9292
})
9393
treeData = setPath(treeData)
@@ -123,7 +123,7 @@ const Index = forwardRef((props, ref) => {
123123
const defaultKey = selectable
124124
? {
125125
selected: [treeData[0].key],
126-
expanded: [treeData[0].key],
126+
expanded: [treeData[0].key]
127127
}
128128
: getDefaultKey(treeData)
129129
selected = defaultKey.selected
@@ -133,7 +133,7 @@ const Index = forwardRef((props, ref) => {
133133
const defaultKey = selectable
134134
? {
135135
selected: [treeData[0].key],
136-
expanded: [treeData[0].key],
136+
expanded: [treeData[0].key]
137137
}
138138
: getDefaultKey(treeData)
139139
selected = defaultKey.selected
@@ -159,7 +159,7 @@ const Index = forwardRef((props, ref) => {
159159
})
160160
selected = selectedKeys
161161

162-
function loop(params) {
162+
function loop (params) {
163163
return params.some((item) => {
164164
if (item.realId === selectedKeys[0]) {
165165
expanded = [item.key]
@@ -176,7 +176,7 @@ const Index = forwardRef((props, ref) => {
176176
const defaultKey = selectable
177177
? {
178178
selected: [treeData[0].key],
179-
expanded: [treeData[0].key],
179+
expanded: [treeData[0].key]
180180
}
181181
: getDefaultKey(treeData)
182182
selected = defaultKey.selected
@@ -216,14 +216,14 @@ const Index = forwardRef((props, ref) => {
216216
expandedKeys,
217217
setExpandedKeys,
218218
setSelectedKeys: setFixSelectedKeys,
219-
treeData,
219+
treeData
220220
}))
221221

222222
return (
223223
<div className={`${styles.treeList} treeList`}>
224224
<div>
225225
{search && (
226-
<Search placeholder="查询" onSearch={onSearch} style={{ marginBottom: 10, width: '100%' }} allowClear />
226+
<Search placeholder='查询' onSearch={onSearch} style={{ marginBottom: 10, width: '100%' }} allowClear />
227227
)}
228228
<Tree
229229
selectedKeys={!isEmpty(selectedKeys) ? selectedKeys : fixSelectedKeys}

0 commit comments

Comments
 (0)