Closed BenoitAverty closed 4 years ago
Hey,
Thanks for bug-report. First af all prettier-eslint is a part of prettier-standard so you don't need both if you happen to depend on both of them.
For now I'm not able to reproduce this issue. What's the location of package.json? I see you're writing client/src/**/*.js
in linters section, but node_modules seems to be in ihm-address-control/client/node_modules
. What's your node version? Maybe you could push a repository that reproduces this issue?
Thanks for the quick reply.
Here is how the repository is :
ihm-address-control # that's the root of my repo
├ integration-tests/ #Contains some javascript code that I don't want touched by prettier-standard
├ server/ # that's java code in there. We don't care
└ client/
├ src/ # my source code. This is what I want formatted
├ node_modules/
└ package.json # this is the package.json I've included earlier.
Currently, my package.json contains "prettier-eslint": "4.2.0"
, but that's only because this is the workaround I've found. Ideally, i'd remove this (like I showed in the package.json included above).
When I put prettier-eslint inside my package.json, I have the following in the repo directory :
client/node_modules/eslint/
client/node_modules/prettier-eslint/node_modules/eslint
client/node_modules/prettier-standard/node_modules/eslint
client/node_modules/prettier-standard/node_modules/prettier-eslint
With this, everything works fine.
But when I don't put prettier-eslint in my package.json, here's what I have
client/node_modules/eslint/
(no change : probably the eslint included by react-scripts)client/node_modules/prettier-eslint/node_modules/eslint
client/node_modules/prettier-standard
but nothing in client/node_modules/prettier-standard/node_modules
(because prettier-eslint is already in the parent node_modules since yarn flattens the dependencies if it can)I think this is normal : Yarn tries to flattent the dependencies inside node_modules when it can, and when I include an older version of prettier-eslint this has the effet of preventing this, which makes eslint end up in prettier-standard node_modules.
But what I don't understand is why the correct path of eslint is not detected : from what I've read of your source code, you are using find-up to find eslint, which should always work (at worst, finding eslint at the topmost level in my project's node_modules). But when eslint is not present in the prettier-standard node_module, it seems to still look for it at the same place (which cause the error i've copied in my first post).
I hope this helps you understand the problem. I'll try to make a repo to reproduce.
Thanks, I've managed to reproduce the issue, let me see what I can do
This should be fixed if you update to 1.0.5, thanks!
@BenoitAverty Do you mind if I add you to the contributors list in the README?
Awesome, It looks like it works ! Tanks a lot for your very quick fix.
You're welcome to add me to the contributors list of course, and thank you for that also (I just now discovered the awesome contributors spec)
Oops, this is broken again in 6.0.0
, but works in 5.1.0
Im seeing this same error in 7.x
Experiencing in 8.0.1
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"
},
I'm experiencing the same issue on version 9.0.1
@sheerun: would you please confirm whether it happens on your end for version 9.0.1?
Works for me. Please remove eslint from devDependencies or use the latest version. Otherwise please provide package.json that reproduces this issue and doesn't use legacy version of eslint
Here my package.json
"scripts": {
"lint": "eslint '**/*.js'",
"lint:fix": "prettier-eslint '**/*.js' --write"
},
"devDependencies": {
"eslint": "^6.7.2",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-standard": "^4.0.1",
"prettier-eslint": "^9.0.1",
"prettier-eslint-cli": "^5.0.0"
}
@gsonly You are using prettier-eslint
, not prettier-standard
this is prettier-standard
@sheerun oh my bad but thanks for response anyway
Hello !
First of all, thanks for this amazing project, I love it :)
Context : I'm using
prettier-standard
withhusky
andlint-staged
. Relevant parts of package.json :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 :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