Skip to content

Commit

Permalink
[core] Avoid over-transpiling
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed May 10, 2020
1 parent a528ab4 commit 4a42017
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/src/modules/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions packages/material-ui-lab/src/TreeView/TreeView.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import TreeViewContext from './TreeViewContext';
import { withStyles } from '@material-ui/core/styles';
import { useControlled } from '@material-ui/core/utils';
import TreeViewContext from './TreeViewContext';

export const styles = {
/* Styles applied to the root element. */
Expand Down Expand Up @@ -196,7 +196,7 @@ const TreeView = React.forwardRef(function TreeView(props, ref) {
return oldTabbable;
});
} else {
newExpanded = [value, ...expanded];
newExpanded = [value].concat(expanded);
}

if (onNodeToggle) {
Expand All @@ -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);
Expand Down Expand Up @@ -295,7 +295,7 @@ const TreeView = React.forwardRef(function TreeView(props, ref) {
if (selected.indexOf(value) !== -1) {
newSelected = selected.filter((id) => id !== value);
} else {
newSelected = [value, ...selected];
newSelected = [value].concat(selected);
}

if (onNodeSelect) {
Expand Down Expand Up @@ -411,9 +411,9 @@ const TreeView = React.forwardRef(function TreeView(props, ref) {
if (map) {
nodes.push(id);
if (map.children) {
nodes.push(...map.children);
nodes.concat(map.children);
map.children.forEach((node) => {
nodes.push(...getNodesToRemove(node));
nodes.concat(getNodesToRemove(node));
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, assert } from 'chai';
import { expect } from 'chai';
import React from 'react';
import PropTypes from 'prop-types';
import { stub } from 'sinon';
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Select/SelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
let newValue;

if (multiple) {
newValue = Array.isArray(value) ? [...value] : [];
newValue = Array.isArray(value) ? value.slice() : [];
const itemIndex = value.indexOf(child.props.value);
if (itemIndex === -1) {
newValue.push(child.props.value);
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function setValueIndex({ values, source, newValue, index }) {
return source;
}

const output = [...values];
const output = values.slice();
output[index] = newValue;
return output;
}
Expand Down Expand Up @@ -386,7 +386,7 @@ const Slider = React.forwardRef(function Slider(props, ref) {

const range = Array.isArray(valueDerived);
const instanceRef = React.useRef();
let values = range ? [...valueDerived].sort(asc) : [valueDerived];
let values = range ? valueDerived.slice().sort(asc) : [valueDerived];
values = values.map((value) => clamp(value, min, max));
const marks =
marksProp === true && step !== null
Expand Down
4 changes: 1 addition & 3 deletions packages/material-ui/src/test-utils/describeConformance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`',
);
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/withWidth/withWidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions test/utils/consoleErrorMock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
});
Expand Down

0 comments on commit 4a42017

Please sign in to comment.