-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Build Tooling: Try to extract shared eslint config #5502
Conversation
test/eslint-config.js
Outdated
@@ -0,0 +1,165 @@ | |||
module.exports = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it's in the test
folder? Should it be a special eslint
folder to be extracted to the packages repository later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a temp thing. I want to have it inside WordPress/packages
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm moving to eslint
folder because Jest loads this file as it was a test 😃
test/eslint-config.js
Outdated
module.exports = { | ||
parser: 'babel-eslint', | ||
extends: [ | ||
'wordpress', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we copy the WordPress rules here instead of using them as plugin. If I understand correctly this config is meant to be the new WordPress default eslint config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we need to keep both for some time until merge happens. Otherwise, we will have to keep those 2 in sync. I don't have a strong opinion on this one. I think @ntwb will have some opinions here.
4db53b4
to
7e48167
Compare
We had a quick chat with @ntwb and it looks like we can update the existing https://github.com/WordPress-Coding-Standards/eslint-plugin-wordpress/ repository and expose a few new configurations to be consumed as follows: module.exports = {
...
extends: [
'plugin:wordpress/recommended',
'plugin:wordpress/es-next',
'plugin:wordpress/react',
'plugin:wordpress/jest',
],
...
}; Where the 4 configurations would be exposed from |
Let’s extract shared rules to https://github.com/WordPress-Coding-Standards/eslint-plugin-wordpress/ as the next step according to what I commented above. |
To clarify, is the plan for the |
Yes, I hope to get it sorted out this month. |
@gziolo the plan for this is to be used by other plugins too, right? If so, could you please give a practical example of how this could be done? Thank you in advance. |
@kmgalanakis See #5600 and the linked pull request, it's a WIP and some docs will follow once PRs are merged. p.s. You also need to |
@kmgalanakis, it should work similar to unit tests in scripts. First step is to move all Eslint rules to the repository @ntwb linked. |
@grappler I'll get something sorted on the weekend for you |
Description
Follow-up for #5491.
Yes, it was very easy :)
Let's agree what should be a shared config and then we can publish to npm as
@wordpress/eslint-config-default
from the packages repository and consume it here.Bonus feature: it would be nice to have Jest included in the default setup, but maybe all the rules would be enabled only based on relative glob patterns as described in here: https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns.
This should be also possible with the changes proposed in this PR. @aduth feel free to update this PR.
How Has This Been Tested?
npm run lint
Types of changes
Refactoring.