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 303263d
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 19 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
2 changes: 1 addition & 1 deletion docs/src/pages/components/lists/CheckboxList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/TreeView/TreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
2 changes: 1 addition & 1 deletion packages/material-ui/src/MobileStepper/MobileStepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const MobileStepper = React.forwardRef(function MobileStepper(props, ref) {

{variant === 'dots' && (
<div className={classes.dots}>
{[...new Array(steps)].map((_, index) => (
{Array.apply(null, Array(steps)).map((_, index) => (
<div
key={index}
className={clsx(classes.dot, {
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
7 changes: 4 additions & 3 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,11 +386,12 @@ 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
? [...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 || [];
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 303263d

Please sign in to comment.