Skip to content

Commit

Permalink
Add test rules only when jest is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Sep 9, 2021
1 parent 7141756 commit 3d1f22f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- The bundled `eslint-plugin-jsdoc` dependency has been updated from requiring `^34.1.0` to requiring `^36.0.8` ([#34338](https://github.com/WordPress/gutenberg/pull/34338)).

### Bug Fix

- Use Jest related rules only when the `jest` package is installed ([#33120](https://github.com/WordPress/gutenberg/pull/33120)).

## 9.1.2 (2021-09-09)

### Bug Fix
Expand Down
18 changes: 14 additions & 4 deletions packages/eslint-plugin/configs/recommended-with-formatting.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
module.exports = {
/**
* Internal dependencies
*/
const { isPackageInstalled } = require( '../utils' );

const config = {
parser: 'babel-eslint',
extends: [
require.resolve( './jsx-a11y.js' ),
Expand Down Expand Up @@ -27,7 +32,10 @@ module.exports = {
'import/default': 'warn',
'import/named': 'warn',
},
overrides: [
};

if ( isPackageInstalled( 'jest' ) ) {
config.overrides = [
{
// Unit test files and their helpers only.
files: [ '**/@(test|__tests__)/**/*.js', '**/?(*.)test.js' ],
Expand All @@ -38,5 +46,7 @@ module.exports = {
files: [ '**/specs/**/*.js', '**/?(*.)spec.js' ],
extends: [ require.resolve( './test-e2e.js' ) ],
},
],
};
];
}

module.exports = config;
1 change: 0 additions & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"globals": "^12.0.0",
"jest": "26.6.3",
"prettier": "npm:[email protected]",
"requireindex": "^1.2.0"
},
Expand Down

0 comments on commit 3d1f22f

Please sign in to comment.