Skip to content

Commit d99268e

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

38 files changed

Lines changed: 1640 additions & 1557 deletions

File tree

eslint.config.mjs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ const __dirname = path.dirname(__filename)
1717
const compat = new FlatCompat({
1818
baseDirectory: __dirname,
1919
recommendedConfig: js.configs.recommended,
20-
allConfig: js.configs.all,
20+
allConfig: js.configs.all
2121
})
2222
// npx @eslint/migrate-config .eslintrc.json
2323
export default [
2424
{
25-
ignores: ['node_modules/**/*', '**/CHANGELOG.md', '**/package-lock.json', 'dist/**/*', 'build/**/*', '**/coverage'],
25+
ignores: ['node_modules/**/*', '**/CHANGELOG.md', '**/package-lock.json', 'dist/**/*', 'build/**/*', '**/coverage']
2626
},
2727
...compat.extends('plugin:react/recommended', 'prettier'),
2828
{
2929
plugins: {
3030
react,
3131
'@typescript-eslint': typescriptEslint,
32-
'react-hooks': fixupPluginRules(reactHooks),
32+
'react-hooks': fixupPluginRules(reactHooks)
3333
},
3434

3535
languageOptions: {
3636
globals: {
37-
...globals.browser,
37+
...globals.browser
3838
},
3939

4040
parser: tsParser,
@@ -43,15 +43,15 @@ export default [
4343

4444
parserOptions: {
4545
ecmaFeatures: {
46-
jsx: true,
47-
},
48-
},
46+
jsx: true
47+
}
48+
}
4949
},
5050

5151
settings: {
5252
react: {
53-
version: 'detect',
54-
},
53+
version: 'detect'
54+
}
5555
},
5656

5757
rules: {
@@ -87,8 +87,8 @@ export default [
8787
'no-inner-declarations': 'off',
8888
'no-unused-expressions': 'off',
8989
'no-unused-vars': 'off',
90-
'no-plusplus': 'off',
91-
},
90+
'no-plusplus': 'off'
91+
}
9292
},
93-
...storybook.configs['flat/recommended'],
93+
...storybook.configs['flat/recommended']
9494
]

jest.config.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ module.exports = {
22
testEnvironment: 'jsdom',
33
collectCoverage: true,
44
transform: {
5-
'^.+\\.(t|j)sx?$': 'babel-jest',
5+
'^.+\\.(t|j)sx?$': 'babel-jest'
66
},
77
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
88
moduleNameMapper: {
99
'\\.(css|less|scss)$': '<rootDir>/jest/styleMock.js',
10-
'^@\\/(.*)$': '<rootDir>/src/$1',
10+
'^@\\/(.*)$': '<rootDir>/src/$1'
1111
},
1212
testPathIgnorePatterns: ['/tests/e2e/'],
13-
setupFilesAfterEnv: ['<rootDir>/jest/setupTests.js'],
13+
setupFilesAfterEnv: ['<rootDir>/jest/setupTests.js']
1414
}

scripts/depcheck.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const buildScriptDeps = () => {
5959
const depNames = [
6060
...Object.keys(pkg.dependencies || {}),
6161
...Object.keys(pkg.devDependencies || {}),
62-
...Object.keys(pkg.optionalDependencies || {}),
62+
...Object.keys(pkg.optionalDependencies || {})
6363
]
6464

6565
for (const name of depNames) {
@@ -112,7 +112,7 @@ const buildConfigDeps = () => {
112112
const depNames = [
113113
...Object.keys(pkg.dependencies || {}),
114114
...Object.keys(pkg.devDependencies || {}),
115-
...Object.keys(pkg.optionalDependencies || {}),
115+
...Object.keys(pkg.optionalDependencies || {})
116116
]
117117

118118
const files = []
@@ -192,7 +192,7 @@ const report = await new Promise((resolve, reject) => {
192192
'storybook-static',
193193
'coverage',
194194
'playwright-report',
195-
'test-results',
195+
'test-results'
196196
],
197197
// Avoid the ttypescript special (it reads tsconfig.json as strict JSON and can fail on JSONC).
198198
specials: [
@@ -203,8 +203,8 @@ const report = await new Promise((resolve, reject) => {
203203
depcheck.special.webpack,
204204
depcheck.special.husky,
205205
depcheck.special.prettier,
206-
depcheck.special.commitizen,
207-
],
206+
depcheck.special.commitizen
207+
]
208208
},
209209
(unused) => resolve(unused)
210210
)
@@ -221,7 +221,7 @@ const ignoreMissingPrefixes = [
221221
'@assets/',
222222
'@app-hooks/',
223223
'@container/',
224-
'@theme/',
224+
'@theme/'
225225
]
226226

227227
const pickArray = (key) => {

scripts/optimize-media.mjs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ const MP4_AUDIO_BITRATE = process.env.MP4_AUDIO_BITRATE || '128k'
2121
const MIN_SAVINGS_PCT = Number(process.env.MEDIA_MIN_SAVINGS_PCT || '5')
2222
const SKIP_SMALL_KB = Number(process.env.MEDIA_SKIP_SMALL_KB || '256')
2323

24-
function bytesToMiB(bytes) {
24+
function bytesToMiB (bytes) {
2525
return (bytes / 1024 / 1024).toFixed(2)
2626
}
2727

28-
function runFfmpeg(args) {
28+
function runFfmpeg (args) {
2929
const result = spawnSync('ffmpeg', args, {
3030
stdio: 'inherit',
31-
windowsHide: true,
31+
windowsHide: true
3232
})
3333
if (result.error) {
3434
throw result.error
@@ -38,7 +38,7 @@ function runFfmpeg(args) {
3838
}
3939
}
4040

41-
function isFileExists(filePath) {
41+
function isFileExists (filePath) {
4242
try {
4343
fsSync.accessSync(filePath)
4444
return true
@@ -47,29 +47,29 @@ function isFileExists(filePath) {
4747
}
4848
}
4949

50-
async function ensureDir(dirPath) {
50+
async function ensureDir (dirPath) {
5151
await fs.mkdir(dirPath, { recursive: true })
5252
}
5353

54-
async function cleanDir(dirPath) {
54+
async function cleanDir (dirPath) {
5555
await fs.rm(dirPath, { recursive: true, force: true })
5656
await ensureDir(dirPath)
5757
}
5858

59-
async function* walkFiles(dirPath) {
59+
async function * walkFiles (dirPath) {
6060
if (!isFileExists(dirPath)) return
6161
const entries = await fs.readdir(dirPath, { withFileTypes: true })
6262
for (const entry of entries) {
6363
const fullPath = path.join(dirPath, entry.name)
6464
if (entry.isDirectory()) {
65-
yield* walkFiles(fullPath)
65+
yield * walkFiles(fullPath)
6666
} else if (entry.isFile()) {
6767
yield fullPath
6868
}
6969
}
7070
}
7171

72-
async function optimizeOne({ inputPath, inputBaseDir, outputBaseDir }) {
72+
async function optimizeOne ({ inputPath, inputBaseDir, outputBaseDir }) {
7373
const relPath = path.relative(inputBaseDir, inputPath)
7474
const outputPath = path.join(outputBaseDir, relPath)
7575

@@ -111,7 +111,7 @@ async function optimizeOne({ inputPath, inputBaseDir, outputBaseDir }) {
111111
MP3_BITRATE,
112112
'-id3v2_version',
113113
'3',
114-
tmpPath,
114+
tmpPath
115115
])
116116
} else {
117117
// Re-encode MP4 (H.264 + AAC) and enable faststart
@@ -133,7 +133,7 @@ async function optimizeOne({ inputPath, inputBaseDir, outputBaseDir }) {
133133
MP4_AUDIO_BITRATE,
134134
'-movflags',
135135
'+faststart',
136-
tmpPath,
136+
tmpPath
137137
])
138138
}
139139

@@ -151,12 +151,12 @@ async function optimizeOne({ inputPath, inputBaseDir, outputBaseDir }) {
151151
return { changed: true, reason: 'optimized', before: stat.size, after: outStat.size, outputPath }
152152
}
153153

154-
function checkFfmpegAvailable() {
154+
function checkFfmpegAvailable () {
155155
const result = spawnSync('ffmpeg', ['-version'], { stdio: 'ignore', windowsHide: true })
156156
return result.status === 0
157157
}
158158

159-
async function main() {
159+
async function main () {
160160
if (!checkFfmpegAvailable()) {
161161
console.error('[optimize:media] ffmpeg not found in PATH.')
162162
console.error('Install ffmpeg and ensure `ffmpeg` is available in your terminal, then re-run.')
@@ -167,7 +167,7 @@ async function main() {
167167
const targets = [
168168
{ inputDir: SRC_AUDIO_DIR, outputDir: OUT_AUDIO_DIR },
169169
{ inputDir: SRC_VIDEO_DIR, outputDir: OUT_VIDEO_DIR },
170-
{ inputDir: SRC_PUBLIC_AUDIO_DIR, outputDir: OUT_PUBLIC_AUDIO_DIR },
170+
{ inputDir: SRC_PUBLIC_AUDIO_DIR, outputDir: OUT_PUBLIC_AUDIO_DIR }
171171
]
172172

173173
let changedCount = 0
@@ -188,7 +188,7 @@ async function main() {
188188
const result = await optimizeOne({
189189
inputPath,
190190
inputBaseDir: target.inputDir,
191-
outputBaseDir: target.outputDir,
191+
outputBaseDir: target.outputDir
192192
})
193193
if (result.changed) {
194194
changedCount += 1

scripts/prepare-lib-publish.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs/promises'
22
import path from 'node:path'
33

4-
async function fileExists(filePath) {
4+
async function fileExists (filePath) {
55
try {
66
await fs.access(filePath)
77
return true
@@ -10,11 +10,11 @@ async function fileExists(filePath) {
1010
}
1111
}
1212

13-
function pickDefined(obj) {
13+
function pickDefined (obj) {
1414
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined))
1515
}
1616

17-
async function main() {
17+
async function main () {
1818
const repoRoot = process.cwd()
1919
const rootPkgPath = path.join(repoRoot, 'package.json')
2020
const distDir = path.join(repoRoot, 'dist-lib')
@@ -46,25 +46,25 @@ async function main() {
4646
'.': {
4747
types: './index.d.ts',
4848
import: './pro-react-components.es.js',
49-
require: './pro-react-components.umd.js',
49+
require: './pro-react-components.umd.js'
5050
},
5151
'./core': {
5252
types: './entries/core.d.ts',
5353
import: './entries/core.es.js',
54-
require: './entries/core.cjs.js',
54+
require: './entries/core.cjs.js'
5555
},
5656
'./stateful': {
5757
types: './entries/stateful.d.ts',
5858
import: './entries/stateful.es.js',
59-
require: './entries/stateful.cjs.js',
59+
require: './entries/stateful.cjs.js'
6060
},
6161
'./stateless': {
6262
types: './entries/stateless.d.ts',
6363
import: './entries/stateless.es.js',
64-
require: './entries/stateless.cjs.js',
64+
require: './entries/stateless.cjs.js'
6565
},
66-
'./style.css': './style.css',
67-
},
66+
'./style.css': './style.css'
67+
}
6868
}
6969

7070
const distPkgPath = path.join(distDir, 'package.json')

scripts/run-lighthouse.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ const buildPortList = () => {
99
const raw = process.env.LH_PORTS
1010
if (raw && raw.trim()) {
1111
// supports: "8080,8081,8090" or "8080-8090"
12-
const parts = raw.split(',').map((s) => s.trim()).filter(Boolean)
12+
const parts = raw
13+
.split(',')
14+
.map((s) => s.trim())
15+
.filter(Boolean)
1316
const ports = []
1417
for (const part of parts) {
1518
const range = part.split('-').map((s) => s.trim())
@@ -48,8 +51,8 @@ const fetchOk = async (url) => {
4851
signal: controller.signal,
4952
headers: {
5053
// Some dev servers behave differently for default fetch UA.
51-
'User-Agent': 'wui-react-lighthouse-probe',
52-
},
54+
'User-Agent': 'wui-react-lighthouse-probe'
55+
}
5356
})
5457
if (!res.ok) return false
5558
const text = await res.text()
@@ -104,7 +107,7 @@ const runLighthouse = (url) => {
104107
const args = ['--view', url, '--preset=desktop']
105108
const result = spawnSync('lighthouse', args, {
106109
stdio: 'inherit',
107-
shell: process.platform === 'win32',
110+
shell: process.platform === 'win32'
108111
})
109112

110113
process.exit(result.status ?? 1)

src/components/KeepAlive/index.jsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,16 @@ const createKeepAliveManager = () => {
8888
// set global options: { deactivateDelay, keepInactiveCount, limit }
8989
setOptions: (opts = {}) => {
9090
if (typeof opts.deactivateDelay === 'number') deactivateDelay = opts.deactivateDelay
91-
if (typeof opts.keepInactiveCount === 'number')
91+
if (typeof opts.keepInactiveCount === 'number') {
9292
keepInactiveCount = Math.max(0, Math.floor(opts.keepInactiveCount))
93+
}
9394
if (typeof opts.limit === 'number') limit = Math.max(0, Math.floor(opts.limit))
9495
},
9596
register: (id, opts) => {
9697
// opts: { setShouldRender, persistOnUnmount }
9798
instances.set(id, {
9899
setShouldRender: opts.setShouldRender,
99-
persistOnUnmount: !!opts.persistOnUnmount,
100+
persistOnUnmount: !!opts.persistOnUnmount
100101
})
101102
},
102103
unregister: (id) => {
@@ -196,7 +197,7 @@ const createKeepAliveManager = () => {
196197
instances.delete(id)
197198
activeMap.delete(id)
198199
keys = keys.filter((k) => k !== id)
199-
},
200+
}
200201
}
201202
}
202203

@@ -239,7 +240,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
239240
const effectivePersist = ActivityComponent ? true : persistOnUnmount
240241
keepAliveManager.register(id, {
241242
setShouldRender,
242-
persistOnUnmount: effectivePersist,
243+
persistOnUnmount: effectivePersist
243244
})
244245
}
245246
return () => {
@@ -308,14 +309,14 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
308309
if (!active) return
309310
scrollPos.current.set(e.target, {
310311
left: e.target.scrollLeft,
311-
top: e.target.scrollTop,
312+
top: e.target.scrollTop
312313
})
313314
}
314315

315316
// Capture scroll events to record positions
316317
container.addEventListener('scroll', onScroll, {
317318
capture: true,
318-
passive: true,
319+
passive: true
319320
})
320321

321322
return () => {
@@ -359,7 +360,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
359360
if (container.parentNode !== placeholder) {
360361
// 在移动DOM之前,发送自定义事件通知子组件
361362
const event = new CustomEvent('keepalive-dom-move', {
362-
detail: { from: container.parentNode, to: placeholder },
363+
detail: { from: container.parentNode, to: placeholder }
363364
})
364365
container.dispatchEvent(event)
365366

@@ -429,7 +430,7 @@ KeepAlive.propTypes = {
429430
active: PropTypes.bool,
430431
children: PropTypes.node,
431432
persistOnUnmount: PropTypes.bool,
432-
cacheLimit: PropTypes.number,
433+
cacheLimit: PropTypes.number
433434
}
434435

435436
export default KeepAlive

0 commit comments

Comments
 (0)