prefer rest and spread

master
Futago-za Ryuu 6 years ago
parent 60f69d6558
commit f66751ba39

@ -7,7 +7,6 @@ module.exports = {
"rules": {
"no-eval": 0,
"prefer-rest-params": 0,
},

@ -1,12 +0,0 @@
"use strict";
module.exports = {
"rules": {
"prefer-spread": 0,
"strict": 0,
},
};

@ -17,7 +17,7 @@ class ASTVisitor {
// istanbul ignore next
if ( ! fn ) throw new Error( `Visitor function for node type "${ node.type }" not defined` );
return fn.apply( this, arguments );
return fn.apply( this, arguments ); // eslint-disable-line prefer-rest-params
}
@ -45,14 +45,13 @@ const on = ASTVisitor.on = {
// Visit a node that is defined as a property on another node
property( name ) {
return function visitProperty( node ) {
return function visitProperty( node, ...extraArgs ) {
const extraArgs = __slice.call( arguments, 1 );
const value = node[ name ];
if ( extraArgs.length )
this.visit.apply( this, [ value ].concat( extraArgs ) );
this.visit( value, ...extraArgs );
else
@ -65,13 +64,12 @@ const on = ASTVisitor.on = {
// Visit an array of nodes that are defined as a property on another node
children( name ) {
return function visitProperty( node ) {
return function visitProperty( node, ...extraArgs ) {
const args = __slice.call( arguments, 0 );
const children = node[ name ];
const visitor = this;
const cb = args.length < 2
const cb = extraArgs.length < 1
? function withoutArgs( child ) {
visitor.visit( child );
@ -79,8 +77,7 @@ const on = ASTVisitor.on = {
}
: function withArgs( child ) {
args[ 0 ] = child;
visitor.visit.apply( visitor, args );
visitor.visit( child, ...extraArgs );
};
@ -99,21 +96,17 @@ const visitExpression = on.property( "expression" );
const DEFAULT_FUNCTIONS = {
grammar( node ) {
const args = [ void 0 ].concat( __slice.call( arguments, 1 ) );
grammar( node, ...extraArgs ) {
if ( node.initializer ) {
args[ 0 ] = node.initializer;
this.visit.apply( this, args );
this.visit( node.initializer, ...extraArgs );
}
node.rules.forEach( rule => {
args[ 0 ] = rule;
this.visit.apply( this, args );
this.visit( rule, ...extraArgs );
} );

@ -244,11 +244,7 @@ function generateBytecode( ast, session ) {
}
function buildSequence() {
return Array.prototype.concat.apply( [], arguments );
}
const buildSequence = ( ...parts ) => [].concat( ...parts );
function buildCondition( match, condCode, thenCode, elseCode ) {

Loading…
Cancel
Save