Skip to content

FIREFLY-74_upgrade_babel_and_eslint #833

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

Merged
merged 5 commits into from
Jul 18, 2019
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
6 changes: 4 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"plugins": [
"react",
"jsdoc"

"jsdoc",
"react-hooks"
],
/* "settings": {
"jsdoc": {
Expand Down Expand Up @@ -75,6 +75,8 @@
"react/prop-types": [1, {"ignore": ["children"], "skipUndeclared": true}],
"react/react-in-jsx-scope": 1,
"react/self-closing-comp": 1,
"react-hooks/rules-of-hooks": "error", // Checks rules of Hooks
"react-hooks/exhaustive-deps": "warn", // Checks effect dependencies
"semi": [2, "always"],
"space-infix-ops": 0,
"quotes": [2, "single", "avoid-escape"],
Expand Down
12 changes: 11 additions & 1 deletion __jest__/jest.transform.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
// Custom Jest transform implementation that wraps babel-jest and injects our
// babel presets, so we don't have to use .babelrc.

/*eslint no-undef: "error"*/
/*eslint-env node*/

module.exports = require('babel-jest').createTransformer({
presets: ["env", "react", "stage-3"],
presets: [
'@babel/preset-env',
'@babel/preset-react',
],
plugins:[
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-class-properties'
]
});
15 changes: 9 additions & 6 deletions buildScript/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ process.traceDeprecation = true;
* @param {string} config.firefly_root Firefly's build root
* @param {string} [config.firefly_dir] Firefly's JS source directory
* @param {Object} [config.alias] additional alias
* @param {boolean=true} [config.use_loader] generate a loader to load compiled JS script(s). Defautls to true
* @param {boolean=true} [config.use_loader] generate a loader to load compiled JS script(s). Defaults to true
* @param {string} [config.project] project name
* @param {string} [config.filename] name of the generated JS script.
* @param {string} [config.baseWarName] name of the the war file base, defaults to config.name
Expand Down Expand Up @@ -119,19 +119,22 @@ export default function makeWebpackConfig(config) {
// later presets run before earlier for each AST node
// use 'es2015', {modules: false}] for es5 with es6 modules
presets: [
['env',
['@babel/preset-env',
{
targets: {
browsers: ['safari >= 10', 'chrome >= 67', 'firefox >= 60', 'edge >= 16']
},
debug: !ENV_PROD,
modules: false, // preserve application module style - in our case es6 modules
useBuiltIns : true
useBuiltIns : 'usage'
}
],
'react',
'stage-3'],
plugins: ['transform-runtime']
'@babel/preset-react'
],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-class-properties'
]
}
},
{
Expand Down
34 changes: 20 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
"url": "https://github.com/Caltech-IPAC/firefly.git"
},
"dependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"@babel/core": "^7.5.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above plugins are needed now? Do you know what is requiring it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These plugins are used instead of stage-3 plugin. As far as I understood from:
https://github.com/babel/babel-upgrade
(it is mentioned at the end of that link).

Copy link
Contributor

@robyww robyww Jul 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we are using all these. I think we where using stage-3 there before for object expanding (ie.{...x, {y:1}}) when it is not part of the standard.

Let me look at each of these. I will update this comment.

We want:

  • @babel/plugin-transform-runtime

We might be using this one, if not, it is useful:

  • plugin-proposal-class-properties

I don't think we use:

  • plugin-proposal-json-strings
  • plugin-syntax-dynamic-import
  • plugin-syntax-import-meta

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I will take them out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take them out and test, make sure nothing breaks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "^7.0.0",
"@babel/preset-stage-3": "^7.0.0",
"@babel/register": "^7.4.4",
"@babel/runtime-corejs2": "^7.0.0",
"babel-loader": "^8.0.0",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0 ",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"babel-runtime": "^6.26.0",
"classnames": "^2.2.5",
"core-js": "^2.6.4",
"enum": "^2.5",
Expand All @@ -34,6 +36,7 @@
"react": "^16.8",
"react-addons-update": "^15.6.2",
"react-color": "^2.17.0",
"react-datetime": "^2.16.0",
"react-dnd": "^7.0.2",
"react-dnd-html5-backend": "^7.0.2",
"react-dom": "^16.8.1",
Expand All @@ -47,18 +50,21 @@
"redux-thunk": "^2.2",
"shallowequal": "^1.0.2",
"transformation-matrix-js": "^2.7.1",
"validator": "^9.4",
"react-datetime": "^2.16.0"
"validator": "^9.4"
},
"devDependencies": {
"babel-jest": "^23.6.0",
"@babel/core": "^7.5.0",
"@babel/preset-env": "^7.4.4",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.4.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it has to be declared at 2 places?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think those are extra ones. I will go ahead and remove them.
Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

"chai": "^3.5.0",
"css-loader": "^0.19.0",
"eslint": "^4.3.0",
"eslint-loader": "^1.9.0",
"eslint": "^5.1.0",
"eslint-loader": "^2.1.0",
"eslint-plugin-jsdoc": "^v3.4.1",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.6.1",
"eslint-plugin-react-hooks": "^1.6.1",
"file-loader": "^0.9.0",
"ink-docstrap": "^1.2.1",
"jest": "^23.6.0",
Expand All @@ -73,8 +79,8 @@
"script-loader": "^0.6.1",
"style-loader": "^0.12.3",
"url-loader": "^0.5.7",
"webpack-cli": "^3.2",
"webpack": "^4.29",
"webpack-cli": "^3.2",
"webpack-visualizer-plugin": "^0.1.11"
}
}
1 change: 0 additions & 1 deletion src/firefly/js/Firefly.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/

import 'babel-polyfill';
import 'isomorphic-fetch';
import React from 'react';
import ReactDOM from 'react-dom';
Expand Down
5 changes: 4 additions & 1 deletion src/firefly/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* eslint-env node */

require('babel-core/register')({presets: ['env']});
require('@babel/register')({
presets: ['@babel/preset-env'],
ignore: [/node_modules/]
});
var path = require('path');

var firefly_root = path.resolve(__dirname, '../..');
Expand Down
Loading