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

support presets (google, nodeguide, idiomatic) #2

Closed
millermedeiros opened this issue Dec 10, 2012 · 5 comments
Closed

support presets (google, nodeguide, idiomatic) #2

millermedeiros opened this issue Dec 10, 2012 · 5 comments
Labels

Comments

@millermedeiros
Copy link
Owner

I think we should have presets for the most common styles:

also do it in a way that user can store their settings on the project folder or as a global file.

@jzaefferer
Copy link
Collaborator

The google styleguide is supposed to be the default. They don't provide that many details on code formatting, so we'd probably have to actually run some of their code through the default preset to see what changes. Once obvious difference is the indent: They use two spaces, while the default currently is four spaces.

idiomatic.js seems to overlap a lot with the jQuery Style Guide. Looking around for a bit I didn't spot much differences. It doesn't have the top-level block exception. The guide itself doesn't seem to enforce indentation, but the examples all use two spaces.

nodeguide has even less detail on actual code formatting. Overall it looks very similar to the Google guide, including the two space indentation.

Seems to me like we should change the default for indent.value to two spaces, make other adjustments to match the Google guide and sample code and finish #19 to provide an alternative (jQuery/idiomatic).

If you're okay with changing the indent default, I can make a PR for that and adjust all the tests.

@piuccio
Copy link
Contributor

piuccio commented Aug 23, 2013

Hi, I wrote an extremely simple tool that formats your files (of course without changing them) and tells you how close they are to the formatted version.

It doesn't try to infer any configuration option, but at least it can be used to tweak it.

The project is called esformatter-diff and can be used like this

npm install -g esformatter-diff
cd your/source/code
esformatter-diff --default
# or
esformatter-diff myOptions.json

@millermedeiros
Copy link
Owner Author

just a FYI that the preset logic is already in place, just need to create the JSON files with the settings and update the lib/options.js file. the user would set it like:

code = esformatter.format(code, {"preset": "idiomatic"});

and later we need to add an option to the cli as well like:

esformatter -p idiomatic foo.js

@millermedeiros
Copy link
Owner Author

the latest 3 commits added support for presets and also for preset inheritance - so user can say his config is based on jquery style guide for instance and just tweak the values he needs.

// use all the jQuery settings and overwrite the "indent.value"
{
  "preset": "jquery",
  "indent": {
    "value": "  "
  } 
}

now we need to finish the settings and start implementing the actual config files for different style guides (after we finish pending tasks). jQuery style guide will be the first one to be added since a lot of people is asking for it but feel free to provide pull requests for different style guides (as long as they are popular).

@millermedeiros
Copy link
Owner Author

the preset logic is in place, so I'm going to close this issue (and will handle each preset as a separate issue).

uiur pushed a commit to uiur/esformatter that referenced this issue Aug 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants