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

ESLint plugin: Enable wp global by default in the recommended config #16904

Merged
merged 1 commit into from
Aug 12, 2019

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Aug 5, 2019

Description

Related PR where I encountered this issue: WordPress/gutenberg-examples#83.

It's perfectly fine to use wp globals when developing plugins as presented below:

/* global wp */
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;

However, the recommended ESLing config considers this as an error so the only way to make it happy is to silence it. This PR tries to fix this issue which is extremely inconvenient for those using @wordpress/scripts with the default configuration.

In Gutenberg, it's still something that we want to avoid, so I updated the local config accordingly.

How has this been tested?

npm run lint-js should error when wp global is used in Gutenberg.

You can add const { registerBlockType } = wp.blocks; anywhere in the source code to validate it.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@gziolo gziolo added [Type] Bug An existing feature does not function as intended [Package] ESLint plugin /packages/eslint-plugin labels Aug 5, 2019
@gziolo gziolo self-assigned this Aug 5, 2019
@gziolo gziolo requested a review from youknowriad August 5, 2019 15:00
@gziolo gziolo requested a review from iandunn August 5, 2019 15:06
@gziolo gziolo force-pushed the update/eslint-plugin-wp-global branch from 5d78e9b to 7a44a81 Compare August 8, 2019 09:48
@gziolo gziolo requested review from swissspidy and a team August 12, 2019 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] ESLint plugin /packages/eslint-plugin [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants