From 303263d4d608d5d7709d78b417aade0c79ae3111 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 10 May 2020 01:11:10 +0200 Subject: [PATCH] [core] Avoid over-transpiling https://github.com/mui-org/material-ui/issues/20896#issuecomment-623698873 --- docs/src/modules/constants.js | 2 +- docs/src/pages/components/lists/CheckboxList.js | 2 +- .../src/ToggleButtonGroup/ToggleButtonGroup.js | 4 ++-- packages/material-ui-lab/src/TreeView/TreeView.js | 2 +- .../material-ui-lab/src/useAutocomplete/useAutocomplete.js | 6 +++--- packages/material-ui/src/MobileStepper/MobileStepper.js | 2 +- packages/material-ui/src/Select/SelectInput.js | 2 +- packages/material-ui/src/Slider/Slider.js | 7 ++++--- packages/material-ui/src/test-utils/describeConformance.js | 4 +--- packages/material-ui/src/withWidth/withWidth.js | 2 +- test/utils/consoleErrorMock.test.js | 3 +-- 11 files changed, 17 insertions(+), 19 deletions(-) diff --git a/docs/src/modules/constants.js b/docs/src/modules/constants.js index 137e8f5efa3c96..8ba7cf480772eb 100644 --- a/docs/src/modules/constants.js +++ b/docs/src/modules/constants.js @@ -15,7 +15,7 @@ const LANGUAGES = ['en', 'zh', 'ru', 'pt', 'es', 'fr', 'de', 'ja', 'aa']; const LANGUAGES_SSR = ['en', 'zh', 'ru', 'pt', 'es']; // Work in progress -const LANGUAGES_IN_PROGRESS = [...LANGUAGES]; +const LANGUAGES_IN_PROGRESS = LANGUAGES.slice(); // Valid languages to use in production const LANGUAGES_LABEL = [ diff --git a/docs/src/pages/components/lists/CheckboxList.js b/docs/src/pages/components/lists/CheckboxList.js index 2ef8bb1811cd1e..7fa53292bb4eb8 100644 --- a/docs/src/pages/components/lists/CheckboxList.js +++ b/docs/src/pages/components/lists/CheckboxList.js @@ -23,7 +23,7 @@ export default function CheckboxList() { const handleToggle = (value) => () => { const currentIndex = checked.indexOf(value); - const newChecked = [...checked]; + const newChecked = checked.slice(); if (currentIndex === -1) { newChecked.push(value); diff --git a/packages/material-ui-lab/src/ToggleButtonGroup/ToggleButtonGroup.js b/packages/material-ui-lab/src/ToggleButtonGroup/ToggleButtonGroup.js index ec5b209a3d3d9d..e496b9a9fcd92b 100644 --- a/packages/material-ui-lab/src/ToggleButtonGroup/ToggleButtonGroup.js +++ b/packages/material-ui-lab/src/ToggleButtonGroup/ToggleButtonGroup.js @@ -58,10 +58,10 @@ const ToggleButtonGroup = React.forwardRef(function ToggleButton(props, ref) { let newValue; if (value && index >= 0) { - newValue = [...value]; + newValue = value.slice(); newValue.splice(index, 1); } else { - newValue = value ? [...value, buttonValue] : [buttonValue]; + newValue = value ? value.concat(buttonValue) : [buttonValue]; } onChange(event, newValue); diff --git a/packages/material-ui-lab/src/TreeView/TreeView.js b/packages/material-ui-lab/src/TreeView/TreeView.js index 5cfa1211488b64..3518410dcc766a 100644 --- a/packages/material-ui-lab/src/TreeView/TreeView.js +++ b/packages/material-ui-lab/src/TreeView/TreeView.js @@ -217,7 +217,7 @@ const TreeView = React.forwardRef(function TreeView(props, ref) { const topLevelNodes = nodeMap.current[-1].children; diff = topLevelNodes.filter((node) => !isExpanded(node)); } - const newExpanded = [...expanded, ...diff]; + const newExpanded = expanded.concat(diff); if (diff.length > 0) { setExpandedState(newExpanded); diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js index 4f41fedd800c59..db79387aee6ef6 100644 --- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js +++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js @@ -500,7 +500,7 @@ export default function useAutocomplete(props) { let newValue = option; if (multiple) { - newValue = Array.isArray(value) ? [...value] : []; + newValue = Array.isArray(value) ? value.slice() : []; if (process.env.NODE_ENV !== 'production') { const matches = newValue.filter((val) => getOptionSelected(option, val)); @@ -716,7 +716,7 @@ export default function useAutocomplete(props) { case 'Backspace': if (multiple && inputValue === '' && value.length > 0) { const index = focusedTag === -1 ? value.length - 1 : focusedTag; - const newValue = [...value]; + const newValue = value.slice(); newValue.splice(index, 1); handleValue(event, newValue, 'remove-option', { option: value[index], @@ -805,7 +805,7 @@ export default function useAutocomplete(props) { }; const handleTagDelete = (index) => (event) => { - const newValue = [...value]; + const newValue = value.slice(); newValue.splice(index, 1); handleValue(event, newValue, 'remove-option', { option: value[index], diff --git a/packages/material-ui/src/MobileStepper/MobileStepper.js b/packages/material-ui/src/MobileStepper/MobileStepper.js index b9a8f7a5b28cd1..4ea392ea9a7d73 100644 --- a/packages/material-ui/src/MobileStepper/MobileStepper.js +++ b/packages/material-ui/src/MobileStepper/MobileStepper.js @@ -88,7 +88,7 @@ const MobileStepper = React.forwardRef(function MobileStepper(props, ref) { {variant === 'dots' && (
- {[...new Array(steps)].map((_, index) => ( + {Array.apply(null, Array(steps)).map((_, index) => (
clamp(value, min, max)); const marks = marksProp === true && step !== null - ? [...Array(Math.floor((max - min) / step) + 1)].map((_, index) => ({ + ? // eslint-disable-next-line prefer-spread + Array.apply(null, Array(Math.floor((max - min) / step) + 1)).map((_, index) => ({ value: min + step * index, })) : marksProp || []; diff --git a/packages/material-ui/src/test-utils/describeConformance.js b/packages/material-ui/src/test-utils/describeConformance.js index 90d6c2cbd2be56..70e01dd3e3b202 100644 --- a/packages/material-ui/src/test-utils/describeConformance.js +++ b/packages/material-ui/src/test-utils/describeConformance.js @@ -47,9 +47,7 @@ function testClassName(element, getOptions) { const wrapper = mount(React.cloneElement(element, { className })); - expect( - findOutermostIntrinsic(wrapper).hasClass(className) - ).to.equal( + expect(findOutermostIntrinsic(wrapper).hasClass(className)).to.equal( true, 'does have a custom `className`', ); diff --git a/packages/material-ui/src/withWidth/withWidth.js b/packages/material-ui/src/withWidth/withWidth.js index 6aa6f849e4d3f7..6d9300b121efbb 100644 --- a/packages/material-ui/src/withWidth/withWidth.js +++ b/packages/material-ui/src/withWidth/withWidth.js @@ -51,7 +51,7 @@ const withWidth = (options = {}) => (Component) => { * |-------|-------|-------|-------|------> * width | xs | sm | md | lg | xl */ - const keys = [...theme.breakpoints.keys].reverse(); + const keys = theme.breakpoints.keys.slice().reverse(); const widthComputed = keys.reduce((output, key) => { // eslint-disable-next-line react-hooks/rules-of-hooks const matches = useMediaQuery(theme.breakpoints.up(key)); diff --git a/test/utils/consoleErrorMock.test.js b/test/utils/consoleErrorMock.test.js index 03a7d9d9b4130d..14de8e18f343ef 100644 --- a/test/utils/consoleErrorMock.test.js +++ b/test/utils/consoleErrorMock.test.js @@ -12,8 +12,7 @@ describe('consoleErrorMock()', () => { describe('args', () => { it('was removed but throws a descriptive error', () => { - expect( - () => consoleErrorMock.args()).to.throw( + expect(() => consoleErrorMock.args()).to.throw( 'args() was removed in favor of messages(). Use messages() to match against the actual error message that will be displayed in the console.', ); });