Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

There was trouble creating the ESLint CLIEngine

There was trouble creating the ESLint CLIEngine. -
 'basePath' should be an absolute path

Trying to use eslint

$ npx prettier-eslint **/*.js

but getting:

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.
like image 439
Michael Durrant Avatar asked Feb 06 '20 21:02

Michael Durrant


Video Answer


1 Answers

This is due to an issue with selecting the files with

**/*.js

A current UNIX workaround: use $PWD, i.e.

$ npx prettier-eslint $PWD/'**/*.js'

This produced correct files as output

re: https://github.com/prettier/prettier-eslint-cli/issues/208

This also applies to similar issues using package.json

for instance having

"lint": "eslint . && prettier-eslint --list-different **/*.js",
"format": "prettier-eslint --write **/*.js"

will also generate that error. On Unix this can currently be fixed with $PWD

"lint": "eslint . && prettier-eslint --list-different $PWD/'**/*.js'",
//                                                    /|\
"format": "prettier-eslint --write $PWD/'**/*.js'"
//                                 /|\
like image 199
Michael Durrant Avatar answered Sep 30 '22 10:09

Michael Durrant