1 Star 0 Fork 0

lihuali_osc/next.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
lint-staged.config.js 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
Leah 提交于 2023-10-04 19:46 . add cargo fmt to lint staged (#56430)
const { quote } = require('shell-quote')
const { ESLint } = require('eslint')
const eslint = new ESLint()
const isWin = process.platform === 'win32'
module.exports = {
'**/*.{js,jsx,mjs,ts,tsx,mts}': (filenames) => {
const escapedFileNames = filenames
.map((filename) => (isWin ? filename : escape([filename])))
.join(' ')
return [
`prettier --with-node-modules --ignore-path .prettierignore_staged --write ${escapedFileNames}`,
`eslint --no-ignore --max-warnings=0 --fix ${filenames
.filter((file) => !eslint.isPathIgnored(file))
.map((f) => `"${f}"`)
.join(' ')}`,
`git add ${escapedFileNames}`,
]
},
'**/*.{json,md,mdx,css,html,yml,yaml,scss}': (filenames) => {
const escapedFileNames = filenames
.map((filename) => (isWin ? filename : escape([filename])))
.join(' ')
return [
`prettier --with-node-modules --ignore-path .prettierignore_staged --write ${escapedFileNames}`,
`git add ${escapedFileNames}`,
]
},
'**/*.rs': (filenames) => {
const escapedFileNames = filenames
.map((filename) => (isWin ? filename : escape([filename])))
.join(' ')
return [`cargo fmt -- ${escapedFileNames}`, `git add ${escapedFileNames}`]
},
}
function escape(str) {
const escaped = quote(str)
return escaped.replace(/\\@/g, '@')
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lihuali_osc/next.js.git
git@gitee.com:lihuali_osc/next.js.git
lihuali_osc
next.js
next.js
01-02-Copy_58398

搜索帮助