Skip to content

Commit

Permalink
Testing: Prevent a direct usage of Reakit (#28095)
Browse files Browse the repository at this point in the history
* Testing: Prevent of direct usage of Reakit

* Add exceptions for Reakit usage in @wordpress/components
  • Loading branch information
gziolo authored Jan 12, 2021
1 parent 195a73e commit 59923c1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
33 changes: 23 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,29 @@ module.exports = {
},
],
'@wordpress/no-unsafe-wp-apis': 'off',
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'lodash',
importNames: [ 'memoize' ],
message: 'Please use `memize` instead.',
},
{
name: 'reakit',
message:
'Please use Reakit API through `@wordpress/components` instead.',
},
{
name: 'redux',
importNames: [ 'combineReducers' ],
message:
'Please use `combineReducers` from `@wordpress/data` instead.',
},
],
},
],
'no-restricted-syntax': [
'error',
// NOTE: We can't include the forward slash in our regex or
Expand All @@ -79,16 +102,6 @@ module.exports = {
message:
'Deprecated functions must be removed before releasing this version.',
},
{
selector:
'ImportDeclaration[source.value="redux"] Identifier.imported[name="combineReducers"]',
message: 'Use `combineReducers` from `@wordpress/data`',
},
{
selector:
'ImportDeclaration[source.value="lodash"] Identifier.imported[name="memoize"]',
message: 'Use memize instead of Lodash’s memoize',
},
{
selector:
'CallExpression[callee.object.name="page"][callee.property.name="waitFor"]',
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/composite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* The plan is to build own API that accounts for future breaking changes
* in Reakit (https://github.com/WordPress/gutenberg/pull/28085).
*/
/* eslint-disable-next-line no-restricted-imports */
export {
Composite,
CompositeGroup,
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/disclosure/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
* The plan is to build own API that accounts for future breaking changes
* in Reakit (https://github.com/WordPress/gutenberg/pull/28085).
*/
/* eslint-disable-next-line no-restricted-imports */
export { DisclosureContent } from 'reakit';

0 comments on commit 59923c1

Please sign in to comment.