Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
'jsstyle -h' for usage output. Update usage and readme. Doc config op…
…tions.
  • Loading branch information
trentm committed Feb 9, 2012
1 parent 5980622 commit bb0aa81
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 24 deletions.
58 changes: 42 additions & 16 deletions README.md
@@ -1,21 +1,18 @@
jsstyle
==============
# jsstyle

Overview
--------
## Overview

jsstyle is a style checker for JavaScript coding style. This tool is derived
`jsstyle` is a style checker for JavaScript coding style. This tool is derived
from the cstyle tool used to check for the style used in the Solaris kernel,
sometimes known as "Bill Joy Normal Form". This tools is not configurable.
It enforces a single coding style based on that cstyle.
sometimes known as "Bill Joy Normal Form". This tool is a *little bit*
configurable. However it strives to enforces a single coding style based on
that cstyle. See "Configuration Options" below.

The original cstyle tool can be found here:

http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/tools/scripts/cstyle.pl
<http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/tools/scripts/cstyle.pl>

The document describing C Style is available here:

http://www.cis.upenn.edu/~lee/06cse480/data/cstyle.ms.pdf
<http://www.cis.upenn.edu/~lee/06cse480/data/cstyle.ms.pdf>

Examples of conditions checked by this tool include:

Expand All @@ -31,13 +28,42 @@ Examples of conditions checked by this tool include:
* Return expressions must be parenthesized.


Status
------
## Status

No known bugs. No new features planned.


Usage
-----
## Usage

jsstyle [OPTIONS] file1.js [file2.js ...]


## Configuration Options

Configuration options may be specified in a file (one option per line)
with the "-f PATH" switch, or on the command line with the "-o
OPTION1,OPTION2" switch.

As stated about, `jsstyle` is opinionated and intends to stay that way.
That said, this author was arm twisted under duress to allow the following
configurability.

doxygen Allow doxygen-style block comments `/** /*!`.
splint Allow splint-style lint comments `/*@ ... @*/`.
This is legacy. Does anyone use this?
indent=<NUM|tab> An integer number of spaces for indentation, or
'tab' for tab indentation (the default).
literal-string-quote 'single' (the default), 'double' or 'ignore'.
Specifies the preferred quote character for
literal strings.
unparenthesized-return Boolean option, set to 0 to disable the
"unparenthesized return expression" check.
blank-after-start-comment
Boolean option, set to 0 to disable the
"missing blank after start comment" check.



## License

# jsstyle file1.js [file2.js ...]
CDDL
28 changes: 20 additions & 8 deletions jsstyle
Expand Up @@ -55,17 +55,25 @@ use Getopt::Std;
use strict;

my $usage =
"usage: jsstyle [-chvC] [-t <num>] [-o constructs] file ...
"Usage: jsstyle [-hvcC] [-t <num>] [-f <path>] [-o <config>] file ...
Check your JavaScript file for style.
See <https://github.com/davepacheco/jsstyle> for details on config options.
Report bugs to <https://github.com/davepacheco/jsstyle/issues>.
Options:
-h print this help and exit
-v verbose
-c check continuation indentation inside functions
-t specify tab width for line length calculation
-v verbose
-C don't check anything in header block comments
-f CONFIG
-f PATH
path to a jsstyle config file
-o constructs
allow a comma-seperated list of optional constructs:
doxygen allow doxygen-style block comments (/** /*!)
splint allow splint-style lint comments (/*@ ... @*/)
-o OPTION1,OPTION2
set config options, e.g. '-o doxygen,indent=2'
";

my %opts;
Expand All @@ -75,6 +83,11 @@ if (!getopts("cho:t:f:vC", \%opts)) {
exit 2;
}

if (defined($opts{'h'})) {
print $usage;
exit;
}

my $check_continuation = $opts{'c'};
my $verbose = $opts{'v'};
my $ignore_hdr_comment = $opts{'C'};
Expand Down Expand Up @@ -259,7 +272,6 @@ line: while (<$filehandle>) {
# double or single quotes, we do not want to check such text.

$line = $_;
#print("--\nXXX line '$line'\n");

#
# C allows strings to be continued with a backslash at the end of
Expand Down

0 comments on commit bb0aa81

Please sign in to comment.