From ee69822d9317d0d4c9ca42b951dbf6700b0dadd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=B3=C5=82kowski?= Date: Mon, 21 Jun 2021 10:45:41 +0200 Subject: [PATCH] Quality: Promote lint rule to error when validating store string literals (#32537) * Quality: Promote lint rule for store string literals to error * Try to replace `core/data` with selectors from related stores * Disable rule violation in the `@wordpress/server-side-render` component --- .eslintrc.js | 2 +- packages/block-editor/src/index.js | 5 -- packages/block-library/src/categories/edit.js | 5 +- packages/block-library/src/embed/edit.js | 6 +-- packages/block-library/src/index.js | 2 - packages/core-data/src/actions.js | 54 ++++++++----------- packages/core-data/src/entities.js | 4 +- packages/core-data/src/entity-provider.js | 10 ++-- packages/core-data/src/locks/actions.js | 6 +-- packages/core-data/src/resolvers.js | 14 ++--- packages/core-data/src/selectors.js | 7 +-- packages/core-data/src/utils/constants.js | 13 ----- .../core-data/src/utils/if-not-resolved.js | 4 +- packages/data/src/registry.js | 3 +- .../data/src/resolvers-cache-middleware.js | 9 +++- packages/data/src/store/name.js | 6 +++ packages/data/src/test/registry.js | 5 +- .../header/fullscreen-mode-close/index.js | 7 +-- packages/edit-post/src/index.js | 3 -- .../post-publish-panel/prepublish.js | 5 +- packages/editor/src/index.js | 7 --- packages/reusable-blocks/src/index.js | 6 --- packages/server-side-render/src/index.js | 3 ++ 23 files changed, 74 insertions(+), 112 deletions(-) delete mode 100644 packages/core-data/src/utils/constants.js create mode 100644 packages/data/src/store/name.js diff --git a/.eslintrc.js b/.eslintrc.js index ad6be56298f2c6..5ad25a66edaff4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -63,7 +63,7 @@ module.exports = { }, ], '@wordpress/no-unsafe-wp-apis': 'off', - '@wordpress/data-no-store-string-literals': 'warn', + '@wordpress/data-no-store-string-literals': 'error', 'import/default': 'error', 'import/named': 'error', 'no-restricted-imports': [ diff --git a/packages/block-editor/src/index.js b/packages/block-editor/src/index.js index 27af4c4be666b8..1e567a9c295af4 100644 --- a/packages/block-editor/src/index.js +++ b/packages/block-editor/src/index.js @@ -1,8 +1,3 @@ -/** - * WordPress dependencies - */ -import '@wordpress/rich-text'; - /** * Internal dependencies */ diff --git a/packages/block-library/src/categories/edit.js b/packages/block-library/src/categories/edit.js index 12adf03e1ffcee..08be1b3a7053aa 100644 --- a/packages/block-library/src/categories/edit.js +++ b/packages/block-library/src/categories/edit.js @@ -26,12 +26,11 @@ export default function CategoriesEdit( { } ) { const selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' ); const { categories, isRequesting } = useSelect( ( select ) => { - const { getEntityRecords } = select( coreStore ); - const { isResolving } = select( 'core/data' ); + const { getEntityRecords, isResolving } = select( coreStore ); const query = { per_page: -1, hide_empty: true }; return { categories: getEntityRecords( 'taxonomy', 'category', query ), - isRequesting: isResolving( 'core', 'getEntityRecords', [ + isRequesting: isResolving( 'getEntityRecords', [ 'taxonomy', 'category', query, diff --git a/packages/block-library/src/embed/edit.js b/packages/block-library/src/embed/edit.js index a02371c0d4c637..e5c0484b49a9b4 100644 --- a/packages/block-library/src/embed/edit.js +++ b/packages/block-library/src/embed/edit.js @@ -64,7 +64,7 @@ const EmbedEdit = ( props ) => { const [ url, setURL ] = useState( attributesUrl ); const [ isEditingURL, setIsEditingURL ] = useState( false ); - const { invalidateResolution } = useDispatch( 'core/data' ); + const { invalidateResolution } = useDispatch( coreStore ); const { preview, @@ -214,9 +214,7 @@ const EmbedEdit = ( props ) => { onChange={ ( event ) => setURL( event.target.value ) } fallback={ () => fallback( url, onReplace ) } tryAgain={ () => { - invalidateResolution( 'core', 'getEmbedPreview', [ - url, - ] ); + invalidateResolution( 'getEmbedPreview', [ url ] ); } } /> diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index 0716373e244b8b..da7fcacc8cadff 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -1,8 +1,6 @@ /** * WordPress dependencies */ -import '@wordpress/core-data'; -import '@wordpress/block-editor'; import { registerBlockType, setDefaultBlockName, diff --git a/packages/core-data/src/actions.js b/packages/core-data/src/actions.js index d4ccbbd3ae9971..6c3d392c31210b 100644 --- a/packages/core-data/src/actions.js +++ b/packages/core-data/src/actions.js @@ -22,7 +22,7 @@ import { } from './locks'; import { createBatch } from './batch'; import { getDispatch } from './controls'; -import { CORE_STORE_NAME as coreStoreName } from './utils/constants'; +import { STORE_NAME } from './name'; /** * Returns an action object used in signalling that authors have been received. @@ -183,7 +183,7 @@ export function* deleteEntityRecord( } const lock = yield* __unstableAcquireStoreLock( - coreStoreName, + STORE_NAME, [ 'entities', 'data', kind, name, recordId ], { exclusive: true } ); @@ -247,12 +247,7 @@ export function* deleteEntityRecord( * @return {Object} Action object. */ export function* editEntityRecord( kind, name, recordId, edits, options = {} ) { - const entity = yield controls.select( - coreStoreName, - 'getEntity', - kind, - name - ); + const entity = yield controls.select( STORE_NAME, 'getEntity', kind, name ); if ( ! entity ) { throw new Error( `The entity being edited (${ kind }, ${ name }) does not have a loaded config.` @@ -260,14 +255,14 @@ export function* editEntityRecord( kind, name, recordId, edits, options = {} ) { } const { transientEdits = {}, mergedEdits = {} } = entity; const record = yield controls.select( - coreStoreName, + STORE_NAME, 'getRawEntityRecord', kind, name, recordId ); const editedRecord = yield controls.select( - coreStoreName, + STORE_NAME, 'getEditedEntityRecord', kind, name, @@ -312,7 +307,7 @@ export function* editEntityRecord( kind, name, recordId, edits, options = {} ) { * an entity record, if any. */ export function* undo() { - const undoEdit = yield controls.select( coreStoreName, 'getUndoEdit' ); + const undoEdit = yield controls.select( STORE_NAME, 'getUndoEdit' ); if ( ! undoEdit ) { return; } @@ -330,7 +325,7 @@ export function* undo() { * edit to an entity record, if any. */ export function* redo() { - const redoEdit = yield controls.select( coreStoreName, 'getRedoEdit' ); + const redoEdit = yield controls.select( STORE_NAME, 'getRedoEdit' ); if ( ! redoEdit ) { return; } @@ -380,7 +375,7 @@ export function* saveEntityRecord( const recordId = record[ entityIdKey ]; const lock = yield* __unstableAcquireStoreLock( - coreStoreName, + STORE_NAME, [ 'entities', 'data', kind, name, recordId || uuid() ], { exclusive: true } ); @@ -391,7 +386,7 @@ export function* saveEntityRecord( if ( typeof value === 'function' ) { const evaluatedValue = value( yield controls.select( - coreStoreName, + STORE_NAME, 'getEditedEntityRecord', kind, name, @@ -425,7 +420,7 @@ export function* saveEntityRecord( recordId ? '/' + recordId : '' }`; const persistedRecord = yield controls.select( - coreStoreName, + STORE_NAME, 'getRawEntityRecord', kind, name, @@ -438,12 +433,12 @@ export function* saveEntityRecord( // but ideally this should all be handled in the back end, // so the client just sends and receives objects. const currentUser = yield controls.select( - coreStoreName, + STORE_NAME, 'getCurrentUser' ); const currentUserId = currentUser ? currentUser.id : undefined; const autosavePost = yield controls.select( - coreStoreName, + STORE_NAME, 'getAutosave', persistedRecord.type, persistedRecord.id, @@ -614,20 +609,15 @@ export function* __experimentalBatch( requests ) { const api = { saveEntityRecord( kind, name, record, options ) { return batch.add( ( add ) => - dispatch( coreStoreName ).saveEntityRecord( - kind, - name, - record, - { - ...options, - __unstableFetch: add, - } - ) + dispatch( STORE_NAME ).saveEntityRecord( kind, name, record, { + ...options, + __unstableFetch: add, + } ) ); }, saveEditedEntityRecord( kind, name, recordId, options ) { return batch.add( ( add ) => - dispatch( coreStoreName ).saveEditedEntityRecord( + dispatch( STORE_NAME ).saveEditedEntityRecord( kind, name, recordId, @@ -640,7 +630,7 @@ export function* __experimentalBatch( requests ) { }, deleteEntityRecord( kind, name, recordId, query, options ) { return batch.add( ( add ) => - dispatch( coreStoreName ).deleteEntityRecord( + dispatch( STORE_NAME ).deleteEntityRecord( kind, name, recordId, @@ -671,7 +661,7 @@ export function* __experimentalBatch( requests ) { export function* saveEditedEntityRecord( kind, name, recordId, options ) { if ( ! ( yield controls.select( - coreStoreName, + STORE_NAME, 'hasEditsForEntityRecord', kind, name, @@ -681,7 +671,7 @@ export function* saveEditedEntityRecord( kind, name, recordId, options ) { return; } const edits = yield controls.select( - coreStoreName, + STORE_NAME, 'getEntityRecordNonTransientEdits', kind, name, @@ -709,7 +699,7 @@ export function* __experimentalSaveSpecifiedEntityEdits( ) { if ( ! ( yield controls.select( - coreStoreName, + STORE_NAME, 'hasEditsForEntityRecord', kind, name, @@ -719,7 +709,7 @@ export function* __experimentalSaveSpecifiedEntityEdits( return; } const edits = yield controls.select( - coreStoreName, + STORE_NAME, 'getEntityRecordNonTransientEdits', kind, name, diff --git a/packages/core-data/src/entities.js b/packages/core-data/src/entities.js index 85f0cf5797f162..f22010c58dddc6 100644 --- a/packages/core-data/src/entities.js +++ b/packages/core-data/src/entities.js @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n'; * Internal dependencies */ import { addEntities } from './actions'; -import { CORE_STORE_NAME as coreStoreName } from './utils/constants'; +import { STORE_NAME } from './name'; export const DEFAULT_ENTITY_KEY = 'id'; @@ -250,7 +250,7 @@ export const getMethodName = ( */ export function* getKindEntities( kind ) { let entities = yield controls.select( - coreStoreName, + STORE_NAME, 'getEntitiesByKind', kind ); diff --git a/packages/core-data/src/entity-provider.js b/packages/core-data/src/entity-provider.js index cfbf7bc7c638d3..fc842a14f41f75 100644 --- a/packages/core-data/src/entity-provider.js +++ b/packages/core-data/src/entity-provider.js @@ -13,7 +13,7 @@ import { parse, __unstableSerializeAndClean } from '@wordpress/blocks'; /** * Internal dependencies */ -import { CORE_STORE_NAME as coreStoreName } from './utils/constants'; +import { STORE_NAME } from './name'; const EMPTY_ARRAY = []; @@ -100,7 +100,7 @@ export function useEntityProp( kind, type, prop, _id ) { const { value, fullValue } = useSelect( ( select ) => { const { getEntityRecord, getEditedEntityRecord } = select( - coreStoreName + STORE_NAME ); const entity = getEntityRecord( kind, type, id ); // Trigger resolver. const editedEntity = getEditedEntityRecord( kind, type, id ); @@ -113,7 +113,7 @@ export function useEntityProp( kind, type, prop, _id ) { }, [ kind, type, id, prop ] ); - const { editEntityRecord } = useDispatch( coreStoreName ); + const { editEntityRecord } = useDispatch( STORE_NAME ); const setValue = useCallback( ( newValue ) => { editEntityRecord( kind, type, id, { @@ -149,7 +149,7 @@ export function useEntityBlockEditor( kind, type, { id: _id } = {} ) { const id = _id ?? providerId; const { content, blocks } = useSelect( ( select ) => { - const { getEditedEntityRecord } = select( coreStoreName ); + const { getEditedEntityRecord } = select( STORE_NAME ); const editedEntity = getEditedEntityRecord( kind, type, id ); return { blocks: editedEntity.blocks, @@ -159,7 +159,7 @@ export function useEntityBlockEditor( kind, type, { id: _id } = {} ) { [ kind, type, id ] ); const { __unstableCreateUndoLevel, editEntityRecord } = useDispatch( - coreStoreName + STORE_NAME ); useEffect( () => { diff --git a/packages/core-data/src/locks/actions.js b/packages/core-data/src/locks/actions.js index e0a54311e3fea1..aab16dd703bbad 100644 --- a/packages/core-data/src/locks/actions.js +++ b/packages/core-data/src/locks/actions.js @@ -7,7 +7,7 @@ import { controls } from '@wordpress/data'; /** * Internal dependencies */ -import { CORE_STORE_NAME as coreStoreName } from '../utils/constants'; +import { STORE_NAME } from '../name'; export function* __unstableAcquireStoreLock( store, path, { exclusive } ) { const promise = yield* __unstableEnqueueLockRequest( store, path, { @@ -42,13 +42,13 @@ export function* __unstableProcessPendingLockRequests() { type: 'PROCESS_PENDING_LOCK_REQUESTS', }; const lockRequests = yield controls.select( - coreStoreName, + STORE_NAME, '__unstableGetPendingLockRequests' ); for ( const request of lockRequests ) { const { store, path, exclusive, notifyAcquired } = request; const isAvailable = yield controls.select( - coreStoreName, + STORE_NAME, '__unstableIsLockAvailable', store, path, diff --git a/packages/core-data/src/resolvers.js b/packages/core-data/src/resolvers.js index 48fd962c028442..6a68c22da2578d 100644 --- a/packages/core-data/src/resolvers.js +++ b/packages/core-data/src/resolvers.js @@ -13,7 +13,7 @@ import { apiFetch } from '@wordpress/data-controls'; * Internal dependencies */ import { regularFetch } from './controls'; -import { CORE_STORE_NAME as coreStoreName } from './utils/constants'; +import { STORE_NAME } from './name'; /** * Internal dependencies @@ -86,7 +86,7 @@ export function* getEntityRecord( kind, name, key = '', query ) { } const lock = yield* __unstableAcquireStoreLock( - coreStoreName, + STORE_NAME, [ 'entities', 'data', kind, name, key ], { exclusive: false } ); @@ -123,7 +123,7 @@ export function* getEntityRecord( kind, name, key = '', query ) { // fields, so it's tested here, prior to initiating the REST request, // and without causing `getEntityRecords` resolution to occur. const hasRecords = yield controls.select( - coreStoreName, + STORE_NAME, 'hasEntityRecords', kind, name, @@ -175,7 +175,7 @@ export function* getEntityRecords( kind, name, query = {} ) { } const lock = yield* __unstableAcquireStoreLock( - coreStoreName, + STORE_NAME, [ 'entities', 'data', kind, name ], { exclusive: false } ); @@ -370,7 +370,7 @@ export function* canUserEditEntityRecord( kind, name, recordId ) { */ export function* getAutosaves( postType, postId ) { const { rest_base: restBase } = yield controls.resolveSelect( - coreStoreName, + STORE_NAME, 'getPostType', postType ); @@ -394,7 +394,7 @@ export function* getAutosaves( postType, postId ) { */ export function* getAutosave( postType, postId ) { yield controls.resolveSelect( - coreStoreName, + STORE_NAME, 'getAutosaves', postType, postId @@ -427,7 +427,7 @@ export function* __experimentalGetTemplateForLink( link ) { yield getEntityRecord( 'postType', 'wp_template', template.id ); const record = yield controls.select( - coreStoreName, + STORE_NAME, 'getEntityRecord', 'postType', 'wp_template', diff --git a/packages/core-data/src/selectors.js b/packages/core-data/src/selectors.js index 5b28c1df5146c1..57f1da34786060 100644 --- a/packages/core-data/src/selectors.js +++ b/packages/core-data/src/selectors.js @@ -17,7 +17,6 @@ import { STORE_NAME } from './name'; import { getQueriedItems } from './queried-data'; import { DEFAULT_ENTITY_KEY } from './entities'; import { getNormalizedCommaSeparable } from './utils'; -import { CORE_DATA_STORE_NAME as coreDataStoreName } from './utils/constants'; /** * Shared reference to an empty array for cases where it is important to avoid @@ -41,11 +40,7 @@ const EMPTY_ARRAY = []; */ export const isRequestingEmbedPreview = createRegistrySelector( ( select ) => ( state, url ) => { - return select( coreDataStoreName ).isResolving( - STORE_NAME, - 'getEmbedPreview', - [ url ] - ); + return select( STORE_NAME ).isResolving( 'getEmbedPreview', [ url ] ); } ); diff --git a/packages/core-data/src/utils/constants.js b/packages/core-data/src/utils/constants.js deleted file mode 100644 index 9e05d0959a228c..00000000000000 --- a/packages/core-data/src/utils/constants.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * The identifier for the core store. - * - * @type {string} - */ -export const CORE_STORE_NAME = 'core'; - -/** - * The identifier for the core/data store. - * - * @type {string} - */ -export const CORE_DATA_STORE_NAME = 'core/data'; diff --git a/packages/core-data/src/utils/if-not-resolved.js b/packages/core-data/src/utils/if-not-resolved.js index fda22b930215b9..0baf36f0e5d8d9 100644 --- a/packages/core-data/src/utils/if-not-resolved.js +++ b/packages/core-data/src/utils/if-not-resolved.js @@ -6,7 +6,7 @@ import { controls } from '@wordpress/data'; /** * Internal dependencies */ -import { CORE_STORE_NAME as coreStoreName } from './constants'; +import { STORE_NAME } from '../name'; /** * Higher-order function which invokes the given resolver only if it has not @@ -26,7 +26,7 @@ const ifNotResolved = ( resolver, selectorName ) => */ function* resolveIfNotResolved( ...args ) { const hasStartedResolution = yield controls.select( - coreStoreName, + STORE_NAME, 'hasStartedResolution', selectorName, args diff --git a/packages/data/src/registry.js b/packages/data/src/registry.js index 151bdd3d6d095d..240f1040cd1b69 100644 --- a/packages/data/src/registry.js +++ b/packages/data/src/registry.js @@ -8,6 +8,7 @@ import { without, mapValues, isObject } from 'lodash'; */ import createReduxStore from './redux-store'; import createCoreDataStore from './store'; +import { STORE_NAME } from './store/name'; /** @typedef {import('./types').WPDataStore} WPDataStore */ @@ -259,7 +260,7 @@ export function createRegistry( storeConfigs = {}, parent = null ) { return registry; } - registerGenericStore( 'core/data', createCoreDataStore( registry ) ); + registerGenericStore( STORE_NAME, createCoreDataStore( registry ) ); Object.entries( storeConfigs ).forEach( ( [ name, config ] ) => registry.registerStore( name, config ) diff --git a/packages/data/src/resolvers-cache-middleware.js b/packages/data/src/resolvers-cache-middleware.js index 85f0f8a65cd25a..3f514e67ce0a1e 100644 --- a/packages/data/src/resolvers-cache-middleware.js +++ b/packages/data/src/resolvers-cache-middleware.js @@ -3,6 +3,11 @@ */ import { get } from 'lodash'; +/** + * Internal dependencies + */ +import { STORE_NAME } from './store/name'; + /** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */ /** @@ -19,7 +24,7 @@ const createResolversCacheMiddleware = ( registry, reducerKey ) => () => ( next ) => ( action ) => { const resolvers = registry - .select( 'core/data' ) + .select( STORE_NAME ) .getCachedResolvers( reducerKey ); Object.entries( resolvers ).forEach( ( [ selectorName, resolversByArgs ] ) => { @@ -44,7 +49,7 @@ const createResolversCacheMiddleware = ( registry, reducerKey ) => () => ( // Trigger cache invalidation registry - .dispatch( 'core/data' ) + .dispatch( STORE_NAME ) .invalidateResolution( reducerKey, selectorName, args ); } ); } diff --git a/packages/data/src/store/name.js b/packages/data/src/store/name.js new file mode 100644 index 00000000000000..a50bd512300965 --- /dev/null +++ b/packages/data/src/store/name.js @@ -0,0 +1,6 @@ +/** + * The identifier for the core/data store. + * + * @type {string} + */ +export const STORE_NAME = 'core/data'; diff --git a/packages/data/src/test/registry.js b/packages/data/src/test/registry.js index c36bbe98654188..8796fc4300ff1d 100644 --- a/packages/data/src/test/registry.js +++ b/packages/data/src/test/registry.js @@ -9,6 +9,7 @@ import { castArray, mapValues } from 'lodash'; import { createRegistry } from '../registry'; import { createRegistrySelector } from '../factory'; import createReduxStore from '../redux-store'; +import { STORE_NAME } from '../store/name'; jest.useFakeTimers(); @@ -376,7 +377,7 @@ describe( 'createRegistry', () => { () => registry.select( 'demo' ).getValue() === 'OK', () => registry - .select( 'core/data' ) + .select( STORE_NAME ) .hasFinishedResolution( 'demo', 'getValue' ), ] ); @@ -403,7 +404,7 @@ describe( 'createRegistry', () => { () => registry.select( 'demo' ).getValue() === 'OK', () => registry - .select( 'core/data' ) + .select( STORE_NAME ) .hasFinishedResolution( 'demo', 'getValue' ), ] ); diff --git a/packages/edit-post/src/components/header/fullscreen-mode-close/index.js b/packages/edit-post/src/components/header/fullscreen-mode-close/index.js index 5f63c8108af579..21863f5ad5afc1 100644 --- a/packages/edit-post/src/components/header/fullscreen-mode-close/index.js +++ b/packages/edit-post/src/components/header/fullscreen-mode-close/index.js @@ -24,14 +24,15 @@ function FullscreenModeClose( { showTooltip, icon, href } ) { ( select ) => { const { getCurrentPostType } = select( editorStore ); const { isFeatureActive } = select( editPostStore ); - const { isResolving } = select( 'core/data' ); - const { getEntityRecord, getPostType } = select( coreStore ); + const { getEntityRecord, getPostType, isResolving } = select( + coreStore + ); const siteData = getEntityRecord( 'root', '__unstableBase', undefined ) || {}; return { isActive: isFeatureActive( 'fullscreenMode' ), - isRequestingSiteIcon: isResolving( 'core', 'getEntityRecord', [ + isRequestingSiteIcon: isResolving( 'getEntityRecord', [ 'root', '__unstableBase', undefined, diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js index 25acadf68292c4..a97ece5c01d41a 100644 --- a/packages/edit-post/src/index.js +++ b/packages/edit-post/src/index.js @@ -1,9 +1,6 @@ /** * WordPress dependencies */ -import '@wordpress/core-data'; -import '@wordpress/block-editor'; -import '@wordpress/editor'; import { registerCoreBlocks, __experimentalRegisterExperimentalCoreBlocks, diff --git a/packages/editor/src/components/post-publish-panel/prepublish.js b/packages/editor/src/components/post-publish-panel/prepublish.js index 1c82adaa148e3a..40adeab40af3e7 100644 --- a/packages/editor/src/components/post-publish-panel/prepublish.js +++ b/packages/editor/src/components/post-publish-panel/prepublish.js @@ -33,11 +33,10 @@ function PostPublishPanelPrepublish( { children } ) { siteTitle, siteHome, } = useSelect( ( select ) => { - const { isResolving } = select( 'core/data' ); const { getCurrentPost, isEditedPostBeingScheduled } = select( editorStore ); - const { getEntityRecord } = select( coreStore ); + const { getEntityRecord, isResolving } = select( coreStore ); const siteData = getEntityRecord( 'root', '__unstableBase', undefined ) || {}; @@ -48,7 +47,7 @@ function PostPublishPanelPrepublish( { children } ) { false ), isBeingScheduled: isEditedPostBeingScheduled(), - isRequestingSiteIcon: isResolving( 'core', 'getEntityRecord', [ + isRequestingSiteIcon: isResolving( 'getEntityRecord', [ 'root', '__unstableBase', undefined, diff --git a/packages/editor/src/index.js b/packages/editor/src/index.js index d84cb1fcf21b4d..31fe9a672a72d1 100644 --- a/packages/editor/src/index.js +++ b/packages/editor/src/index.js @@ -1,10 +1,3 @@ -/** - * WordPress dependencies - */ -import '@wordpress/block-editor'; -import '@wordpress/core-data'; -import '@wordpress/rich-text'; - /** * Internal dependencies */ diff --git a/packages/reusable-blocks/src/index.js b/packages/reusable-blocks/src/index.js index 2c29c97f829920..cf6bfc074cc058 100644 --- a/packages/reusable-blocks/src/index.js +++ b/packages/reusable-blocks/src/index.js @@ -1,8 +1,2 @@ -/** - * WordPress dependencies - */ -import '@wordpress/block-editor'; -import '@wordpress/core-data'; - export { store } from './store'; export * from './components'; diff --git a/packages/server-side-render/src/index.js b/packages/server-side-render/src/index.js index 6baf0fc85b9fd4..49cbeb7625c919 100644 --- a/packages/server-side-render/src/index.js +++ b/packages/server-side-render/src/index.js @@ -16,6 +16,9 @@ import ServerSideRender from './server-side-render'; const EMPTY_OBJECT = {}; const ExportedServerSideRender = withSelect( ( select ) => { + // FIXME: @wordpress/server-side-render should not depend on @wordpress/editor. + // It is used by blocks that can be loaded into a *non-post* block editor. + // eslint-disable-next-line @wordpress/data-no-store-string-literals const coreEditorSelect = select( 'core/editor' ); if ( coreEditorSelect ) { const currentPostId = coreEditorSelect.getCurrentPostId();