diff --git a/news/4917.bugfix b/news/4917.bugfix new file mode 100644 index 0000000000..938e6722b5 --- /dev/null +++ b/news/4917.bugfix @@ -0,0 +1 @@ +Remove anonymous function calls. Remove default exports from. @sneridagh diff --git a/packages/volto-slate/src/actions/index.js b/packages/volto-slate/src/actions/index.js index b73121ac23..7cbe33490e 100644 --- a/packages/volto-slate/src/actions/index.js +++ b/packages/volto-slate/src/actions/index.js @@ -1,3 +1,3 @@ -export saveSlateBlockSelection from './selection'; +export { default as saveSlateBlockSelection } from './selection'; export * from './content'; export * from './plugins'; diff --git a/packages/volto-slate/src/blocks/Text/index.js b/packages/volto-slate/src/blocks/Text/index.js index 8082b45296..c6ee9893de 100644 --- a/packages/volto-slate/src/blocks/Text/index.js +++ b/packages/volto-slate/src/blocks/Text/index.js @@ -35,7 +35,7 @@ import textSVG from '@plone/volto/icons/subtext.svg'; export { TextBlockView, TextBlockEdit, TextBlockSchema }; -export default (config) => { +export default function applyConfig(config) { config.settings.slate = { // TODO: should we inverse order? First here gets executed last textblockExtensions: [ @@ -165,4 +165,4 @@ export default (config) => { restricted: true, }; return config; -}; +} diff --git a/packages/volto-slate/src/editor/index.js b/packages/volto-slate/src/editor/index.js index c092f1927d..0200279e01 100644 --- a/packages/volto-slate/src/editor/index.js +++ b/packages/volto-slate/src/editor/index.js @@ -1,9 +1,9 @@ import * as slateConfig from './config'; import installDefaultPlugins from './plugins'; -export SlateEditor from './SlateEditor'; -export EditorReference from './EditorReference'; +export { default as SlateEditor } from './SlateEditor'; +export { default as EditorReference } from './EditorReference'; -export default (config) => { +export default function applyConfig(config) { config.settings.slate = { ...slateConfig, // showExpandedToolbar: false, @@ -11,4 +11,4 @@ export default (config) => { }; config = installDefaultPlugins(config); return config; -}; +} diff --git a/packages/volto-slate/src/editor/ui/SlateContextToolbar.jsx b/packages/volto-slate/src/editor/ui/SlateContextToolbar.jsx index d140070779..6f8e494bfb 100644 --- a/packages/volto-slate/src/editor/ui/SlateContextToolbar.jsx +++ b/packages/volto-slate/src/editor/ui/SlateContextToolbar.jsx @@ -3,11 +3,11 @@ import Toolbar from './Toolbar'; // A toolbar that conditionally renders itself based on the presense of // children -export default ({ editor, plugins, show }) => { +export default function SlateContextToolbar({ editor, plugins, show }) { if (!show) { return null; } const components = plugins.map((plug) => plug(editor)).filter((c) => !!c); return components.length ? {components} : ''; -}; +} diff --git a/packages/volto-slate/src/editor/ui/index.js b/packages/volto-slate/src/editor/ui/index.js index 089e0012c3..422bc6ac2c 100644 --- a/packages/volto-slate/src/editor/ui/index.js +++ b/packages/volto-slate/src/editor/ui/index.js @@ -1,15 +1,15 @@ -export BasicToolbar from './BasicToolbar'; -export BlockButton from './BlockButton'; -export ClearFormattingButton from './ClearFormattingButton'; -export ExpandedToolbar from './ExpandedToolbar'; -export Expando from './Expando'; -export MarkButton from './MarkButton'; -export Menu from './Menu'; -export Separator from './Separator'; -export SlateContextToolbar from './SlateContextToolbar'; -export SlateToolbar from './SlateToolbar'; -export Toolbar from './Toolbar'; -export ToolbarButton from './ToolbarButton'; -export MarkElementButton from './MarkElementButton'; -export PositionedToolbar from './PositionedToolbar'; -export InlineToolbar from './InlineToolbar'; +export { default as BasicToolbar } from './BasicToolbar'; +export { default as BlockButton } from './BlockButton'; +export { default as ClearFormattingButton } from './ClearFormattingButton'; +export { default as ExpandedToolbar } from './ExpandedToolbar'; +export { default as Expando } from './Expando'; +export { default as MarkButton } from './MarkButton'; +export { default as Menu } from './Menu'; +export { default as Separator } from './Separator'; +export { default as SlateContextToolbar } from './SlateContextToolbar'; +export { default as SlateToolbar } from './SlateToolbar'; +export { default as Toolbar } from './Toolbar'; +export { default as ToolbarButton } from './ToolbarButton'; +export { default as MarkElementButton } from './MarkElementButton'; +export { default as PositionedToolbar } from './PositionedToolbar'; +export { default as InlineToolbar } from './InlineToolbar'; diff --git a/packages/volto-slate/src/index.js b/packages/volto-slate/src/index.js index ffcb29c775..a9ba83c2f5 100644 --- a/packages/volto-slate/src/index.js +++ b/packages/volto-slate/src/index.js @@ -8,7 +8,7 @@ import RichTextWidgetView from './widgets/RichTextWidgetView'; import HtmlSlateWidget from './widgets/HtmlSlateWidget'; import ObjectByTypeWidget from './widgets/ObjectByTypeWidget'; -export default (config) => { +export default function applyConfig(config) { config = [installSlate, installTextBlock, installTableBlock].reduce( (acc, apply) => apply(acc), config, @@ -58,4 +58,4 @@ export default (config) => { } return config; -}; +} diff --git a/src/components/manage/AnchorPlugin/index.jsx b/src/components/manage/AnchorPlugin/index.jsx index 1043887bf1..66f9726fe3 100644 --- a/src/components/manage/AnchorPlugin/index.jsx +++ b/src/components/manage/AnchorPlugin/index.jsx @@ -44,7 +44,7 @@ function unboundRemoveEntity(editorState) { return newEditorState; } -export default (config = {}) => { +export default function AnchorPlugin(config = {}) { // ToDo: Get rif of the remainings of having the original CSS modules const defaultTheme = {}; @@ -79,4 +79,4 @@ export default (config = {}) => { setEditorState(removeEntity(getEditorState())), }), }; -}; +} diff --git a/src/components/manage/AnchorPlugin/utils/EditorUtils.js b/src/components/manage/AnchorPlugin/utils/EditorUtils.js index 1623ca82f7..81117fb0ea 100644 --- a/src/components/manage/AnchorPlugin/utils/EditorUtils.js +++ b/src/components/manage/AnchorPlugin/utils/EditorUtils.js @@ -1,4 +1,4 @@ -export default ({ draftJs }) => ({ +const EditorUtils = ({ draftJs }) => ({ createLinkAtSelection(editorState, url) { const contentState = editorState .getCurrentContent() @@ -43,3 +43,5 @@ export default ({ draftJs }) => ({ return entity && entity.getType() === entityType; }, }); + +export default EditorUtils; diff --git a/src/components/manage/Blocks/Block/Style.jsx b/src/components/manage/Blocks/Block/Style.jsx index 4ea8f09ef7..42d5393e0d 100644 --- a/src/components/manage/Blocks/Block/Style.jsx +++ b/src/components/manage/Blocks/Block/Style.jsx @@ -1,7 +1,7 @@ import React from 'react'; import cx from 'classnames'; -export default ({ data, detached, children }) => { +export default function Style({ data, detached, children }) { return (
{
); -}; +} diff --git a/src/components/manage/Blocks/Listing/getAsyncData.js b/src/components/manage/Blocks/Listing/getAsyncData.js index 7d4ffe3662..c0947c7e75 100644 --- a/src/components/manage/Blocks/Listing/getAsyncData.js +++ b/src/components/manage/Blocks/Listing/getAsyncData.js @@ -1,7 +1,12 @@ import { getQueryStringResults } from '@plone/volto/actions'; import { resolveBlockExtensions } from '@plone/volto/helpers'; -export default ({ dispatch, data, path, blocksConfig }) => { +export default function getListingBlockAsyncData({ + dispatch, + data, + path, + blocksConfig, +}) { const { resolvedExtensions } = resolveBlockExtensions(data, blocksConfig); return [ @@ -18,4 +23,4 @@ export default ({ dispatch, data, path, blocksConfig }) => { ), ), ]; -}; +} diff --git a/src/components/manage/Blocks/Search/components/index.js b/src/components/manage/Blocks/Search/components/index.js index a6cad24b8c..d8b8d5c2d1 100644 --- a/src/components/manage/Blocks/Search/components/index.js +++ b/src/components/manage/Blocks/Search/components/index.js @@ -1,13 +1,13 @@ -export SearchDetails from './SearchDetails'; -export Facets from './Facets'; -export SelectFacet from './SelectFacet'; -export CheckboxFacet from './CheckboxFacet'; -export DateRangeFacet from './DateRangeFacet'; -export SearchInput from './SearchInput'; -export FilterList from './FilterList'; -export SortOn from './SortOn'; -export ToggleFacet from './ToggleFacet'; -export SelectFacetFilterListEntry from './SelectFacetFilterListEntry'; -export ToggleFacetFilterListEntry from './ToggleFacetFilterListEntry'; -export DateRangeFacetFilterListEntry from './DateRangeFacetFilterListEntry'; -export ViewSwitcher from './ViewSwitcher'; +export { default as SearchDetails } from './SearchDetails'; +export { default as Facets } from './Facets'; +export { default as SelectFacet } from './SelectFacet'; +export { default as CheckboxFacet } from './CheckboxFacet'; +export { default as DateRangeFacet } from './DateRangeFacet'; +export { default as SearchInput } from './SearchInput'; +export { default as FilterList } from './FilterList'; +export { default as SortOn } from './SortOn'; +export { default as ToggleFacet } from './ToggleFacet'; +export { default as SelectFacetFilterListEntry } from './SelectFacetFilterListEntry'; +export { default as ToggleFacetFilterListEntry } from './ToggleFacetFilterListEntry'; +export { default as DateRangeFacetFilterListEntry } from './DateRangeFacetFilterListEntry'; +export { default as ViewSwitcher } from './ViewSwitcher'; diff --git a/src/components/manage/Blocks/Search/hocs/index.js b/src/components/manage/Blocks/Search/hocs/index.js index 370c7a9299..6bbb624810 100644 --- a/src/components/manage/Blocks/Search/hocs/index.js +++ b/src/components/manage/Blocks/Search/hocs/index.js @@ -1,2 +1,2 @@ -export withQueryString from './withQueryString'; -export withSearch from './withSearch'; +export { default as withQueryString } from './withQueryString'; +export { default as withSearch } from './withSearch'; diff --git a/src/components/manage/Blocks/Search/hocs/withQueryString.jsx b/src/components/manage/Blocks/Search/hocs/withQueryString.jsx index d676858748..98c4b12faa 100644 --- a/src/components/manage/Blocks/Search/hocs/withQueryString.jsx +++ b/src/components/manage/Blocks/Search/hocs/withQueryString.jsx @@ -10,7 +10,7 @@ function getDisplayName(WrappedComponent) { * A HOC that injects querystring metadata information from the backend. * */ -export default (WrappedComponent) => { +export default function withQueryString(WrappedComponent) { function WithQueryString(props) { const dispatch = useDispatch(); @@ -29,4 +29,4 @@ export default (WrappedComponent) => { WrappedComponent, )})`; return WithQueryString; -}; +} diff --git a/src/components/manage/Blocks/ToC/variations/index.js b/src/components/manage/Blocks/ToC/variations/index.js index e77eb48319..ca49592d44 100644 --- a/src/components/manage/Blocks/ToC/variations/index.js +++ b/src/components/manage/Blocks/ToC/variations/index.js @@ -1,7 +1,7 @@ import DefaultTocRenderer from './DefaultTocRenderer'; import HorizontalMenu from './HorizontalMenu'; -export default [ +const ToCVariations = [ { id: 'default', title: 'Listing (default)', @@ -14,3 +14,5 @@ export default [ view: HorizontalMenu, }, ]; + +export default ToCVariations; diff --git a/src/config/RichTextEditor/Blocks.jsx b/src/config/RichTextEditor/Blocks.jsx index 22c7e76588..fd4c5eca96 100644 --- a/src/config/RichTextEditor/Blocks.jsx +++ b/src/config/RichTextEditor/Blocks.jsx @@ -1,4 +1,4 @@ -export default (props) => { +export default function Blocks(props) { const { draftJs, immutableLib } = props; const { DefaultDraftBlockRenderMap } = draftJs; const { Map } = immutableLib; @@ -27,4 +27,4 @@ export default (props) => { const listBlockTypes = ['unordered-list-item', 'ordered-list-item']; return { extendedBlockRenderMap, blockStyleFn, listBlockTypes }; -}; +} diff --git a/src/config/RichTextEditor/FromHTML.jsx b/src/config/RichTextEditor/FromHTML.jsx index fcac2c82c9..194ba9d79b 100644 --- a/src/config/RichTextEditor/FromHTML.jsx +++ b/src/config/RichTextEditor/FromHTML.jsx @@ -1,8 +1,8 @@ -export default (element) => { +export default function FromHTMLCustomBlockFn(element) { if (element.className === 'callout') { return { type: 'callout', }; } return null; -}; +} diff --git a/src/config/RichTextEditor/Styles.jsx b/src/config/RichTextEditor/Styles.jsx index 537276769f..8f905817c3 100644 --- a/src/config/RichTextEditor/Styles.jsx +++ b/src/config/RichTextEditor/Styles.jsx @@ -13,7 +13,7 @@ import orderedListSVG from '@plone/volto/icons/list-numbered.svg'; import blockquoteSVG from '@plone/volto/icons/quote.svg'; import calloutSVG from '@plone/volto/icons/megaphone.svg'; -export default function (props) { +export default function Styles(props) { const createInlineStyleButton = props.draftJsCreateInlineStyleButton.default; const createBlockStyleButton = props.draftJsCreateBlockStyleButton.default; diff --git a/src/constants/Indexes.js b/src/constants/Indexes.js index 4dd90bb47b..d4dd0731b6 100644 --- a/src/constants/Indexes.js +++ b/src/constants/Indexes.js @@ -3,7 +3,7 @@ * @module constants/indexes */ -export default { +const Indexes = { sortable_title: { label: 'Title', type: 'string', sort_on: 'sortable_title' }, review_state: { label: 'Review state', type: 'string' }, ModificationDate: { @@ -35,6 +35,8 @@ export default { Type: { label: 'Type', type: 'string' }, }; +export default Indexes; + export const defaultIndexes = [ 'review_state', 'ModificationDate', diff --git a/src/express-middleware/devproxy.js b/src/express-middleware/devproxy.js index d3411fdf89..1f0a6273aa 100644 --- a/src/express-middleware/devproxy.js +++ b/src/express-middleware/devproxy.js @@ -37,7 +37,7 @@ function getEnv() { return _env; } -export default function () { +export default function devProxyMiddleware() { const middleware = express.Router(); const devProxy = createProxyMiddleware(filter, { selfHandleResponse: true, diff --git a/src/express-middleware/files.js b/src/express-middleware/files.js index 2579c112ad..80ab96e21b 100644 --- a/src/express-middleware/files.js +++ b/src/express-middleware/files.js @@ -9,7 +9,7 @@ const HEADERS = [ 'Content-Type', ]; -function fileMiddleware(req, res, next) { +function filesMiddlewareFn(req, res, next) { getAPIResourceWithAuth(req) .then((resource) => { // Just forward the headers that we need @@ -24,10 +24,10 @@ function fileMiddleware(req, res, next) { .catch(next); } -export default function () { +export default function filesMiddleware() { const middleware = express.Router(); - middleware.all(['**/@@download/*', '**/@@display-file/*'], fileMiddleware); + middleware.all(['**/@@download/*', '**/@@display-file/*'], filesMiddlewareFn); middleware.id = 'filesResourcesProcessor'; return middleware; } diff --git a/src/express-middleware/images.js b/src/express-middleware/images.js index 2a86c203d1..11bbacf273 100644 --- a/src/express-middleware/images.js +++ b/src/express-middleware/images.js @@ -3,7 +3,7 @@ import { getAPIResourceWithAuth } from '@plone/volto/helpers'; const HEADERS = ['content-type', 'content-disposition', 'cache-control']; -function imageMiddleware(req, res, next) { +function imageMiddlewareFn(req, res, next) { getAPIResourceWithAuth(req) .then((resource) => { // Just forward the headers that we need @@ -17,11 +17,11 @@ function imageMiddleware(req, res, next) { .catch(next); } -export default function () { +export default function imagesMiddleware() { const middleware = express.Router(); - middleware.all(['**/@@images/*'], imageMiddleware); - middleware.all(['/@portrait/*'], imageMiddleware); + middleware.all(['**/@@images/*'], imageMiddlewareFn); + middleware.all(['/@portrait/*'], imageMiddlewareFn); middleware.id = 'imageResourcesProcessor'; return middleware; } diff --git a/src/express-middleware/robotstxt.js b/src/express-middleware/robotstxt.js index 3f8e49deab..4a68ed7001 100644 --- a/src/express-middleware/robotstxt.js +++ b/src/express-middleware/robotstxt.js @@ -22,7 +22,7 @@ const envRobots = function (req, res, next) { res.send(process.env.VOLTO_ROBOTSTXT); }; -export default function () { +export default function robotstxtMiddleware() { const middleware = express.Router(); if (process.env.VOLTO_ROBOTSTXT) { middleware.all('**/robots.txt', envRobots); diff --git a/src/express-middleware/sitemap.js b/src/express-middleware/sitemap.js index 8b05884bb3..59bf641c8f 100644 --- a/src/express-middleware/sitemap.js +++ b/src/express-middleware/sitemap.js @@ -47,7 +47,7 @@ export const sitemapIndex = function (req, res, next) { }); }; -export default function () { +export default function sitemapMiddleware() { const middleware = express.Router(); middleware.all('**/sitemap.xml.gz', sitemap); diff --git a/src/express-middleware/static.js b/src/express-middleware/static.js index 5e90754bc0..d7392ce668 100644 --- a/src/express-middleware/static.js +++ b/src/express-middleware/static.js @@ -2,7 +2,7 @@ import express from 'express'; import path from 'path'; import config from '@plone/volto/registry'; -const staticMiddleware = express.static( +const staticMiddlewareFn = express.static( process.env.BUILD_DIR ? path.join(process.env.BUILD_DIR, 'public') : process.env.RAZZLE_PUBLIC_DIR, @@ -24,9 +24,9 @@ const staticMiddleware = express.static( }, ); -export default function () { +export default function staticsMiddleware() { const middleware = express.Router(); - middleware.all('*', staticMiddleware); + middleware.all('*', staticMiddlewareFn); middleware.id = 'staticResourcesProcessor'; return middleware; } diff --git a/src/helpers/Extensions/index.js b/src/helpers/Extensions/index.js index 1fabfa7452..cc4c042dfb 100644 --- a/src/helpers/Extensions/index.js +++ b/src/helpers/Extensions/index.js @@ -1,5 +1,6 @@ export * from './withBlockSchemaEnhancer'; -export withBlockExtensions, { +export { + default as withBlockExtensions, resolveExtension, resolveBlockExtensions, } from './withBlockExtensions'; diff --git a/src/helpers/index.js b/src/helpers/index.js index 212eb17f18..ef59a10445 100644 --- a/src/helpers/index.js +++ b/src/helpers/index.js @@ -5,9 +5,9 @@ */ // export { injectLazyLibs } from './Loadable/Loadable'; -export Api from '@plone/volto/helpers/Api/Api'; +export { default as Api } from '@plone/volto/helpers/Api/Api'; export { getAPIResourceWithAuth } from '@plone/volto/helpers/Api/APIResourceWithAuth'; -export Html from '@plone/volto/helpers/Html/Html'; +export { default as Html } from '@plone/volto/helpers/Html/Html'; export { getAuthToken, persistAuthToken, @@ -59,8 +59,8 @@ export { buildStyleClassNamesExtenders, getPreviousNextBlock, } from '@plone/volto/helpers/Blocks/Blocks'; -export BodyClass from '@plone/volto/helpers/BodyClass/BodyClass'; -export ScrollToTop from '@plone/volto/helpers/ScrollToTop/ScrollToTop'; +export { default as BodyClass } from '@plone/volto/helpers/BodyClass/BodyClass'; +export { default as ScrollToTop } from '@plone/volto/helpers/ScrollToTop/ScrollToTop'; export { getBoolean, getVocabName, @@ -70,11 +70,10 @@ export { getFieldsVocabulary, } from '@plone/volto/helpers/Vocabularies/Vocabularies'; -export langmap from './LanguageMap/LanguageMap'; -export Helmet from './Helmet/Helmet'; -export FormValidation, { - validateFileUploadSize, -} from './FormValidation/FormValidation'; +export { default as langmap } from './LanguageMap/LanguageMap'; +export { default as Helmet } from './Helmet/Helmet'; +export { default as FormValidation } from './FormValidation/FormValidation'; +export { validateFileUploadSize } from './FormValidation/FormValidation'; export { difference, getColor, @@ -111,7 +110,7 @@ export { useDetectClickOutside } from './Utils/useDetectClickOutside'; export { useEvent } from './Utils/useEvent'; export { usePrevious } from './Utils/usePrevious'; export { usePagination } from './Utils/usePagination'; -export useUndoManager from './UndoManager/useUndoManager'; +export { default as useUndoManager } from './UndoManager/useUndoManager'; export { getCookieOptions } from './Cookies/cookies'; export { getWidgetView } from './Widget/widget'; export { diff --git a/src/middleware/index.js b/src/middleware/index.js index 5eed62a627..f8f6fae956 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -4,8 +4,8 @@ * @example import { api } from 'middleware'; */ -export api from '@plone/volto/middleware/api'; -export blacklistRoutes from './blacklistRoutes'; +export { default as api } from '@plone/volto/middleware/api'; +export { default as blacklistRoutes } from './blacklistRoutes'; export { protectLoadStart, protectLoadEnd, diff --git a/src/start-server.js b/src/start-server.js index ee34673e29..5e8fcc1449 100644 --- a/src/start-server.js +++ b/src/start-server.js @@ -4,7 +4,7 @@ import http from 'http'; import app from './server'; import debug from 'debug'; -export default () => { +export default function server() { const server = http.createServer(app); // const host = process.env.HOST || 'localhost'; const port = process.env.PORT || 3000; @@ -46,4 +46,4 @@ export default () => { currentApp = newApp; }); }; -}; +}