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: always use a trailing comma in arrays #20703

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ module.exports = {
{
property: '__defineSetter__',
message: '__defineSetter__ is deprecated.',
}
},
],
/* eslint-disable max-len, quotes */
// If this list is modified, please copy the change to lib/.eslintrc.yaml
Expand Down Expand Up @@ -178,7 +178,7 @@ module.exports = {
{
selector: 'ThrowStatement > CallExpression[callee.name=/Error$/]',
message: 'Use new keyword when throwing an Error.',
}
},
],
/* eslint-enable max-len, quotes */
'no-return-await': 'error',
Expand Down
9 changes: 9 additions & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ rules:
node-core/no-let-in-for-declaration: error
node-core/lowercase-name-for-primitive: error
node-core/non-ascii-character: error
# Rules specific to /lib
comma-dangle: [error, {
arrays: "always-multiline",
objects: "only-multiline",
imports: "only-multiline",
exports: "only-multiline",
functions: "only-multiline"
}]

globals:
CHECK: false
CHECK_EQ: false
Expand Down
2 changes: 1 addition & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ var proxiedMethods = [
'setSimultaneousAccepts', 'setBlocking',

// PipeWrap
'setPendingInstances'
'setPendingInstances',
];

// Proxy HandleWrap, PipeWrap and TCPWrap methods
Expand Down
2 changes: 1 addition & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,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[str.charCodeAt(0)];
Expand Down
2 changes: 1 addition & 1 deletion lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ Console.prototype.table = function(tabularData, properties) {
length++;
}
return final([
iterKey, keyKey, valuesKey
iterKey, keyKey, valuesKey,
], [
getIndexArray(length),
keys,
Expand Down
2 changes: 1 addition & 1 deletion lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ const resolverKeys = [
'resolvePtr',
'resolveNaptr',
'resolveSoa',
'reverse'
'reverse',
];

function setExportsFunctions() {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@

NativeModule.wrapper = [
'(function (exports, require, module, process) {',
'\n});'
'\n});',
];

NativeModule.prototype.compile = function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
'isArrayBuffer', 'isArrayBufferView', 'isAsyncFunction',
'isDataView', 'isDate', 'isExternal', 'isMap', 'isMapIterator',
'isNativeError', 'isPromise', 'isRegExp', 'isSet', 'isSetIterator',
'isTypedArray', 'isUint8Array', 'isAnyArrayBuffer'
'isTypedArray', 'isUint8Array', 'isAnyArrayBuffer',
]) {
utilBinding[name] = pendingDeprecation ?
deprecate(types[name],
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ const encodings = new Map([
['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
6 changes: 3 additions & 3 deletions lib/internal/http2/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const kValidPseudoHeaders = new Set([
HTTP2_HEADER_METHOD,
HTTP2_HEADER_AUTHORITY,
HTTP2_HEADER_SCHEME,
HTTP2_HEADER_PATH
HTTP2_HEADER_PATH,
]);

// This set contains headers that are permitted to have only a single
Expand Down Expand Up @@ -121,7 +121,7 @@ const kSingleValueHeaders = new Set([
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 @@ -131,7 +131,7 @@ const kSingleValueHeaders = new Set([
const kNoPayloadMethods = new Set([
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
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const builtinLibs = [
'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'http2', 'https', 'net',
'os', 'path', 'perf_hooks', 'punycode', 'querystring', 'readline', 'repl',
'stream', 'string_decoder', 'tls', 'trace_events', 'tty', 'url', 'util',
'v8', 'vm', 'zlib'
'v8', 'vm', 'zlib',
];

if (typeof process.binding('inspector').open === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Module.wrap = function(script) {

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

const debug = util.debuglog('module');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function setup_hrtime() {

return [
hrValues[0] * 0x100000000 + hrValues[1],
hrValues[2]
hrValues[2],
];
};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/process/next_tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function setupNextTick() {
// runMicrotasks is used to run V8's micro task queue.
const [
tickInfo,
runMicrotasks
runMicrotasks,
] = process._setupNextTick(_tickCallback);

// *Must* match Environment::TickInfo::Fields in src/env.h.
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const isHexTable = [
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
];

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/safe_globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const copyProps = (unsafe, safe) => {
for (const key of [...Object.getOwnPropertyNames(unsafe),
...Object.getOwnPropertySymbols(unsafe)
...Object.getOwnPropertySymbols(unsafe),
]) {
if (!Object.getOwnPropertyDescriptor(safe, key)) {
Object.defineProperty(
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/tty.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const TERM_ENVS = [
'mlterm',
'putty',
'st',
'terminator'
'terminator',
];

const TERM_ENVS_REG_EXP = [
Expand All @@ -63,7 +63,7 @@ const TERM_ENVS_REG_EXP = [
/^rxvt/,
/^screen/,
/^xterm/,
/^vt100/
/^vt100/,
];

// The `getColorDepth` API got inspired by multiple sources such as
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ const noEscape = [
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
2 changes: 1 addition & 1 deletion lib/internal/v8_prof_processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const scriptFiles = [
'internal/deps/v8/tools/arguments',
'internal/deps/v8/tools/tickprocessor',
'internal/deps/v8/tools/SourceMap',
'internal/deps/v8/tools/tickprocessor-driver'
'internal/deps/v8/tools/tickprocessor-driver',
];
var script = '';

Expand Down
2 changes: 1 addition & 1 deletion lib/perf_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const observerableTypes = [
'measure',
'gc',
'function',
'http2'
'http2',
];

const IDX_STREAM_STATS_ID = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const unhexTable = [
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // ... 255
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 255
];
// a safe fast alternative to decodeURIComponent
function unescapeBuffer(s, decodeSpaces) {
Expand Down Expand Up @@ -129,7 +129,7 @@ const noEscape = [
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64 - 79
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 80 - 95
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96 - 111
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0 // 112 - 127
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, // 112 - 127
];
// QueryString.escape() replaces encodeURIComponent()
// http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.4
Expand Down
4 changes: 2 additions & 2 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const GLOBAL_OBJECT_PROPERTIES = [
'isFinite', 'decodeURI', 'decodeURIComponent', 'encodeURI',
'encodeURIComponent', 'Object', 'Function', 'Array', 'String', 'Boolean',
'Number', 'Date', 'RegExp', 'Error', 'EvalError', 'RangeError',
'ReferenceError', 'SyntaxError', 'TypeError', 'URIError', 'Math', 'JSON'
'ReferenceError', 'SyntaxError', 'TypeError', 'URIError', 'Math', 'JSON',
];
const GLOBAL_OBJECT_PROPERTY_MAP = {};
for (var n = 0; n < GLOBAL_OBJECT_PROPERTIES.length; n++) {
Expand Down Expand Up @@ -1356,7 +1356,7 @@ function addStandardGlobals(completionGroups, filter) {
'debugger', 'default', 'delete', 'do', 'else', 'export', 'false',
'finally', 'for', 'function', 'if', 'import', 'in', 'instanceof', 'let',
'new', 'null', 'return', 'switch', 'this', 'throw', 'true', 'try',
'typeof', 'undefined', 'var', 'void', 'while', 'with', 'yield'
'typeof', 'undefined', 'var', 'void', 'while', 'with', 'yield',
]);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ const escapedCodes = [
/* 90 - 99 */ '', '', '%5C', '', '%5E', '', '%60', '', '', '',
/* 100 - 109 */ '', '', '', '', '', '', '', '', '', '',
/* 110 - 119 */ '', '', '', '', '', '', '', '', '', '',
/* 120 - 125 */ '', '', '', '%7B', '%7C', '%7D'
/* 120 - 125 */ '', '', '', '%7B', '%7C', '%7D',
];

// Automatically escape all delimiters and unwise characters from RFC 2396.
Expand Down Expand Up @@ -555,7 +555,7 @@ const noEscapeAuth = [
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, 1, 0 // 0x70 - 0x7F
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, // 0x70 - 0x7F
];

Url.prototype.format = function format() {
Expand Down
6 changes: 3 additions & 3 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const meta = [
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '\\\\'
'', '', '', '', '', '', '', '\\\\',
];

const escapeFn = (str) => meta[str.charCodeAt(0)];
Expand Down Expand Up @@ -445,7 +445,7 @@ function formatValue(ctx, value, recurseTimes, ln) {
ctx.indentationLvl += 2;
const res = [
formatValue(ctx, proxy[0], recurseTimes),
formatValue(ctx, proxy[1], recurseTimes)
formatValue(ctx, proxy[1], recurseTimes),
];
ctx.indentationLvl -= 2;
const str = reduceToSingleString(ctx, res, '', ['[', ']']);
Expand Down Expand Up @@ -867,7 +867,7 @@ function formatTypedArray(ctx, value, recurseTimes, keys) {
'length',
'byteLength',
'byteOffset',
'buffer'
'buffer',
];
for (i = 0; i < extraKeys.length; i++) {
const str = formatValue(ctx, value[extraKeys[i]], recurseTimes);
Expand Down