Skip to content

Commit

Permalink
Avoid false positives in a regex quantifier: 'comma or semicolon
Browse files Browse the repository at this point in the history
followed by non-blank' and 'missing space before left brace'.

Also document JSSTYLED comments in readme.
  • Loading branch information
trentm committed Feb 10, 2012
1 parent c83e3a2 commit 623835a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions jsstyle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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+{/ &&
Expand Down

0 comments on commit 623835a

Please sign in to comment.