Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to the stable babel 7 release #460

Merged
merged 3 commits into from
Aug 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions .babelrc

This file was deleted.

14 changes: 10 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ defaults: &defaults
docker:
- image: circleci/node:8
restore_repo: &restore_repo
restore_cache:
keys:
- v1-repo-{{ .Branch }}-{{ .Revision }}
# The cache logic of CircleCI has been disabled for Security reasons.
# We can no longer use it.
# restore_cache:
# keys:
# - v1-repo-{{ .Branch }}-{{ .Revision }}
run:
name: Install js dependencies
command: yarn
version: 2
jobs:
checkout:
<<: *defaults
steps:
- *restore_repo
- checkout
- *restore_repo
- run:
name: Check versions and env
command: |
Expand Down Expand Up @@ -41,6 +46,7 @@ jobs:
test_unit:
<<: *defaults
steps:
- checkout
- *restore_repo
- run:
name: Lint
Expand Down
11 changes: 6 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.git
/.next/
node_modules
/.next
/coverage
/docs/export
/docs/src/modules/utils/find.js
/flow/interfaces
lib/
/next.config.js
/docs/src/modules/utils/find.js
/docs/export/
lib/
node_modules
51 changes: 31 additions & 20 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const path = require('path');

module.exports = {
// So parent files don't get applied
root: true,
Expand All @@ -20,18 +22,20 @@ module.exports = {
settings: {
'import/resolver': {
webpack: {
config: './docs/webpackBaseConfig.js',
config: path.join(__dirname, './docs/webpackBaseConfig.js'),
},
},
},
rules: {
'linebreak-style': 'off', // Don't play nicely with Windows.
'arrow-body-style': 'off', // Not our taste?
'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
'consistent-this': ['error', 'self'],
'max-len': [
Expand All @@ -43,25 +47,29 @@ module.exports = {
},
], // airbnb is allowing some edge cases
'no-console': 'error', // airbnb is using warn
'prefer-destructuring': 'off', // airbnb is using error. destructuring harm grep potential.
'no-alert': 'error', // airbnb is using warn
'no-param-reassign': 'off', // Not our taste?
'no-param-reassign': 'off', // airbnb use error
'no-prototype-builtins': 'off', // airbnb use error
'object-curly-spacing': 'off', // use babel plugin rule
'no-restricted-properties': 'off', // To remove once react-docgen support ** operator.
'prefer-destructuring': 'off', // To remove once react-docgen support ** operator.

'babel/object-curly-spacing': ['error', 'always'],
'operator-linebreak': 'off', // airbnb use error

'import/unambiguous': 'off', // scripts
'import/namespace': ['error', { allowComputed: true }],
// It would be better to enable this rule, but it might slow us down.
'import/no-extraneous-dependencies': 'off',
'import/extensions': 'off',
'import/no-unresolved': 'off',
'import/namespace': ['error', { allowComputed: true }],
'import/order': [
'error',
{
groups: [['index', 'sibling', 'parent', 'internal', 'external', 'builtin']],
'newlines-between': 'never',
},
],
'import/no-unresolved': 'off', // To fix at some point

'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',
{
Expand All @@ -70,23 +78,26 @@ module.exports = {
eventHandlerPropPrefix: 'on',
},
],
'react/require-default-props': 'off', // airbnb use error
'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 disabling this rule
'react/no-find-dom-node': 'off', // I don't know
'react/no-unused-prop-types': 'off', // Is still buggy
'react/sort-prop-types': 'error', // airbnb do nothing here.
'react/default-props-match-prop-types': 'off', // Buggy
'react/jsx-curly-brace-presence': 'off', // Buggy
'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

'mocha/handle-done-callback': 'error',
'mocha/no-exclusive-tests': 'error',
'mocha/no-global-tests': 'error',
'mocha/no-pending-tests': '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.

'prettier/prettier': ['error'],
},
};
163 changes: 163 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
let defaultPresets;

// We release a ES version of Material-UI.
// It's something that matches the latest official supported features of JavaScript.
// Nothing more (stage-1, etc), nothing less (require, etc).
if (process.env.BABEL_ENV === 'es') {
defaultPresets = [];
} else {
defaultPresets = [
[
'@babel/preset-env',
{
targets: {
ie: 10,
edge: 14,
firefox: 28,
chrome: 29,
safari: 9,
node: '6.11',
},
modules: ['modules', 'production-umd'].includes(process.env.BABEL_ENV) ? false : 'commonjs',
},
],
];
}

module.exports = {
presets: defaultPresets.concat(['@babel/preset-react']),
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }],
[
'@babel/plugin-proposal-object-rest-spread',
{
// Workaround for /~https://github.com/babel/babel/issues/8323
loose: process.env.BABEL_ENV !== 'es',
},
],
'@babel/plugin-transform-object-assign',
'@babel/plugin-transform-runtime',
],
env: {
coverage: {
plugins: [
'babel-plugin-istanbul',
[
'babel-plugin-module-resolver',
{
root: ['./'],
alias: {
pages: './pages',
'react-swipeable-views': './packages/react-swipeable-views/src',
'react-swipeable-views-utils': './packages/react-swipeable-views-utils/src',
'react-swipeable-views-core': './packages/react-swipeable-views-core/src',
docs: './docs',
},
},
],
],
},
development: {},
'docs-development': {
plugins: [
'babel-plugin-preval',
[
'babel-plugin-module-resolver',
{
alias: {
'react-swipeable-views': './packages/react-swipeable-views/src',
'react-swipeable-views-core': './packages/react-swipeable-views-core/src',
'react-swipeable-views-utils': './packages/react-swipeable-views-utils/src',
docs: './docs',
pages: './pages',
},
},
],
],
},
'docs-production': {
plugins: [
'babel-plugin-preval',
[
'babel-plugin-module-resolver',
{
alias: {
'react-swipeable-views': './packages/react-swipeable-views/src',
'react-swipeable-views-core': './packages/react-swipeable-views-core/src',
'react-swipeable-views-utils': './packages/react-swipeable-views-utils/src',
docs: './docs',
pages: './pages',
},
},
],
'transform-react-constant-elements',
'transform-dev-warning',
['react-remove-properties', { properties: ['data-mui-test'] }],
['transform-react-remove-prop-types', { mode: 'remove' }],
],
},
es: {
plugins: [
'transform-react-constant-elements',
'transform-dev-warning',
['react-remove-properties', { properties: ['data-mui-test'] }],
[
'transform-react-remove-prop-types',
{
mode: 'wrap',
},
],
],
// It's most likely a babel bug.
// We are using this ignore option in the CLI command but that has no effect.
ignore: ['**/*.test.js'],
},
production: {
plugins: [
'transform-react-constant-elements',
'transform-dev-warning',
['react-remove-properties', { properties: ['data-mui-test'] }],
[
'transform-react-remove-prop-types',
{
mode: 'wrap',
},
],
],
// It's most likely a babel bug.
// We are using this ignore option in the CLI command but that has no effect.
ignore: ['**/*.test.js'],
},
'production-umd': {
plugins: [
'transform-react-constant-elements',
'transform-dev-warning',
['react-remove-properties', { properties: ['data-mui-test'] }],
[
'transform-react-remove-prop-types',
{
mode: 'wrap',
},
],
],
},
test: {
sourceMaps: 'both',
plugins: [
[
'babel-plugin-module-resolver',
{
root: ['./'],
alias: {
'react-swipeable-views': './packages/react-swipeable-views/src',
'react-swipeable-views-core': './packages/react-swipeable-views-core/src',
'react-swipeable-views-utils': './packages/react-swipeable-views-utils/src',
docs: './docs',
pages: './pages',
},
},
],
],
},
},
};
Loading