Permalink
Browse files

Avoid false positives in a regex quantifier: 'comma or semicolon

followed by non-blank' and 'missing space before left brace'.

Also document JSSTYLED comments in readme.
  • Loading branch information...
1 parent c83e3a2 commit 623835a0953574a7264b31c83fa41d10b3038138 @trentm trentm committed Feb 10, 2012
Showing with 22 additions and 2 deletions.
  1. +16 −0 README.md
  2. +6 −2 jsstyle
View
@@ -62,6 +62,22 @@ configurability.
"missing blank after start comment" check.
+## "JSSTYLED"-comments
+
+When you want `jsstyle` to ignore a line, you can use this:
+
+ /* JSSTYLED */
+ ignore = this + line;
+
+Or for a block:
+
+ /* BEGIN JSSTYLED */
+ var here
+ , be
+ , some = funky
+ , style
+ /* END JSSTYLED */
+
## License
View
@@ -561,7 +561,9 @@ line: while (<$filehandle>) {
err("missing space around assignment operator");
}
}
- if (/[,;]\S/ && !/\bfor \(;;\)/) {
+ if (/[,;]\S/ && !/\bfor \(;;\)/ &&
+ # Allow a comma in a regex quantifier.
+ !/\/.*?\{\d+,?\d*\}.*?\//) {
err("comma or semicolon followed by non-blank");
}
# allow "for" statements to have empty "while" clauses
@@ -620,7 +622,9 @@ line: while (<$filehandle>) {
if (/^\s*\(void\)[^ ]/) {
err("missing space after (void) cast");
}
- if (/\S{/ && !/({|\(){/) {
+ if (/\S{/ && !/({|\(){/ &&
+ # Allow a brace in a regex quantifier.
+ !/\/.*?\{\d+,?\d*\}.*?\//) {
err("missing space before left brace");
}
if ($in_function && /^\s+{/ &&

0 comments on commit 623835a

Please sign in to comment.