Skip to content

Commit

Permalink
Allow ariakit and framer motion imports in components package (WordPr…
Browse files Browse the repository at this point in the history
…ess#63123)

* ESLint: allow importing from ariakit and framer motion in the components package

* Remove unnecessary eslint disable comments

* CHANGELOG

* Add comment in ESLint config

---

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
3 people authored and carstingaxion committed Jul 18, 2024
1 parent ed021f7 commit d0747d9
Show file tree
Hide file tree
Showing 31 changed files with 21 additions and 32 deletions.
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,26 @@ module.exports = {
plugins: [ 'ssr-friendly' ],
extends: [ 'plugin:ssr-friendly/recommended' ],
},
{
files: [ 'packages/components/src/**' ],
rules: {
'no-restricted-imports': [
'error',
// The `ariakit` and `framer-motion` APIs are meant to be consumed via
// the `@wordpress/components` package, hence why importing those
// dependencies should be allowed in the components package.
{
paths: restrictedImports.filter(
( { name } ) =>
! [
'@ariakit/react',
'framer-motion',
].includes( name )
),
},
],
},
},
{
files: [ 'packages/block-editor/**' ],
rules: {
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

### Internal

- `Allow ariakit and framer motion imports in the components package. ([#63123](https://github.com/WordPress/gutenberg/pull/63123))
- `CustomSelectControlV2`: prevent keyboard event propagation in legacy wrapper. ([#62907](https://github.com/WordPress/gutenberg/pull/62907))
- `CustomSelectControlV2`: expose legacy wrapper through private APIs. ([#62936](https://github.com/WordPress/gutenberg/pull/62936))
- `CustomSelectControlV2`: fix item styles ([#62825](https://github.com/WordPress/gutenberg/pull/62825))
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/animation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* @see https://www.framer.com/docs/animation/
*/

// eslint-disable-next-line no-restricted-imports
export {
motion as __unstableMotion,
AnimatePresence as __unstableAnimatePresence,
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/composite/current/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @see https://ariakit.org/components/composite
*/

/* eslint-disable-next-line no-restricted-imports */
export {
Composite,
CompositeGroup,
Expand All @@ -18,5 +17,4 @@ export {
useCompositeStore,
} from '@ariakit/react';

/* eslint-disable-next-line no-restricted-imports */
export type { CompositeStore, CompositeStoreProps } from '@ariakit/react';
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
/**
* Internal dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
import clsx from 'clsx';

Expand Down
1 change: 0 additions & 1 deletion packages/components/src/custom-select-control-v2/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/custom-select-control-v2/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import type * as Ariakit from '@ariakit/react';
import type { FocusEventHandler, MouseEventHandler } from 'react';

Expand Down
1 change: 0 additions & 1 deletion packages/components/src/disclosure/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/divider/component.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
import type { ForwardedRef } from 'react';

Expand Down
1 change: 0 additions & 1 deletion packages/components/src/divider/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import type { SeparatorProps } from '@ariakit/react';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/dropdown-menu-v2/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/dropdown-menu-v2/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
import { css, keyframes } from '@emotion/react';
import styled from '@emotion/styled';
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/dropdown-menu-v2/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import type * as Ariakit from '@ariakit/react';
import type { Placement } from '@floating-ui/react-dom';

Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import {
offset as offsetMiddleware,
size,
} from '@floating-ui/react-dom';
// eslint-disable-next-line no-restricted-imports
import type { HTMLMotionProps, MotionProps } from 'framer-motion';
// eslint-disable-next-line no-restricted-imports
import { motion } from 'framer-motion';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/popover/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import type { MotionProps } from 'framer-motion';
import type { Placement, ReferenceType } from '@floating-ui/react-dom';

Expand Down
1 change: 0 additions & 1 deletion packages/components/src/radio-group/context.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import type * as Ariakit from '@ariakit/react';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/radio-group/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/radio-group/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { forwardRef, useContext } from '@wordpress/element';
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/tab-panel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
import clsx from 'clsx';
import type { ForwardedRef } from 'react';
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/tabs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/tabs/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import styled from '@emotion/styled';
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/tabs/tablist.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/tabs/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import type * as Ariakit from '@ariakit/react';

export type TabsContextProps =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
* External dependencies
*/
import type { ForwardedRef } from 'react';
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
// eslint-disable-next-line no-restricted-imports
import { motion } from 'framer-motion';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import type { ForwardedRef } from 'react';
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import type { ForwardedRef } from 'react';
// eslint-disable-next-line no-restricted-imports
import { LayoutGroup } from 'framer-motion';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/toolbar/toolbar-context/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import type * as Ariakit from '@ariakit/react';

/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/toolbar/toolbar-item/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
import type { ForwardedRef } from 'react';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
import type { ForwardedRef } from 'react';

Expand Down
1 change: 0 additions & 1 deletion packages/components/src/tooltip/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';

/**
Expand Down

0 comments on commit d0747d9

Please sign in to comment.