Skip to content

Commit 1a6d1b7

Browse files
authored
Scripts: Improve recommended settings included in the package (#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
1 parent ce46a4f commit 1a6d1b7

File tree

17 files changed

+101
-28
lines changed

17 files changed

+101
-28
lines changed

.eslintrc.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module.exports = {
2020
root: true,
2121
extends: [
2222
'plugin:@wordpress/eslint-plugin/recommended',
23-
'plugin:jest/recommended',
2423
'plugin:eslint-comments/recommended',
2524
],
2625
plugins: [
@@ -30,6 +29,8 @@ module.exports = {
3029
wp: 'off',
3130
},
3231
rules: {
32+
'@wordpress/dependency-group': 'error',
33+
'@wordpress/gutenberg-phase': 'error',
3334
'@wordpress/react-no-unsafe-timeout': 'error',
3435
'no-restricted-syntax': [
3536
'error',
@@ -123,16 +124,19 @@ module.exports = {
123124
'**/@(benchmark|test|__tests__)/**/*.js',
124125
],
125126
},
127+
{
128+
files: [
129+
'packages/jest*/**/*.js',
130+
],
131+
extends: [
132+
'plugin:@wordpress/eslint-plugin/test-unit',
133+
],
134+
},
126135
{
127136
files: [ 'packages/e2e-test*/**/*.js' ],
128-
env: {
129-
browser: true,
130-
},
131-
globals: {
132-
browser: 'readonly',
133-
page: 'readonly',
134-
wp: 'readonly',
135-
},
137+
extends: [
138+
'plugin:@wordpress/eslint-plugin/test-e2e',
139+
],
136140
},
137141
],
138142
};

package-lock.json

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
"enzyme": "3.9.0",
104104
"eslint-plugin-eslint-comments": "3.1.2",
105105
"eslint-plugin-import": "2.18.2",
106-
"eslint-plugin-jest": "22.14.1",
107106
"fast-glob": "2.2.7",
108107
"fbjs": "0.8.17",
109108
"fs-extra": "8.0.1",

packages/babel-preset-default/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Master
2+
3+
### Bug Fixes
4+
5+
- Added missing `@wordpress/element` dependency which is used internally.
6+
17
## 4.4.0 (2019-08-05)
28

39
### Bug Fixes

packages/babel-preset-default/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@
3636
"@babel/runtime": "^7.4.4",
3737
"@wordpress/babel-plugin-import-jsx-pragma": "file:../babel-plugin-import-jsx-pragma",
3838
"@wordpress/browserslist-config": "file:../browserslist-config",
39+
"@wordpress/element": "file:../element",
3940
"core-js": "^3.1.4"
4041
},
41-
"peerDependencies": {
42-
"@babel/core": "^7.0.0"
43-
},
4442
"publishConfig": {
4543
"access": "public"
4644
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"overrides": [
3+
{
4+
"files": [ "shared-tests.js" ],
5+
"extends": [
6+
"plugin:@wordpress/eslint-plugin/test-unit"
7+
]
8+
}
9+
]
10+
}

packages/eslint-plugin/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44

55
- The [`@wordpress/no-unused-vars-before-return` rule](https://github.com/WordPress/gutenberg/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars-before-return.md) has been improved to exempt object destructuring only if destructuring to more than one property.
66
- Stricter JSDoc linting using [`eslint-plugin-jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc).
7+
- Stricter validation enabled for test files only using new `test-e2e` and `test-unit` rulesets.
78

89
### New Features
910

1011
- New Rule: [`@wordpress/no-unguarded-get-range-at`](https://github.com/WordPress/gutenberg/blob/master/packages/eslint-plugin/docs/rules/no-unguarded-get-range-at.md)
1112
- Enable `wp` global by default in the `recommended` config.
13+
- New ruleset `test-e2e` added for end-to-end tests validation.
14+
- New ruleset `test-unit` added for unit tests validation.
15+
16+
### Enhancements
17+
18+
- Remove `@wordpress/dependency-group` and `@wordpress/gutenberg-phase` rules from the `custom` and `recommended` configs and leave them as opt-in features.
1219

1320
## 2.4.0 (2019-08-05)
1421

packages/eslint-plugin/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ The `recommended` preset will include rules governing an ES2015+ environment, an
2828

2929
Alternatively, you can opt-in to only the more granular rulesets offered by the plugin. These include:
3030

31+
- `custom`
3132
- `es5`
3233
- `esnext`
34+
- `jsdoc`
35+
- `jshint` (legacy)
3336
- `jsx-a11y`
3437
- `react`
38+
- `test-e2e`
39+
- `test-unit`
3540

3641
For example, if your project does not use React, you could consider extending including only the ESNext rules in your project using the following `extends` definition:
3742

packages/eslint-plugin/configs/custom.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ module.exports = {
33
'@wordpress',
44
],
55
rules: {
6-
'@wordpress/dependency-group': 'error',
7-
'@wordpress/gutenberg-phase': 'error',
86
'@wordpress/no-unused-vars-before-return': 'error',
97
'@wordpress/valid-sprintf': 'error',
108
'@wordpress/no-base-control-with-label-without-id': 'error',

packages/eslint-plugin/configs/recommended.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,26 @@ module.exports = {
1414
document: true,
1515
wp: 'readonly',
1616
},
17+
overrides: [
18+
{
19+
// Unit test files and their helpers only.
20+
files: [
21+
'**/@(test|__tests__)/**/*.js',
22+
'**/?(*.)test.js',
23+
],
24+
extends: [
25+
require.resolve( './test-unit.js' ),
26+
],
27+
},
28+
{
29+
// End-to-end test files and their helpers only.
30+
files: [
31+
'**/specs/**/*.js',
32+
'**/?(*.)spec.js',
33+
],
34+
extends: [
35+
require.resolve( './test-e2e.js' ),
36+
],
37+
},
38+
],
1739
};

0 commit comments

Comments
 (0)