Files
orca/config/scripts/lint-react-doctor-changed.mjs
mirror 34fa2cd5ca
Skill update round trip / roundtrip (false, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, latest) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
source snapshot 2026-09-02
2026-09-02 02:03:16 +08:00

45 lines
1.1 KiB
JavaScript

import { existsSync } from 'node:fs'
import { spawnSync } from 'node:child_process'
const SOURCE_FILE_PATTERN = /\.(?:[cm]?[jt]sx?)$/
function run(command, args) {
const result = spawnSync(command, args, {
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'inherit']
})
if (result.error) {
throw result.error
}
if (result.status !== 0) {
return []
}
return result.stdout.split(/\r?\n/).filter(Boolean)
}
const changedFiles = new Set([
...run('git', ['diff', '--name-only', '--diff-filter=ACMRTUB']),
...run('git', ['diff', '--cached', '--name-only', '--diff-filter=ACMRTUB']),
...run('git', ['ls-files', '--others', '--exclude-standard'])
])
const lintTargets = [...changedFiles].filter(
(file) => SOURCE_FILE_PATTERN.test(file) && existsSync(file)
)
if (lintTargets.length === 0) {
process.exit(0)
}
const pnpm = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'
const result = spawnSync(
pnpm,
['exec', 'oxlint', '--config', 'config/oxlint-react-doctor.json', ...lintTargets],
{ stdio: 'inherit' }
)
if (result.error) {
throw result.error
}
process.exit(result.status ?? 1)