Skip to content

Commit e140d41

Browse files
BridgeARBethGriggs
authored andcommitted
tools: capitalize sentences
This adds the `capitalized-comments` eslint rule to verify that actual sentences use capital letters as starting letters. It ignores special words and all lines below 62 characters. PR-URL: #24808 Reviewed-By: Sam Ruby <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent ad6104d commit e140d41

File tree

156 files changed

+774
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+774
-244
lines changed

.eslintrc.js

+12
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ module.exports = {
5858
'arrow-spacing': ['error', { before: true, after: true }],
5959
'block-spacing': 'error',
6060
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
61+
'capitalized-comments': ['error', 'always', {
62+
line: {
63+
// Ignore all lines that have less characters than 62 and all lines that
64+
// start with something that looks like a variable name or code.
65+
ignorePattern: '^.{0,62}$|^ [a-z]+ ?[0-9A-Z_.(/=:-]',
66+
ignoreInlineComments: true,
67+
ignoreConsecutiveComments: true
68+
},
69+
block: {
70+
ignorePattern: '.*'
71+
}
72+
}],
6173
'comma-dangle': ['error', 'only-multiline'],
6274
'comma-spacing': 'error',
6375
'comma-style': 'error',

benchmark/_cli.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function CLI(usage, settings) {
4949
this.optional[currentOptional] = true;
5050
mode = 'both';
5151
} else {
52-
// expect the next value to be option related (either -- or the value)
52+
// Expect the next value to be option related (either -- or the value)
5353
mode = 'option';
5454
}
5555
} else if (mode === 'option') {

benchmark/child_process/child-process-exec-stdout.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function childProcessExecStdout({ dur, len }) {
3131
try {
3232
execSync(`taskkill /f /t /pid ${child.pid}`);
3333
} catch {
34-
// this is a best effort kill. stderr is piped to parent for tracing.
34+
// This is a best effort kill. stderr is piped to parent for tracing.
3535
}
3636
} else {
3737
child.kill();

benchmark/common.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Benchmark.prototype._run = function() {
146146
(function recursive(queueIndex) {
147147
const config = self.queue[queueIndex];
148148

149-
// set NODE_RUN_BENCHMARK_FN to indicate that the child shouldn't construct
149+
// Set NODE_RUN_BENCHMARK_FN to indicate that the child shouldn't construct
150150
// a configuration queue, but just execute the benchmark function.
151151
const childEnv = Object.assign({}, process.env);
152152
childEnv.NODE_RUN_BENCHMARK_FN = '';
@@ -187,7 +187,7 @@ Benchmark.prototype.start = function() {
187187
};
188188

189189
Benchmark.prototype.end = function(operations) {
190-
// get elapsed time now and do error checking later for accuracy.
190+
// Get elapsed time now and do error checking later for accuracy.
191191
const elapsed = process.hrtime(this._time);
192192

193193
if (!this._started) {

benchmark/crypto/cipher-stream.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function main({ api, cipher, type, len, writes }) {
5858

5959
const fn = api === 'stream' ? streamWrite : legacyWrite;
6060

61-
// write data as fast as possible to alice, and have bob decrypt.
61+
// Write data as fast as possible to alice, and have bob decrypt.
6262
// use old API for comparison to v0.8
6363
bench.start();
6464
fn(alice_cipher, bob_cipher, message, encoding, writes);

benchmark/dgram/array-vs-concat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// test UDP send throughput with the multi buffer API against Buffer.concat
1+
// Test UDP send throughput with the multi buffer API against Buffer.concat
22
'use strict';
33

44
const common = require('../common.js');

benchmark/dgram/offset-length.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// test UDP send/recv throughput with the "old" offset/length API
1+
// Test UDP send/recv throughput with the "old" offset/length API
22
'use strict';
33

44
const common = require('../common.js');

benchmark/napi/function_call/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
const assert = require('assert');
88
const common = require('../../common.js');
99

10-
// this fails when we try to open with a different version of node,
10+
// This fails when we try to open with a different version of node,
1111
// which is quite common for benchmarks. so in that case, just
1212
// abort quietly.
1313

benchmark/net/net-wrap-js-stream-passthrough.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// test the speed of .pipe() with JSStream wrapping for PassThrough streams
1+
// Test the speed of .pipe() with JSStream wrapping for PassThrough streams
22
'use strict';
33

44
const common = require('../common.js');

doc/api/async_hooks.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ asyncHook.disable();
6161
// resource referenced by "asyncId" may not have been populated.
6262
function init(asyncId, type, triggerAsyncId, resource) { }
6363

64-
// before is called just before the resource's callback is called. It can be
64+
// Before is called just before the resource's callback is called. It can be
6565
// called 0-N times for handles (e.g. TCPWrap), and will be called exactly 1
6666
// time for requests (e.g. FSReqCallback).
6767
function before(asyncId) { }
6868

69-
// after is called just after the resource's callback has finished.
69+
// After is called just after the resource's callback has finished.
7070
function after(asyncId) { }
7171

7272
// destroy is called when an AsyncWrap instance is destroyed.
@@ -159,7 +159,7 @@ const fs = require('fs');
159159
const util = require('util');
160160

161161
function debug(...args) {
162-
// use a function like this one when debugging inside an AsyncHooks callback
162+
// Use a function like this one when debugging inside an AsyncHooks callback
163163
fs.writeFileSync('log.out', `${util.format(...args)}\n`, { flag: 'a' });
164164
}
165165
```

doc/api/crypto.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ const uncompressedKey = ECDH.convertKey(compressedKey,
772772
'hex',
773773
'uncompressed');
774774

775-
// the converted key and the uncompressed public key should be the same
775+
// The converted key and the uncompressed public key should be the same
776776
console.log(uncompressedKey === ecdh.getPublicKey('hex'));
777777
```
778778

doc/api/domain.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ if (cluster.isMaster) {
143143
// a new worker.
144144
cluster.worker.disconnect();
145145

146-
// try to send an error to the request that triggered the problem
146+
// Try to send an error to the request that triggered the problem
147147
res.statusCode = 500;
148148
res.setHeader('content-type', 'text/plain');
149149
res.end('Oops, there was a problem!\n');

doc/api/errors.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ range, or outside the set of options for a given function parameter.
371371

372372
```js
373373
require('net').connect(-1);
374-
// throws "RangeError: "port" option should be >= 0 and < 65536: -1"
374+
// Throws "RangeError: "port" option should be >= 0 and < 65536: -1"
375375
```
376376

377377
Node.js will generate and throw `RangeError` instances *immediately* as a form
@@ -388,7 +388,7 @@ will do so.
388388

389389
```js
390390
doesNotExist;
391-
// throws ReferenceError, doesNotExist is not a variable in this program.
391+
// Throws ReferenceError, doesNotExist is not a variable in this program.
392392
```
393393

394394
Unless an application is dynamically generating and running code,

doc/api/events.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -638,14 +638,14 @@ emitter.once('log', () => console.log('log once'));
638638
const listeners = emitter.rawListeners('log');
639639
const logFnWrapper = listeners[0];
640640

641-
// logs "log once" to the console and does not unbind the `once` event
641+
// Logs "log once" to the console and does not unbind the `once` event
642642
logFnWrapper.listener();
643643

644644
// logs "log once" to the console and removes the listener
645645
logFnWrapper();
646646

647647
emitter.on('log', () => console.log('log persistently'));
648-
// will return a new Array with a single function bound by `.on()` above
648+
// Will return a new Array with a single function bound by `.on()` above
649649
const newListeners = emitter.rawListeners('log');
650650

651651
// logs "log persistently" twice

doc/api/fs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,7 @@ console.log(fs.readFileSync('temp.txt', 'utf8'));
19261926
// get the file descriptor of the file to be truncated
19271927
const fd = fs.openSync('temp.txt', 'r+');
19281928

1929-
// truncate the file to 10 bytes, whereas the actual size is 7 bytes
1929+
// Truncate the file to 10 bytes, whereas the actual size is 7 bytes
19301930
fs.ftruncate(fd, 10, (err) => {
19311931
assert.ifError(err);
19321932
console.log(fs.readFileSync('temp.txt'));

doc/api/modules.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ console.log(`The area of mySquare is ${mySquare.area()}`);
4949
The `square` module is defined in `square.js`:
5050

5151
```js
52-
// assigning to exports will not modify module, must use module.exports
52+
// Assigning to exports will not modify module, must use module.exports
5353
module.exports = class Square {
5454
constructor(width) {
5555
this.width = width;

doc/api/process.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ The listener function is called with the following arguments:
286286
```js
287287
process.on('unhandledRejection', (reason, p) => {
288288
console.log('Unhandled Rejection at:', p, 'reason:', reason);
289-
// application specific logging, throwing an error, or other logic here
289+
// Application specific logging, throwing an error, or other logic here
290290
});
291291

292292
somePromise.then((res) => {

doc/api/stream.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const server = http.createServer((req, res) => {
131131
body += chunk;
132132
});
133133

134-
// the 'end' event indicates that the entire body has been received
134+
// The 'end' event indicates that the entire body has been received
135135
req.on('end', () => {
136136
try {
137137
const data = JSON.parse(body);

doc/api/util.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const util = require('util');
159159
const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001');
160160
const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001');
161161
fn1(); // emits a deprecation warning with code DEP0001
162-
fn2(); // does not emit a deprecation warning because it has the same code
162+
fn2(); // Does not emit a deprecation warning because it has the same code
163163
```
164164

165165
If either the `--no-deprecation` or `--no-warnings` command line flags are

doc/api/worker_threads.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const { MessageChannel } = require('worker_threads');
109109
const { port1, port2 } = new MessageChannel();
110110
port1.on('message', (message) => console.log('received', message));
111111
port2.postMessage({ foo: 'bar' });
112-
// prints: received { foo: 'bar' } from the `port1.on('message')` listener
112+
// Prints: received { foo: 'bar' } from the `port1.on('message')` listener
113113
```
114114

115115
## Class: MessagePort

lib/_http_agent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function Agent(options) {
5050

5151
this.options = util._extend({}, options);
5252

53-
// don't confuse net and make it think that we're connecting to a pipe
53+
// Don't confuse net and make it think that we're connecting to a pipe
5454
this.options.path = null;
5555
this.requests = {};
5656
this.sockets = {};

lib/_http_outgoing.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ function _storeHeader(firstLine, headers) {
387387
this._header = header + CRLF;
388388
this._headerSent = false;
389389

390-
// wait until the first body chunk, or close(), is sent to flush,
390+
// Wait until the first body chunk, or close(), is sent to flush,
391391
// UNLESS we're sending Expect: 100-continue.
392392
if (state.expect) this._send('');
393393
}

lib/_http_server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ function writeHead(statusCode, reason, obj) {
261261
this._hasBody = false;
262262
}
263263

264-
// don't keep alive connections where the client expects 100 Continue
264+
// Don't keep alive connections where the client expects 100 Continue
265265
// but we sent a final status; they may put extra bytes on the wire.
266266
if (this._expect_continue && !this._sent100) {
267267
this.shouldKeepAlive = false;

lib/_stream_readable.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function ReadableState(options, stream, isDuplex) {
8585
if (isDuplex)
8686
this.objectMode = this.objectMode || !!options.readableObjectMode;
8787

88-
// the point at which it stops calling _read() to fill the buffer
88+
// The point at which it stops calling _read() to fill the buffer
8989
// Note: 0 is a valid value, means "don't call _read preemptively ever"
9090
this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark',
9191
isDuplex);
@@ -102,7 +102,7 @@ function ReadableState(options, stream, isDuplex) {
102102
this.endEmitted = false;
103103
this.reading = false;
104104

105-
// a flag to be able to tell if the event 'readable'/'data' is emitted
105+
// A flag to be able to tell if the event 'readable'/'data' is emitted
106106
// immediately, or on a later tick. We set this to true at first, because
107107
// any actions that shouldn't happen until "later" should generally also
108108
// not happen before the first read call.
@@ -130,7 +130,7 @@ function ReadableState(options, stream, isDuplex) {
130130
// Everything else in the universe uses 'utf8', though.
131131
this.defaultEncoding = options.defaultEncoding || 'utf8';
132132

133-
// the number of writers that are awaiting a drain event in .pipe()s
133+
// The number of writers that are awaiting a drain event in .pipe()s
134134
this.awaitDrain = 0;
135135

136136
// if true, a maybeReadMore has been scheduled
@@ -373,7 +373,7 @@ function howMuchToRead(n, state) {
373373
return state.length;
374374
}
375375

376-
// you can override either this method, or the async _read(n) below.
376+
// You can override either this method, or the async _read(n) below.
377377
Readable.prototype.read = function(n) {
378378
debug('read', n);
379379
n = parseInt(n, 10);
@@ -435,13 +435,13 @@ Readable.prototype.read = function(n) {
435435
var doRead = state.needReadable;
436436
debug('need readable', doRead);
437437

438-
// if we currently have less than the highWaterMark, then also read some
438+
// If we currently have less than the highWaterMark, then also read some
439439
if (state.length === 0 || state.length - n < state.highWaterMark) {
440440
doRead = true;
441441
debug('length less than watermark', doRead);
442442
}
443443

444-
// however, if we've ended, then there's no point, and if we're already
444+
// However, if we've ended, then there's no point, and if we're already
445445
// reading, then it's unnecessary.
446446
if (state.ended || state.reading) {
447447
doRead = false;
@@ -450,7 +450,7 @@ Readable.prototype.read = function(n) {
450450
debug('do read');
451451
state.reading = true;
452452
state.sync = true;
453-
// if the length is currently zero, then we *need* a readable event.
453+
// If the length is currently zero, then we *need* a readable event.
454454
if (state.length === 0)
455455
state.needReadable = true;
456456
// call internal read method
@@ -553,7 +553,7 @@ function emitReadable_(stream) {
553553
}
554554

555555

556-
// at this point, the user has presumably seen the 'readable' event,
556+
// At this point, the user has presumably seen the 'readable' event,
557557
// and called read() to consume some data. that may have triggered
558558
// in turn another _read(n) call, in which case reading = true if
559559
// it's in progress.
@@ -581,7 +581,7 @@ function maybeReadMore_(stream, state) {
581581
state.readingMore = false;
582582
}
583583

584-
// abstract method. to be overridden in specific implementation classes.
584+
// Abstract method. to be overridden in specific implementation classes.
585585
// call cb(er, data) where data is <= n in length.
586586
// for virtual (non-string, non-buffer) streams, "length" is somewhat
587587
// arbitrary, and perhaps not very meaningful.

lib/_stream_transform.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ function Transform(options) {
116116
writeencoding: null
117117
};
118118

119-
// start out asking for a readable event once data is transformed.
119+
// Start out asking for a readable event once data is transformed.
120120
this._readableState.needReadable = true;
121121

122-
// we have implemented the _read method, and done the other things
122+
// We have implemented the _read method, and done the other things
123123
// that Readable wants before the first _read call, so unset the
124124
// sync guard flag.
125125
this._readableState.sync = false;

lib/_stream_writable.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function WritableState(options, stream, isDuplex) {
9090
// has it been destroyed
9191
this.destroyed = false;
9292

93-
// should we decode strings into buffers before passing to _write?
93+
// Should we decode strings into buffers before passing to _write?
9494
// this is here so that some node-core streams can optimize string
9595
// handling at a lower level.
9696
var noDecode = options.decodeStrings === false;
@@ -112,21 +112,21 @@ function WritableState(options, stream, isDuplex) {
112112
// when true all writes will be buffered until .uncork() call
113113
this.corked = 0;
114114

115-
// a flag to be able to tell if the onwrite cb is called immediately,
115+
// A flag to be able to tell if the onwrite cb is called immediately,
116116
// or on a later tick. We set this to true at first, because any
117117
// actions that shouldn't happen until "later" should generally also
118118
// not happen before the first write call.
119119
this.sync = true;
120120

121-
// a flag to know if we're processing previously buffered items, which
121+
// A flag to know if we're processing previously buffered items, which
122122
// may call the _write() callback in the same tick, so that we don't
123123
// end up in an overlapped onwrite situation.
124124
this.bufferProcessing = false;
125125

126126
// the callback that's passed to _write(chunk,cb)
127127
this.onwrite = onwrite.bind(undefined, stream);
128128

129-
// the callback that the user supplies to write(chunk,encoding,cb)
129+
// The callback that the user supplies to write(chunk,encoding,cb)
130130
this.writecb = null;
131131

132132
// the amount that is being written when _write is called.
@@ -139,7 +139,7 @@ function WritableState(options, stream, isDuplex) {
139139
// this must be 0 before 'finish' can be emitted
140140
this.pendingcb = 0;
141141

142-
// emit prefinish if the only thing we're waiting for is _write cbs
142+
// Emit prefinish if the only thing we're waiting for is _write cbs
143143
// This is relevant for synchronous Transform streams
144144
this.prefinished = false;
145145

@@ -376,7 +376,7 @@ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
376376
state.length += len;
377377

378378
var ret = state.length < state.highWaterMark;
379-
// we must ensure that previous needDrain will not be reset to false.
379+
// We must ensure that previous needDrain will not be reset to false.
380380
if (!ret)
381381
state.needDrain = true;
382382

0 commit comments

Comments
 (0)