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

Scripts: Improve recommended settings included in the package #17027

Merged
merged 5 commits into from Aug 23, 2019

Conversation

@gziolo
Copy link
Member

commented Aug 13, 2019

Description

Fixes #17016.
Closes #17061.

Known Issues

When running npm run lint-js I see the following errors:

/Users/gziolo/PhpstormProjects/gutenberg-examples/test/examples.js
  10:1  error  'test' is not defined    no-undef
  11:2  error  'expect' is not defined  no-undef
  14:1  error  'test' is not defined    no-undef
  15:2  error  'expect' is not defined  no-undef

✖ 4 problems (4 errors, 0 warnings)

To solve it I had to add:

+ /* global test, expect */

at the top of the file which should work out of the box. This should work out of the box when using @wordpress/scripts.

I also had to put:

+ /**
+  * WordPress dependencies
+  */
import { Button } from '@wordpress/components';

above the import statement to fix the following issue:

 1:1  error  Expected preceding "WordPress dependencies" comment block  @wordpress/dependency-group

which I don't think we want to enforce outside of Gutenberg.

WordPress/gutenberg-examples#84 (review)

I think that having @wordpress/components as a dependency brings @wordpress/element as well. Ideally, we bring it as part of @wordpress/babel-preset-default which is the default handler for React regardless.

Changes Applied

@wordpress/babel-preset-default

Bug fix:

  • Added missing @wordpress/element dependency which is used internally.

@wordpress/eslint-plugin

Breaking changes:

  • New ruleset test-e2e added for end-to-end tests validation.
  • New ruleset test-unit added for unit tests validation.

Enhancement:

  • Remove @wordpress/dependency-group and @wordpress/gutenberg-phase rules from the custom and recommended configs and leave them as opt-in features.

All those changes directly influence @wordpress/scripts and improves the experience around its setup.

How has this been tested?

npm run lint-js

Types of changes

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 self-assigned this Aug 13, 2019
@gziolo gziolo changed the title Fix/wp scripts recommended settings Scripts: Improve recommended settings included in the package Aug 13, 2019
@gziolo gziolo force-pushed the fix/wp-scripts-recommended-settings branch from add25d0 to 8a8c320 Aug 14, 2019
@gziolo gziolo requested a review from dmsnell as a code owner Aug 14, 2019
@gziolo gziolo requested a review from iandunn Aug 14, 2019
@@ -14,4 +14,26 @@ module.exports = {
document: true,
wp: 'readonly',
},
overrides: [

This comment has been minimized.

Copy link
@gziolo

gziolo Aug 16, 2019

Author Member

@ntwb, I was referring to this changes in #17061 (comment). I linked wrong PR 😃

@gziolo

This comment has been minimized.

Copy link
Member Author

commented Aug 22, 2019

@youknowriad - can we include this change in Gutenberg 6.4 release so we could batch all breaking changes related to @wordpress/scripts package and all its dependencies?

@youknowriad

This comment has been minimized.

Copy link
Contributor

commented Aug 22, 2019

Sure, I'd appreciate a review from someone actually using the scripts package. Maybe @swissspidy @ntwb or @nerrad

@nerrad
nerrad approved these changes Aug 22, 2019
Copy link
Contributor

left a comment

I had a question but on the whole these changes look good.

"core-js": "^3.1.4"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
},

This comment has been minimized.

Copy link
@nerrad

nerrad Aug 22, 2019

Contributor

So does this change essentially mean that packages consuming wp-script don't need @babel/core as a dependency anymore?

This comment has been minimized.

Copy link
@gziolo

gziolo Aug 22, 2019

Author Member

At some point, it was added as a regular dependencies so it is redundant here.


### Enhancements

- Remove `@wordpress/dependency-group` and `@wordpress/gutenberg-phase` rules from the `custom` and `recommended` configs and leave them as opt-in features.

This comment has been minimized.

Copy link
@nerrad

nerrad Aug 22, 2019

Contributor

👍 This is mostly a breaking change for consumers that are using these rules. Most consumers won't want/need them so I like.

This comment has been minimized.

Copy link
@gziolo

gziolo Aug 22, 2019

Author Member

Do you think it should be highlighted as breaking change? I wasn’t sure where to put it. Given that, there are other breaking changes, we can more freely move it if necessary 😃

This comment has been minimized.

Copy link
@nerrad

nerrad Aug 23, 2019

Contributor

I'm not sure either. The scope of when it's considered a breaking change is fairly narrow and it's only breaking in the sense the rules won't be applied automatically anymore.

@gziolo gziolo merged commit 1a6d1b7 into master Aug 23, 2019
7 checks passed
7 checks passed
Filter opened
Details
Filter opened
Details
Filter opened
Details
Filter opened
Details
Milestone It
Details
Milestone It
Details
Travis CI - Pull Request Build Passed
Details
@gziolo gziolo deleted the fix/wp-scripts-recommended-settings branch Aug 23, 2019
@gziolo gziolo added this to the Gutenberg 6.4 milestone Aug 23, 2019
donmhico added a commit to donmhico/gutenberg that referenced this pull request Aug 27, 2019
…ess#17027)

* Babel Preset Default: Add missing @wordpress/element dependency

* Remove `@wordpress/dependency-group` and `@wordpress/gutenberg-phase` rules from the `custom` and `recommended` configs and leave them as opt-in features.

* ESLint Plugin: Extract 2 test configs and add them conditionally to the recommended one

* Add missing documentation for changes applied

* Scripts: Update CHANGELOG file
dratwas added a commit to callstack/gutenberg that referenced this pull request Aug 28, 2019
…ess#17027)

* Babel Preset Default: Add missing @wordpress/element dependency

* Remove `@wordpress/dependency-group` and `@wordpress/gutenberg-phase` rules from the `custom` and `recommended` configs and leave them as opt-in features.

* ESLint Plugin: Extract 2 test configs and add them conditionally to the recommended one

* Add missing documentation for changes applied

* Scripts: Update CHANGELOG file
gziolo added a commit that referenced this pull request Aug 29, 2019
* Babel Preset Default: Add missing @wordpress/element dependency

* Remove `@wordpress/dependency-group` and `@wordpress/gutenberg-phase` rules from the `custom` and `recommended` configs and leave them as opt-in features.

* ESLint Plugin: Extract 2 test configs and add them conditionally to the recommended one

* Add missing documentation for changes applied

* Scripts: Update CHANGELOG file
gziolo added a commit that referenced this pull request Aug 29, 2019
* Babel Preset Default: Add missing @wordpress/element dependency

* Remove `@wordpress/dependency-group` and `@wordpress/gutenberg-phase` rules from the `custom` and `recommended` configs and leave them as opt-in features.

* ESLint Plugin: Extract 2 test configs and add them conditionally to the recommended one

* Add missing documentation for changes applied

* Scripts: Update CHANGELOG file
dd32 pushed a commit to dd32/gutenberg that referenced this pull request Sep 27, 2019
…ess#17027)

* Babel Preset Default: Add missing @wordpress/element dependency

* Remove `@wordpress/dependency-group` and `@wordpress/gutenberg-phase` rules from the `custom` and `recommended` configs and leave them as opt-in features.

* ESLint Plugin: Extract 2 test configs and add them conditionally to the recommended one

* Add missing documentation for changes applied

* Scripts: Update CHANGELOG file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.