Update eslint configuration

Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
soupette 2020-01-21 16:03:31 +01:00
parent 6c27d224f2
commit f50f89f0a8
145 changed files with 529 additions and 520 deletions

View File

@ -2,4 +2,7 @@
**/build/**
**/dist/**
testApp/**
packages/strapi-plugin-users-permissions/admin/**
packages/strapi-plugin-upload/admin/**
packages/strapi-generate-plugin/files/admin/src/**
.eslintrc.js

View File

@ -59,16 +59,32 @@ module.exports = {
'arrow-body-style': 0,
'arrow-parens': 0,
camelcase: 0,
'comma-dangle': 0,
'consistent-return': [
2,
{
treatUndefinedAsUnspecified: true,
},
],
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
indent: [
2,
2,
{
flatTernaryExpressions: false,
SwitchCase: 1,
ignoredNodes: [
'ConditionalExpression',
"VariableDeclarator[kind='const']",
],
},
],
'func-names': ['error', 'never'],
'function-paren-newline': 0,
'implicit-arrow-linebreak': 0,
'import/no-extraneous-dependencies': 0,
'import/no-named-as-default': 0,
'import/order': 2,
'jsx-a11y/click-events-have-key-events': 1,
'max-len': [
2,
{
@ -80,19 +96,37 @@ module.exports = {
ignoreTemplateLiterals: true,
},
],
'no-confusing-arrow': 0,
'no-else-return': 1,
'no-nested-ternary': ['error'],
'no-return-assign': 0,
'no-param-reassign': 0,
'no-shadow': 0,
'no-underscore-dangle': 0,
'no-use-before-define': [
'error',
{ functions: false, classes: false, variables: false },
],
'object-curly-newline': [2, { multiline: true, consistent: true }],
'operator-linebreak': 0,
'prefer-arrow-callback': 0,
'prefer-const': 0,
'prefer-destructuring': 0,
'prefer-object-spread': 0,
'react/destructuring-assignment': 1,
'prefer-spread': 0,
'space-before-function-paren': [
'error',
{
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
},
],
'react/destructuring-assignment': 0,
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
'react/forbid-prop-types': 0,
'react/jsx-props-no-spreading': 0,
'react/jsx-one-expression-per-line': 0,
'react/state-in-constructor': 0,
'react/static-property-placement': 0,
},

View File

@ -5,6 +5,8 @@
// * Entry point of the application
// */
/* eslint-disable */
import '@babel/polyfill';
import 'sanitize.css/sanitize.css';

View File

@ -7,12 +7,10 @@
import React from 'react';
import { defineMessages, FormattedMessage } from 'react-intl';
import { PropTypes } from 'prop-types';
import LeftMenuLink from '../LeftMenuLink';
import Wrapper from './Wrapper';
import messages from './messages.json';
defineMessages(messages);
function LeftMenuFooter({ version, ...rest }) {

View File

@ -13,6 +13,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import en from '../../translations/en.json';
import Li from './Li';
/* eslint-disable */
function LeftMenuLink(props) {
const isLinkActive = startsWith(
props.location.pathname.replace('/admin', '').concat('/'),

View File

@ -8,11 +8,12 @@ import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { get, snakeCase, isEmpty, map, sortBy } from 'lodash';
import LeftMenuLink from '../LeftMenuLink';
import Wrapper from './Wrapper';
import messages from './messages.json';
/* eslint-disable */
function LeftMenuLinkContainer({ plugins, ...rest }) {
// Generate the list of sections
const pluginsSections = Object.keys(plugins).reduce((acc, current) => {

View File

@ -15,6 +15,8 @@ import { Button } from 'strapi-helper-plugin';
import Row from '../Row';
import Wrapper from './Wrapper';
/* eslint-disable react/prefer-stateless-function */
class ListPlugins extends React.Component {
render() {
const listSize = size(this.props.plugins);

View File

@ -3,7 +3,7 @@
* Notification
*
*/
/* eslint-disable */
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';

View File

@ -11,6 +11,8 @@ import { CSSTransition } from 'react-transition-group';
import Notification from '../Notification';
import Wrapper from './Wrapper';
/* eslint-disable */
const NotificationsContainer = ({ notifications, onHideNotification }) => {
if (notifications.length === 0) {
return false;

View File

@ -13,6 +13,8 @@ import { Player } from 'video-react';
import 'video-react/dist/video-react.css';
import Li from './Li';
/* eslint-disable */
class OnboardingVideo extends React.Component {
componentDidMount() {
this.hiddenPlayer.current.subscribeToStateChange(this.handleChangeState);

View File

@ -22,6 +22,8 @@ import Content from './Content';
const PLUGINS_WITH_CONFIG = ['email', 'upload'];
/* eslint-disable */
class Row extends React.Component {
static contextType = GlobalContext;
state = { showModal: false };

View File

@ -51,6 +51,14 @@ import Content from './Content';
export class Admin extends React.Component {
// eslint-disable-line react/prefer-stateless-function
helpers = {
updatePlugin: this.props.updatePlugin,
};
componentDidMount() {
this.props.emitEvent('didAccessAuthenticatedAdministration');
}
shouldComponentUpdate(prevProps) {
return !isEmpty(difference(prevProps, this.props));
}
@ -69,10 +77,6 @@ export class Admin extends React.Component {
this.props.setAppError();
}
componentDidMount() {
this.props.emitEvent('didAccessAuthenticatedAdministration');
}
hasApluginNotReady = props => {
const {
global: { plugins },
@ -83,10 +87,6 @@ export class Admin extends React.Component {
);
};
helpers = {
updatePlugin: this.props.updatePlugin,
};
/**
* Display the app loader until the app is ready
* @returns {Boolean}
@ -136,10 +136,10 @@ export class Admin extends React.Component {
// We need the admin data in order to make the initializers work
if (this.showLoader()) {
return (
<React.Fragment>
<>
{this.renderInitializers()}
<LoadingIndicatorPage />
</React.Fragment>
</>
);
}
@ -200,6 +200,12 @@ export class Admin extends React.Component {
}
}
Admin.defaultProps = {
intl: {
formatMessage: () => {},
},
};
Admin.propTypes = {
admin: PropTypes.shape({
appError: PropTypes.bool,

View File

@ -23,6 +23,7 @@ import GlobalStyle from '../../components/GlobalStyle';
import Admin from '../Admin';
import AuthPage from '../AuthPage';
import NotFoundPage from '../NotFoundPage';
// eslint-disable-next-line import/no-cycle
import NotificationProvider from '../NotificationProvider';
import PrivateRoute from '../PrivateRoute';
import Theme from '../Theme';

View File

@ -6,6 +6,8 @@ import { get } from 'lodash';
import { InputsIndex as Inputs } from 'strapi-helper-plugin';
import CustomLabel from './CustomLabel';
/* eslint-disable */
const Input = ({
autoFocus,
customBootstrapClass,

View File

@ -1,8 +1,7 @@
import React, { memo, useEffect, useReducer, useRef } from 'react';
import PropTypes from 'prop-types';
import { get, isEmpty, omit, set } from 'lodash';
import { get, isEmpty, omit, set, upperFirst } from 'lodash';
import { FormattedMessage } from 'react-intl';
import { upperFirst } from 'lodash';
import { Link, Redirect } from 'react-router-dom';
import {
auth,
@ -267,12 +266,12 @@ AuthPage.propTypes = {
hasAdminUser: PropTypes.bool.isRequired,
location: PropTypes.shape({
search: PropTypes.string.isRequired,
}),
}).isRequired,
match: PropTypes.shape({
params: PropTypes.shape({
authType: PropTypes.string,
}),
}),
}).isRequired,
}).isRequired,
};
export default memo(AuthPage);

View File

@ -38,7 +38,7 @@ const SocialLink = ({ link, name }) => {
return (
<SocialLinkWrapper className="col-6">
<a href={link} target="_blank" rel="noopener noreferrer">
<img src={getSrc(name)} />
<img src={getSrc(name)} alt="social" />
<span>{name}</span>
</a>
</SocialLinkWrapper>

View File

@ -1,3 +1,4 @@
/* eslint-disable */
import styled, { css } from 'styled-components';
const Block = styled.div`

View File

@ -4,9 +4,9 @@
*
*/
import {
CHANGE_LOCALE,
} from './constants';
/* eslint-disable */
import { CHANGE_LOCALE } from './constants';
export function changeLocale(languageLocale) {
return {

View File

@ -4,4 +4,5 @@
*
*/
/* eslint-disable */
export const CHANGE_LOCALE = 'app/LanguageToggle/CHANGE_LOCALE';

View File

@ -14,12 +14,12 @@ import { IntlProvider } from 'react-intl';
import { defaultsDeep } from 'lodash';
import { selectLocale } from './selectors';
// eslint-disable-next-line react/prefer-stateless-function
export class LanguageProvider extends React.Component {
// eslint-disable-line react/prefer-stateless-function
render() {
const messages = defaultsDeep(
this.props.messages[this.props.locale],
this.props.messages.en,
this.props.messages.en
);
return (
<IntlProvider
@ -41,7 +41,7 @@ LanguageProvider.propTypes = {
const mapStateToProps = createSelector(
selectLocale(),
locale => ({ locale }),
locale => ({ locale })
);
function mapDispatchToProps(dispatch) {
@ -52,5 +52,5 @@ function mapDispatchToProps(dispatch) {
export default connect(
mapStateToProps,
mapDispatchToProps,
mapDispatchToProps
)(LanguageProvider);

View File

@ -9,11 +9,10 @@ import { get, includes, split } from 'lodash';
// Import supported languages from the translations folder
import trads from '../../translations';
import { CHANGE_LOCALE } from './constants';
const languages = Object.keys(trads);
import { CHANGE_LOCALE } from './constants';
// Define a key to store and get user preferences in local storage.
const localStorageKey = 'strapi-admin-language';
@ -24,6 +23,7 @@ const userLanguage =
window.navigator.userLanguage;
let foundLanguage = includes(languages, userLanguage) && userLanguage;
if (!foundLanguage) {
// Split user language in a correct format.
const userLanguageShort = get(split(userLanguage, '-'), '0');

View File

@ -86,7 +86,7 @@ export class ListPluginsPage extends React.Component {
ListPluginsPage.propTypes = {
global: PropTypes.shape({
currentEnvironment: PropTypes.string.isRequired,
}),
}).isRequired,
getPlugins: PropTypes.func.isRequired,
history: PropTypes.object.isRequired,
intl: PropTypes.shape({

View File

@ -7,6 +7,8 @@ import { deletePluginSucceeded, getPluginsSucceeded } from './actions';
import { GET_PLUGINS, ON_DELETE_PLUGIN_CONFIRM } from './constants';
import { makeSelectPluginToDelete } from './selectors';
/* eslint-disable */
export function* deletePlugin() {
try {
const plugin = yield select(makeSelectPluginToDelete());

View File

@ -1,12 +1,9 @@
/**
*
*
* LocaleToggle actions
*/
import {
RESET_DEFAULT_CLASSNAME,
SET_CUSTOM_CLASSNAME,
} from './constants';
import { RESET_DEFAULT_CLASSNAME, SET_CUSTOM_CLASSNAME } from './constants';
export function resetLocaleDefaultClassName() {
return {

View File

@ -89,7 +89,7 @@ describe('<LocaleToggle />', () => {
'https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.1.0/flags/4x3/vn.svg'
);
});
it('should return the sk flag', () => {
const renderedComponent = shallow(<LocaleToggle {...props} />);
const { getFlagUrl } = renderedComponent.instance();

View File

@ -11,7 +11,7 @@ describe('<LocaleToggle /> selectors', () => {
const mockedState = fromJS({
localeToggle: state,
});
expect(selectLocaleToggle()(mockedState)).toEqual(state);
});
});
@ -29,5 +29,3 @@ describe('<LocaleToggle /> selectors', () => {
});
});
});

View File

@ -118,7 +118,7 @@ Marketplace.propTypes = {
global: PropTypes.shape({
autoReload: PropTypes.bool.isRequired,
currentEnvironment: PropTypes.string.isRequired,
}),
}).isRequired,
history: PropTypes.object.isRequired,
installedPlugins: PropTypes.array.isRequired,
intl: PropTypes.shape({

View File

@ -4,6 +4,7 @@
*
*/
/* eslint-disable import/no-cycle */
import { dispatch } from '../../app';
import { SHOW_NOTIFICATION, HIDE_NOTIFICATION } from './constants';

View File

@ -4,16 +4,16 @@
*
*/
/* eslint-disable */
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import NotificationsContainer from '../../components/NotificationsContainer';
import { selectNotifications } from './selectors';
import { hideNotification } from './actions';
export class NotificationProvider extends React.Component { // eslint-disable-line react/prefer-stateless-function
export class NotificationProvider extends React.Component {
render() {
return (
<NotificationsContainer
@ -35,11 +35,14 @@ const mapStateToProps = createStructuredSelector({
function mapDispatchToProps(dispatch) {
return {
onHideNotification: (id) => {
onHideNotification: id => {
dispatch(hideNotification(id));
},
dispatch,
};
}
export default connect(mapStateToProps, mapDispatchToProps)(NotificationProvider);
export default connect(
mapStateToProps,
mapDispatchToProps
)(NotificationProvider);

View File

@ -1,5 +1,36 @@
import styled, { keyframes } from 'styled-components';
const fadeIn = keyframes`
0% {
width: auto;
height: auto;
opacity: 0;
}
5% {
opacity: 0;
}
100% {
opacity: 1;
}
`;
const fadeOut = keyframes`
0% {
opacity: 1;
}
60% {
opacity: 0;
}
100% {
opacity: 0;
width: 0;
height: 0;
}
`;
const Wrapper = styled.div`
position: fixed;
right: 15px;
@ -93,35 +124,4 @@ const Wrapper = styled.div`
}
`;
const fadeIn = keyframes`
0% {
width: auto;
height: auto;
opacity: 0;
}
5% {
opacity: 0;
}
100% {
opacity: 1;
}
`;
const fadeOut = keyframes`
0% {
opacity: 1;
}
60% {
opacity: 0;
}
100% {
opacity: 0;
width: 0;
height: 0;
}
`;
export default Wrapper;

View File

@ -27,9 +27,9 @@ import makeSelectOnboarding from './selectors';
import reducer from './reducer';
import saga from './saga';
export class Onboarding extends React.Component {
static contextType = GlobalContext;
/* eslint-disable react/no-array-index-key */
export class Onboarding extends React.Component {
state = { showVideos: false };
componentDidMount() {
@ -92,6 +92,8 @@ export class Onboarding extends React.Component {
this.props.setVideoEnd(index, true);
};
static contextType = GlobalContext;
render() {
const { videos, onClick, setVideoDuration } = this.props;
const { showVideos } = this.state;
@ -144,6 +146,7 @@ export class Onboarding extends React.Component {
<button
onClick={this.handleVideosToggle}
className={this.state.showVideos ? 'active' : ''}
type="button"
>
<i className="fa fa-question" />
<i className="fa fa-times" />

View File

@ -5,7 +5,15 @@
*/
import { fromJS } from 'immutable';
import { GET_VIDEOS_SUCCEEDED, SHOULD_OPEN_MODAL, ON_CLICK, SET_VIDEOS_DURATION, UPDATE_VIDEO_START_TIME, SET_VIDEO_END, REMOVE_VIDEOS } from './constants';
import {
GET_VIDEOS_SUCCEEDED,
SHOULD_OPEN_MODAL,
ON_CLICK,
SET_VIDEOS_DURATION,
UPDATE_VIDEO_START_TIME,
SET_VIDEO_END,
REMOVE_VIDEOS,
} from './constants';
const initialState = fromJS({
videos: fromJS([]),
@ -20,7 +28,6 @@ function onboardingReducer(state = initialState, action) {
case ON_CLICK:
return state.updateIn(['videos'], list => {
return list.reduce((acc, current, index) => {
if (index === action.index) {
return acc.updateIn([index, 'isOpen'], v => !v);
}
@ -29,13 +36,14 @@ function onboardingReducer(state = initialState, action) {
}, list);
});
case SET_VIDEOS_DURATION:
return state.updateIn(['videos', action.index, 'duration'], () => action.duration);
return state.updateIn(
['videos', action.index, 'duration'],
() => action.duration
);
case UPDATE_VIDEO_START_TIME: {
const storedVideos = JSON.parse(localStorage.getItem('videos'));
const videos = state.updateIn(['videos'], list => {
return list.reduce((acc, current, index) => {
if (index === action.index) {
storedVideos[index].startTime = action.startTime;
return acc.updateIn([index, 'startTime'], () => action.startTime);
@ -52,8 +60,8 @@ function onboardingReducer(state = initialState, action) {
return videos;
}
case SET_VIDEO_END: {
const storedVideos = JSON.parse(localStorage.getItem('videos'));
storedVideos[action.index].end = action.end;
localStorage.setItem('videos', JSON.stringify(storedVideos));

View File

@ -10,9 +10,10 @@
import React, { memo } from 'react';
import { Redirect, Route } from 'react-router-dom';
import PropTypes from 'prop-types';
import { auth } from 'strapi-helper-plugin';
/* eslint-disable react/jsx-curly-newline */
const PrivateRoute = ({ component: Component, path, ...rest }) => (
<Route
path={path}

View File

@ -1,3 +1,5 @@
/* eslint-disable */
const injectReducer = require('./utils/injectReducer').default;
const useInjectReducer = require('./utils/injectReducer').useInjectReducer;
const injectSaga = require('./utils/injectSaga').default;

View File

@ -1,4 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable */
import React from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { ReactReduxContext } from 'react-redux';

View File

@ -1,4 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable */
import React from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { ReactReduxContext } from 'react-redux';

View File

@ -1,3 +1,5 @@
/* eslint-disable */
import invariant from 'invariant';
import isEmpty from 'lodash/isEmpty';
import isFunction from 'lodash/isFunction';
@ -12,7 +14,7 @@ export function injectReducerFactory(store, isValid) {
invariant(
isString(key) && !isEmpty(key) && isFunction(reducer),
'(app/utils...) injectReducer: Expected `reducer` to be a reducer function',
'(app/utils...) injectReducer: Expected `reducer` to be a reducer function'
);
// Check `store.injectedReducers[key] === reducer` for hot reloading when a key is the same but a reducer is different

View File

@ -1,3 +1,5 @@
/* eslint-disable */
import isEmpty from 'lodash/isEmpty';
import isFunction from 'lodash/isFunction';
import isString from 'lodash/isString';
@ -5,23 +7,20 @@ import invariant from 'invariant';
import conformsTo from 'lodash/conformsTo';
import checkStore from './checkStore';
import {
DAEMON,
ONCE_TILL_UNMOUNT,
RESTART_ON_REMOUNT,
} from './constants';
import { DAEMON, ONCE_TILL_UNMOUNT, RESTART_ON_REMOUNT } from './constants';
const allowedModes = [RESTART_ON_REMOUNT, DAEMON, ONCE_TILL_UNMOUNT];
const checkKey = (key) => invariant(
isString(key) && !isEmpty(key),
'(app/utils...) injectSaga: Expected `key` to be a non empty string'
);
const checkKey = key =>
invariant(
isString(key) && !isEmpty(key),
'(app/utils...) injectSaga: Expected `key` to be a non empty string'
);
const checkDescriptor = (descriptor) => {
const checkDescriptor = descriptor => {
const shape = {
saga: isFunction,
mode: (mode) => isString(mode) && allowedModes.includes(mode),
mode: mode => isString(mode) && allowedModes.includes(mode),
};
invariant(
conformsTo(descriptor, shape),
@ -33,7 +32,10 @@ export function injectSagaFactory(store, isValid) {
return function injectSaga(key, descriptor = {}, args) {
if (!isValid) checkStore(store);
const newDescriptor = { ...descriptor, mode: descriptor.mode || RESTART_ON_REMOUNT };
const newDescriptor = {
...descriptor,
mode: descriptor.mode || RESTART_ON_REMOUNT,
};
const { saga, mode } = newDescriptor;
checkKey(key);
@ -50,8 +52,14 @@ export function injectSagaFactory(store, isValid) {
}
}
if (!hasSaga || (hasSaga && mode !== DAEMON && mode !== ONCE_TILL_UNMOUNT)) {
store.injectedSagas[key] = { ...newDescriptor, task: store.runSaga(saga, args) }; // eslint-disable-line no-param-reassign
if (
!hasSaga ||
(hasSaga && mode !== DAEMON && mode !== ONCE_TILL_UNMOUNT)
) {
store.injectedSagas[key] = {
...newDescriptor,
task: store.runSaga(saga, args),
}; // eslint-disable-line no-param-reassign
}
};
}

View File

@ -1,4 +1,5 @@
import styled, { css } from 'styled-components';
/* eslint-disable */
const Wrapper = styled.div`
margin-left: 29px;

View File

@ -1,4 +1,5 @@
import styled, { css } from 'styled-components';
/* eslint-disable */
const Label = styled.label`
cursor: pointer;

View File

@ -10,6 +10,8 @@ import MediaPreviewList from '../MediaPreviewList';
import { ActionContainer, Truncate, Truncated } from './styledComponents';
import DATE_FORMATS from './DATE_FORMATS';
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
const dateToUtcTime = date => moment.parseZone(date).utc();
const getDisplayedValue = (type, value, name) => {
@ -104,9 +106,7 @@ function Row({ goTo, isBulkable, row, headers }) {
<Truncated>{memoizedDisplayedValue(header.name)}</Truncated>
</Truncate>
) : (
<MediaPreviewList
files={memoizedDisplayedValue(header.name)}
></MediaPreviewList>
<MediaPreviewList files={memoizedDisplayedValue(header.name)} />
)}
</td>
);

View File

@ -5,6 +5,8 @@ import useListView from '../../hooks/useListView';
import CustomInputCheckbox from '../CustomInputCheckbox';
import { Arrow, Thead } from './styledComponents';
/* eslint-disable jsx-a11y/control-has-associated-label */
function TableHeader({ headers, isBulkable }) {
const {
data,
@ -67,7 +69,7 @@ function TableHeader({ headers, isBulkable }) {
</th>
);
})}
<th></th>
<th />
</tr>
</Thead>
);

View File

@ -94,7 +94,6 @@ CustomTable.defaultProps = {
data: [],
headers: [],
isBulkable: true,
slug: '',
};
CustomTable.propTypes = {
@ -108,7 +107,6 @@ CustomTable.propTypes = {
push: PropTypes.func.isRequired,
}).isRequired,
isBulkable: PropTypes.bool,
slug: PropTypes.string,
};
export default withRouter(memo(CustomTable));

View File

@ -1,3 +1,5 @@
/* eslint-disable */
import styled, { css } from 'styled-components';
const Table = styled.table`

View File

@ -17,6 +17,8 @@ const MenuDropdown = styled(DropdownMenu)`
border-top-right-radius: 0;
`;
}
return '';
}}
`;

View File

@ -1,3 +1,5 @@
/* eslint-disable */
import styled, { css } from 'styled-components';
import getColor from './utils/getColor';

View File

@ -20,6 +20,8 @@ const NameWrapper = styled.div`
color: #007eff;
`;
}
return '';
}}
`;

View File

@ -30,6 +30,8 @@ const RemoveWrapper = styled.div`
}
`;
}
return '';
}}
`;

View File

@ -1,3 +1,5 @@
/* eslint-disable */
import styled from 'styled-components';
import getColor from './utils/getColor';
import getHeight from './utils/getHeight';

View File

@ -1,3 +1,5 @@
/* eslint-disable */
import styled, { css } from 'styled-components';
import PropTypes from 'prop-types';
import getColor from './utils/getColor';

View File

@ -14,6 +14,7 @@ import SubWrapper from './SubWrapper';
import Wrapper from './Wrapper';
import Close from './Close';
/* eslint-disable */
const DraggedField = forwardRef(
(
{

View File

@ -8,6 +8,8 @@ import DynamicZoneWrapper from './DynamicZoneWrapper';
import Wrapper from './Wrapper';
import DynamicComponent from './DynamicComponent';
/* eslint-disable react/no-array-index-key */
const DraggedFieldWithPreview = forwardRef(
(
{
@ -136,7 +138,7 @@ const DraggedFieldWithPreview = forwardRef(
withLongerHeight={higherFields.includes(
fieldType
)}
></DraggedField>
/>
</div>
);
})}

View File

@ -19,7 +19,7 @@ const DynamicComponentCard = ({
onClick(componentUid);
}}
>
<button className="component-icon">
<button className="component-icon" type="button">
<FontAwesomeIcon icon={icon} />
</button>

View File

@ -22,6 +22,8 @@ const Button = styled(PlusButton)`
}
`;
}
return '';
}}
&.isOpen {
transform: rotate(-45deg);

View File

@ -17,6 +17,8 @@ import Label from './Label';
import RoundCTA from './RoundCTA';
import Wrapper from './Wrapper';
/* eslint-disable react/no-array-index-key */
const DynamicZone = ({ max, min, name }) => {
const [isOpen, setIsOpen] = useState(false);
const {
@ -117,7 +119,7 @@ const DynamicZone = ({ max, min, name }) => {
<RoundCTA
onClick={() => removeComponentFromDynamicZone(name, index)}
>
<FontAwesomeIcon icon={'trash'} />
<FontAwesomeIcon icon="trash" />
</RoundCTA>
<FieldComponent
componentUid={componentUid}
@ -127,7 +129,7 @@ const DynamicZone = ({ max, min, name }) => {
icon={getDynamicComponentInfos(componentUid).icon}
label=""
name={`${name}.${index}`}
isFromDynamicZone={true}
isFromDynamicZone
/>
</div>
);

View File

@ -12,6 +12,8 @@ const Wrapper = styled.div`
background-color: #fff;
`;
}
return '';
}}
`;

View File

@ -1,3 +1,4 @@
/* eslint-disable import/no-cycle */
import React from 'react';
import PropTypes from 'prop-types';
import { get, size } from 'lodash';

View File

@ -85,8 +85,6 @@ const Item = ({
item.rowIndex = targetRow;
item.itemIndex = hoverIndex;
return;
},
drop(item, monitor) {
if (!dropRef.current) {
@ -122,6 +120,7 @@ const Item = ({
item.itemIndex = hoverIndex + 1;
item.rowIndex = targetRow;
return;
}
@ -136,8 +135,6 @@ const Item = ({
item.itemIndex = hoverIndex;
item.rowIndex = targetRow;
return;
},
collect: monitor => ({
canDrop: monitor.canDrop(),

View File

@ -5,4 +5,4 @@ const Wrapper = styled.div`
margin-bottom: 6px;
`;
export { Wrapper };
export default Wrapper;

View File

@ -6,7 +6,7 @@ import useLayoutDnd from '../../hooks/useLayoutDnd';
import Add from '../AddDropdown';
import SortWrapper from '../SortWrapper';
import { Wrapper } from './components';
import Wrapper from './components';
import Item from './Item';
const FieldsReorder = ({ className }) => {

View File

@ -48,6 +48,8 @@ const Div = styled.div`
? 'margin-top .3s ease-out, margin-bottom .2s ease-out'
: 'margin .3s ease-in';
}
return '';
}};
`;

View File

@ -153,6 +153,7 @@ function FilterPicker({
}}
type={get(schema, ['attributes', filter.name, 'type'], '')}
showAddButton={key === modifiedData.length - 1}
// eslint-disable-next-line react/no-array-index-key
key={key}
/>
))}
@ -180,8 +181,7 @@ FilterPicker.propTypes = {
isOpen: PropTypes.bool,
location: PropTypes.shape({
search: PropTypes.string.isRequired,
}),
}).isRequired,
name: PropTypes.string,
onSubmit: PropTypes.func.isRequired,
toggleFilterPickerState: PropTypes.func.isRequired,

View File

@ -48,7 +48,7 @@ function Input({ type, ...rest }) {
const styles =
type === 'boolean' ? { minWidth: '100px', maxWidth: '200px' } : style;
const wrapperStyle =
type == 'boolean' ||
type === 'boolean' ||
['date', 'timestamp', 'time', 'datetime'].includes(type)
? { marginRight: '20px' }
: { marginRight: '10px' };

View File

@ -1,5 +1,7 @@
import styled, { css } from 'styled-components';
/* eslint-disable */
const Wrapper = styled.div`
min-height: 38px;
border-left: ${props => props.borderLeft && '3px solid #007EFF'};

View File

@ -3,14 +3,14 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
const FormTitle = ({ description, title }) => (
<React.Fragment>
<>
{!!title && <FormattedMessage id={title} />}
{!!description && (
<FormattedMessage id={description}>
{msg => <p>{msg}</p>}
</FormattedMessage>
)}
</React.Fragment>
</>
);
FormTitle.propTypes = {

View File

@ -58,6 +58,8 @@ const Label = styled.label`
}
`;
}
return '';
}}
`;

View File

@ -24,6 +24,8 @@ const stringify = JSON.stringify;
const DEFAULT_THEME = '3024-night';
class InputJSON extends React.Component {
timer = null;
constructor(props) {
super(props);
this.editor = React.createRef();
@ -88,7 +90,7 @@ class InputJSON extends React.Component {
let content = this.getContentAtLine(line);
if (content === '{') {
line = line + 1;
line += 1;
content = this.getContentAtLine(line);
}
const chEnd = content.length;
@ -101,8 +103,6 @@ class InputJSON extends React.Component {
this.setState({ markedText });
};
timer = null;
handleBlur = ({ target }) => {
const { name, onBlur } = this.props;

View File

@ -17,7 +17,6 @@ import Wrapper from './Wrapper';
class InputJSONWithErrors extends React.Component {
handleChange = e => {
this.setState({ errors: [] });
this.props.onChange(e);
};

View File

@ -1,3 +1,6 @@
/* eslint-disable react/no-array-index-key */
/* eslint-disable import/no-cycle */
import React from 'react';
import PropTypes from 'prop-types';
import { get } from 'lodash';

View File

@ -14,6 +14,8 @@ const Wrapper = styled.div`
padding: 0;
`;
}
return '';
}}
border-radius: 2px;
> div {

View File

@ -21,6 +21,8 @@ const Button = styled.button`
border-radius: 2px;
`;
}
return '';
}}
${({ hasMinError }) => {
@ -30,6 +32,8 @@ const Button = styled.button`
border-top-color: rgba(227, 233, 243, 0.75);
`;
}
return '';
}}
color: #007eff;

View File

@ -8,6 +8,8 @@ import PreviewCarret from '../PreviewCarret';
import BannerWrapper from './BannerWrapper';
import CarretTop from './CarretTop';
/* eslint-disable jsx-a11y/no-static-element-interactions */
const Banner = forwardRef(
(
{

View File

@ -1,5 +1,7 @@
import styled from 'styled-components';
/* eslint-disable */
const BannerWrapper = styled.button`
display: flex;
height: 36px;

View File

@ -1,3 +1,4 @@
/* eslint-disable import/no-cycle */
import React, { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { get } from 'lodash';
@ -12,6 +13,8 @@ import FieldComponent from '../FieldComponent';
import Banner from './Banner';
import FormWrapper from './FormWrapper';
/* eslint-disable react/no-array-index-key */
// Issues:
// https://github.com/react-dnd/react-dnd/issues/1368
// https://github.com/frontend-collective/react-sortable-tree/issues/490
@ -109,8 +112,6 @@ const DraggedItem = ({
// but it's good here for the sake of performance
// to avoid expensive index searches.
item.originalPath = hoverPath;
return;
},
});
const [{ isDragging }, drag, preview] = useDrag({

View File

@ -12,8 +12,10 @@ const EmptyComponent = styled.div`
${({ hasMinError }) => {
if (hasMinError) {
return `border-color: #FAA684`;
return 'border-color: #FAA684';
}
return '';
}}
> p {

View File

@ -1,5 +1,7 @@
import styled from 'styled-components';
/* eslint-disable indent */
const FormWrapper = styled.div`
padding-top: 24px;
padding-left: 20px;
@ -9,11 +11,10 @@ const FormWrapper = styled.div`
${({ hasErrors, isOpen }) => {
if (hasErrors) {
return '#ffa784';
} else if (isOpen) {
} if (isOpen) {
return '#AED4FB';
} else {
return 'rgba(227, 233, 243, 0.75)';
}
return 'rgba(227, 233, 243, 0.75)';
}};
`;

View File

@ -1,3 +1,4 @@
/* eslint-disable import/no-cycle */
import React, { useReducer } from 'react';
import { useDrop } from 'react-dnd';
import PropTypes from 'prop-types';

View File

@ -12,11 +12,14 @@ import Cross from '../../icons/Cross';
import Filter from '../../icons/Filter';
import SearchIcon from '../../icons/Search';
import { Wrapper, Infos, Clear } from './components';
const WAIT = 400;
class Search extends React.Component {
state = { value: this.props.initValue };
timer = null;
componentDidUpdate(prevProps) {
const { model, value } = this.props;
@ -28,8 +31,6 @@ class Search extends React.Component {
}
}
timer = null;
resetState = () => this.setState({ value: '' });
handleChange = ({ target }) => {

View File

@ -7,6 +7,8 @@ import { FormattedMessage } from 'react-intl';
import pluginId from '../../pluginId';
import IconRemove from '../../assets/images/icon_remove.svg';
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
const Relation = ({ data, mainField, onRemove, to }) => {
return (
<>

View File

@ -59,7 +59,7 @@ function SelectWrapper({
const data = await request(requestUrl, {
method: 'GET',
params: params,
params,
signal,
});
@ -220,7 +220,6 @@ SelectWrapper.defaultProps = {
editable: true,
description: '',
label: '',
plugin: '',
placeholder: '',
};
@ -231,7 +230,6 @@ SelectWrapper.propTypes = {
mainField: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
placeholder: PropTypes.string,
plugin: PropTypes.string,
relationType: PropTypes.string.isRequired,
targetModel: PropTypes.string.isRequired,
};

View File

@ -51,7 +51,7 @@ const SettingsViewWrapper = ({
id: `${pluginId}.popUpWarning.button.cancel`,
}),
type: 'button',
disabled: isEqual(modifiedData, initialData) ? true : false,
disabled: isEqual(modifiedData, initialData),
style: {
fontWeight: 600,
paddingLeft: 15,
@ -64,7 +64,7 @@ const SettingsViewWrapper = ({
id: `${pluginId}.containers.Edit.submit`,
}),
type: 'submit',
disabled: isEqual(modifiedData, initialData) ? true : false,
disabled: isEqual(modifiedData, initialData),
style: {
minWidth: 150,
fontWeight: 600,

View File

@ -1,5 +1,5 @@
import styled, { css } from 'styled-components';
/* eslint-disable */
const EditorWrapper = styled.div`
${({ isFullscreen }) => {
if (isFullscreen) {

View File

@ -1,5 +1,7 @@
import styled, { css } from 'styled-components';
/* eslint-disable */
const PreviewWysiwygWrapper = styled.div`
max-height: 555px;
min-height: 294px;

View File

@ -1,5 +1,7 @@
import styled, { css } from 'styled-components';
/* eslint-disable */
const SelectWrapper = styled.div`
min-width: ${({ isFullScreen }) => (isFullScreen ? '161px' : '115px')}
margin-left: 15px;

View File

@ -47,6 +47,8 @@ import EditorWrapper from './EditorWrapper';
/* eslint-disable react/jsx-handler-names */
/* eslint-disable react/sort-comp */
/* eslint-disable */
class Wysiwyg extends React.Component {
constructor(props) {
super(props);

View File

@ -33,6 +33,9 @@ import Link from './link';
import Video from './video';
/* eslint-disable react/no-unused-state */
/* eslint-disable no-new */
/* eslint-disable consistent-return */
/* eslint-disable react/sort-comp */
function getBlockStyle(block) {
switch (block.getType()) {
case 'blockquote':

View File

@ -7,6 +7,8 @@
import React from 'react';
import PropTypes from 'prop-types';
/* eslint-disable jsx-a11y/media-has-caption */
const Video = props => {
const { height, src, width } = props.contentState
.getEntity(props.entityKey)

View File

@ -9,6 +9,10 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { Span, Wrapper } from './components';
/* eslint-disable jsx-a11y/label-has-associated-control */
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
/* eslint-disable jsx-a11y/no-static-element-interactions */
const WysiwygBottomControls = ({ isPreviewMode, onChange, onClick }) => {
const browse = (
<FormattedMessage id="components.WysiwygBottomControls.uploadFiles.browse">

View File

@ -36,6 +36,8 @@ const Button = styled.button`
cursor: not-allowed;
`;
}
return '';
}}
> svg {

View File

@ -15,6 +15,7 @@ import { Error } from '@buffetjs/core';
import Wysiwyg from '../Wysiwyg';
import Wrapper from './Wrapper';
// eslint-disable-next-line react/prefer-stateless-function
class WysiwygWithErrors extends React.Component {
render() {
const {
@ -114,6 +115,7 @@ WysiwygWithErrors.defaultProps = {
style: {},
tabIndex: '0',
validations: {},
value: null,
};
WysiwygWithErrors.propTypes = {

View File

@ -463,16 +463,13 @@ const EditSettingsView = ({
};
EditSettingsView.defaultProps = {
deleteAllLayouts: () => {},
slug: null,
};
EditSettingsView.propTypes = {
components: PropTypes.array.isRequired,
models: PropTypes.array.isRequired,
currentEnvironment: PropTypes.string,
currentEnvironment: PropTypes.string.isRequired,
deleteLayout: PropTypes.func.isRequired,
deleteLayouts: PropTypes.func,
deleteLayouts: PropTypes.func.isRequired,
componentsAndModelsMainPossibleMainFields: PropTypes.object.isRequired,
history: PropTypes.shape({
push: PropTypes.func,
@ -480,7 +477,7 @@ EditSettingsView.propTypes = {
location: PropTypes.shape({
search: PropTypes.string.isRequired,
}).isRequired,
plugins: PropTypes.object,
plugins: PropTypes.object.isRequired,
slug: PropTypes.string,
};

View File

@ -104,7 +104,7 @@ const reducer = (state, action) => {
// Delete the entire row if length is one or if lenght is equal to 2 and the second element is the hidden div used to make the dnd exp smoother
if (
row.size === 1 ||
(row.size == 2 && row.getIn([1, 'name']) === '_TEMP_')
(row.size === 2 && row.getIn([1, 'name']) === '_TEMP_')
) {
newState = state.updateIn(layoutPathEdit, list =>
list.delete(action.rowIndex)

View File

@ -37,12 +37,14 @@ const Header = () => {
);
const isCreatingEntry = id === 'create';
/* eslint-disable indent */
const headerTitle = isCreatingEntry
? formatMessage({
id: `${pluginId}.containers.Edit.pluginHeader.title.new`,
})
: templateObject({ mainField: currentContentTypeMainField }, initialData)
.mainField;
/* eslint-enable indent */
const getHeaderActions = () => {
const headerActions = [

View File

@ -26,6 +26,8 @@ import { LinkWrapper, SubWrapper } from './components';
import init from './init';
import reducer, { initialState } from './reducer';
/* eslint-disable react/no-array-index-key */
const EditView = ({
components,
currentEnvironment,
@ -274,7 +276,7 @@ const EditView = ({
}}
icon="layout"
key={`${pluginId}.link`}
url={`ctm-configurations/edit-settings/content-types`}
url="ctm-configurations/edit-settings/content-types"
onClick={() => {
// emitEvent('willEditContentTypeLayoutFromEditView');
}}

View File

@ -1,5 +1,7 @@
import { get, isEmpty } from 'lodash';
/* eslint-disable no-restricted-syntax */
const createAttributesLayout = (currentLayout, attributes) => {
const getType = name => get(attributes, [name, 'type'], '');
let currentRowIndex = 0;

View File

@ -1,5 +1,7 @@
import { get, isArray, isEmpty, isObject } from 'lodash';
/* eslint-disable indent */
export const cleanData = (retrievedData, ctLayout, groupLayouts) => {
const getType = (schema, attrName) =>
get(schema, ['attributes', attrName, 'type'], '');
@ -112,11 +114,10 @@ export const getMediaAttributes = (ctLayout, groupLayouts) => {
export const helperCleanData = (value, key) => {
if (isArray(value)) {
return value.map(obj => (obj[key] ? obj[key] : obj));
} else if (isObject(value)) {
} if (isObject(value)) {
return value[key];
} else {
return value;
}
return value;
};
export const mapDataKeysToFilesToUpload = (filesMap, data) => {

View File

@ -1,5 +1,7 @@
import { get, isArray, isObject } from 'lodash';
/* eslint-disable indent */
const cleanData = (retrievedData, currentSchema, componentsSchema) => {
const getType = (schema, attrName) =>
get(schema, ['attributes', attrName, 'type'], '');
@ -90,11 +92,10 @@ const cleanData = (retrievedData, currentSchema, componentsSchema) => {
export const helperCleanData = (value, key) => {
if (isArray(value)) {
return value.map(obj => (obj[key] ? obj[key] : obj));
} else if (isObject(value)) {
} if (isObject(value)) {
return value[key];
} else {
return value;
}
return value;
};
export default cleanData;

View File

@ -42,7 +42,7 @@ const createDefaultForm = (attributes, allComponentsSchema) => {
if (min && repeatable === true && required) {
acc[current] = [];
for (let i = 0; i < min; i++) {
for (let i = 0; i < min; i += 1) {
acc[current].push(currentComponentDefaultForm);
}
}

View File

@ -119,23 +119,22 @@ const createYupSchema = (model, { components }) => {
acc[current] = componentSchema;
return acc;
} else {
const componentSchema = yup.lazy(obj => {
if (obj !== undefined) {
return attribute.required === true
}
const componentSchema = yup.lazy(obj => {
if (obj !== undefined) {
return attribute.required === true
? componentFieldSchema.defined()
: componentFieldSchema.nullable();
}
}
return attribute.required === true
return attribute.required === true
? yup.object().defined()
: yup.object().nullable();
});
});
acc[current] = componentSchema;
acc[current] = componentSchema;
return acc;
}
return acc;
}
if (attribute.type === 'dynamiczone') {
@ -156,6 +155,7 @@ const createYupSchema = (model, { components }) => {
.required(errorsTrads.required);
}
} else {
// eslint-disable-next-line no-lonely-if
if (min) {
dynamicZoneSchema = dynamicZoneSchema.notEmptyMin(min);
}

View File

@ -46,7 +46,6 @@ LayoutDndProvider.defaultProps = {
buttonData: [],
goTo: () => {},
layout: [],
isDraggingSibling: true,
metadatas: {},
moveItem: () => {},
moveRow: () => {},
@ -55,7 +54,6 @@ LayoutDndProvider.defaultProps = {
removeField: () => {},
selectedItemName: null,
setEditFieldToSelect: () => {},
setIsDraggingSibling: () => {},
};
LayoutDndProvider.propTypes = {

Some files were not shown because too many files have changed in this diff Show More