Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Add boolean options leading-comma-ok, uncuddled-else-ok, whitespace-after-left-paren-ok #11

Merged
merged 1 commit into from about 2 years ago

2 participants

Orlando Vazquez David Pacheco
Orlando Vazquez

No description provided.

David Pacheco davepacheco merged commit da42b50 into from February 22, 2012
David Pacheco davepacheco closed this February 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 17, 2012
Orlando Vazquez Add boolean options leading-comma-ok, uncuddled-else-ok, whitespace-a…
…fter-left-paren-ok
1d971bd
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 22 additions and 4 deletions. Show diff stats Hide diff stats

  1. 10  README.md
  2. 16  jsstyle
10  README.md
Source Rendered
@@ -67,6 +67,16 @@ configurability.
67 67
     leading-right-paren-ok  Boolean option, set to 1 to allow ) to start a
68 68
                             line.
69 69
 
  70
+    whitespace-after-left-paren-ok
  71
+                            Boolean option, allow whitespace after a (
  72
+                            character.
  73
+
  74
+    leading-comma-ok        Boolean option to allow lines to begin with commas
  75
+                            (preceded by whitespace).
  76
+
  77
+    uncuddled-else-ok       Boolean option to allow for an else block to begin
  78
+                            on a new line.
  79
+
70 80
 ## "JSSTYLED"-comments
71 81
 
72 82
 When you want `jsstyle` to ignore a line, you can use this:
16  jsstyle
@@ -133,6 +133,9 @@ sub add_config_var ($$) {
133 133
 		 $name eq "unparenthesized-return" ||
134 134
 		 $name eq "continuation-at-front" ||
135 135
 		 $name eq "leading-right-paren-ok" ||
  136
+		 $name eq "leading-comma-ok" ||
  137
+		 $name eq "uncuddled-else-ok" ||
  138
+		 $name eq "whitespace-after-left-paren-ok" ||
136 139
 		 $name eq "strict-indent" ||
137 140
 		 $name eq "blank-after-start-comment") {
138 141
 
@@ -577,9 +580,14 @@ line: while (<$filehandle>) {
577 580
 	    !/\/.*?\{\d+,?\d*\}.*?\//) {
578 581
 		err("comma or semicolon followed by non-blank");
579 582
 	}
  583
+	# check for commas preceded by blanks
  584
+	if ((!$config{"leading-comma-ok"} && /^\s*,/) || (!/^\s*,/ && /\s,/)) {
  585
+		err("comma preceded by blank");
  586
+	}
  587
+	# check for semicolons preceded by blanks
580 588
 	# allow "for" statements to have empty "while" clauses
581  
-	if (/\s[,;]/ && !/^[\t]+;$/ && !/^\s*for \([^;]*; ;[^;]*\)/) {
582  
-		err("comma or semicolon preceded by blank");
  589
+	if (/\s;/ && !/^[\t]+;$/ && !/^\s*for \([^;]*; ;[^;]*\)/) {
  590
+		err("semicolon preceded by blank");
583 591
 	}
584 592
 	if (!$config{"continuation-at-front"} && /^\s*(&&|\|\|)/) {
585 593
 		err("improper boolean continuation");
@@ -627,7 +635,7 @@ line: while (<$filehandle>) {
627 635
 	if (/\btypeof\b/ && !/\btypeof\s*\(.*\)/) {
628 636
 		err("unparenthesized typeof expression");
629 637
 	}
630  
-	if (/\(\s/) {
  638
+	if (!$config{"whitespace-after-left-paren-ok"} && /\(\s/) {
631 639
 		err("whitespace after left paren");
632 640
 	}
633 641
 	# allow "for" statements to have empty "continue" clauses
@@ -673,7 +681,7 @@ line: while (<$filehandle>) {
673 681
 	}
674 682
 
675 683
 	if (/^\s*else\W/) {
676  
-		if ($prev =~ /^\s*}$/) {
  684
+		if (!$config{"uncuddled-else-ok"} && $prev =~ /^\s*}$/) {
677 685
 			err_prefix($prev,
678 686
 			    "else and right brace should be on same line");
679 687
 		}
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.