diff --git a/.eslintrc.js b/.eslintrc.js index ee9ce95..5cc8274 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,7 +7,6 @@ module.exports = { "rules": { "no-eval": 0, - "prefer-rest-params": 0, }, diff --git a/lib/.eslintrc.js b/lib/.eslintrc.js deleted file mode 100644 index 52908c5..0000000 --- a/lib/.eslintrc.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -module.exports = { - - "rules": { - - "prefer-spread": 0, - "strict": 0, - - }, - -}; diff --git a/lib/ast/visitor.js b/lib/ast/visitor.js index 4148331..099b9d0 100644 --- a/lib/ast/visitor.js +++ b/lib/ast/visitor.js @@ -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 ); } ); diff --git a/lib/compiler/passes/generate-bytecode.js b/lib/compiler/passes/generate-bytecode.js index 4b89a05..5ab1c80 100644 --- a/lib/compiler/passes/generate-bytecode.js +++ b/lib/compiler/passes/generate-bytecode.js @@ -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 ) {