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 <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
  • Loading branch information
aduh95 authored and danielleadams committed Apr 3, 2023
1 parent 3afbb92 commit c410572
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 12 deletions.
49 changes: 49 additions & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,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/cjs/helpers.js
Original file line number Diff line number Diff line change
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 @@ -201,7 +201,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit c410572

Please sign in to comment.