mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-12-01 17:23:40 +08:00
Improve theme consistency, keyboard navigation, and reusable frontend components. Harden fullstack initialization and expose scoped lint and Vitest commands.
39 lines
1008 B
JavaScript
39 lines
1008 B
JavaScript
import { statSync } from 'node:fs'
|
|
|
|
const files = process.argv.slice(process.argv[2] === '--' ? 3 : 2)
|
|
|
|
if (files.length === 0) {
|
|
console.error('Usage: pnpm lint:fix <file> [<file> ...]')
|
|
process.exit(1)
|
|
}
|
|
|
|
const invalidFile = files.find(
|
|
(file) => !statSync(file, { throwIfNoEntry: false })?.isFile(),
|
|
)
|
|
|
|
if (invalidFile !== void 0) {
|
|
console.error(`Expected an existing file path: ${invalidFile}`)
|
|
process.exit(1)
|
|
}
|
|
|
|
const { ESLint } = await import('eslint')
|
|
const eslint = new ESLint({ fix: true, globInputPaths: false })
|
|
const lintableFiles = []
|
|
|
|
for (const file of files) {
|
|
if (!(await eslint.isPathIgnored(file))) lintableFiles.push(file)
|
|
}
|
|
|
|
if (lintableFiles.length > 0) {
|
|
const results = await eslint.lintFiles(lintableFiles)
|
|
const formatter = await eslint.loadFormatter()
|
|
|
|
await ESLint.outputFixes(results)
|
|
process.stdout.write(await formatter.format(results))
|
|
|
|
if (
|
|
results.some(({ errorCount, warningCount }) => errorCount || warningCount)
|
|
)
|
|
process.exitCode = 1
|
|
}
|