Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: make comma-dangle ESLint rule more stringent #37088

Merged
merged 2 commits into from Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion .eslintrc.js
Expand Up @@ -95,7 +95,13 @@ module.exports = {
ignorePattern: '.*',
},
}],
'comma-dangle': ['error', 'only-multiline'],
'comma-dangle': ['error', {
arrays: 'always-multiline',
exports: 'only-multiline',
functions: 'only-multiline',
imports: 'only-multiline',
objects: 'only-multiline',
}],
'comma-spacing': 'error',
'comma-style': 'error',
'computed-property-spacing': 'error',
Expand Down
4 changes: 2 additions & 2 deletions doc/api/child_process.md
Expand Up @@ -1225,7 +1225,7 @@ const subprocess = spawn(
'-c',
`node -e "setInterval(() => {
console.log(process.pid, 'is alive')
}, 500);"`
}, 500);"`,
], {
stdio: ['inherit', 'inherit', 'inherit']
}
Expand Down Expand Up @@ -1558,7 +1558,7 @@ const subprocess = child_process.spawn('ls', {
stdio: [
0, // Use parent's stdin for child.
'pipe', // Pipe child's stdout to parent.
fs.openSync('err.out', 'w') // Direct child's stderr to a file.
fs.openSync('err.out', 'w'), // Direct child's stderr to a file.
]
});

Expand Down
8 changes: 4 additions & 4 deletions doc/api/dns.md
Expand Up @@ -155,7 +155,7 @@ section if a custom port is used.
'4.4.4.4',
'2001:4860:4860::8888',
'4.4.4.4:1053',
'[2001:4860:4860::8888]:1053'
'[2001:4860:4860::8888]:1053',
]
```

Expand Down Expand Up @@ -645,7 +645,7 @@ dns.setServers([
'4.4.4.4',
'[2001:4860:4860::8888]',
'4.4.4.4:1053',
'[2001:4860:4860::8888]:1053'
'[2001:4860:4860::8888]:1053',
]);
```

Expand Down Expand Up @@ -755,7 +755,7 @@ section if a custom port is used.
'4.4.4.4',
'2001:4860:4860::8888',
'4.4.4.4:1053',
'[2001:4860:4860::8888]:1053'
'[2001:4860:4860::8888]:1053',
]
```

Expand Down Expand Up @@ -1148,7 +1148,7 @@ dnsPromises.setServers([
'4.4.4.4',
'[2001:4860:4860::8888]',
'4.4.4.4:1053',
'[2001:4860:4860::8888]:1053'
'[2001:4860:4860::8888]:1053',
]);
```

Expand Down
2 changes: 1 addition & 1 deletion doc/api/os.md
Expand Up @@ -115,7 +115,7 @@ The properties included on each object include:
idle: 1070905480,
irq: 20
}
}
},
]
```

Expand Down
6 changes: 3 additions & 3 deletions doc/api/url.md
Expand Up @@ -566,7 +566,7 @@ with [`JSON.stringify()`][].
```js
const myURLs = [
new URL('https://www.example.com'),
new URL('https://test.example.org')
new URL('https://test.example.org'),
];
console.log(JSON.stringify(myURLs));
// Prints ["https://www.example.com/","https://test.example.org/"]
Expand Down Expand Up @@ -703,7 +703,7 @@ let params;
params = new URLSearchParams([
['user', 'abc'],
['query', 'first'],
['query', 'second']
['query', 'second'],
]);
console.log(params.toString());
// Prints 'user=abc&query=first&query=second'
Expand All @@ -728,7 +728,7 @@ console.log(params.toString());

// Each key-value pair must have exactly two elements
new URLSearchParams([
['user', 'abc', 'error']
['user', 'abc', 'error'],
]);
// Throws TypeError [ERR_INVALID_TUPLE]:
// Each query pair must be an iterable [name, value] tuple
Expand Down
4 changes: 2 additions & 2 deletions doc/api/webcrypto.md
Expand Up @@ -187,15 +187,15 @@ const { subtle } = require('crypto').webcrypto;
async function generateAndWrapHmacKey(format = 'jwk', hash = 'SHA-512') {
const [
key,
wrappingKey
wrappingKey,
] = await Promise.all([
subtle.generateKey({
name: 'HMAC', hash
}, true, ['sign', 'verify']),
subtle.generateKey({
name: 'AES-KW',
length: 256
}, true, ['wrapKey', 'unwrapKey'])
}, true, ['wrapKey', 'unwrapKey']),
]);

const wrappedKey = await subtle.wrapKey(format, key, wrappingKey, 'AES-KW');
Expand Down
4 changes: 2 additions & 2 deletions lib/assert.js
Expand Up @@ -95,7 +95,7 @@ const meta = [
'\\u000f', '\\u0010', '\\u0011', '\\u0012', '\\u0013',
'\\u0014', '\\u0015', '\\u0016', '\\u0017', '\\u0018',
'\\u0019', '\\u001a', '\\u001b', '\\u001c', '\\u001d',
'\\u001e', '\\u001f'
'\\u001e', '\\u001f',
];

const escapeFn = (str) => meta[StringPrototypeCharCodeAt(str, 0)];
Expand Down Expand Up @@ -276,7 +276,7 @@ function parseCode(code, offset) {
node.node.start,
StringPrototypeReplace(StringPrototypeSlice(code,
node.node.start, node.node.end),
escapeSequencesRegExp, escapeFn)
escapeSequencesRegExp, escapeFn),
];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/loaders.js
Expand Up @@ -102,7 +102,7 @@ const internalBindingAllowlist = new SafeSet([
'util',
'uv',
'v8',
'zlib'
'zlib',
]);

// Set up process.binding() and process._linkedBinding().
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/pre_execution.js
Expand Up @@ -263,7 +263,7 @@ function initializeDeprecations() {
'isSetIterator',
'isTypedArray',
'isUint8Array',
'isAnyArrayBuffer'
'isAnyArrayBuffer',
]) {
utilBinding[name] = pendingDeprecation ?
deprecate(types[name],
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/child_process/serialization.js
Expand Up @@ -84,7 +84,7 @@ const advanced = {
sizeBuffer.writeUInt32BE(serializedMessage.length);
return channel.writeBuffer(req, Buffer.concat([
sizeBuffer,
serializedMessage
serializedMessage,
]), handle);
},
};
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/console/constructor.js
Expand Up @@ -532,7 +532,7 @@ const consoleMethods = {
}
}
return final([
iterKey, keyKey, valuesKey
iterKey, keyKey, valuesKey,
], [
getIndexArray(length),
keys,
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/crypto/hkdf.js
Expand Up @@ -95,7 +95,7 @@ function prepareKey(key) {
'ArrayBuffer',
'TypedArray',
'DataView',
'Buffer'
'Buffer',
],
key);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/crypto/keygen.js
Expand Up @@ -150,7 +150,7 @@ function parseKeyEncoding(keyType, options = {}) {
privateFormat,
privateType,
cipher,
passphrase
passphrase,
];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/crypto/keys.js
Expand Up @@ -90,7 +90,7 @@ const [
KeyObject,
SecretKeyObject,
PublicKeyObject,
PrivateKeyObject
PrivateKeyObject,
] = createNativeKeyObjectClass((NativeKeyObject) => {
// Publicly visible KeyObject class.
class KeyObject extends NativeKeyObject {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/crypto/random.js
Expand Up @@ -296,7 +296,7 @@ function getRandomValues(data) {

const kHexDigits = [
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 97, 98, 99, 100, 101, 102
56, 57, 97, 98, 99, 100, 101, 102,
];

const kBatchSize = 128;
Expand Down
6 changes: 3 additions & 3 deletions lib/internal/crypto/util.js
Expand Up @@ -133,7 +133,7 @@ const getArrayBufferOrView = hideStackFrames((buffer, name, encoding) => {
'ArrayBuffer',
'Buffer',
'TypedArray',
'DataView'
'DataView',
],
buffer
);
Expand Down Expand Up @@ -200,7 +200,7 @@ const kHashTypes = [
'SHA-1',
'SHA-256',
'SHA-384',
'SHA-512'
'SHA-512',
];

function validateMaxBufferLength(data, name) {
Expand Down Expand Up @@ -278,7 +278,7 @@ const validateByteSource = hideStackFrames((val, name) => {
'ArrayBuffer',
'TypedArray',
'DataView',
'Buffer'
'Buffer',
],
val);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/encoding.js
Expand Up @@ -285,7 +285,7 @@ const encodings = new SafeMap([
['windows-949', 'euc-kr'],
['utf-16be', 'utf-16be'],
['utf-16le', 'utf-16le'],
['utf-16', 'utf-16le']
['utf-16', 'utf-16le'],
]);

// Unfortunately, String.prototype.trim also removes non-ascii whitespace,
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Expand Up @@ -70,7 +70,7 @@ const kTypes = [
'Object',
'boolean',
'bigint',
'symbol'
'symbol',
];

const MainContextError = Error;
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/freeze_intrinsics.js
Expand Up @@ -203,7 +203,7 @@ module.exports = function() {
WebAssembly.CompileError.prototype,
WebAssembly.LinkError.prototype,
WebAssembly.RuntimeError.prototype,
SharedArrayBuffer.prototype
SharedArrayBuffer.prototype,
];
const intrinsics = [
// Anonymous Intrinsics
Expand Down Expand Up @@ -317,7 +317,7 @@ module.exports = function() {
BigInt,
Atomics,
WebAssembly,
SharedArrayBuffer
SharedArrayBuffer,
];

if (typeof Intl !== 'undefined') {
Expand Down
6 changes: 3 additions & 3 deletions lib/internal/http2/util.js
Expand Up @@ -108,7 +108,7 @@ const kValidPseudoHeaders = new SafeSet([
HTTP2_HEADER_AUTHORITY,
HTTP2_HEADER_SCHEME,
HTTP2_HEADER_PATH,
HTTP2_HEADER_PROTOCOL
HTTP2_HEADER_PROTOCOL,
]);

// This set contains headers that are permitted to have only a single
Expand Down Expand Up @@ -153,7 +153,7 @@ const kSingleValueHeaders = new SafeSet([
HTTP2_HEADER_TK,
HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS,
HTTP2_HEADER_USER_AGENT,
HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS
HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS,
]);

// The HTTP methods in this set are specifically defined as assigning no
Expand All @@ -163,7 +163,7 @@ const kSingleValueHeaders = new SafeSet([
const kNoPayloadMethods = new SafeSet([
HTTP2_METHOD_DELETE,
HTTP2_METHOD_GET,
HTTP2_METHOD_HEAD
HTTP2_METHOD_HEAD,
]);

// The following ArrayBuffer instances are used to share memory more efficiently
Expand Down
8 changes: 4 additions & 4 deletions lib/internal/main/print_help.js
Expand Up @@ -55,13 +55,13 @@ const envVars = new SafeMap(ArrayPrototypeConcat([
['NODE_V8_COVERAGE', { helpText: 'directory to output v8 coverage JSON ' +
'to' }],
['UV_THREADPOOL_SIZE', { helpText: 'sets the number of threads used in ' +
'libuv\'s threadpool' }]
'libuv\'s threadpool' }],
], hasIntl ? [
['NODE_ICU_DATA', { helpText: 'data path for ICU (Intl object) data' +
hasSmallICU ? '' : ' (will extend linked-in data)' }]
hasSmallICU ? '' : ' (will extend linked-in data)' }],
] : []), (hasNodeOptions ? [
['NODE_OPTIONS', { helpText: 'set CLI options in the environment via a ' +
'space-separated list' }]
'space-separated list' }],
] : []), hasCrypto ? [
['OPENSSL_CONF', { helpText: 'load OpenSSL configuration from file' }],
['SSL_CERT_DIR', { helpText: 'sets OpenSSL\'s directory of trusted ' +
Expand Down Expand Up @@ -108,7 +108,7 @@ function format(
let maxFirstColumnUsed = 0;

for (const [
name, { helpText, type, value }
name, { helpText, type, value },
] of ArrayPrototypeSort([...options.entries()])) {
if (!helpText) continue;

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/loader.js
Expand Up @@ -198,7 +198,7 @@ let wrap = function(script) {

const wrapper = [
'(function (exports, require, module, __filename, __dirname) { ',
'\n});'
'\n});',
];

let wrapperProxy = new Proxy(wrapper, {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/per_context/primordials.js
Expand Up @@ -145,7 +145,7 @@ function copyPrototype(src, dest, prefix) {
[
'JSON',
'Math',
'Reflect'
'Reflect',
].forEach((name) => {
copyPropsRenamed(global[name], primordials, name);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/process/per_thread.js
Expand Up @@ -72,7 +72,7 @@ function getFastAPIs(binding) {

return [
hrValues[0] * 0x100000000 + hrValues[1],
hrValues[2]
hrValues[2],
];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/querystring.js
Expand Up @@ -33,7 +33,7 @@ const isHexTable = new Int8Array([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // ... 256
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ... 256
]);

function encodeStr(str, noEscapeTable, hexTable) {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/streams/pipeline.js
Expand Up @@ -241,7 +241,7 @@ function pipeline(...streams) {
pt.end(val);
}, (err) => {
pt.destroy(err);
}
},
]);
} else if (isIterable(ret, true)) {
finishCount++;
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/tty.js
Expand Up @@ -77,7 +77,7 @@ const TERM_ENVS_REG_EXP = [
/^rxvt/,
/^screen/,
/^xterm/,
/^vt100/
/^vt100/,
];

let warned = false;
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/url.js
Expand Up @@ -1088,7 +1088,7 @@ const noEscape = new Int8Array([
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 0x4F
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50 - 0x5F
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 0x6F
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 // 0x70 - 0x7F
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // 0x70 - 0x7F
]);

// Special version of hexTable that uses `+` for U+0020 SPACE.
Expand Down