Skip to content

Commit

Permalink
indent dot
Browse files Browse the repository at this point in the history
  • Loading branch information
douglascrockford committed May 3, 2015
1 parent d9877fb commit bef458b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
10 changes: 4 additions & 6 deletions help.html
Expand Up @@ -426,7 +426,7 @@ <h1><code>/*jslint*/</code></h1>
<tr>
<td> Tolerate messy white space</td>
<td><code>white</code></td>
<td><code>true</code> if strict whitespace rules should be ignored.</td>
<td><code>true</code> if the whitespace rules should be ignored.</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -673,16 +673,14 @@ <h1>Whitespace</h1>
<code>(</code>&nbsp;<small>left paren</small>. The matching closing
token will be the first token on a line, restoring the previous
indentation.</p>
<p>The ternary operator can be visually confusing, so <code>?</code>&nbsp;<small>question mark</small> and <code>:</code>&nbsp;<small>colon</small> always begin a line and increase the indentation by 4 spaces.</p>
<p>If <code>.</code> <small>period</small> is the first character on a line, the indentation is increased by 4 spaces.</p>
<p>A <code>var</code>, <code>let</code>, or <code>const</code> statement will
also cause an indentation if it declares two or more variables, and if the
second variable is not on the same line as the start of the statement.</p>
second variable is not on the same line as the start of the statement.</p>
<p>Long lines can be continued on the next line with 8 spaces added to the
current indentation. Those 8 spaces do not change the current indentation.
It is 8 to avoid confusion with ordinary indentation.</p>
<p>The ternary operator can be visually confusing, so
<code>?</code>&nbsp;<small>question mark</small> and
<code>:</code>&nbsp;<small>colon</small> are always placed at the current
indentation.</p>
<p>The word <code>function</code> is always followed with one space.</p>
<p>Clauses (<code>else</code>, <code>case</code>, <code>default</code>,
<code>catch</code>, <code>finally</code>) are not statements and so should
Expand Down
18 changes: 12 additions & 6 deletions jslint.js
@@ -1,5 +1,5 @@
// jslint.js
// 2015-05-02
// 2015-05-03
// Copyright (c) 2015 Douglas Crockford (www.JSLint.com)

// Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -383,8 +383,9 @@ var jslint = (function JSLint() {
rx_bits = /^([01]+)(.*)$/,
// mega
rx_mega = /`|\$\{/,
// colons
rx_colons = /^(.*)\?(\:*)$/,
// indentation
rx_colons = /^(.*)\?([:.]*)$/,
rx_dot = /\.$/,
// JSON number
rx_JSON_number = /^-?\d+(?:\.\d*)?(?:e[\-+]?\d+)?$/i;

Expand Down Expand Up @@ -3685,6 +3686,7 @@ var jslint = (function JSLint() {
nr_comments_skipped = 0,
open = true,
qmark = '',
result,
right;

function at_margin(fit) {
Expand Down Expand Up @@ -3906,7 +3908,7 @@ var jslint = (function JSLint() {
margin += 4;
qmark += '?';
} else {
var result = qmark.match(rx_colons);
result = qmark.match(rx_colons);
qmark = result[1] + ':';
margin -= 4 * result[2].length;
}
Expand All @@ -3928,7 +3930,11 @@ var jslint = (function JSLint() {
if (left.line === right.line) {
no_space();
} else {
at_margin(8);
if (!rx_dot.test(qmark)) {
qmark += '.';
margin += 4;
}
at_margin(0);
}
} else if (left.id === ';') {
unqmark();
Expand Down Expand Up @@ -4139,7 +4145,7 @@ var jslint = (function JSLint() {
warnings: warnings.sort(function (a, b) {
return a.line - b.line || a.column - b.column;
}),
edition: "2015-05-02 BETA"
edition: "2015-05-03 BETA"
};
};
}());
8 changes: 4 additions & 4 deletions report.js
@@ -1,5 +1,5 @@
// report.js
// 2015-05-02
// 2015-05-03
// Copyright (c) 2015 Douglas Crockford (www.JSLint.com)

// Generate JSLint HTML reports.
Expand All @@ -23,9 +23,9 @@ var REPORT = (function () {
// Replace & < > with less destructive entities.

return String(string)
.replace(rx_amp, '&amp;')
.replace(rx_lt, '&lt;')
.replace(rx_gt, '&gt;');
.replace(rx_amp, '&amp;')
.replace(rx_lt, '&lt;')
.replace(rx_gt, '&gt;');
}

return {
Expand Down

0 comments on commit bef458b

Please sign in to comment.