Enable ESLint prefer-rest-params rule (#7400)

This commit is contained in:
fisker Cheung authored and Georgii Dolzhykov committed 2020-01-23 10:36:18 +02:00
1 parent 6f1ed54206
commit 27b5cb4d9d
3 files changed
+18 -20

No files matched your search

+1
View File
@@ -44,6 +44,7 @@ rules:
object: false
- enforceForRenamedProperties: false
prefer-object-spread: error
prefer-rest-params: error
prefer-spread: error
quotes:
- error
+15 -15
View File
@@ -56,13 +56,13 @@ FastPath.prototype.getParentNode = function getParentNode(count) {
// reference to this (modified) FastPath object. Note that the stack will
// be restored to its original state after the callback is finished, so it
// is probably a mistake to retain a reference to the path.
FastPath.prototype.call = function call(callback /*, name1, name2, ... */) {
FastPath.prototype.call = function call(callback, ...names) {
const s = this.stack;
const origLen = s.length;
let value = s[origLen - 1];
const argc = arguments.length;
for (let i = 1; i < argc; ++i) {
const name = arguments[i];
const argc = names.length;
for (let i = 0; i < argc; ++i) {
const name = names[i];
value = value[name];
s.push(name, value);
}
@@ -83,14 +83,14 @@ FastPath.prototype.callParent = function callParent(callback, count) {
// accessing this.getValue()[name1][name2]... should be array-like. The
// callback will be called with a reference to this path object for each
// element of the array.
FastPath.prototype.each = function each(callback /*, name1, name2, ... */) {
FastPath.prototype.each = function each(callback, ...names) {
const s = this.stack;
const origLen = s.length;
let value = s[origLen - 1];
const argc = arguments.length;
const argc = names.length;
for (let i = 1; i < argc; ++i) {
const name = arguments[i];
for (let i = 0; i < argc; ++i) {
const name = names[i];
value = value[name];
s.push(name, value);
}
@@ -111,14 +111,14 @@ FastPath.prototype.each = function each(callback /*, name1, name2, ... */) {
// Similar to FastPath.prototype.each, except that the results of the
// callback function invocations are stored in an array and returned at
// the end of the iteration.
FastPath.prototype.map = function map(callback /*, name1, name2, ... */) {
FastPath.prototype.map = function map(callback, ...names) {
const s = this.stack;
const origLen = s.length;
let value = s[origLen - 1];
const argc = arguments.length;
const argc = names.length;
for (let i = 1; i < argc; ++i) {
const name = arguments[i];
for (let i = 0; i < argc; ++i) {
const name = names[i];
value = value[name];
s.push(name, value);
}
@@ -144,13 +144,13 @@ FastPath.prototype.map = function map(callback /*, name1, name2, ... */) {
* | undefined
* )} predicates
*/
FastPath.prototype.match = function match(/* predicates */) {
FastPath.prototype.match = function match(...predicates) {
let stackPointer = this.stack.length - 1;
let name = null;
let node = this.stack[stackPointer--];
for (let i = 0; i < arguments.length; ++i) {
for (let i = 0; i < predicates.length; ++i) {
if (node === undefined) {
return false;
}
@@ -163,7 +163,7 @@ FastPath.prototype.match = function match(/* predicates */) {
node = this.stack[stackPointer--];
}
if (arguments[i] && !arguments[i](node, name, number)) {
if (predicates[i] && !predicates[i](node, name, number)) {
return false;
}
+2 -5
View File
@@ -516,11 +516,8 @@ function requireParser(isSCSSParser) {
// TODO: Remove this hack when this issue is fixed:
// https://github.com/shellscape/postcss-less/issues/88
const LessParser = require("postcss-less/dist/less-parser");
LessParser.prototype.atrule = function() {
return Object.getPrototypeOf(LessParser.prototype).atrule.apply(
this,
arguments
);
LessParser.prototype.atrule = function(...args) {
return Object.getPrototypeOf(LessParser.prototype).atrule.apply(this, args);
};
return require("postcss-less");