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

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

Loading…
Cancel
Save