There was trouble creating the ESLint CLIEngine
Asked Answered
R

1

6
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.
Reeder answered 6/2, 2020 at 21:9 Comment(0)
R
8

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'"
//                                 /|\
Reeder answered 6/2, 2020 at 21:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.