Zyn*_*cho 5 eslint next.js husky lint-staged
我正在关注从其github README打包的 lint-staged 自定义配置文件 (lint-staged.config.js) 的第一个示例(复制/粘贴) ,但没有成功。我error Command failed with exit code 1.总是得到。
我尝试了三件事,对于每种情况,我都将其lint-staged.config.js放在根目录中。
error Command failed with exit code 1."lint-staged": {
"packages/**/*.{ts,tsx}": [
"yarn lint-staged --config ./lint-staged.config.js"
]
},
Run Code Online (Sandbox Code Playgroud)
error Command failed with exit code 1.npx lint-staged --config ../lint-staged.config.js
Run Code Online (Sandbox Code Playgroud)
error Command failed with exit code 1.yarn lint-staged --config lint-staged.config.js
Run Code Online (Sandbox Code Playgroud)
我只是在寻找运行自定义配置文件。
问题是执行失败,错误消息与命令相关,但命令本身正确为lint-staged [options](yarn/npx lint-staged -h),然后提供一个自定义配置文件,但它lint-staged [--config [path]]失败了(我什至提供路径的各种引号)。
问题是,当模块没有为验证提供明确的肯定答案时,它总是返回error Command failed with exit code 1意味着验证失败。
为了按预期正常工作,就我而言,应该:
然后,接下来的字符串可能是一条或多条消息,例如“error some A”和“error some B”和“error some C”等等......
例如:['0', 'error some A', 'error some B', 'error some C']
const path = require("path");
module.exports = (absolutePaths) => {
const cwd = process.cwd();
const relativePaths = absolutePaths.map((file) => path.relative(cwd, file));
console.log("query", relativePaths)
return ['0', 'error some A', 'error some B', 'error some C']
};
Run Code Online (Sandbox Code Playgroud)
这运行正常,但正如 Andrey Mikhaylov 在这篇文章中所说,运行类似的东西
"lint-staged": {
"packages/**/*.{ts,tsx}": [
"yarn lint-staged --config ./lint-staged.config.js"
]
},
Run Code Online (Sandbox Code Playgroud)
如果 lint 返回错误,它将清除暂存的文件,导致回归,从而完全放弃提交,这意味着所有工作都将丢失。
我修复了这个不是预期/期望的行为,运行相同的命令yarn lint-staged --config ./lint-staged.config.js,但从哈士奇在预提交文件中运行
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn lint-staged --config ./lint-staged.config.js`
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3557 次 |
| 最近记录: |