Skip to content

Commit

Permalink
Removed all imports from barrel files for components, actions, helper…
Browse files Browse the repository at this point in the history
…s, hooks and lodash
  • Loading branch information
pnicolli committed Dec 2, 2024
1 parent 596ae97 commit 300a9c4
Show file tree
Hide file tree
Showing 288 changed files with 1,195 additions and 938 deletions.
2 changes: 1 addition & 1 deletion packages/volto/.eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
types/
/types/
52 changes: 35 additions & 17 deletions packages/volto/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{
"extends": ["react-app", "prettier", "plugin:jsx-a11y/recommended"],
"plugins": ["prettier", "react-hooks", "jsx-a11y"],
"root": true,
"env": {
"es6": true,
"browser": true,
"node": true,
"mocha": true,
"jasmine": true,
"jasmine": true
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"legacyDecorators": true,
},
"legacyDecorators": true
}
},
"rules": {
"import/no-unresolved": 1,
Expand All @@ -24,33 +25,50 @@
"no-debugger": 1,
"prettier/prettier": [
"error",
{ "trailingComma": "all", "singleQuote": true },
{ "trailingComma": "all", "singleQuote": true }
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react/react-in-jsx-scope": "off",
"jsx-a11y/label-has-associated-control": "off",
"jsx-a11y/label-has-associated-control": "off"
},
"settings": {
"import/named": "error",
"react/jsx-filename-extension": [1, { "extensions": [".tsx", ".jsx"] }],
"no-restricted-imports": [
"error",
{
"name": "@plone/volto/components",
"message": "Importing from barrel files is not allowed. Please use direct imports of the modules instead."
},
{
"name": "@plone/volto/helpers",
"message": "Importing from barrel files is not allowed. Please use direct imports of the modules instead."
},
{
"name": "@plone/volto/actions",
"message": "Importing from barrel files is not allowed. Please use direct imports of the modules instead."
}
],
"import/resolver": {
"alias": {
"map": [
["@plone/volto", "./src"],
["@plone/volto-slate", "../volto-slate/src"],
["@plone/types", "../types"],
["@package", "./src"],
["@root", "./src"],
["@root", "./src"]
],
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json"],
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json"]
},
"babel-plugin-root-import": {
"rootPathSuffix": "src",
},
"rootPathSuffix": "src"
}
},
"import/core-modules": ["load-volto-addons"],
"react": {
"version": "detect",
},
"version": "detect"
}
},
"overrides": [
{
Expand All @@ -60,14 +78,14 @@
// Re-add it if at some point, we stop relying on it
"extends": ["react-app", "prettier", "plugin:jsx-a11y/recommended"],
"plugins": ["prettier", "react-hooks", "jsx-a11y"],
"parser": "@typescript-eslint/parser",
"parser": "@typescript-eslint/parser"
},
{
"files": ["**/*.stories.js", "**/*.stories.jsx"],
"rules": {
"import/no-anonymous-default-export": "off",
},
},
"import/no-anonymous-default-export": "off"
}
}
],
"globals": {
"root": true,
Expand All @@ -83,6 +101,6 @@
"Cypress": true,
"jest": true,
"socket": true,
"webpackIsomorphicTools": true,
},
"webpackIsomorphicTools": true
}
}
2 changes: 1 addition & 1 deletion packages/volto/src/actions/content/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
LINK_INTEGRITY_CHECK,
UPDATE_UPLOADED_FILES,
} from '@plone/volto/constants/ActionTypes';
import { nestContent } from '@plone/volto/helpers';
import { nestContent } from '@plone/volto/helpers/Content/Content';
import config from '@plone/volto/registry';

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/volto/src/actions/language/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { updateIntl } from 'react-intl-redux';
import {
toGettextLang,
toReactIntlLang,
getCookieOptions,
} from '@plone/volto/helpers';
} from '@plone/volto/helpers/Utils/Utils';
import { getCookieOptions } from '@plone/volto/helpers/Cookies/cookies';
import Cookies from 'universal-cookie';

export function changeLanguageCookies(language, req) {
Expand Down
8 changes: 7 additions & 1 deletion packages/volto/src/actions/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
* @module actions/search/search
*/

import { compact, concat, isArray, join, map, pickBy, toPairs } from 'lodash';
import compact from 'lodash/compact';
import concat from 'lodash/concat';
import isArray from 'lodash/isArray';
import join from 'lodash/join';
import map from 'lodash/map';
import pickBy from 'lodash/pickBy';
import toPairs from 'lodash/toPairs';

import {
RESET_SEARCH_CONTENT,
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/src/actions/workflow/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
GET_WORKFLOW_MULTIPLE,
TRANSITION_WORKFLOW,
} from '@plone/volto/constants/ActionTypes';
import { flattenToAppURL } from '@plone/volto/helpers';
import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';

/**
* Get workflow function.
Expand Down
11 changes: 8 additions & 3 deletions packages/volto/src/components/manage/Actions/Actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ import { Dropdown, Icon } from 'semantic-ui-react';
import { toast } from 'react-toastify';
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';

import { cut, copy, copyContent, moveContent } from '@plone/volto/actions';
import { getBaseUrl } from '@plone/volto/helpers';
import { Toast } from '@plone/volto/components';
import {
cut,
copy,
copyContent,
moveContent,
} from '@plone/volto/actions/clipboard/clipboard';
import { getBaseUrl } from '@plone/volto/helpers/Url/Url';
import Toast from '@plone/volto/components/manage/Toast/Toast';
import { ContentsRenameModal } from '@plone/volto/components/manage/Contents';

const messages = defineMessages({
Expand Down
52 changes: 26 additions & 26 deletions packages/volto/src/components/manage/Add/Add.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,50 @@

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
BodyClass,
Helmet,
extractInvariantErrors,
} from '@plone/volto/helpers';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { keys, isEmpty } from 'lodash';
import keys from 'lodash/keys';
import isEmpty from 'lodash/isEmpty';
import { defineMessages, injectIntl } from 'react-intl';
import { Button, Grid, Menu } from 'semantic-ui-react';
import { createPortal } from 'react-dom';
import { v4 as uuid } from 'uuid';
import qs from 'query-string';
import { toast } from 'react-toastify';

import {
createContent,
getSchema,
changeLanguage,
setFormData,
} from '@plone/volto/actions';
import {
Icon,
Toolbar,
Sidebar,
Toast,
TranslationObject,
} from '@plone/volto/components';
import { createContent } from '@plone/volto/actions/content/content';
import { getSchema } from '@plone/volto/actions/schema/schema';
import { changeLanguage } from '@plone/volto/actions/language/language';
import { setFormData } from '@plone/volto/actions/form/form';

import Icon from '@plone/volto/components/theme/Icon/Icon';
import Toolbar from '@plone/volto/components/manage/Toolbar/Toolbar';
import Sidebar from '@plone/volto/components/manage/Sidebar/Sidebar';
import Toast from '@plone/volto/components/manage/Toast/Toast';
import TranslationObject from '@plone/volto/components/manage/Multilingual/TranslationObject';
import { Form } from '@plone/volto/components/manage/Form';

import { getBaseUrl, flattenToAppURL } from '@plone/volto/helpers/Url/Url';
import {
getBaseUrl,
hasBlocksData,
flattenToAppURL,
getBlocksFieldname,
getBlocksLayoutFieldname,
getLanguageIndependentFields,
langmap,
toGettextLang,
} from '@plone/volto/helpers/Blocks/Blocks';
import { getLanguageIndependentFields } from '@plone/volto/helpers/Content/Content';
import langmap from '@plone/volto/helpers/LanguageMap/LanguageMap';
import { toGettextLang } from '@plone/volto/helpers/Utils/Utils';
import {
getSimpleDefaultBlocks,
getDefaultBlocks,
} from '@plone/volto/helpers';
} from '@plone/volto/helpers/Blocks/defaultBlocks';
import {
tryParseJSON,
extractInvariantErrors,
} from '@plone/volto/helpers/FormValidation/FormValidation';
import BodyClass from '@plone/volto/helpers/BodyClass/BodyClass';
import Helmet from '@plone/volto/helpers/Helmet/Helmet';

import { preloadLazyLibs } from '@plone/volto/helpers/Loadable';
import { tryParseJSON } from '@plone/volto/helpers';

import config from '@plone/volto/registry';

Expand Down
16 changes: 9 additions & 7 deletions packages/volto/src/components/manage/Aliases/Aliases.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Helmet } from '@plone/volto/helpers';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { Link } from 'react-router-dom';
import { createPortal } from 'react-dom';
import { toast } from 'react-toastify';
import {
Button,
Checkbox,
Expand All @@ -24,15 +24,17 @@ import {
removeAliases,
addAliases,
getAliases,
getContent,
} from '@plone/volto/actions';
} from '@plone/volto/actions/aliases/aliases';
import { getContent } from '@plone/volto/actions/content/content';

import Helmet from '@plone/volto/helpers/Helmet/Helmet';
import { getBaseUrl } from '@plone/volto/helpers/Url/Url';

import { Icon, Toolbar } from '@plone/volto/components';
import Icon from '@plone/volto/components/theme/Icon/Icon';
import Toolbar from '@plone/volto/components/manage/Toolbar/Toolbar';
import Toast from '@plone/volto/components/manage/Toast/Toast';

import backSVG from '@plone/volto/icons/back.svg';
import { getBaseUrl } from '@plone/volto/helpers';
import { toast } from 'react-toastify';
import { Toast } from '@plone/volto/components';

const messages = defineMessages({
back: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { compose } from 'redux';

// import unionClassNames from 'union-class-names';
import { withRouter } from 'react-router';
import cx from 'classnames';

import {
addAppURL,
isInternalURL,
flattenToAppURL,
URLUtils,
} from '@plone/volto/helpers';
} from '@plone/volto/helpers/Url/Url';

import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
import doesNodeContainClick from 'semantic-ui-react/dist/commonjs/lib/doesNodeContainClick';
import { Input, Form, Button } from 'semantic-ui-react';
import { defineMessages, injectIntl } from 'react-intl';

Expand All @@ -25,10 +25,8 @@ import navTreeSVG from '@plone/volto/icons/nav.svg';
import aheadSVG from '@plone/volto/icons/ahead.svg';
import linkSVG from '@plone/volto/icons/link.svg';

import Icon from '@plone/volto/components/theme/Icon/Icon';
import withObjectBrowser from '@plone/volto/components/manage/Sidebar/ObjectBrowser';
import { withRouter } from 'react-router';

import { Icon } from '@plone/volto/components';

const messages = defineMessages({
placeholder: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';
import { useUser } from '@plone/volto/hooks';
import useUser from '@plone/volto/hooks/user/useUser';
import PropTypes from 'prop-types';
import { filter, map, groupBy, isEmpty } from 'lodash';
import filter from 'lodash/filter';
import map from 'lodash/map';
import groupBy from 'lodash/groupBy';
import isEmpty from 'lodash/isEmpty';
import { Accordion, Button } from 'semantic-ui-react';
import { useIntl, defineMessages } from 'react-intl';
import { Icon } from '@plone/volto/components';
import Icon from '@plone/volto/components/theme/Icon/Icon';
import AnimateHeight from 'react-animate-height';
import config from '@plone/volto/registry';
import upSVG from '@plone/volto/icons/up-key.svg';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
import doesNodeContainClick from 'semantic-ui-react/dist/commonjs/lib/doesNodeContainClick';
import addSVG from '@plone/volto/icons/circle-plus.svg';
import { blockHasValue } from '@plone/volto/helpers';
import { Icon, BlockChooser } from '@plone/volto/components';
import { blockHasValue } from '@plone/volto/helpers/Blocks/Blocks';
import Icon from '@plone/volto/components/theme/Icon/Icon';
import BlockChooser from '@plone/volto/components/manage/BlockChooser/BlockChooser';
import config from '@plone/volto/registry';
import { Button, Ref } from 'semantic-ui-react';
import { defineMessages, useIntl } from 'react-intl';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useRef } from 'react';
import { Button, Form, Input } from 'semantic-ui-react';
import { Icon } from '@plone/volto/components';
import Icon from '@plone/volto/components/theme/Icon/Icon';
import { defineMessages, useIntl } from 'react-intl';
import clearSVG from '@plone/volto/icons/clear.svg';

Expand Down
15 changes: 8 additions & 7 deletions packages/volto/src/components/manage/Blocks/Block/BlocksForm.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React, { useEffect, useState } from 'react';
import { useIntl } from 'react-intl';
import { cloneDeep, map } from 'lodash';
import cloneDeep from 'lodash/cloneDeep';
import map from 'lodash/map';
import EditBlock from './Edit';
import { DragDropList } from '@plone/volto/components';
import DragDropList from '@plone/volto/components/manage/DragDropList/DragDropList';
import {
getBlocks,
getBlocksFieldname,
getBlocksLayoutFieldname,
applyBlockDefaults,
getBlocksHierarchy,
} from '@plone/volto/helpers';
import {
addBlock,
insertBlock,
changeBlock,
Expand All @@ -20,11 +19,13 @@ import {
mutateBlock,
nextBlockId,
previousBlockId,
} from '@plone/volto/helpers';
} from '@plone/volto/helpers/Blocks/Blocks';
import { useDetectClickOutside } from '@plone/volto/helpers/Utils/useDetectClickOutside';
import { useEvent } from '@plone/volto/helpers/Utils/useEvent';
import EditBlockWrapper from './EditBlockWrapper';
import { setSidebarTab, setUIState } from '@plone/volto/actions';
import { setSidebarTab } from '@plone/volto/actions/sidebar/sidebar';
import { setUIState } from '@plone/volto/actions/form/form';
import { useDispatch } from 'react-redux';
import { useDetectClickOutside, useEvent } from '@plone/volto/helpers';
import config from '@plone/volto/registry';
import { createPortal } from 'react-dom';

Expand Down
Loading

0 comments on commit 300a9c4

Please sign in to comment.