-
Notifications
You must be signed in to change notification settings - Fork 14
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
Sort require statements #595
Comments
I added a grunt task that sorts require statements alphabetically. It seems like it is working OK on CCK code. But it could use broader testing and review. |
Here is the grunt doc and usage: sort-require-statements Sort the require statements for all *.js
files in the js/ directory. This assumes the
code is formatted with IDEA code style and
that require statements take one line each
(not split across lines). The files are
overwritten. |
This code would benefit from a regular expression. |
Also, we could update this to sort by package if we want. |
I'm done working on this, no plans to update further at the moment. |
Upon reflection, I thought it might be more useful to sort by repo then class name (so all DOT things are together, SCENERY things are together, etc.) . However, this would be incompatible with other team members using alphabetical sort (like in Sublime). Note: this will also put model things together and view things together. |
I'll be fine with either approach, but would only prefer path-sorting if sorting is an easy in-IDE shortcut in IDEA and Sublime. |
It would also be possible to add a script or step that removes unused require statements. We would adapt or factor out lint.js to work on a single file and return a report. It would take 1-2 hours to build this, document it and integrate it with existing tools. |
After Slack discussion in dev-public channel, we decided to sort by filename instead of path. @samreid has made it so in the above commit. |
We also decided to run |
@jonathanolson mentioned that he and some other developers sometimes like to alphabetically sort the require statements. I asked on skype and heard 3 "yesses" right away, this is in addition to @jonathanolson. Sublime had built in support for this. IDEA doesn't have built in support for it (though maybe a plugin), but it would be nice if we had a tool for this.
The text was updated successfully, but these errors were encountered: