Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

share config never works and always reports "ESLint couldn't find the config" in v6 #12654

Closed
lwr opened this issue Dec 9, 2019 · 7 comments
Closed
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint

Comments

@lwr
Copy link

lwr commented Dec 9, 2019

Tell us about your environment

We are upgrading ESLint from 4 to 6

  • ESLint Version: 6.7.2
  • Node Version: 13.2.0
  • npm Version: 6.13.2

What parser (default, Babel-ESLint, etc.) are you using?
default

Please show your full configuration:

no config, just make a simple example with standard

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

mkdir -p 1/1 && echo '{}' > 1/package.json
npm i --prefix=1 -D eslint eslint-config-standard eslint-plugin-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise

echo '{"extends":"standard"}' > 1/.eslintrc
touch 1/1/foo.js

1/node_modules/.bin/eslint --resolve-plugins-relative-to 1 1/1 && echo ok
## output is "ok"

mkdir 2
echo '{"extends":"standard"}' > 2/.eslintrc
touch 2/foo.js
1/node_modules/.bin/eslint --resolve-plugins-relative-to 1 2 && echo ok
## failed with "ESLint couldn't find the config "standard" to extend from"

What did you expect to happen?
It works in eslint 4 and now broken

What actually happened? Please include the actual, raw output from ESLint.
It is broken now in eslint 6, failed with

Oops! Something went wrong! :(

ESLint: 6.7.2.

ESLint couldn't find the config "standard" to extend from. Please check that the name of the config is correct.

The config "standard" was referenced from the config file in "/path/to/2/.eslintrc".

If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team.

option --resolve-plugins-relative-to did not do any help
and I can not find any workaround or replaced to make it work again

@lwr lwr added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Dec 9, 2019
@lwr lwr changed the title share config never works and always reports "ESLint couldn't find the config" share config never works and always reports "ESLint couldn't find the config" in v6 Dec 9, 2019
@mysticatea
Copy link
Member

Thank you for your report.

This is the correct behavior.
The 2/.eslintrc uses eslint-config-standard, but require("eslint-config-standard") in 2/.eslintrc throws "module not found" error. Therefore, ESLint said "ESLint couldn't find the config "standard" to extend from."

@mysticatea mysticatea added question This issue asks a question about ESLint and removed bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Dec 10, 2019
@lwr
Copy link
Author

lwr commented Dec 10, 2019

@mysticatea thank you for reply

so how to ref a config outside (but not using relative path) correctly in eslint6?

what is the replacement for this using case?

@lwr
Copy link
Author

lwr commented Dec 11, 2019

I have do a second try

echo '{"extends":"plugin:es/no-2019","plugins":["es"]}' > 1/.eslintrc
1/node_modules/.bin/eslint --resolve-plugins-relative-to 1 1/1 && echo ok
## outputs "ok"

echo '{"extends":"plugin:es/no-2019","plugins":["es"]}' > 2/.eslintrc
1/node_modules/.bin/eslint --resolve-plugins-relative-to 1 2 && echo ok
## outputs "ok"

so it seems that --resolve-plugins-relative-to can workaround it by only using plugin instead of config module

but three problems

  1. It requires to change or wrap the origin shared config module with an empty plugin
  2. eslintrc file is now more complicated
    • origin
      extends: x / extends: x/foo / extends: x/bar
    • now
      "extends" : "plugin:wrapX/recommended",
      "plugins" : ["wrapX"],
      "extends" : "plugin:wrapX/foo",
      "plugins" : ["wrapX"],
      "extends" : "plugin:wrapX/bar",
      "plugins" : ["wrapX"],
  3. yaml can not exported by plugin, so all the origin config must rewrite

@mysticatea
Copy link
Member

mysticatea commented Dec 11, 2019

Generally, we cannot separate config files from dependencies. Those should be tied.

I think that you can use --config option to use config files of another place.

rm 2/.eslintrc
1/node_modules/.bin/eslint --resolve-plugins-relative-to 1 --config 1/.eslintrc 2 && echo ok

After RFC47 is implemented, you can drop --resolve-plugins-relative-to 1 from that.

@lwr
Copy link
Author

lwr commented Dec 11, 2019

I have think about using --config, but it breaks the ci process which run eslint to check root path

we have to split the lint task to run multiple times for different directories and it is difficult

because different directories can have different eslintrc

@lwr
Copy link
Author

lwr commented Dec 11, 2019

maybe we need something likes --resolve-config-relative-to

@lwr
Copy link
Author

lwr commented Dec 11, 2019

Good news, we had just do a success migration in https://github.com/Mailtech/eslint-config-coremail

steps bellow

  1. change the module from config to plugin: Mailtech/eslint-config-coremail@7805f2c
  2. migrate all existing eslintrc's "extends" property, because no plugin rules, it it no need to add "plugins" property
    • extends : ["coremail"] ->
      extends : ["plugin:coremail/standard"]
    • extends : coremail/config/compliant.yaml ->
      extends : "plugin:coremail/compliant"
  3. change the ci scripts, add --resolve-plugin-relative-to option

@lwr lwr closed this as completed Dec 18, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jun 17, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint
Projects
None yet
Development

No branches or pull requests

2 participants