AMP Stories: Use Gutenberg ESLint config #1894
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on #1885 and #1893 I noticed some odd ESLint rules that I thought could be streamlined so they're more in line with PHP and with core.
When looking into it, I found #1019 with relevant commits 277da63 and 34024cc.
I noticed that
eslint-config-wordpress
is being used as the foundation for the ESLint config, which hasn't seen any new notable updates since 2017. However, a lot has changed since then.The WordPress JS coding standards have evolved over time, mainly due to Gutenberg development. Gutenberg has way more rules for JS development in WordPress. Some of them which were manually ported over into this repository.
Nowadays, Gutenberg uses and publishes
@wordpress/eslint-plugin
as a central way to get an up-to-date ESLint config.For this PR I adapted the config and then tried to fix all linting errors. The diff is quite long, mainly due to the following two reasons:
const
, and not justlet
or evenvar
.I think this could be a good starting point to improve the code base in the long term, separate components, and make them testable.
For example, I am thinking about adopting
@wordpress/scripts
for testing and configuration. Thanks to WordPress/gutenberg#13814 we can simplify #1886 even further.