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 the source to use ES6 syntax including classes, import and static properties #679

Merged
merged 13 commits into from
Jul 3, 2017

Conversation

HosseinAgha
Copy link
Collaborator

@HosseinAgha HosseinAgha commented Apr 9, 2017

Discussed at #654.
I also think this fixes the second issue in the project's backlog here.

@khanbot
Copy link

khanbot commented Apr 9, 2017

CLA signature looks good 👍

.eslintrc Outdated
@@ -14,7 +15,7 @@
"indent": [2, 4, {"SwitchCase": 1}],
"keyword-spacing": 2,
"linebreak-style": [2, "unix"],
"max-len": [2, 80, 4, { "ignoreUrls": true, "ignorePattern": "\\brequire\\([\"']|eslint-disable" }],
"max-len": [2, 90, 4, { "ignoreUrls": true, "ignorePattern": "\\brequire\\([\"']|eslint-disable" }],
Copy link
Member

Choose a reason for hiding this comment

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

why the change in max length?

Copy link
Member

Choose a reason for hiding this comment

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

Answering my own question: because of the extra indent. I'm fine with this.

Copy link
Member

Choose a reason for hiding this comment

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

My two cents: I'm a fan of limiting to 80 columns. All my terminal windows are that wide, thanks to good old punch cards...

Copy link
Member

Choose a reason for hiding this comment

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

@HosseinAgha how much of the code would be affected by keeping the 80 column limit?

Copy link
Collaborator Author

@HosseinAgha HosseinAgha Apr 16, 2017

Choose a reason for hiding this comment

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

@kevinbarabash Adding classes adds about 4 spaces to each line. I can decrease it to 84 but a number less than that makes a lot of lint errors.
most of the Parser code (about 13 lines) would have error for example.

.gitignore Outdated
@@ -4,6 +4,7 @@ npm-debug.log
last.png
diff.png
/.npm-install.stamp
/.vscode
Copy link
Member

Choose a reason for hiding this comment

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

could add this to your global .gitignore?

Copy link
Collaborator Author

@HosseinAgha HosseinAgha Apr 16, 2017

Choose a reason for hiding this comment

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

@kevinbarabash sorry I missed that one. Fixed.

@kevinbarabash
Copy link
Member

@HosseinAgha cool! Thanks for taking this on.

@kevinbarabash
Copy link
Member

Thanks for keeping the constant definitions close to their use site.

@kevinbarabash
Copy link
Member

@HosseinAgha after you resolve this conflict this should be good to go.

@HosseinAgha
Copy link
Collaborator Author

HosseinAgha commented Apr 16, 2017

Thank you all the KaTeX team specially @kevinbarabash for all your help and patiently answering questions.

@HosseinAgha
Copy link
Collaborator Author

HosseinAgha commented Apr 16, 2017

@kevinbarabash All Done.

@HosseinAgha HosseinAgha changed the title Upgrade the source to use ES6 classes, import, static syntax Upgrade the source to use ES6 classes, import, static properties and syntax Apr 16, 2017
@HosseinAgha HosseinAgha changed the title Upgrade the source to use ES6 classes, import, static properties and syntax Upgrade the source to use ES6 syntax including classes, import and static properties Apr 16, 2017
@pouriaMaleki
Copy link

How it's going? @kevinbarabash

@kevinbarabash
Copy link
Member

I forgot about this PR :(. I'd like to land #670 first b/c I think it's going to be less work to rebase this on to those changes than the other way around. @HosseinAgha sorry about not merging this sooner and avoid extra work for you.

@kevinbarabash
Copy link
Member

@HosseinAgha #670 has been merged. As a result there are lots of conflicts. :sad: Would you be willing to rebase this? If not, no worries. I have some and come open a fresh PR for this.

@HosseinAgha
Copy link
Collaborator Author

HosseinAgha commented Jun 30, 2017

@kevinbarabash Sure, if you did not do anything yet.
I had problems with server.js file you have a babel and none babel endpoint for it. Is it OK to change it to only use babel transpiled files?
I will start merging as soon as you give a OK here.

@kevinbarabash
Copy link
Member

@HosseinAgha awesome! What kind of issues are you seeing with server.js?

@HosseinAgha
Copy link
Collaborator Author

HosseinAgha commented Jul 1, 2017

@kevinbarabash I've described the problem at the end of
this issue

@kevinbarabash
Copy link
Member

@HosseinAgha thanks or refreshing my memory. I don't think we have much of choice here. Could you make a separate PR for the changes to server.js?

@HosseinAgha
Copy link
Collaborator Author

@kevinbarabash OK

@HosseinAgha
Copy link
Collaborator Author

HosseinAgha commented Jul 2, 2017

@kevinbarabash I created the PR (#756) for server.js fix. I working on fixing conflicts now.

@HosseinAgha
Copy link
Collaborator Author

HosseinAgha commented Jul 2, 2017

@kevinbarabash everything is merged and all tests are passing.
Could you please consider merging this before any new merge? because fixing merge conflicts in this scale is a bit time consuming and git is a bit dumb in this case. Thanks.

Copy link
Member

@kevinbarabash kevinbarabash left a comment

Choose a reason for hiding this comment

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

Requesting changes to server.js before this can proceed.

server.js Outdated
@@ -47,8 +47,9 @@ function serveBrowserified(file, standaloneName, doBabelify) {
}

function twoBrowserified(url, file, standaloneName) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you change the name to browserified?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

server.js Outdated
app.get("/babel" + url, serveBrowserified(file, standaloneName, true));
// we should always transpile all js files
// in order to support all ES2015 features
app.get(url, serveBrowserified(file, standaloneName, true));
}

function twoUse(url, handler) {
Copy link
Member

Choose a reason for hiding this comment

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

We don't need the /babel endpoints that this function generates either. Can you replace all calls to twoUse with app.use?

@@ -14,7 +15,7 @@
"indent": [2, 4, {"SwitchCase": 1}],
"keyword-spacing": 2,
"linebreak-style": [2, "unix"],
"max-len": [2, 80, 4, { "ignoreUrls": true, "ignorePattern": "\\brequire\\([\"']|eslint-disable" }],
"max-len": [2, 84, 4, { "ignoreUrls": true, "ignorePattern": "\\brequire\\([\"']|eslint-disable" }],
Copy link
Member

Choose a reason for hiding this comment

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

I'm okay with this for this commit, but we should revert it afterwards. How do other people feel?

}
};
}

Parser.prototype.ParseNode = ParseNode;
Copy link
Member

Choose a reason for hiding this comment

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

Within the class you could have a line ParseNode = ParseNode. This is similar to static ParseNode = ParseNode but adds the value to the prototype instead of the class itself.

@@ -84,26 +79,36 @@ const tokenRegex = new RegExp(
")"
);

/**
* This function lexes a single token.
/*
Copy link
Member

Choose a reason for hiding this comment

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

super minor nit: /**

@kevinbarabash
Copy link
Member

I just realized that screenshotter also uses /babel endpoint. Can you update screenshotter.js to not use the /babel endpoint?

@HosseinAgha
Copy link
Collaborator Author

All Done

@kevinbarabash
Copy link
Member

@HosseinAgha thanks for the PR. I'm excited about using ES6 in our codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants