Skip to content

Commit

Permalink
[core] Prefer other over rest
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Dec 5, 2020
1 parent 0835aa1 commit 4c62a99
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 21 deletions.
6 changes: 3 additions & 3 deletions packages/material-ui-lab/src/TreeView/descendants.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ export function DescendantProvider(props) {

const [items, set] = React.useState([]);

const registerDescendant = React.useCallback(({ element, ...rest }) => {
const registerDescendant = React.useCallback(({ element, ...other }) => {
set((oldItems) => {
let newItems;
if (oldItems.length === 0) {
// If there are no items, register at index 0 and bail.
return [
{
...rest,
...other,
element,
index: 0,
},
Expand All @@ -163,7 +163,7 @@ export function DescendantProvider(props) {
// elements come or go from our component.

const newItem = {
...rest,
...other,
element,
index,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export function makeWrapperComponent<TWrapper extends SomeWrapper = any>(
const {
disableCloseOnSelect,
cancelText,
children,
clearable,
clearText,
DateInputProps,
Expand All @@ -46,7 +45,7 @@ export function makeWrapperComponent<TWrapper extends SomeWrapper = any>(
todayText,
value,
wrapperProps,
...restPropsForTextField
...other
} = props;

const TypedWrapper = Wrapper as SomeWrapper;
Expand All @@ -65,10 +64,8 @@ export function makeWrapperComponent<TWrapper extends SomeWrapper = any>(
PureDateInputComponent={PureDateInputComponent}
displayStaticWrapperAs={displayStaticWrapperAs}
{...wrapperProps}
{...restPropsForTextField}
>
{children}
</TypedWrapper>
{...other}
/>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ function isEmpty(string) {
* @param {object} props - the properties for which the classKey should be created
*/
export default function propsToClassKey(props) {
const { variant, ...rest } = props;
const { variant, ...other } = props;

let classKey = variant || '';

Object.keys(rest)
Object.keys(other)
.sort()
.forEach((key) => {
if (key === 'color') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ describe('<SliderUnstyled />', () => {
let theme = null;

const Root = React.forwardRef(
({ styleProps: stylePropsProp, theme: themeProp, ...rest }, ref) => {
({ styleProps: stylePropsProp, theme: themeProp, ...other }, ref) => {
styleProps = stylePropsProp;
theme = themeProp;
return <span ref={ref} {...rest} />;
return <span ref={ref} {...other} />;
},
);

Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Box/Box.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ interface TestProps {
}

function Test(props: TestProps) {
const { test, ...rest } = props;
return <span {...rest}>{test}</span>;
const { test, ...other } = props;
return <span {...other}>{test}</span>;
}

function ResponsiveTest() {
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/styles/experimentalStyled.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ const experimentalStyled = (tag, options, muiOptions = {}) => {
const expressionsWithDefaultTheme = expressions
? expressions.map((stylesArg) => {
return typeof stylesArg === 'function'
? ({ theme: themeInput, ...rest }) => {
? ({ theme: themeInput, ...oter }) => {
return stylesArg({
theme: isEmpty(themeInput) ? defaultTheme : themeInput,
...rest,
...oter,

This comment has been minimized.

Copy link
@eps1lon

eps1lon Dec 6, 2020

Member

Small typo 😁
L'Otters are not afraid

});
}
: stylesArg;
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript-to-proptypes/test/unused-prop/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ type Props = {
};

export default function Foo(props: Props) {
const { foo, ...rest } = props;
const { foo, ...other } = props;

return (
<div className={props.bar} {...rest}>
<div className={props.bar} {...other}>
{foo}
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript-to-proptypes/test/unused-prop/output.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import PropTypes from 'prop-types';
function Foo(props) {
const { foo, ...rest } = props;
const { foo, ...other } = props;
return (
<div className={props.bar} {...rest}>
<div className={props.bar} {...other}>
{foo}
</div>
);
Expand Down

0 comments on commit 4c62a99

Please sign in to comment.