Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove anonymous function calls. Remove default exports from. #4917

Merged
merged 4 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/4917.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove anonymous function calls. Remove default exports from. @sneridagh
2 changes: 1 addition & 1 deletion packages/volto-slate/src/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export saveSlateBlockSelection from './selection';
export { default as saveSlateBlockSelection } from './selection';
export * from './content';
export * from './plugins';
4 changes: 2 additions & 2 deletions packages/volto-slate/src/blocks/Text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -165,4 +165,4 @@ export default (config) => {
restricted: true,
};
return config;
};
}
8 changes: 4 additions & 4 deletions packages/volto-slate/src/editor/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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,
enableExpandedToolbar: false,
};
config = installDefaultPlugins(config);
return config;
};
}
4 changes: 2 additions & 2 deletions packages/volto-slate/src/editor/ui/SlateContextToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? <Toolbar>{components}</Toolbar> : '';
};
}
30 changes: 15 additions & 15 deletions packages/volto-slate/src/editor/ui/index.js
Original file line number Diff line number Diff line change
@@ -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';
4 changes: 2 additions & 2 deletions packages/volto-slate/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -58,4 +58,4 @@ export default (config) => {
}

return config;
};
}
4 changes: 2 additions & 2 deletions src/components/manage/AnchorPlugin/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down Expand Up @@ -79,4 +79,4 @@ export default (config = {}) => {
setEditorState(removeEntity(getEditorState())),
}),
};
};
}
4 changes: 3 additions & 1 deletion src/components/manage/AnchorPlugin/utils/EditorUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default ({ draftJs }) => ({
const EditorUtils = ({ draftJs }) => ({
createLinkAtSelection(editorState, url) {
const contentState = editorState
.getCurrentContent()
Expand Down Expand Up @@ -43,3 +43,5 @@ export default ({ draftJs }) => ({
return entity && entity.getType() === entityType;
},
});

export default EditorUtils;
4 changes: 2 additions & 2 deletions src/components/manage/Blocks/Block/Style.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<div
className={cx(
Expand All @@ -25,4 +25,4 @@ export default ({ data, detached, children }) => {
</div>
</div>
);
};
}
8 changes: 3 additions & 5 deletions src/components/manage/Blocks/Listing/getAsyncData.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { getQueryStringResults } from '@plone/volto/actions';
import { resolveBlockExtensions } from '@plone/volto/helpers';

const getListingBlockAsyncData = ({
export default function getListingBlockAsyncData({
dispatch,
id,
data,
path,
blocksConfig,
}) => {
}) {
const { resolvedExtensions } = resolveBlockExtensions(data, blocksConfig);

return [
Expand All @@ -24,6 +24,4 @@ const getListingBlockAsyncData = ({
),
),
];
};

export default getListingBlockAsyncData;
}
26 changes: 13 additions & 13 deletions src/components/manage/Blocks/Search/components/index.js
Original file line number Diff line number Diff line change
@@ -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';
4 changes: 2 additions & 2 deletions src/components/manage/Blocks/Search/hocs/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export withQueryString from './withQueryString';
export withSearch from './withSearch';
export { default as withQueryString } from './withQueryString';
export { default as withSearch } from './withSearch';
4 changes: 2 additions & 2 deletions src/components/manage/Blocks/Search/hocs/withQueryString.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -29,4 +29,4 @@ export default (WrappedComponent) => {
WrappedComponent,
)})`;
return WithQueryString;
};
}
4 changes: 3 additions & 1 deletion src/components/manage/Blocks/ToC/variations/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import DefaultTocRenderer from './DefaultTocRenderer';
import HorizontalMenu from './HorizontalMenu';

export default [
const ToCVariations = [
{
id: 'default',
title: 'Listing (default)',
Expand All @@ -14,3 +14,5 @@ export default [
view: HorizontalMenu,
},
];

export default ToCVariations;
4 changes: 2 additions & 2 deletions src/config/RichTextEditor/Blocks.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default (props) => {
export default function Blocks(props) {
const { draftJs, immutableLib } = props;
const { DefaultDraftBlockRenderMap } = draftJs;
const { Map } = immutableLib;
Expand Down Expand Up @@ -27,4 +27,4 @@ export default (props) => {
const listBlockTypes = ['unordered-list-item', 'ordered-list-item'];

return { extendedBlockRenderMap, blockStyleFn, listBlockTypes };
};
}
4 changes: 2 additions & 2 deletions src/config/RichTextEditor/FromHTML.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export default (element) => {
export default function FromHTMLCustomBlockFn(element) {
if (element.className === 'callout') {
return {
type: 'callout',
};
}
return null;
};
}
2 changes: 1 addition & 1 deletion src/config/RichTextEditor/Styles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion src/constants/Indexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -35,6 +35,8 @@ export default {
Type: { label: 'Type', type: 'string' },
};

export default Indexes;

export const defaultIndexes = [
'review_state',
'ModificationDate',
Expand Down
2 changes: 1 addition & 1 deletion src/express-middleware/devproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/express-middleware/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
8 changes: 4 additions & 4 deletions src/express-middleware/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion src/express-middleware/robotstxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/express-middleware/sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/express-middleware/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
3 changes: 2 additions & 1 deletion src/helpers/Extensions/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './withBlockSchemaEnhancer';
export withBlockExtensions, {
export {
default as withBlockExtensions,
resolveExtension,
resolveBlockExtensions,
} from './withBlockExtensions';
Loading