diff --git a/.eslintrc.js b/.eslintrc.js index ce319a3d37f558..b928c441e32463 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,10 +1,9 @@ const path = require('path'); module.exports = { - // So parent files don't get applied - root: true, + root: true, // So parent files don't get applied globals: { - preval: false, + preval: false, // Used in the documentation }, env: { es6: true, @@ -12,13 +11,13 @@ module.exports = { node: true, mocha: true, }, - extends: ['plugin:import/recommended', 'airbnb'], + extends: ['plugin:import/recommended', 'airbnb', 'prettier'], parser: 'babel-eslint', parserOptions: { ecmaVersion: 7, sourceType: 'module', }, - plugins: ['babel', 'import', 'jsx-a11y', 'mocha', 'material-ui'], + plugins: ['babel', 'mocha', 'material-ui'], settings: { 'import/resolver': { webpack: { @@ -27,16 +26,35 @@ module.exports = { }, }, rules: { - 'linebreak-style': 'off', // Don't play nicely with Windows - 'arrow-body-style': 'off', // Incompatible with prettier - 'arrow-parens': 'off', // Incompatible with prettier - 'object-curly-newline': 'off', // Incompatible with prettier - 'function-paren-newline': 'off', // Incompatible with prettier - indent: 'off', // Incompatible with prettier - 'implicit-arrow-linebreak': 'off', // Incompatible with prettier - 'space-before-function-paren': 'off', // Incompatible with prettier - 'no-confusing-arrow': 'off', // Incompatible with prettier - 'no-mixed-operators': 'off', // Incompatible with prettier + // Incompatible with prettier + 'react/jsx-wrap-multilines': 'off', + 'react/jsx-one-expression-per-line': 'off', + 'react/jsx-indent': 'off', + + // It's buggy + 'react/jsx-curly-brace-presence': 'off', + 'react/require-default-props': 'off', + 'jsx-a11y/label-has-associated-control': 'off', + 'jsx-a11y/label-has-for': 'off', // deprecated + + // Strict, airbnb is using warn + 'no-console': 'error', + 'no-alert': 'error', + 'react/no-danger': 'error', + + // Strict, airbnb is using off + 'react/no-direct-mutation-state': 'error', + 'react/sort-prop-types': 'error', + + // Airbnb use error + 'no-param-reassign': 'off', + 'no-prototype-builtins': 'off', + 'react/forbid-prop-types': 'off', + 'react/destructuring-assignment': 'off', + 'react/no-find-dom-node': 'off', + + 'jsx-a11y/no-autofocus': 'off', // We are a library, people do what they want. + 'prefer-destructuring': 'off', // Destructuring harm grep potential. 'consistent-this': ['error', 'self'], 'max-len': [ 'error', @@ -46,16 +64,7 @@ module.exports = { ignoreUrls: true, }, ], // airbnb is allowing some edge cases - 'no-console': 'error', // airbnb is using warn - 'template-curly-spacing': 'off', // Crash - 'prefer-destructuring': 'off', // airbnb is using error. destructuring harm grep potential. - 'no-alert': 'error', // airbnb is using warn - 'no-param-reassign': 'off', // airbnb use error - 'no-prototype-builtins': 'off', // airbnb use error - 'operator-linebreak': 'off', // airbnb use error - - // It would be better to enable this rule, but it might slow us down. - 'import/no-extraneous-dependencies': 'off', + 'import/no-extraneous-dependencies': 'off', // It would be better to enable this rule. 'import/namespace': ['error', { allowComputed: true }], 'import/order': [ 'error', @@ -64,12 +73,6 @@ module.exports = { 'newlines-between': 'never', }, ], - - 'react/jsx-indent': 'off', // Incompatible with prettier - 'react/jsx-closing-bracket-location': 'off', // Incompatible with prettier - 'react/jsx-wrap-multilines': 'off', // Incompatible with prettier - 'react/jsx-indent-props': 'off', // Incompatible with prettier - 'react/jsx-one-expression-per-line': 'off', // Incompatible with prettier 'react/jsx-handler-names': [ 'error', { @@ -78,26 +81,19 @@ module.exports = { eventHandlerPropPrefix: 'on', }, ], - 'react/jsx-curly-brace-presence': 'off', // airbnb use error, it's buggy - 'react/forbid-prop-types': 'off', // airbnb use error - 'react/require-default-props': 'off', // airbnb use error, it's buggy - 'react/destructuring-assignment': 'off', // airbnb use error 'react/jsx-filename-extension': ['error', { extensions: ['.js'] }], // airbnb is using .jsx - 'react/no-danger': 'error', // airbnb is using warn - 'react/no-direct-mutation-state': 'error', // airbnb is using off - 'react/no-find-dom-node': 'off', // airbnb use error - 'react/sort-prop-types': 'error', // airbnb use off - 'material-ui/docgen-ignore-before-comment': 'error', - 'mocha/handle-done-callback': 'error', 'mocha/no-exclusive-tests': 'error', 'mocha/no-global-tests': 'error', + 'mocha/no-identical-title': 'error', + 'mocha/no-nested-tests': 'error', 'mocha/no-pending-tests': 'error', + 'mocha/no-return-and-callback': 'error', + 'mocha/no-sibling-hooks': 'error', 'mocha/no-skipped-tests': 'error', - - 'jsx-a11y/label-has-associated-control': 'off', - 'jsx-a11y/label-has-for': 'off', - 'jsx-a11y/no-autofocus': 'off', // We are a library, people do what they want. + 'mocha/no-top-level-hooks': 'error', + 'mocha/prefer-arrow-callback': 'error', + 'mocha/valid-suite-description': 'error', }, }; diff --git a/docs/src/modules/components/Demo.js b/docs/src/modules/components/Demo.js index 79f3c6414f2cd8..1ab5fd2fc11c2c 100644 --- a/docs/src/modules/components/Demo.js +++ b/docs/src/modules/components/Demo.js @@ -235,16 +235,14 @@ class Demo extends React.Component { }); } - this.setState(prevState => { - return { - /** - * if the the same code type is open, - * toggle the state, otherwise if it is - * another code type always open it. i.e, true - */ - codeOpen: this.props.codeVariant === codeVariant ? !prevState.codeOpen : true, - }; - }); + this.setState(prevState => ({ + /** + * if the the same code type is open, + * toggle the state, otherwise if it is + * another code type always open it. i.e, true + */ + codeOpen: this.props.codeVariant === codeVariant ? !prevState.codeOpen : true, + })); }; handleClickCodeOpen = () => { diff --git a/docs/src/modules/utils/helpers.test.js b/docs/src/modules/utils/helpers.test.js index f4db78a4a17812..7e654f497a4348 100644 --- a/docs/src/modules/utils/helpers.test.js +++ b/docs/src/modules/utils/helpers.test.js @@ -20,7 +20,7 @@ const styles = theme => ({ formContro `; - it('generates the right npm dependencies', () => { + it('should handle @ dependencies', () => { assert.deepEqual(getDependencies(s1), { '@foo-bar/bip': 'latest', '@material-ui/core': 'latest', @@ -30,7 +30,7 @@ const styles = theme => ({ }); }); - it('generates the right npm dependencies', () => { + it('should handle * dependencies', () => { const s2 = ` import React from 'react'; import PropTypes from 'prop-types'; @@ -56,7 +56,7 @@ const suggestions = [ }); }); - it('generates the right npm dependencies', () => { + it('should support next dependencies', () => { assert.deepEqual(getDependencies(s1, 'next'), { '@foo-bar/bip': 'latest', '@material-ui/core': 'latest', @@ -66,7 +66,7 @@ const suggestions = [ }); }); - it('generates the right npm dependencies', () => { + it('should support direct import', () => { const s3 = ` import 'date-fns'; import React from 'react'; diff --git a/docs/src/pages/demos/autocomplete/IntegrationAutosuggest.js b/docs/src/pages/demos/autocomplete/IntegrationAutosuggest.js index 0e0341b1033f96..1c848d920cdc2c 100644 --- a/docs/src/pages/demos/autocomplete/IntegrationAutosuggest.js +++ b/docs/src/pages/demos/autocomplete/IntegrationAutosuggest.js @@ -74,8 +74,8 @@ function renderSuggestion(suggestion, { query, isHighlighted }) { return (
- {parts.map((part, index) => { - return part.highlight ? ( + {parts.map((part, index) => + part.highlight ? ( {part.text} @@ -83,8 +83,8 @@ function renderSuggestion(suggestion, { query, isHighlighted }) { {part.text} - ); - })} + ), + )}
); diff --git a/docs/src/pages/demos/buttons/TextButtons.js b/docs/src/pages/demos/buttons/TextButtons.js index c49dcf881cff9f..e8d40843bf5ce3 100644 --- a/docs/src/pages/demos/buttons/TextButtons.js +++ b/docs/src/pages/demos/buttons/TextButtons.js @@ -32,11 +32,11 @@ function TextButtons(props) { -