Mic*_*ant 6 javascript npm eslint npx prettier-eslint
There was trouble creating the ESLint CLIEngine. -
'basePath' should be an absolute path
Run Code Online (Sandbox Code Playgroud)
尝试使用 eslint
$ npx prettier-eslint **/*.js
Run Code Online (Sandbox Code Playgroud)
但得到:
prettier-eslint [ERROR]: There was trouble creating the ESLint CLIEngine.
prettier-eslint-cli [ERROR]: There was an error formatting "test/fizzBuzz.test.js":
AssertionError [ERR_ASSERTION]: 'basePath' should be an absolute path.
Run Code Online (Sandbox Code Playgroud)
**/*.js
当前的 UNIX 解决方法:使用$PWD,即
$ npx prettier-eslint $PWD/'**/*.js'
Run Code Online (Sandbox Code Playgroud)
这产生了正确的文件作为输出
回复:https : //github.com/prettier/prettier-eslint-cli/issues/208
这也适用于使用类似的问题 package.json
例如有
"lint": "eslint . && prettier-eslint --list-different **/*.js",
"format": "prettier-eslint --write **/*.js"
Run Code Online (Sandbox Code Playgroud)
也会产生那个错误。在 Unix 上,这目前可以通过以下方式修复$PWD
"lint": "eslint . && prettier-eslint --list-different $PWD/'**/*.js'",
// /|\
"format": "prettier-eslint --write $PWD/'**/*.js'"
// /|\
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1584 次 |
| 最近记录: |