Skip to content

Commit 9be890c

Browse files
committed
review eslint core rules: enable some rules for parameters
1 parent bc32a7f commit 9be890c

25 files changed

+43
-16
lines changed

packages/core-js-compat/compat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function getModules(filter) {
2525

2626
function normalizeModules(option) {
2727
// TODO: use `.flatMap` in core-js@4
28-
return new Set(Array.isArray(option) ? [].concat.apply([], option.map(getModules)) : getModules(option));
28+
return new Set(Array.isArray(option) ? [].concat(...option.map(getModules)) : getModules(option));
2929
}
3030

3131
function checkModule(name, targets) {

tests/eslint/eslint.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ const base = {
124124
camelcase: [ERROR, { properties: NEVER }],
125125
// enforce default clauses in switch statements to be last
126126
'default-case-last': ERROR,
127+
// enforce default parameters to be last
128+
'default-param-last': ERROR,
127129
// encourages use of dot notation whenever possible
128130
'dot-notation': [ERROR, { allowKeywords: true }],
129131
// require the use of === and !==
@@ -262,6 +264,10 @@ const base = {
262264
'prefer-exponentiation-operator': ERROR,
263265
// prefer `Object.hasOwn`
264266
'prefer-object-has-own': ERROR,
267+
// require rest parameters instead of `arguments`
268+
'prefer-rest-params': ERROR,
269+
// require spread operators instead of `.apply()`
270+
'prefer-spread': ERROR,
265271
// require template literals instead of string concatenation
266272
'prefer-template': ERROR,
267273
// require or disallow use of quotes around object literal property names
@@ -767,6 +773,10 @@ const es3 = {
767773
'prefer-exponentiation-operator': OFF,
768774
// prefer `Object.hasOwn`
769775
'prefer-object-has-own': OFF,
776+
// require rest parameters instead of `arguments`
777+
'prefer-rest-params': OFF,
778+
// require spread operators instead of `.apply()`
779+
'prefer-spread': OFF,
770780
// require template literals instead of string concatenation
771781
'prefer-template': OFF,
772782
// require or disallow use of quotes around object literal property names

tests/helpers/helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ export function patchRegExp$exec(run) {
139139
return assert => {
140140
const originalExec = RegExp.prototype.exec;
141141
// eslint-disable-next-line no-extend-native -- required for testing
142-
RegExp.prototype.exec = function () {
143-
return originalExec.apply(this, arguments);
142+
RegExp.prototype.exec = function (...args) {
143+
return originalExec.apply(this, args);
144144
};
145145
try {
146146
return run(assert);

tests/helpers/qunit-helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ assign(QUnit.assert, {
3333
: 'Enumerability is not applicable',
3434
});
3535
},
36-
epsilon(a, b, EPSILON = 1e-11, message) {
36+
epsilon(a, b, EPSILON = 1e-11, message = null) {
3737
const result = Math.abs(a - b) <= EPSILON;
3838
this.pushResult({
3939
result,

tests/unit-global/es.array.from.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable prefer-rest-params -- required for testing */
12
import { DESCRIPTORS, GLOBAL } from '../helpers/constants';
23
import { createIterable } from '../helpers/helpers';
34

tests/unit-global/es.array.is-array.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ QUnit.test('Array.isArray', assert => {
77
assert.nonEnumerable(Array, 'isArray');
88
assert.false(isArray({}));
99
assert.false(isArray(function () {
10+
// eslint-disable-next-line prefer-rest-params -- required for testing
1011
return arguments;
1112
}()));
1213
assert.true(isArray([]));

tests/unit-global/es.object.to-string.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ QUnit.test('Object#toString', assert => {
2020
assert.same(toString.call(/./), '[object RegExp]', 'regexp -> `RegExp`');
2121
assert.same(toString.call(new TypeError()), '[object Error]', 'new TypeError -> `Error`');
2222
assert.same(toString.call(function () {
23+
// eslint-disable-next-line prefer-rest-params -- required for testing
2324
return arguments;
2425
}()), '[object Arguments]', 'arguments -> `Arguments`');
2526
const constructors = [

tests/unit-global/es.regexp.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
QUnit.test('RegExp#test delegates to exec', assert => {
3-
const exec = function () {
3+
const exec = function (...args) {
44
execCalled = true;
5-
return /./.exec.apply(this, arguments);
5+
return /./.exec.apply(this, args);
66
};
77

88
let execCalled = false;

tests/unit-global/es.string.from-code-point.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable prefer-spread -- required for testing */
12
QUnit.test('String.fromCodePoint', assert => {
23
const { fromCodePoint } = String;
34
assert.isFunction(fromCodePoint);

tests/unit-global/es.string.match.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ QUnit.test('String#match delegates to @@match', assert => {
228228
});
229229

230230
QUnit.test('RegExp#@@match delegates to exec', assert => {
231-
const exec = function () {
231+
const exec = function (...args) {
232232
execCalled = true;
233-
return /./.exec.apply(this, arguments);
233+
return /./.exec.apply(this, args);
234234
};
235235

236236
let execCalled = false;

0 commit comments

Comments
 (0)