Add `eslint-config-prettier` to `dependencies`
Currently, eslint-config-prettier is a dev and peer dependency.
This causes an error when trying to extend plugin:prettier/recommended in another shareable ESLint config. Linting in VSCode results in an error

As described in https://eslint.org/docs/user-guide/configuring/configuration-files#extending-configuration-files:
Relative paths and shareable config names in an extends property are resolved from the location of the config file where they appear.
Since eslint-plugin-prettier uses eslint-config-prettier, I think it should work (I haven't tried it) if eslint-plugin-prettier would move eslint-config-prettier to dependencies, which would eliminate the need for a peer dependency.
What do you think?
I think eslint-config-prettier should not be marked as an optional dependency,the following should be removed from package json:
"peerDependenciesMeta": {
"eslint-config-prettier": {
"optional": true
}
},
It is perfectly possible to use this package without using behaviour that depends upon eslint-config-prettier, thus it is an optional dependency. Adding a direct dependency can also potentially lead to duplication of eslint-config-prettier in your package.json which can then cause further problems.
the problem here, with optional eslint-config-prettier dependency, is it is not possible to build a self-sufficient eslint preset module. In the end project, you still need to install eslint-config-prettier next to eslint preset module.
Yes that seems reasonable. You can explicitly control the version eslint-config-prettier you desire, which would be harder if it was a transitive dependency of eslint-plugin-prettier
please look, eslint-plugin-prettier is not even using eslint-config-prettier, I done quick search:
https://github.com/prettier/eslint-plugin-prettier/search?q=eslint-config-prettier
so why eslint-config-prettier is a dependency of eslint-plugin-prettier? It can be easily removed from its package.josn, then I am still able to control the version of eslint-config-prettier and also it solves the problem with a self-sufficient eslint preset
This plugin exposes a recommended config that extends from eslint-config-prettier.
You can choose not to use the config - in which case the dependency eslint-config-prettier is not required.
Or you can choose to use that config - in which case the dependency eslint-config-prettier is required.
Thus it is an optional dependency, depending on that choice the user makes.
So how can I prepare eslint preset package which uses prettier (with some custom config too) and in end project install only "one dependency"?
e.g., I want to have a my-app which depends only on eslint and my-eslint-preset
{
"name": "my-app",
"devDependency": {
"eslint": "",
"my-eslint-preset": ""
}
}
where my-eslint-preset is
{
"name": " my-eslint-preset",
"dependency": {
"eslint-config-prettier": "",
"eslint-plugin-prettier": "",
"some-another-eslint-plugin": ""
// .....
},
"devDependencies": {
"eslint": "",
}
}
?
currently, in app my-app" I need to install eslint-config-prettier too:
{
"name": "my-app",
"devDependency": {
"eslint": "",
"my-eslint-preset": ""
"eslint-config-prettier": "",
}
}
currently, in app my-app" I need to install eslint-config-prettier too:
You shouldn't need to do this. The dependency on my-eslint-preset is enough to trigger pulling in eslint-config-prettier.
@shopify/eslint-plugin follows the pattern you describe - depending on both eslint-config-prettier and eslint-plugin-prettier, and I have several repositories that depend up only @shopify/eslint-plugin without issue.