Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
/ styleguru Public archive

A little tool to check that your source files meet your code style.

Notifications You must be signed in to change notification settings

wibblymat/styleguru

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StyleGuru

Build Status

A little tool to check that your source files meet your code style.

##What is this?

This is an unfinished, proof-of-concept tool for checking that JavaScript source files meet YOUR code style guidelines. For the moment it should be considered an experiment.

It should report the errors by default - optionally in a format that other tools can consume - but it should also be capable of fixing the errors it finds automatically.

##Isn't there already something like this out there?

Not that I could find, but please let me know if you know of something!

The closest alternatives:

  • JSHint/JSLint - Both of these tools support an option called "white" that will enable a check for "correct" whitespace. Unfortunately the whitespace rules are not configurable and not well-documented. While many have been chosen for sensible reasons, there is a good chunk of Douglas Crockford's personal taste embedded. These tools can only alert you to style problems, not fix them.
  • fixjsstyle - This tool is part of the Google Closure Linter. When it detects simple problems it just fixes them, which is great. Still not configurable, though, so if you aren't working to the Google Style Guide it is no use.
  • CodePainter - This tool is meant to find and/or fix code in abitrary style, much like StyleGuru. Sadly the project has been abandoned. The author has stated that he wasn't happy with the approach he was taking so it is unlikely to be resurrected.

##So where have you got to?

I'm blocked on a couple of issues I'm not sure how to solve, but it should let you know when you deviate from my own personal style preferences. There are a few false positives at the moment though. The output is big mess of JSON.

Most of my blocking issues could be solved by forking Esprima and adding some extra detail to the AST it produces - nodes for parenthesised sub-expressions and parameter/argument lists, adding tokens to the node they belong to rather than having just one set for the whole script, whitespace tokens, better comment information, line wrapping, etc. Maintaining a fork sounds like hard work though so I might instead try and push those ideas upstream. We'll see.

I'd like to get things working with one fixed style before moving on to configuration. In the interests of being more useful earlier I will probably use the jQuery style guidelines as the fixed style.

About

A little tool to check that your source files meet your code style.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published