Skip to content

Commit

Permalink
lib: enforce use of trailing commas in more files
Browse files Browse the repository at this point in the history
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: #46655
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
  • Loading branch information
aduh95 authored and MylesBorins committed Feb 20, 2023
1 parent a0a6ee0 commit 8b46c76
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 13 deletions.
49 changes: 49 additions & 0 deletions lib/.eslintrc.yaml
Expand Up @@ -261,3 +261,52 @@ globals:
module: false
internalBinding: 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]
4 changes: 2 additions & 2 deletions lib/internal/modules/helpers.js
Expand Up @@ -15,7 +15,7 @@ const {
} = primordials;
const {
ERR_MANIFEST_DEPENDENCY_MISSING,
ERR_UNKNOWN_BUILTIN_MODULE
ERR_UNKNOWN_BUILTIN_MODULE,
} = require('internal/errors').codes;
const { BuiltinModule } = require('internal/bootstrap/loaders');

Expand Down Expand Up @@ -210,7 +210,7 @@ function addBuiltinLibsToObject(object, dummyModuleName) {
},
set: setReal,
configurable: true,
enumerable: false
enumerable: false,
});
});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/policy/sri.js
Expand Up @@ -14,7 +14,7 @@ const {
} = primordials;

const {
ERR_SRI_PARSE
ERR_SRI_PARSE,
} = require('internal/errors').codes;
const kWSP = '[\\x20\\x09]';
const kVCHAR = '[\\x21-\\x7E]';
Expand Down Expand Up @@ -55,7 +55,7 @@ const parse = (str) => {
algorithm: match[2],
value: BufferFrom(match[3], 'base64'),
options: match[4] === undefined ? null : match[4],
})
}),
});
prevIndex += match[0].length;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/readline/utils.js
Expand Up @@ -93,7 +93,7 @@ function* emitKeys(stream) {
name: undefined,
ctrl: false,
meta: false,
shift: false
shift: false,
};

if (ch === kEscape) {
Expand Down Expand Up @@ -388,5 +388,5 @@ module.exports = {
commonPrefix,
emitKeys,
kSubstringSearch,
CSI
CSI,
};
2 changes: 1 addition & 1 deletion lib/internal/test/transfer.js
Expand Up @@ -30,7 +30,7 @@ class F extends E {
[kClone]() {
return {
data: { b: this.b },
deserializeInfo: 'internal/test/transfer:F'
deserializeInfo: 'internal/test/transfer:F',
};
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/test_runner/harness.js
Expand Up @@ -113,7 +113,7 @@ function setup(root) {
},
destroy(asyncId) {
testResources.delete(asyncId);
}
},
});

hook.enable();
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/test_runner/yaml_to_js.js
Expand Up @@ -2,7 +2,7 @@
const {
codes: {
ERR_TEST_FAILURE,
}
},
} = require('internal/errors');
const AssertionError = require('internal/assert/assertion_error');
const {
Expand Down Expand Up @@ -37,7 +37,7 @@ function reConstructError(parsedYaml) {
message: parsedYaml.error,
actual: parsedYaml.actual,
expected: parsedYaml.expected,
operator: parsedYaml.operator
operator: parsedYaml.operator,
});
} else {
// eslint-disable-next-line no-restricted-syntax
Expand Down
4 changes: 2 additions & 2 deletions lib/timers/promises.js
Expand Up @@ -12,7 +12,7 @@ const {
const {
Timeout,
Immediate,
insert
insert,
} = require('internal/timers');
const {
clearImmediate,
Expand All @@ -26,7 +26,7 @@ const {
ERR_ILLEGAL_CONSTRUCTOR,
ERR_INVALID_ARG_TYPE,
ERR_INVALID_THIS,
}
},
} = require('internal/errors');

const {
Expand Down
2 changes: 1 addition & 1 deletion lib/vm.js
Expand Up @@ -88,7 +88,7 @@ class Script extends ContextifyScript {
throw new ERR_INVALID_ARG_TYPE(
'options.cachedData',
['Buffer', 'TypedArray', 'DataView'],
cachedData
cachedData,
);
}
validateBoolean(produceCachedData, 'options.produceCachedData');
Expand Down

0 comments on commit 8b46c76

Please sign in to comment.