Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

'jsstyle -h' for usage output. Update usage and readme. Doc config op…

…tions.
  • Loading branch information...
commit bb0aa819999d583338bf380734e50e999ef5c4be 1 parent 5980622
@trentm trentm authored
Showing with 62 additions and 24 deletions.
  1. +42 −16 README.md
  2. +20 −8 jsstyle
View
58 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:
@@ -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
View
28 jsstyle
@@ -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;
@@ -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'};
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.