Skip to content

Commit

Permalink
fix(deps): Upgrade few packages
Browse files Browse the repository at this point in the history
Also add minor changes to improve codebase
  • Loading branch information
acezard committed Mar 22, 2022
1 parent 542e55e commit 75d6915
Show file tree
Hide file tree
Showing 47 changed files with 4,165 additions and 3,935 deletions.
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
"devDependencies": {
"@babel/cli": "7.11.5",
"@babel/core": "7.16.12",
"@babel/helper-builder-react-jsx": "7.16.7",
"@babel/helper-define-map": "7.16.7",
"@babel/helper-regex": "7.10.5",
"@cozy/codemods": "^1.9.0",
"@material-ui/core": "4.12.3",
"@semantic-release/changelog": "5.0.1",
Expand All @@ -83,7 +86,7 @@
"babel-loader": "8.1.0",
"babel-plugin-css-modules-transform": "1.6.2",
"babel-plugin-inline-json-import": "0.3.2",
"babel-preset-cozy-app": "^2.0.2",
"babel-preset-cozy-app": "2.0.2",
"browserslist-config-cozy": "0.4.0",
"commitlint": "7.6.1",
"commitlint-config-cozy": "0.6.0",
Expand All @@ -92,7 +95,7 @@
"cozy-device-helper": "^1.16.1",
"cozy-doctypes": "^1.69.0",
"cozy-harvest-lib": "^6.7.3",
"cozy-intent": "^1.13.0",
"cozy-intent": "1.13.0",
"cozy-sharing": "^3.10.0",
"cozy-stack-client": "27.19.1",
"css-loader": "0.28.11",
Expand All @@ -101,7 +104,7 @@
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.6",
"enzyme-to-json": "3.6.2",
"eslint-config-cozy-app": "^4.0.0",
"eslint-config-cozy-app": "4.0.0",
"express": "^4.17.1",
"focus-trap-react": "^6.0.0",
"git-directory-deploy": "1.5.1",
Expand Down
19 changes: 10 additions & 9 deletions react/ActionMenu/index.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import React from 'react'
import ClickAwayListener from '@material-ui/core/ClickAwayListener'
import PropTypes from 'prop-types'
import React from 'react'
import cx from 'classnames'
import ClickAwayListener from '@material-ui/core/ClickAwayListener'
import styles from './styles.styl'
import { Media, Bd, Img } from '../Media'
import { usePopper } from 'react-popper'
import { useTheme } from '@material-ui/core'

import BottomDrawer from '../BottomDrawer'
import Radio from '../Radio'
import createDepreciationLogger from '../helpers/createDepreciationLogger'
import styles from './styles.styl'
import useBreakpoints from '../hooks/useBreakpoints'
import { Media, Bd, Img } from '../Media'
import { getCssVariableValue } from '../utils/color'
import Radio from '../Radio'
import { spacingProp } from '../Stack'
import { usePopper } from 'react-popper'
import createDepreciationLogger from '../helpers/createDepreciationLogger'
import { useSetFlagshipUI } from '../hooks/useSetFlagshipUi/useSetFlagshipUI'
import { useTheme } from '@material-ui/core'

const ActionMenuWrapper = ({
inline,
Expand Down Expand Up @@ -110,7 +111,7 @@ const ActionMenu = ({
{
bottomBackground: theme.palette.background.paper,
bottomTheme: 'dark',
topOverlay: getCssVariableValue('overlay'),
topOverlay: getCssVariableValue('overlay'), // TODO: refactor to semantic variable
topBackground: theme.palette.background.paper,
topTheme: 'light'
},
Expand Down
19 changes: 15 additions & 4 deletions react/ActionMenu/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('ActionMenu', () => {

beforeEach(() => {
// eslint-disable-next-line no-console
console.error = function (msg, arg) {
console.error = function(msg, arg) {
if (
msg.includes('An update to %s inside a test was not wrapped in act') &&
arg == 'ActionMenuWrapper'
Expand Down Expand Up @@ -43,7 +43,12 @@ describe('ActionMenu', () => {
)
// Remove an update was not wrapped in act() warning
await act(async () => {})
expect(comp.find(ActionMenuItem).parent().getElement()).toMatchSnapshot()
expect(
comp
.find(ActionMenuItem)
.parent()
.getElement()
).toMatchSnapshot()
})

it('should support auto-closing the menu', async () => {
Expand All @@ -67,13 +72,19 @@ describe('ActionMenu', () => {
)

await act(async () => {
comp.find(ActionMenuItem).at(1).simulate('click')
comp
.find(ActionMenuItem)
.at(1)
.simulate('click')
})
expect(menuAction2).toHaveBeenCalled()
expect(closeMenu).not.toHaveBeenCalled()

act(() => {
comp.find(ActionMenuItem).at(0).simulate('click')
comp
.find(ActionMenuItem)
.at(0)
.simulate('click')
})
expect(menuAction1).toHaveBeenCalled()
expect(closeMenu).toHaveBeenCalled()
Expand Down
19 changes: 16 additions & 3 deletions react/Alerter/alerter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ describe('Alerter component', () => {
it(`renders correctly an ${type} alert`, () => {
const wrapper = shallow(<Alerter />)
Alerter[type](`Test ${type} alert`)
expect(wrapper.find(Alert).dive().getElement()).toMatchSnapshot()
expect(
wrapper
.find(Alert)
.dive()
.getElement()
).toMatchSnapshot()
})
})

Expand All @@ -34,7 +39,12 @@ describe('Alerter component', () => {
Alerter.info(`Test alert with button`, {
buttonText: 'BTN'
})
expect(wrapper.find(Alert).dive().getElement()).toMatchSnapshot()
expect(
wrapper
.find(Alert)
.dive()
.getElement()
).toMatchSnapshot()
})

it('handles dismiss provided to buttonAction', () => {
Expand All @@ -54,7 +64,10 @@ describe('Alerter component', () => {
// we have to wait the same delay as in the Alerter didMount
setTimeout(() => {
expect(alert.state('hidden')).toBe(false)
alert.children().find(Button).simulate('click')
alert
.children()
.find(Button)
.simulate('click')
expect(alert.state('hidden')).toBe(true)
}, 20)
})
Expand Down
2 changes: 1 addition & 1 deletion react/AppLinker/expiringMemoize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function (fn, duration, keyFn) {
export default function(fn, duration, keyFn) {
const memo = {}
return arg => {
const key = keyFn(arg)
Expand Down
2 changes: 1 addition & 1 deletion react/AppLinker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class AppLinker extends React.Component {
AppLinker.onAppSwitch(onAppSwitch)
openDeeplinkOrRedirect(
appInfo.uri + (nativePath === '/' ? '' : nativePath),
function () {
function() {
window.location.href = href
}
)
Expand Down
5 changes: 3 additions & 2 deletions react/AppTile/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ export const AppTile = ({
type="button"
onClick={onClick}
className={cx({
[styles['AppTile-container-maintenance']]:
isInMaintenanceWithSpecificDisplay
[styles[
'AppTile-container-maintenance'
]]: isInMaintenanceWithSpecificDisplay
})}
isSecondary={statusLabel === APP_STATUS.installed}
>
Expand Down
4 changes: 2 additions & 2 deletions react/BottomDrawer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class BottomDrawer extends Component {

// to be completely accurate, `maximumGestureDelta` should be the difference between the top of the menu and the
// bottom of the page; but using the height is much easier to compute and accurate enough.
const maximumGestureDistance =
this.menuNode.current.getBoundingClientRect().height
const maximumGestureDistance = this.menuNode.current.getBoundingClientRect()
.height
// between 0 and 1, how far down the gesture must be to be considered complete upon release
const minimumCloseDistance = 0.6
// a gesture faster than this will dismiss the menu, regardless of distance traveled
Expand Down
2 changes: 1 addition & 1 deletion react/Button/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Icon, { iconPropType } from '../Icon'

import SpinnerIcon from 'cozy-ui/transpiled/react/Icons/Spinner'

const btnClass = function (options) {
const btnClass = function(options) {
const { className, extension, size, theme, variant, round, align } = options
return cx(
styles['c-btn'],
Expand Down
6 changes: 4 additions & 2 deletions react/ContactsList/Contacts/ContactName.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { Contact } from 'cozy-doctypes'

const ContactName = ({ contact }) => {
const name = contact.name || {}
const { givenName: firstname = contact.fullname, familyName: lastname = '' } =
name
const {
givenName: firstname = contact.fullname,
familyName: lastname = ''
} = name

return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion react/DateMonthPicker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const DateMonthPicker = ({ initialValue, onSelect }) => {
)
}

const dateMonthProp = function (props, propName, componentName) {
const dateMonthProp = function(props, propName, componentName) {
if (!/^[0-9]{4}-[0-9]{2}$/.test(props[propName])) {
return new Error(
'Invalid prop `' +
Expand Down
2 changes: 1 addition & 1 deletion react/Field/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Field.propTypes = {
name: PropTypes.string,
type: PropTypes.oneOf(allowedTypes),
// value should be an object for type=select and string for others
value: function (props, propName, componentName) {
value: function(props, propName, componentName) {
// not a required props
if (typeof props[propName] === 'undefined') return
if (props.type === 'select' && typeof props[propName] !== 'object') {
Expand Down
5 changes: 1 addition & 4 deletions react/Figure/Figure.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ describe('Figure', () => {
]

const combinations = combine
.apply(
null,
coloredAttributes.map(x => [{ [x]: true }, { [x]: false }])
)
.apply(null, coloredAttributes.map(x => [{ [x]: true }, { [x]: false }]))
.map(attrs => {
return merge.apply(null, [{}, ...attrs])
})
Expand Down
9 changes: 4 additions & 5 deletions react/FilePicker/FilePickerBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ const FilePickerBody = ({
multiple
}) => {
const contentFolderQuery = buildContentFolderQuery(folderId)
const {
data: contentFolder,
hasMore,
fetchMore
} = useQuery(contentFolderQuery.definition, contentFolderQuery.options)
const { data: contentFolder, hasMore, fetchMore } = useQuery(
contentFolderQuery.definition,
contentFolderQuery.options
)

const onCheck = useCallback(
fileId => {
Expand Down
7 changes: 3 additions & 4 deletions react/FilePicker/FilePickerBreadcrumb.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ const FilePickerBreadcrumb = ({ path, onBreadcrumbClick }) => {
const { isMobile } = useBreakpoints()
const hasPath = path && path.length > 0

const navigateTo = useCallback(
folder => () => onBreadcrumbClick(folder),
[onBreadcrumbClick]
)
const navigateTo = useCallback(folder => () => onBreadcrumbClick(folder), [
onBreadcrumbClick
])

return (
<Typography variant="h4" className="u-flex u-flex-items-center">
Expand Down
13 changes: 7 additions & 6 deletions react/I18n/format.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ export const provideDateFnsLocale = (userLang, defaultLang = DEFAULT_LANG) => {
return locales[lang]
}

export const initFormat =
(userLang, defaultLang = DEFAULT_LANG) =>
(date, formatStr) => {
const locale = provideDateFnsLocale(userLang, defaultLang)
return format(date, formatStr, { locale })
}
export const initFormat = (userLang, defaultLang = DEFAULT_LANG) => (
date,
formatStr
) => {
const locale = provideDateFnsLocale(userLang, defaultLang)
return format(date, formatStr, { locale })
}

export const formatLocallyDistanceToNow = date =>
formatDistanceToNow(date, { locale: locales[lang] })
5 changes: 2 additions & 3 deletions react/I18n/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ export const translate = () => WrappedComponent => {
/>
)
}
Wrapper.displayName = `withI18n(${
WrappedComponent.displayName || WrappedComponent.name
})`
Wrapper.displayName = `withI18n(${WrappedComponent.displayName ||
WrappedComponent.name})`
return Wrapper
}

Expand Down
5 changes: 2 additions & 3 deletions react/I18n/withLocales.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ const withLocales = localesOrRequire => Component => {
...I18n.childContextTypes
}

Wrapped.displayName = `withLocales(${
Component.displayName || Component.name
})`
Wrapped.displayName = `withLocales(${Component.displayName ||
Component.name})`

// The outer component needs to receive lang
return translate()(Wrapped)
Expand Down
7 changes: 3 additions & 4 deletions react/Icon/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ function Icon(props) {
...restProps
} = props

const Svg = useMemo(
() => (isFunction(icon) ? icon : getSvgObject(icon)),
[icon]
)
const Svg = useMemo(() => (isFunction(icon) ? icon : getSvgObject(icon)), [
icon
])

let style = props.style
style = Object.assign({}, style)
Expand Down
10 changes: 8 additions & 2 deletions react/Infos/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ const InfosMigration = React.memo(function InfosMigration(props) {
props.text ||
props.title
if (isUsingDeprecatedProps) {
const { title, text, icon, actionButton, isImportant, ...otherProps } =
props
const {
title,
text,
icon,
actionButton,
isImportant,
...otherProps
} = props
logInfosDepecrated(
'The Infos component API has changed, using any of the following props is deprecated: title, text, icon, actionButton, isImportant'
)
Expand Down
2 changes: 1 addition & 1 deletion react/InfosCarrousel/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const InfosCarrousel = ({
const hasNextInfos = index === count - 1

const onChangeIndex = useCallback(
function (index) {
function(index) {
const { onChangeIndex: onChangeIndexProp } = swipeableProps
if (onChangeIndexProp) {
onChangeIndexProp(index)
Expand Down
5 changes: 4 additions & 1 deletion react/InfosCarrousel/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ const getArrowsDisabledProps = root =>

const simulateSwipeToSlideIndex = (root, slideIndex) => {
act(() => {
root.find(SwipeableViews).props().onChangeIndex(slideIndex)
root
.find(SwipeableViews)
.props()
.onChangeIndex(slideIndex)
})
root.update()
}
Expand Down
10 changes: 8 additions & 2 deletions react/InputGroup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ class InputGroup extends Component {
}

render() {
const { children, prepend, append, error, fullwidth, className } =
this.props
const {
children,
prepend,
append,
error,
fullwidth,
className
} = this.props
const { focused } = this.state
return (
<div
Expand Down
Loading

0 comments on commit 75d6915

Please sign in to comment.