diff --git a/.eslintrc.js b/.eslintrc.js index 363cd259c838bf..7d2e6f3d40bca0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -20,7 +20,6 @@ module.exports = { root: true, extends: [ 'plugin:@wordpress/eslint-plugin/recommended', - 'plugin:jest/recommended', 'plugin:eslint-comments/recommended', ], plugins: [ @@ -30,6 +29,8 @@ module.exports = { wp: 'off', }, rules: { + '@wordpress/dependency-group': 'error', + '@wordpress/gutenberg-phase': 'error', '@wordpress/react-no-unsafe-timeout': 'error', 'no-restricted-syntax': [ 'error', @@ -123,16 +124,19 @@ module.exports = { '**/@(benchmark|test|__tests__)/**/*.js', ], }, + { + files: [ + 'packages/jest*/**/*.js', + ], + extends: [ + 'plugin:@wordpress/eslint-plugin/test-unit', + ], + }, { files: [ 'packages/e2e-test*/**/*.js' ], - env: { - browser: true, - }, - globals: { - browser: 'readonly', - page: 'readonly', - wp: 'readonly', - }, + extends: [ + 'plugin:@wordpress/eslint-plugin/test-e2e', + ], }, ], }; diff --git a/package-lock.json b/package-lock.json index db4ab1e5b5f252..b1809c91e94140 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4593,6 +4593,7 @@ "@babel/runtime": "^7.4.4", "@wordpress/babel-plugin-import-jsx-pragma": "file:packages/babel-plugin-import-jsx-pragma", "@wordpress/browserslist-config": "file:packages/browserslist-config", + "@wordpress/element": "file:packages/element", "core-js": "^3.1.4" } }, @@ -4982,6 +4983,7 @@ "dev": true, "requires": { "babel-eslint": "^10.0.2", + "eslint-plugin-jest": "^22.15.1", "eslint-plugin-jsdoc": "^15.8.0", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.14.3", @@ -11057,9 +11059,9 @@ } }, "eslint-plugin-jest": { - "version": "22.14.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-22.14.1.tgz", - "integrity": "sha512-mpLjhADl+HjagrlaGNx95HIji089S18DhnU/Ee8P8VP+dhEnuEzb43BXEaRmDgQ7BiSUPcSCvt1ydtgPkjOF/Q==", + "version": "22.15.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-22.15.1.tgz", + "integrity": "sha512-CWq/RR/3tLaKFB+FZcCJwU9hH5q/bKeO3rFP8G07+q7hcDCFNqpvdphVbEbGE6o6qo1UbciEev4ejUWv7brUhw==", "dev": true, "requires": { "@typescript-eslint/experimental-utils": "^1.13.0" diff --git a/package.json b/package.json index 46ebf924d604a2..49d35dc9f1a907 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,6 @@ "enzyme": "3.9.0", "eslint-plugin-eslint-comments": "3.1.2", "eslint-plugin-import": "2.18.2", - "eslint-plugin-jest": "22.14.1", "fast-glob": "2.2.7", "fbjs": "0.8.17", "fs-extra": "8.0.1", diff --git a/packages/babel-preset-default/CHANGELOG.md b/packages/babel-preset-default/CHANGELOG.md index e84e32066de1ea..ec6cc518320381 100644 --- a/packages/babel-preset-default/CHANGELOG.md +++ b/packages/babel-preset-default/CHANGELOG.md @@ -1,3 +1,9 @@ +## Master + +### Bug Fixes + +- Added missing `@wordpress/element` dependency which is used internally. + ## 4.4.0 (2019-08-05) ### Bug Fixes diff --git a/packages/babel-preset-default/package.json b/packages/babel-preset-default/package.json index a6e298d055ac07..61638438487387 100644 --- a/packages/babel-preset-default/package.json +++ b/packages/babel-preset-default/package.json @@ -36,11 +36,9 @@ "@babel/runtime": "^7.4.4", "@wordpress/babel-plugin-import-jsx-pragma": "file:../babel-plugin-import-jsx-pragma", "@wordpress/browserslist-config": "file:../browserslist-config", + "@wordpress/element": "file:../element", "core-js": "^3.1.4" }, - "peerDependencies": { - "@babel/core": "^7.0.0" - }, "publishConfig": { "access": "public" } diff --git a/packages/block-serialization-spec-parser/.eslintrc.json b/packages/block-serialization-spec-parser/.eslintrc.json new file mode 100644 index 00000000000000..ffee0154641f1d --- /dev/null +++ b/packages/block-serialization-spec-parser/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "overrides": [ + { + "files": [ "shared-tests.js" ], + "extends": [ + "plugin:@wordpress/eslint-plugin/test-unit" + ] + } + ] +} diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index b40d7e8bb8ff4e..4096609b421f40 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -4,11 +4,18 @@ - 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. - Stricter JSDoc linting using [`eslint-plugin-jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc). +- Stricter validation enabled for test files only using new `test-e2e` and `test-unit` rulesets. ### New Features - 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) - Enable `wp` global by default in the `recommended` config. +- New ruleset `test-e2e` added for end-to-end tests validation. +- New ruleset `test-unit` added for unit tests validation. + +### Enhancements + +- Remove `@wordpress/dependency-group` and `@wordpress/gutenberg-phase` rules from the `custom` and `recommended` configs and leave them as opt-in features. ## 2.4.0 (2019-08-05) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index f6f89c95f10819..63034c7efe8005 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -28,10 +28,15 @@ The `recommended` preset will include rules governing an ES2015+ environment, an Alternatively, you can opt-in to only the more granular rulesets offered by the plugin. These include: +- `custom` - `es5` - `esnext` +- `jsdoc` +- `jshint` (legacy) - `jsx-a11y` - `react` +- `test-e2e` +- `test-unit` 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: diff --git a/packages/eslint-plugin/configs/custom.js b/packages/eslint-plugin/configs/custom.js index efb873980b22f4..69ca991b7e56bb 100644 --- a/packages/eslint-plugin/configs/custom.js +++ b/packages/eslint-plugin/configs/custom.js @@ -3,8 +3,6 @@ module.exports = { '@wordpress', ], rules: { - '@wordpress/dependency-group': 'error', - '@wordpress/gutenberg-phase': 'error', '@wordpress/no-unused-vars-before-return': 'error', '@wordpress/valid-sprintf': 'error', '@wordpress/no-base-control-with-label-without-id': 'error', diff --git a/packages/eslint-plugin/configs/recommended.js b/packages/eslint-plugin/configs/recommended.js index 5aaead8880681a..71d8625cd961ba 100644 --- a/packages/eslint-plugin/configs/recommended.js +++ b/packages/eslint-plugin/configs/recommended.js @@ -14,4 +14,26 @@ module.exports = { document: true, wp: 'readonly', }, + overrides: [ + { + // Unit test files and their helpers only. + files: [ + '**/@(test|__tests__)/**/*.js', + '**/?(*.)test.js', + ], + extends: [ + require.resolve( './test-unit.js' ), + ], + }, + { + // End-to-end test files and their helpers only. + files: [ + '**/specs/**/*.js', + '**/?(*.)spec.js', + ], + extends: [ + require.resolve( './test-e2e.js' ), + ], + }, + ], }; diff --git a/packages/eslint-plugin/configs/test-e2e.js b/packages/eslint-plugin/configs/test-e2e.js new file mode 100644 index 00000000000000..63a52f0f0d0105 --- /dev/null +++ b/packages/eslint-plugin/configs/test-e2e.js @@ -0,0 +1,13 @@ +module.exports = { + extends: [ + 'plugin:jest/recommended', + ], + env: { + browser: true, + }, + globals: { + browser: 'readonly', + page: 'readonly', + wp: 'readonly', + }, +}; diff --git a/packages/eslint-plugin/configs/test-unit.js b/packages/eslint-plugin/configs/test-unit.js new file mode 100644 index 00000000000000..048ced2fe38d1f --- /dev/null +++ b/packages/eslint-plugin/configs/test-unit.js @@ -0,0 +1,5 @@ +module.exports = { + extends: [ + 'plugin:jest/recommended', + ], +}; diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 3e5ee9add8aac6..7a0369eaab06e5 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -25,6 +25,7 @@ "main": "index.js", "dependencies": { "babel-eslint": "^10.0.2", + "eslint-plugin-jest": "^22.15.1", "eslint-plugin-jsdoc": "^15.8.0", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.14.3", diff --git a/packages/is-shallow-equal/.eslintrc.json b/packages/is-shallow-equal/.eslintrc.json index 3ab5b55d74cc09..2127e794d08b99 100644 --- a/packages/is-shallow-equal/.eslintrc.json +++ b/packages/is-shallow-equal/.eslintrc.json @@ -1,7 +1,17 @@ { "root": true, - "extends": "plugin:@wordpress/eslint-plugin/es5", + "extends": [ + "plugin:@wordpress/eslint-plugin/es5" + ], "env": { "node": true - } + }, + "overrides": [ + { + "files": [ "@(test|benchmark)/*.js" ], + "extends": [ + "plugin:@wordpress/eslint-plugin/recommended" + ] + } + ] } diff --git a/packages/is-shallow-equal/benchmark/.eslintrc.json b/packages/is-shallow-equal/benchmark/.eslintrc.json deleted file mode 100644 index 93ba810c785626..00000000000000 --- a/packages/is-shallow-equal/benchmark/.eslintrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "root": true, - "extends": "../../../.eslintrc.js" -} diff --git a/packages/is-shallow-equal/test/.eslintrc.json b/packages/is-shallow-equal/test/.eslintrc.json deleted file mode 100644 index 93ba810c785626..00000000000000 --- a/packages/is-shallow-equal/test/.eslintrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "root": true, - "extends": "../../../.eslintrc.js" -} diff --git a/packages/scripts/CHANGELOG.md b/packages/scripts/CHANGELOG.md index 7ccc3d4d75efa7..d7392cd49ce847 100644 --- a/packages/scripts/CHANGELOG.md +++ b/packages/scripts/CHANGELOG.md @@ -5,6 +5,7 @@ - The bundled `puppeteer` dependency has been updated from requiring `1.6.1` to requiring `^1.19.0` ([#16875](https://github.com/WordPress/gutenberg/pull/16875)). It uses Chromium v77 instead of Chromium v69. - The bundled `jest-puppeteer` dependency has been updated from requiring `^4.0.0` to requiring `^4.3.0` ([#16875](https://github.com/WordPress/gutenberg/pull/16875)). - The bundled `eslint` dependency has been updated from requiring `^5.16.0` to requiring `^6.1.0`. +- The bundled `@wordpress/eslint-plugin` dependency has been updated to the next major version `^3.0.0` due to new ESLint rules enabled for all test files. ## 3.4.0 (2019-08-05)