prettier-standard: [Error] There was trouble creating the ESLint CLIEngine

Hello !

First of all, thanks for this amazing project, I love it 😃

Context : I’m using prettier-standard with husky and lint-staged. Relevant parts of package.json :

{
  "name": "client",
  "version": "1.0.0",
  "private": true,
  "devDependencies": {
    "husky": "^0.13.2",
    "lint-staged": "^3.4.0",
    "prettier-standard": "^1.0.4",
    "react-scripts": "^0.8.4"
  },
  "dependencies": {
    ...
  },
  "scripts": {
   ...
    "precommit": "lint-staged"
  },
  "lint-staged": {
    "gitDir": "../",
    "linters": {
      "client/src/**/*.js": [
        "prettier-standard",
        "git add"
      ]
    }
  },
  "proxy": "http://localhost:8080"
}

I don’t know if it’s relevant, but my git repository contains two folders : client and server. Server is a Java spring boot application, and client contains the package.json above (hence the ‘gitDir’ option and the linter pattern)

When I run yarn run precommit, I get the following error :

yarn run v0.20.3
$ lint-staged 
 ❯ Running tasks for client/src/**/*.js
   → failure formatting 1 file with prettier-standard
   ✖ prettier-standard
     → failure formatting 1 file with prettier-standard
     git add
🚫 prettier-standard found some errors. Please fix them and try committing again.
prettier-eslint [ERROR]: There was trouble creating the ESLint CLIEngine. Is "eslintPath: /home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-standard/node_modules/eslint" a correct path to the ESLint module?
prettier-standard [ERROR]: There was an error formatting "/home/benoit/Documents/YR/ihm-address-control/client/src/index.js": 
    Error: Cannot find module '/home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-standard/node_modules/eslint'
        at Function.Module._resolveFilename (module.js:472:15)
        at Function.Module._load (module.js:420:25)
        at Module.require (module.js:500:17)
        at require (internal/module.js:20:19)
        at getESLintCLIEngine (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-eslint/dist/index.js:219:20)
        at getConfig (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-eslint/dist/index.js:187:22)
        at format (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-eslint/dist/index.js:78:54)
        at MapSubscriber.rxReadFile.map.text [as project] (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-standard/lib/format-files.js:242:55)
        at MapSubscriber._next (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/rxjs/operator/map.js:77:35)
        at MapSubscriber.Subscriber.next (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/rxjs/Subscriber.js:89:18)
failure formatting 1 file with prettier-standard

I’m guessing the problem commes from prettier-standard because the path it’s complaining about is in prettier-standard, but I could be wrong.

The problem is that eslint is included both by prettier-standard and prettier-eslint, so yarn doesn’t put it in the prettier-standard node_modules folder. I found a workaround by adding an old version of prettier-eslint in my package.json, so that the current version end up in the folder that causes the error.

Do you know what might be causng this ? I looked in the code a bit, and it seems this line should find the correct path, but it doesn’t for some reason.

Is there an option that I can give to prettier-standard to avoid this, or is there a bug ?

Thanks in advance

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Oops, this is broken again in 6.0.0, but works in 5.1.0

I’m experiencing the same issue on version 9.0.1

Im seeing this same error in 7.x

same here as @mserranom, but adding eslint as an explicit dependency solved the problem for me

here is the relevant part of my package.json (originally bootstrapped with create-react-app at stackblitz):

"scripts": {
    "build-css": "node-sass-chokidar src/ -o src/",
    "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
    "start-js": "react-scripts start",
    "start": "npm-run-all -p watch-css start-js",
    "build": "npm run build-css && react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "lint:js": "prettier-standard 'src/**/*.{js,jsx}'",
    "lint:style": "prettier-stylelint 'src/**/*.scss' --write --quiet",
    "lint": "npm-run-all -p lint:js lint:style",
    "precommit": "lint-staged"
  },
  "dependencies": {
    "autodux": "4.0.0",
    "classnames": "^2.2.6",
    "ramda": "0.25.0",
    "react": "16.5.1",
    "react-dom": "16.5.1",
    "react-redux": "5.0.7",
    "react-redux-lifecycle": "2.2.0",
    "react-scripts": "1.1.5",
    "recompose": "0.30.0",
    "redux": "4.0.0",
    "redux-form": "7.4.2",
    "redux-logger": "3.0.6"
  },
  "devDependencies": {
    "babel-preset-react-app": "^3.1.2",
    "eslint": "^5.6.0",
    "husky": "^0.14.3",
    "lint-staged": "^7.2.2",
    "node-sass-chokidar": "^1.3.3",
    "npm-run-all": "^4.1.3",
    "prettier-standard": "^8.0.1",
    "prettier-stylelint": "^0.4.2",
    "stylelint": "^9.5.0",
    "stylelint-config-standard": "^18.2.0",
    "stylelint-scss": "^3.3.0"
  },