0

I'm currently starting to learn about JavaScript on the server side with node, I've created a project with NPM, implemented some tests, etc.

Something that's bugging me is the ability to force a code style on all files, I've been reading about JSLint and it warns you about the style errors, but I'm looking for a tool that modifies your code to obey a certain standard.

Is there any tool that covers this task?

EDIT

I'm looking for a command line tool, so I can add a task to the project using NPM and I can execute it as:

npm format
eliocs
  • 18,511
  • 7
  • 40
  • 52
  • Are you looking for an editor that helps suggest what you should do or something that will actually modify your code? – kinakuta Feb 20 '12 at 10:23
  • I prefer a command line tool, but I wouldn't mind if it's embedded on the editor, I'm currently using VIM. – eliocs Feb 20 '12 at 10:31

1 Answers1

0

You may want to have a look at something like https://github.com/wbecker/dvcs_hook-jslint-node (and Pre Commit Hook for JSLint in Mercurial and Git) which allows you to run jslint with node, and if you are using a compatible versioning system it may do so on each commit (which is a great way to ensure every file respect your coding standard).

Community
  • 1
  • 1
Shautieh
  • 746
  • 10
  • 17
  • I'm currently using GIT as my code repository so I do consider this as an option. It seems it just shows warnings and avoids the commit instead of modifying your code. – eliocs Feb 20 '12 at 11:14
  • Oh my bad then, I didn't get you wanted this tool to actually modify the source... But are you *sure* you want it to behave that way? This may introduce hard to diagnose bugs in the process (e.g. auto adding a semicolon... :s), and I would rather show the error to the committer so he can change it and actually learn your coding standard. – Shautieh Feb 20 '12 at 14:09
  • Yeah, feels like everybody uses jslint or jshint embedded into their ide and correct the error one by one. Guess there is a reason to it ^^, I tend to be too lazy :P – eliocs Feb 20 '12 at 15:52