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

feat(eslint-config): Improve ESLint v7 support by adding plugins to peerDeps #1740

Merged
merged 3 commits into from Aug 5, 2020

Conversation

busterc
Copy link
Contributor

@busterc busterc commented Jul 2, 2020

To better support ESLint v7 peerDep resolution.
See: #1739

When we extend open-wc/eslint-config and install it on a project, the various plugins found in dependencies are not resolved by ESLint v7:

"dependencies": {
    "eslint-plugin-babel": "^5.3.0",
    "eslint-plugin-html": "^6.0.0",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-lit": "^1.2.0",
    "eslint-plugin-no-only-tests": "^2.4.0",
    "eslint-plugin-wc": "^1.2.0"
  }

Therefore, we have to manually install each plugin individually as a devDependencies for each project that extends open-wc/eslint-config.

You'll notice that the airbnb-base config includes plugin-import in peerDependencies and they refer to installing peerDeps in their README and recommending install-peerdeps as a shortcut.

Like airbnb-base, it would excellent to get to use such a shortcut, but we need those plugins added as peerDependencies:

"peerDependencies": {
    "eslint-plugin-babel": "^5.3.0",
    "eslint-plugin-html": "^6.0.0",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-lit": "^1.2.0",
    "eslint-plugin-no-only-tests": "^2.4.0",
    "eslint-plugin-wc": "^1.2.0"
  }

To better support ESLint v7 peerDep resolution.
See: open-wc#1739
@ghost
Copy link

ghost commented Jul 2, 2020

There were the following issues with this Pull Request

  • Commit: dca7a03
    • ✖ message may not be empty
    • ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

@CLAassistant
Copy link

CLAassistant commented Jul 2, 2020

CLA assistant check
All committers have signed the CLA.

@ghost
Copy link

ghost commented Jul 2, 2020

There were the following issues with this Pull Request

  • Commit: dca7a03
    • ✖ message may not be empty
    • ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

@stale
Copy link

stale bot commented Jul 24, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Jul 24, 2020
@LarsDenBakker
Copy link
Member

@busterc Sorry for the late response here. I get the general idea, but I think it's weird to have it both as dev and peer dependencies. Ideally we should be able to resolve the path before passing it to eslint, but I don't know if eslint supports that yet.

@stale stale bot removed the inactive label Aug 5, 2020
@busterc
Copy link
Contributor Author

busterc commented Aug 5, 2020

@busterc Sorry for the late response here. I get the general idea, but I think it's weird to have it both as dev and peer dependencies. Ideally we should be able to resolve the path before passing it to eslint, but I don't know if eslint supports that yet.

@LarsDenBakker Thanks for looking into this!

It does seem weird to have plugins as both dependencies and peerDependencies; however, for shareable configs that are extended, ESLint simply does not install plugins regardless of where they're defined. Over the years there have been many issues posted about this inconvenience and ESLint developers continue to say 'add plugins as peerDependencies' Eventually the WIP to re-implement eslint configs should resolve those complaints.

In the meantime, you'll notice that the airbnb-base config includes eslint-plugin-import in both dependencies and peerDependencies to minimize the pain when extending their configs: https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/package.json#L62-L69

One alternative is to include the plugins only in peerDependencies; however that would require installing those peerDeps even when not extending the config. As Airbnb didn't opt for that, I guessed open-wc would prefer not too either. Otherwise, I can certainly update the PR to remove the plugin references from dependencies?

@LarsDenBakker
Copy link
Member

Thanks for those references. Seems like it's the best option we have right now then.

@LarsDenBakker LarsDenBakker merged commit 3760f77 into open-wc:master Aug 5, 2020
bennypowers pushed a commit that referenced this pull request Oct 11, 2020
To better support ESLint v7 peer dependency resolution.
See: #1739
@github-actions github-actions bot mentioned this pull request Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants