diff --git a/.eslintrc.js b/.eslintrc.js index 363cd259c838b..7d2e6f3d40bca 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 019dd2a38b237..1478fbce50139 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4668,6 +4668,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" } }, @@ -5057,6 +5058,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", @@ -11131,9 +11133,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 a29163b7492d2..05a45d1b1446f 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,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 e84e32066de1e..ec6cc51832038 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 a6e298d055ac0..6163843848738 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 0000000000000..ffee0154641f1 --- /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 b40d7e8bb8ff4..4096609b421f4 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 f6f89c95f1081..63034c7efe800 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 efb873980b22f..69ca991b7e56b 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 5aaead8880681..71d8625cd961b 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 0000000000000..63a52f0f0d010 --- /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 0000000000000..048ced2fe38d1 --- /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 3e5ee9add8aac..7a0369eaab06e 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 3ab5b55d74cc0..2127e794d08b9 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 93ba810c78562..0000000000000 --- 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 93ba810c78562..0000000000000 --- 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 69166d2f0b3f3..062f51a2cc18a 100644 --- a/packages/scripts/CHANGELOG.md +++ b/packages/scripts/CHANGELOG.md @@ -9,6 +9,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)