-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
… using ES6 classes)
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" }], |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@HosseinAgha cool! Thanks for taking this on. |
Thanks for keeping the constant definitions close to their use site. |
@HosseinAgha after you resolve this conflict this should be good to go. |
Thank you all the KaTeX team specially @kevinbarabash for all your help and patiently answering questions. |
@kevinbarabash All Done. |
How it's going? @kevinbarabash |
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. |
@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. |
@kevinbarabash Sure, if you did not do anything yet. |
@HosseinAgha awesome! What kind of issues are you seeing with server.js? |
@kevinbarabash I've described the problem at the end of |
@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 |
@kevinbarabash I created the PR (#756) for server.js fix. I working on fixing conflicts now. |
@kevinbarabash everything is merged and all tests are passing. |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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" }], |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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. | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super minor nit: /**
I just realized that screenshotter also uses |
All Done |
@HosseinAgha thanks for the PR. I'm excited about using ES6 in our codebase. |
Discussed at #654.
I also think this fixes the second issue in the project's backlog here.