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

Add prettier - code formatter #51

Closed
Proxtx opened this issue Dec 1, 2019 · 8 comments
Closed

Add prettier - code formatter #51

Proxtx opened this issue Dec 1, 2019 · 8 comments

Comments

@Proxtx
Copy link

Proxtx commented Dec 1, 2019

Prettier
Prettier is available for a lot of popular code editors:
VS code, VS, Atom, Webstorm and a lot more.
I don't think it will be hard to implement!🤔
👍😁

@spck-io
Copy link
Collaborator

spck-io commented Dec 4, 2019

There is already an unopinionated code formatter called indent.js that can be accessed in the plus icon menu of the quick keyboard, but if you prefer to use prettier, I can add this as an alternative opinionated formatter that can be changed in the settings.

@Proxtx
Copy link
Author

Proxtx commented Dec 4, 2019

I already discovered this tool but it is a little but it is not working very good:
`function createBlocks (width, height){
for(var i = 0;i<Math.floor(fieldWidth/width);i++){
blocksArray.push([]);
for(var z = 0;z<Math.floor(fieldHeight/height);z++){
blocksArray[i].push({color: "#000000"});
}
}
}

function loadBlocks (width, height){
  for(var i = 0;i<blocksArray.length;i++){
    for(var z = 0;z<blocksArray[i].length;z++){
      if(blocksArray[i][z].color){
        ctx.fillStyle=blocksArray[i][z].color;
      }
      ctx.fillRect(i*width, z*height, width, height);
    }
    }
    }
    initCanvas();
    createBlocks(blockWidth, blockHeight);
    genApple();
    loadBlocks(blockWidth, blockHeight);
    
    
    
    //Game
    
    function updateSnake (){`

For no reason it inserts spaces to the code.

@Proxtx
Copy link
Author

Proxtx commented Dec 4, 2019

I think nobody is actively developing indent.js(look at the dates)
Screenshot_20191204-163346

@spck-io
Copy link
Collaborator

spck-io commented Dec 4, 2019

Ok, I can switch it. I am the developer for indent.js and there has been no bug reports on the repo. Just wondering if prettier can be configured to not put each element of an array on a new line? I find it super annoying when code prettifiers add a whole bunch of new lines to my code, but maybe that’s just me...

@Proxtx
Copy link
Author

Proxtx commented Dec 4, 2019

Maby you just add an option to the settings to choice which prettifier to use.

@Proxtx
Copy link
Author

Proxtx commented Dec 4, 2019

prettest.zip
Here is an test script by me (edit code.txt and run script)
A great think I like of prettier is the semi: true option Wich adds semicolons.

@spck-io
Copy link
Collaborator

spck-io commented Dec 4, 2019

I looked into prettier and I’m shocked that the standalone bundle is over 30000 lines of code. Even when gzipped it still is a huge file, not to mention parsing through so much JavaScript will further slow down the editor load time. I’m going to switch to jsbeautifier, alternately I can refractor the formatter into a webworker, which hopefully shouldn’t bog down the editor start up time.

@Proxtx
Copy link
Author

Proxtx commented Dec 4, 2019

Ok... I'm really looking forward to it!

@Proxtx Proxtx closed this as completed Dec 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants