-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Plan to switch to ES6 syntax #9718
Comments
I'm curious about the switch to I'm also curious to see when we can use
And other ES6 features (e.g. spread syntax where right now we use shallow |
I'm glad to see the official intention to update the syntax of the source code. Using if (isUnderground) { // <- Error, `isUnderground` is not defined
// do something
}
let isUnderground = false if use if (isUnderground) {
// do something
}
var isUnderground = false
import { Cartesian3 } from 'cesium'
const coords = new Cartesian3(100, 200, 0)
coords = 0 // Uncaught TypeError: Assignment to constant variable. If you use For the Modularization technology has been changed from I have used the The above are some of my simple views, I hope it will be useful to the official. In addition, is it possible to extract the math module of CesiumJS (most of the codes is in the |
Related issue: #9610 |
First of all, I just want to say I'm very excited to see that #10026 got merged yesterday! Already enjoying being able to use I'm very curious about what's next, as there's many ES6+ features I wish I could be using. this site has a good overview of features, though it's only ES6, not the later versions (e.g. Given what my team is working on (3D Tiles Next features and Small ImprovementsThese features would be nice to have, at least for new code.
// I want to do this
return {
property1,
property2
}
// instead of this which I find myself doing quite often in ES5
return {
property1: property1,
property2: property2
}
Larger Questions:
|
As a part of this, we should revisit Cesium's default eslintrc configuration as a whole (and the shared eslint-cesium plugin in this repository) to remove the out of date and unneeded rules keeping us on es5 syntax. |
Background
MotivationCesiumJS currently disallows using many language features of ES6 (as seen here). As part of our efforts to modernize the CesiumJS code base and tooling, we want to revisit our usage of ESLint and take advantage of the latest features. This will be beneficial to all contributors to CesiumJS. Proposed ChangesMove eslint-config-cesium to its own repository
graph TD;
eslint:recommended-->eslint-config-cesium:::cesium;
eslint-config-cesium-->eslint-config-cesium/browser:::cesium;
eslint-config-cesium-->eslint-config-cesium/node:::cesium;
classDef cesium color:#6dabe4
Upgrading eslint configuration in CesiumJS
graph TD;
eslint-config-cesium/node.js:::ES6-->.eslintrc.json:::ES6;
eslint-config-prettier:::ES6-->.eslintrc.json:::ES6;
eslint-config-cesium/browser.js:::ES6-->Source/.eslintrc.json:::ES5;
eslint-config-prettier-->Source/.eslintrc.json;
eslint-plugin-es:::ES5-->Source/.eslintrc.json;
Source/.eslintrc.json:::ES5-->Apps/.eslintrc.json;
Apps/.eslintrc.json:::ES5-->Apps/TimelineDemo/.eslintrc.json:::ES5;
Apps/.eslintrc.json-->Apps/Sandcastle/.eslintrc.json:::ES5;
Source/.eslintrc.json-->Specs/.eslintrc.json:::ES5;
Specs/.eslintrc.json-->Specs/TestWorkers/.eslintrc.json:::ES5;
classDef ES6 color:#3fb950
classDef ES5 color:#da3633
ExceptionsAs of 1.93, we use disable eslint in our code for the following rules:
Note: It was easy enough to find these because in most cases, we specify the rule being broken. However, in other cases, we just use Current RulesAt the moment, the primary source of ES6 restrictions come from the
Since each of these is composed of many rules, it may be cumbersome to create a PR for each one. Therefore, I propose that we incrementally work through each of these plugins - with a PR for removing the restrictions for each one, eventually ending up with support for ECMAScript 2020, which is what we should set our Additionally, going through the ESLint documentation for environments, I noticed that the Another step may be to use Proposed RulesI went through all the rules available in
Ideally, anything we exclude we exclude with good reason. I selected these on first impression and am hoping I can get more feedback on what we should allow or not. Upgrade coding guide
|
While I think its definitely possible to cut down on the number here, we will most likely still need a few variations based on the target environment. As part of this plan, can we recommend a new simplified "dependency tree"? |
@ggetz Could you review the updated comment above? I've added my ideas for how we should proceed with these changes and compiled a list of rules we may want to impose. |
Before we get too deep into what rules we plan on adding, I would suggest we streamline our existing configs first. That would include turning off
More linting types certainly isn't a bad idea, but is tangential to this effort. Let's come back to those after first streamlining our configuration. Perhaps open a separate issue. |
I believe any actionable items here have been completed moved to other issues. |
Now that IE support has been dropped in 1.84, we should make a plan to update our code. This issue can be a place to brainstorm ideas for these changes.
There are some things that need to happen before we can start making changes in CesiumJS:
Other things to think about:
when
library is not completely compatible with native promises, use ofasync
andawait
might need to be delayed until we get rid ofwhen
.var
tolet
andconst
now? Some of this effort already started with the last gltf-pipeline PR: Update build-cesium task to account for prettier formatting gltf-pipeline#600.The text was updated successfully, but these errors were encountered: