Code style: Fix some ESLint errors in generated code

Running ESLint on generated code with the configuration used on PEG.js
itself produces a lot of errors. This commit fixes some unnecessary ones
caught by these rules:

  - max-len
  - new-cap
  - newline-before-return
  - no-unused-vars

See also 5dd8e797f7.

Follow-up to #407.
redux
David Majda 8 years ago
parent 7d6ad99e33
commit f4df9ddde1

@ -746,9 +746,9 @@ function generateJS(ast, options) {
parts.push([
"function peg$subclass(child, parent) {",
" function ctor() { this.constructor = child; }",
" ctor.prototype = parent.prototype;",
" child.prototype = new ctor();",
" function C() { this.constructor = child; }",
" C.prototype = parent.prototype;",
" child.prototype = new C();",
"}",
"",
"function peg$SyntaxError(message, expected, found, location) {",
@ -781,11 +781,11 @@ function generateJS(ast, options) {
" return \"[\" + (expectation.inverted ? \"^\" : \"\") + escapedParts + \"]\";",
" },",
"",
" any: function(expectation) {",
" any: function() {",
" return \"any character\";",
" },",
"",
" end: function(expectation) {",
" end: function() {",
" return \"end of input\";",
" },",
"",
@ -1039,7 +1039,9 @@ function generateJS(ast, options) {
" }",
"",
" function expected(description, location) {",
" location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos);",
" location = location !== undefined",
" ? location",
" : peg$computeLocation(peg$savedPos, peg$currPos);",
"",
" throw peg$buildStructuredError(",
" [peg$otherExpectation(description)],",
@ -1049,7 +1051,9 @@ function generateJS(ast, options) {
" }",
"",
" function error(message, location) {",
" location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos);",
" location = location !== undefined",
" ? location",
" : peg$computeLocation(peg$savedPos, peg$currPos);",
"",
" throw peg$buildSimpleError(message, location);",
" }",
@ -1104,6 +1108,7 @@ function generateJS(ast, options) {
" }",
"",
" peg$posDetailsCache[pos] = details;",
"",
" return details;",
" }",
" }",

@ -5,9 +5,9 @@
"use strict";
function peg$subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
function C() { this.constructor = child; }
C.prototype = parent.prototype;
child.prototype = new C();
}
function peg$SyntaxError(message, expected, found, location) {
@ -40,11 +40,11 @@ peg$SyntaxError.buildMessage = function(expected, found) {
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
},
any: function(expectation) {
any: function() {
return "any character";
},
end: function(expectation) {
end: function() {
return "end of input";
},
@ -507,7 +507,9 @@ function peg$parse(input, options) {
}
function expected(description, location) {
location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos);
location = location !== undefined
? location
: peg$computeLocation(peg$savedPos, peg$currPos);
throw peg$buildStructuredError(
[peg$otherExpectation(description)],
@ -517,7 +519,9 @@ function peg$parse(input, options) {
}
function error(message, location) {
location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos);
location = location !== undefined
? location
: peg$computeLocation(peg$savedPos, peg$currPos);
throw peg$buildSimpleError(message, location);
}
@ -572,6 +576,7 @@ function peg$parse(input, options) {
}
peg$posDetailsCache[pos] = details;
return details;
}
}

Loading…
Cancel
Save