Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Conversation

icecream17
Copy link
Contributor

@icecream17 icecream17 commented Mar 30, 2021

This pr uses new javascript syntax

Also by using the new javascript syntax it could change functionality a bit

Also Deepcode noticed some things: https://www.deepcode.ai/app/gh/atom/atom/2beb93b0d7a0447150f52a9326d2c925e64254d2/_/dashboard and I've fixed some problems.

Quantitative Performance Benefits

Well, the build doesn't even succeed yet (#22099). But I think updating will be better for performance

Possible Drawbacks

Updating

Verification Process

The build command doesn't work, but atom-beta --test does. And no errors, so that's great.

Note on commit 1 In the quicksort functions, or some other sort function, I think I changed "shift" to "pop". It's the same thing but faster.

I changed the (Number) thing in some file to warn that binary, octal, and hex literals aren't supported now. (Because the old code doesn't check for this - it uses parseFloat.) Number is generally better than parseFloat but not that much. This doesn't have any affect on the code though.

I randomly've gone through a whole bunch of files so this commit is messy

Sometimes I wasn't sure if `??` could be used, and on those times, a few times I put it there anyways because any code that depends on the obscure exceptions should be fixed. But mostly I didn't change when I was unsure due to laziness

CONTRIBUTING.MD changed, but only for consistency. This was caught by some extension in vscode.
Note on recent commits Most of them just reference that Uzitech originally suggested these changes

Some of them are lint fixes

And then there's one commit that fixed a syntax error

TODO:

  • Revert quicksort function because the tests depend on them
  • Linter fixes
  • Split into multiple PRs
    • (I'll probably just close this one and make new ones from scratch)
    • no-var (superseded by aminya's pr)
    • ??
    • ??=
    • other (maybe also function methods)

Edit: Depends on #21623


View rendered CONTRIBUTING.md

@UziTech
Copy link
Contributor

UziTech commented Mar 30, 2021

Nice work 💯 It is great to see updated code. I love pull requests where the number of lines deleted are greater than the number added. 👍

FYI the tests might continue to fail until #22050 is merged. So don't bang your head if they are failing and you can't figure out why. lol

Copy link
Contributor

@aminya aminya left a comment

Choose a reason for hiding this comment

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

There are some issues with let/const usage. You have used let in many places where the variable is used only once.

For these kinds of changes, you should use automatic tools that verify the changes using JavaScript AST which is more accurate than human eyes.

The whole var conversion can be done using jscodeshift.

npm install -g jscodeshift
git clone https://github.com/cpojer/js-codemod.git
jscodeshift -t js-codemod/transforms/no-vars.js ./src

@@ -611,11 +611,11 @@ module.exports = class Cursor extends Model {
: new Range(position, new Point(position.row, Infinity));

const ranges = this.editor.buffer.findAllInRangeSync(
options.wordRegex || this.wordRegExp(options),
options.wordRegex ?? this.wordRegExp(options),
Copy link
Contributor

@aminya aminya Mar 30, 2021

Choose a reason for hiding this comment

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

Neither Node 12 nor Babel 5 support nullish coalescing

These changes require merging #21623

@@ -63,7 +63,7 @@ module.exports = class DeserializerManager {
const deserializer = this.get(state);
if (deserializer) {
let stateVersion =
(typeof state.get === 'function' && state.get('version')) ||
state.get?.('version') ??
Copy link
Contributor

Choose a reason for hiding this comment

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

Neither Node 12 nor Babel 5 support optional chaining or nullish coalescing

These changes require merging #21623

I don't have access to a terminal right now so aminya's suggestions will happen later
Copy link
Contributor

@aminya aminya left a comment

Choose a reason for hiding this comment

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

@icecream17 This PR is already very hard to verify. Could you make separate PRs for editing individual changes (e.g. one PR for no-var conversion). Also, the commit messages are written very generically. Please be specific/verbose to help the reviewers.

Copy link
Contributor

@aminya aminya left a comment

Choose a reason for hiding this comment

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

I made a PR that supersedes the var conversion

#22103

@icecream17
Copy link
Contributor Author

Closing (will make seperate prs in the future)

@icecream17 icecream17 closed this Mar 31, 2021
@icecream17 icecream17 mentioned this pull request Mar 31, 2021
@icecream17 icecream17 deleted the new-syntax branch April 30, 2021 15:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants