Skip to content

Commit

Permalink
Replace warning with tiny-warning
Browse files Browse the repository at this point in the history
- esm support
- not stuck with mirroring facebook internals once in a year
- jss v10 already migrated to it so size improvement will come in mui v4
- tiny-warning is really console.warn; red wall in console is scary
  • Loading branch information
TrySound committed Jan 12, 2019
1 parent 07bc075 commit a7c0c82
Show file tree
Hide file tree
Showing 65 changed files with 234 additions and 2,051 deletions.
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppTableOfContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import marked from 'marked';
import warning from 'warning';
import warning from 'tiny-warning';
import throttle from 'lodash/throttle';
import EventListener from 'react-event-listener';
import { withStyles } from '@material-ui/core/styles';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/MarkdownDocs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import warning from 'warning';
import warning from 'tiny-warning';
import { connect } from 'react-redux';
import compose from 'recompose/compose';
import { withStyles } from '@material-ui/core/styles';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/utils/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import warning from 'warning';
import warning from 'tiny-warning';
import upperFirst from 'lodash/upperFirst';
import camelCase from 'lodash/camelCase';

Expand Down
2 changes: 1 addition & 1 deletion modules/waterfall/metric.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// The API is inspired by console.time
// The implementation is isomorphic.
import warning from 'warning';
import warning from 'tiny-warning';

const times = new Map();

Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui-lab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"@material-ui/utils": "^3.0.0-alpha.2",
"classnames": "^2.2.5",
"keycode": "^2.1.9",
"prop-types": "^15.6.0"
"prop-types": "^15.6.0",
"tiny-warning": "^1.0.2"
},
"devDependencies": {},
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/SpeedDial/SpeedDial.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import keycode from 'keycode';
import warning from 'warning';
import warning from 'tiny-warning';
import { componentPropType } from '@material-ui/utils';
import { withStyles } from '@material-ui/core/styles';
import Zoom from '@material-ui/core/Zoom';
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"jss-plugin-rule-value-function": "^10.0.0-alpha.7",
"jss-plugin-vendor-prefixer": "^10.0.0-alpha.7",
"prop-types": "^15.6.0",
"warning": "^4.0.1"
"tiny-warning": "^1.0.2"
},
"sideEffects": false,
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-styles/src/StylesProvider.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import warning from 'warning';
import warning from 'tiny-warning';
import { exactProp } from '@material-ui/utils';
import createGenerateClassName from './createGenerateClassName';
import { create } from 'jss';
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-styles/src/ThemeProvider.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import warning from 'warning';
import warning from 'tiny-warning';
import { exactProp } from '@material-ui/utils';
import ThemeContext from './ThemeContext';

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-styles/src/createGenerateClassName.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import warning from 'warning';
import warning from 'tiny-warning';
import hash from '@emotion/hash';

const escapeRegex = /([[\].#*$><+~=|^:(),"'`\s])/g;
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-styles/src/getStylesCreator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import warning from 'warning';
import warning from 'tiny-warning';
import deepmerge from 'deepmerge'; // < 1kb payload overhead when lodash/merge is > 3kb.

// Support for the jss-expand plugin.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-styles/src/indexCounter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/prefer-default-export */

import warning from 'warning';
import warning from 'tiny-warning';

// Global index counter to preserve source order.
// We create the style sheet during at the creation of the component,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-styles/src/mergeClasses.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import warning from 'warning';
import warning from 'tiny-warning';
import { getDisplayName } from '@material-ui/utils';

function mergeClasses(options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-styles/src/withStyles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import warning from 'warning';
import warning from 'tiny-warning';
import { getDynamicStyles } from 'jss';
import { getDisplayName } from '@material-ui/utils';
import { increment } from './indexCounter';
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@babel/runtime": "7.1.2",
"deepmerge": "^2.0.1",
"prop-types": "^15.6.0",
"warning": "^4.0.1"
"tiny-warning": "^1.0.2"
},
"devDependencies": {},
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-system/src/breakpoints.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import warning from 'warning';
import warning from 'tiny-warning';
import PropTypes from 'prop-types';
import merge from './merge';

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-system/src/spacing.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import warning from 'warning';
import warning from 'tiny-warning';
import responsivePropType from './responsivePropType';
import { handleBreakpoints } from './breakpoints';
import merge from './merge';
Expand Down
20 changes: 10 additions & 10 deletions packages/material-ui-system/src/spacing.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from 'chai';
import consoleErrorMock from 'test/utils/consoleErrorMock';
import consoleWarnMock from 'test/utils/consoleWarnMock';
import spacing from './spacing';

describe('spacing', () => {
Expand Down Expand Up @@ -41,11 +41,11 @@ describe('spacing', () => {

describe('warnings', () => {
beforeEach(() => {
consoleErrorMock.spy();
consoleWarnMock.spy();
});

afterEach(() => {
consoleErrorMock.reset();
consoleWarnMock.reset();
});

it('should warn if the value overflow', () => {
Expand All @@ -56,10 +56,10 @@ describe('spacing', () => {
p: 3,
});
assert.deepEqual(output, { padding: undefined });
assert.strictEqual(consoleErrorMock.callCount(), 1);
assert.match(consoleErrorMock.args()[0][0], /the value provided \(3\) overflows\./);
assert.match(consoleErrorMock.args()[0][0], /The supported values are: \[0,3,5\]\./);
assert.match(consoleErrorMock.args()[0][0], /3 > 2, you need to add the missing values\./);
assert.strictEqual(consoleWarnMock.callCount(), 1);
assert.match(consoleWarnMock.args()[0][0], /the value provided \(3\) overflows\./);
assert.match(consoleWarnMock.args()[0][0], /The supported values are: \[0,3,5\]\./);
assert.match(consoleWarnMock.args()[0][0], /3 > 2, you need to add the missing values\./);
});

it('should warn if the theme transformer is invalid', () => {
Expand All @@ -70,13 +70,13 @@ describe('spacing', () => {
p: 3,
});
assert.deepEqual(output, { padding: undefined });
assert.strictEqual(consoleErrorMock.callCount(), 1);
assert.strictEqual(consoleWarnMock.callCount(), 1);
assert.match(
consoleErrorMock.args()[0][0],
consoleWarnMock.args()[0][0],
/the `theme.spacing` value \(\[object Object\]\) is invalid\./,
);
assert.match(
consoleErrorMock.args()[0][0],
consoleWarnMock.args()[0][0],
/It should be a number, an array or a function\./,
);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/material-ui/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"build/umd/material-ui.production.min.js": {
"bundled": 849608,
"minified": 312234,
"gzipped": 85103
"bundled": 849960,
"minified": 312386,
"gzipped": 85138
}
}
2 changes: 1 addition & 1 deletion packages/material-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"react-event-listener": "^0.6.2",
"react-transition-group": "^2.2.1",
"recompose": "0.28.0 - 0.30.0",
"warning": "^4.0.1"
"tiny-warning": "^1.0.2"
},
"sideEffects": false,
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { componentPropType } from '@material-ui/utils';
import warning from 'warning';
import warning from 'tiny-warning';
import withStyles from '../styles/withStyles';

export const styles = theme => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/ButtonBase/focusVisible.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import keycode from 'keycode';
import warning from 'warning';
import warning from 'tiny-warning';
import ownerDocument from '../utils/ownerDocument';

const internal = {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/CardMedia/CardMedia.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import warning from 'warning';
import warning from 'tiny-warning';
import { componentPropType } from '@material-ui/utils';
import withStyles from '../styles/withStyles';

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Chip/Chip.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import keycode from 'keycode';
import warning from 'warning';
import warning from 'tiny-warning';
import { componentPropType } from '@material-ui/utils';
import CancelIcon from '../internal/svg-icons/Cancel';
import withStyles from '../styles/withStyles';
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/ExpansionPanel/ExpansionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import warning from 'warning';
import warning from 'tiny-warning';
import Collapse from '../Collapse';
import Paper from '../Paper';
import withStyles from '../styles/withStyles';
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/GridList/GridList.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import warning from 'warning';
import warning from 'tiny-warning';
import { componentPropType } from '@material-ui/utils';
import withStyles from '../styles/withStyles';

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Hidden/HiddenCss.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import warning from 'warning';
import warning from 'tiny-warning';
import { keys as breakpointKeys } from '../styles/createBreakpoints';
import { capitalize } from '../utils/helpers';
import withStyles from '../styles/withStyles';
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/InputBase/InputBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import warning from 'warning';
import warning from 'tiny-warning';
import classNames from 'classnames';
import { componentPropType } from '@material-ui/utils';
import formControlState from '../FormControl/formControlState';
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/LinearProgress/LinearProgress.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import warning from 'warning';
import warning from 'tiny-warning';
import withStyles from '../styles/withStyles';
import { lighten } from '../styles/colorManipulator';

Expand Down
16 changes: 8 additions & 8 deletions packages/material-ui/src/LinearProgress/LinearProgress.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { assert } from 'chai';
import consoleErrorMock from 'test/utils/consoleErrorMock';
import consoleWarnMock from 'test/utils/consoleWarnMock';
import { createShallow, getClasses } from '@material-ui/core/test-utils';
import LinearProgress from './LinearProgress';

Expand Down Expand Up @@ -166,28 +166,28 @@ describe('<LinearProgress />', () => {

describe('prop: value', () => {
before(() => {
consoleErrorMock.spy();
consoleWarnMock.spy();
});

after(() => {
consoleErrorMock.reset();
consoleWarnMock.reset();
});

it('should warn when not used as expected', () => {
shallow(<LinearProgress variant="determinate" value={undefined} />);
assert.strictEqual(consoleErrorMock.callCount(), 1);
assert.strictEqual(consoleWarnMock.callCount(), 1);
assert.match(
consoleErrorMock.args()[0][0],
consoleWarnMock.args()[0][0],
/Warning: Material-UI: you need to provide a value property/,
);
shallow(<LinearProgress variant="buffer" value={undefined} />);
assert.strictEqual(consoleErrorMock.callCount(), 3);
assert.strictEqual(consoleWarnMock.callCount(), 3);
assert.match(
consoleErrorMock.args()[1][0],
consoleWarnMock.args()[1][0],
/Warning: Material-UI: you need to provide a value property/,
);
assert.match(
consoleErrorMock.args()[2][0],
consoleWarnMock.args()[2][0],
/Warning: Material-UI: you need to provide a valueBuffer property/,
);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/MenuList/MenuList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import keycode from 'keycode';
import warning from 'warning';
import warning from 'tiny-warning';
import ownerDocument from '../utils/ownerDocument';
import List from '../List';

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import warning from 'warning';
import warning from 'tiny-warning';
import keycode from 'keycode';
import { componentPropType } from '@material-ui/utils';
import ownerDocument from '../utils/ownerDocument';
Expand Down
10 changes: 5 additions & 5 deletions packages/material-ui/src/Modal/Modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { assert } from 'chai';
import { spy, stub } from 'sinon';
import PropTypes from 'prop-types';
import keycode from 'keycode';
import consoleErrorMock from 'test/utils/consoleErrorMock';
import consoleWarnMock from 'test/utils/consoleWarnMock';
import { createShallow, createMount, getClasses, unwrap } from '@material-ui/core/test-utils';
import Fade from '../Fade';
import Portal from '../Portal';
Expand Down Expand Up @@ -402,11 +402,11 @@ describe('<Modal />', () => {
document.body.appendChild(focusContainer);
focusContainer.focus();
assert.strictEqual(document.activeElement, focusContainer);
consoleErrorMock.spy();
consoleWarnMock.spy();
});

afterEach(() => {
consoleErrorMock.reset();
consoleWarnMock.reset();
wrapper.unmount();
document.body.removeChild(focusContainer);
});
Expand Down Expand Up @@ -489,8 +489,8 @@ describe('<Modal />', () => {
<Dialog />
</Modal>,
);
assert.strictEqual(consoleErrorMock.callCount(), 1);
assert.match(consoleErrorMock.args()[0][0], /the modal content node does not accept focus/);
assert.strictEqual(consoleWarnMock.callCount(), 1);
assert.match(consoleWarnMock.args()[0][0], /the modal content node does not accept focus/);
});

it('should not attempt to focus nonexistent children', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Paper/Paper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import warning from 'warning';
import warning from 'tiny-warning';
import { componentPropType } from '@material-ui/utils';
import withStyles from '../styles/withStyles';

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Popover/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import warning from 'warning';
import warning from 'tiny-warning';
import debounce from 'debounce'; // < 1kb payload overhead when lodash/debounce is > 3kb.
import EventListener from 'react-event-listener';
import { componentPropType } from '@material-ui/utils';
Expand Down
Loading

0 comments on commit a7c0c82

Please sign in to comment.