lib: enforce use of trailing commas in more files

Some part of the codebase already use trailing commas, this commit is
adding a lint rule to ensure it stays this way.
This commit also adds the rule for a few files that were missing only
one or two trailing commas.

PR-URL: https://github.com/nodejs/node/pull/46655
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
Antoine du Hamel 2023-02-16 18:47:24 +01:00 committed by GitHub
parent 1b87cb6f39
commit cbcefdf253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 61 additions and 12 deletions

View File

@ -261,3 +261,52 @@ globals:
module: false module: false
internalBinding: false internalBinding: false
primordials: false primordials: false
overrides:
- files:
- ./*/promises.js
- ./_stream_*.js
- ./_tls_common.js
- ./assert/*.js
- ./cluster.js
- ./console.js
- ./constants.js
- ./internal/assert.js
- ./internal/child_process/*.js
- ./internal/cli_table.js
- ./internal/debugger/inspect.js
- ./internal/events/*.js
- ./internal/fixed_queue.js
- ./internal/freelist.js
- ./internal/heap_utils.js
- ./internal/http.js
- ./internal/idna.js
- ./internal/js_stream_socket.js
- ./internal/mime.js
- ./internal/modules/*.js
- ./internal/per_context/messageport.js
- ./internal/policy/*.js
- ./internal/priority_queue.js
- ./internal/readline/*.js
- ./internal/readme.md
- ./internal/repl/history.js
- ./internal/source_map/prepare_stack_trace.js
- ./internal/structured_clone.js
- ./internal/test/*.js
- ./internal/test_runner/**/*.js
- ./internal/tls/secure-context.js
- ./internal/util/parse_args/*.js
- ./internal/v8_prof_processor.js
- ./internal/vm.js
- ./internal/watch_mode/*.js
- ./internal/webidl.js
- ./module.js
- ./path/*.js
- ./process.js
- ./punycode.js
- ./stream/*.js
- ./sys.js
- ./test.js
- ./url.js
- ./util/*.js
rules:
comma-dangle: [error, always-multiline]

View File

@ -15,7 +15,7 @@ const {
} = primordials; } = primordials;
const { const {
ERR_MANIFEST_DEPENDENCY_MISSING, ERR_MANIFEST_DEPENDENCY_MISSING,
ERR_UNKNOWN_BUILTIN_MODULE ERR_UNKNOWN_BUILTIN_MODULE,
} = require('internal/errors').codes; } = require('internal/errors').codes;
const { BuiltinModule } = require('internal/bootstrap/loaders'); const { BuiltinModule } = require('internal/bootstrap/loaders');
@ -203,7 +203,7 @@ function addBuiltinLibsToObject(object, dummyModuleName) {
}, },
set: setReal, set: setReal,
configurable: true, configurable: true,
enumerable: false enumerable: false,
}); });
}); });
} }

View File

@ -14,7 +14,7 @@ const {
} = primordials; } = primordials;
const { const {
ERR_SRI_PARSE ERR_SRI_PARSE,
} = require('internal/errors').codes; } = require('internal/errors').codes;
const kWSP = '[\\x20\\x09]'; const kWSP = '[\\x20\\x09]';
const kVCHAR = '[\\x21-\\x7E]'; const kVCHAR = '[\\x21-\\x7E]';
@ -55,7 +55,7 @@ const parse = (str) => {
algorithm: match[2], algorithm: match[2],
value: BufferFrom(match[3], 'base64'), value: BufferFrom(match[3], 'base64'),
options: match[4] === undefined ? null : match[4], options: match[4] === undefined ? null : match[4],
}) }),
}); });
prevIndex += match[0].length; prevIndex += match[0].length;
} }

View File

@ -93,7 +93,7 @@ function* emitKeys(stream) {
name: undefined, name: undefined,
ctrl: false, ctrl: false,
meta: false, meta: false,
shift: false shift: false,
}; };
if (ch === kEscape) { if (ch === kEscape) {
@ -388,5 +388,5 @@ module.exports = {
commonPrefix, commonPrefix,
emitKeys, emitKeys,
kSubstringSearch, kSubstringSearch,
CSI CSI,
}; };

View File

@ -30,7 +30,7 @@ class F extends E {
[kClone]() { [kClone]() {
return { return {
data: { b: this.b }, data: { b: this.b },
deserializeInfo: 'internal/test/transfer:F' deserializeInfo: 'internal/test/transfer:F',
}; };
} }

View File

@ -113,7 +113,7 @@ function setup(root) {
}, },
destroy(asyncId) { destroy(asyncId) {
testResources.delete(asyncId); testResources.delete(asyncId);
} },
}); });
hook.enable(); hook.enable();

View File

@ -2,7 +2,7 @@
const { const {
codes: { codes: {
ERR_TEST_FAILURE, ERR_TEST_FAILURE,
} },
} = require('internal/errors'); } = require('internal/errors');
const AssertionError = require('internal/assert/assertion_error'); const AssertionError = require('internal/assert/assertion_error');
const { const {
@ -37,7 +37,7 @@ function reConstructError(parsedYaml) {
message: parsedYaml.error, message: parsedYaml.error,
actual: parsedYaml.actual, actual: parsedYaml.actual,
expected: parsedYaml.expected, expected: parsedYaml.expected,
operator: parsedYaml.operator operator: parsedYaml.operator,
}); });
} else { } else {
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax

View File

@ -12,7 +12,7 @@ const {
const { const {
Timeout, Timeout,
Immediate, Immediate,
insert insert,
} = require('internal/timers'); } = require('internal/timers');
const { const {
clearImmediate, clearImmediate,
@ -26,7 +26,7 @@ const {
ERR_ILLEGAL_CONSTRUCTOR, ERR_ILLEGAL_CONSTRUCTOR,
ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_TYPE,
ERR_INVALID_THIS, ERR_INVALID_THIS,
} },
} = require('internal/errors'); } = require('internal/errors');
const { const {