Skip to content

Commit 5272ece

Browse files
committed
Fixed some warnings and errors from ESLint
1 parent afec221 commit 5272ece

File tree

5 files changed

+23
-34
lines changed

5 files changed

+23
-34
lines changed

.eslintrc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"eol-last": 2,
1212
"eqeqeq": [2, "allow-null"],
1313
"guard-for-in": 0,
14-
"indent": [1, 4, {"SwitchCase": 1}],
14+
"indent": [1, 4, {"CallExpression": {"arguments": "first"}, "flatTernaryExpressions": true, "SwitchCase": 1}],
1515
"keyword-spacing": 2,
1616
"linebreak-style": [2, "unix"],
1717
"max-len": [2, 84, 4, { "ignoreUrls": true, "ignorePattern": "\\brequire\\([\"']|eslint-disable", "ignoreComments": true, }],
@@ -61,18 +61,6 @@
6161
"valid-jsdoc": 0,
6262
"require-jsdoc": 0
6363
},
64-
"ecmaFeatures": {
65-
"arrowFunctions": true,
66-
"blockBindings": true,
67-
"classes": true,
68-
"destructuring": true,
69-
"experimentalObjectRestSpread": true,
70-
"forOf": true,
71-
"jsx": true,
72-
"restParams": true,
73-
"spread": true,
74-
"templateStrings": true
75-
},
7664
"env": {
7765
"es6": true,
7866
"node": true,

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules/
44
static/katex/
55
static/fonts/
66
npm-debug.log
7+
package-lock.json

src/Lexer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var mathPattern = {
6363
var pos = remain.indexOf(endDel);
6464
if (pos < 0)
6565
throw new ParseError('Math environment is not closed',
66-
this._pos, this._input);
66+
this._pos, this._input);
6767

6868
// false positive, it's escaped, not a match
6969
if (pos > 0 && remain[pos - 1] === '\\') {

src/Parser.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ Parser.prototype._parseFunction = function() {
273273
lexer.expect('func', 'end' + funcType);
274274

275275
var functionNode = new ParseNode('function',
276-
{type: funcType, name: funcName});
276+
{type: funcType, name: funcName});
277277
functionNode.addChild(argsNode);
278278
functionNode.addChild(blockNode);
279279
return functionNode;
@@ -478,9 +478,8 @@ var ACCEPTED_TOKEN_BY_ATOM = {
478478
Parser.prototype._parseAtom = function() {
479479
for (var atomType in ACCEPTED_TOKEN_BY_ATOM) {
480480
var acceptToken = ACCEPTED_TOKEN_BY_ATOM[atomType];
481-
var tokenText = this._lexer.accept(
482-
acceptToken.tokenType,
483-
acceptToken.tokenValues);
481+
var tokenText = this._lexer.accept(acceptToken.tokenType,
482+
acceptToken.tokenValues);
484483
if (tokenText === null) continue;
485484

486485
var anyWhitespace = this._lexer.get().whitespace;

src/Renderer.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ function TextEnvironment(nodes, textStyle) {
139139

140140
TextEnvironment.prototype._renderCloseText = function(node) {
141141
var newTextStyle = new TextStyle(this._textStyle.fontSize());
142-
var closeTextEnv = new TextEnvironment(
143-
node.children, newTextStyle);
142+
var closeTextEnv = new TextEnvironment(node.children, newTextStyle);
144143
if (node.whitespace) this._html.putText(' ');
145144
this._html.putSpan(closeTextEnv.renderToHTML());
146145
};
@@ -169,9 +168,10 @@ TextEnvironment.prototype.renderToHTML = function() {
169168
this._html.putSpan(mathHTML);
170169
break;
171170
case 'cond-symbol':
172-
this._html.beginSpan('ps-keyword')
173-
.putText(text.toLowerCase())
174-
.endSpan();
171+
this._html
172+
.beginSpan('ps-keyword')
173+
.putText(text.toLowerCase())
174+
.endSpan();
175175
break;
176176
case 'special':
177177
if (text === '\\\\') {
@@ -243,7 +243,7 @@ TextEnvironment.prototype.renderToHTML = function() {
243243
this._textStyle.updateByCommand(text);
244244
this._html.beginSpan(null, this._textStyle.toCSS());
245245
var textEnvForDclr = new TextEnvironment(this._nodes,
246-
this._textStyle);
246+
this._textStyle);
247247
this._html.putSpan(textEnvForDclr.renderToHTML());
248248
this._html.endSpan();
249249
break;
@@ -255,7 +255,7 @@ TextEnvironment.prototype.renderToHTML = function() {
255255
innerTextStyle.updateByCommand(text);
256256
this._html.beginSpan(null, innerTextStyle.toCSS());
257257
var textEnvForCmd = new TextEnvironment(textNode.children,
258-
innerTextStyle);
258+
innerTextStyle);
259259
this._html.putSpan(textEnvForCmd.renderToHTML());
260260
this._html.endSpan();
261261
break;
@@ -389,7 +389,7 @@ var entityMap = {
389389
};
390390

391391
HTMLBuilder.prototype._escapeHtml = function(string) {
392-
return String(string).replace(/[&<>"'\/]/g, function(s) {
392+
return String(string).replace(/[&<>"'/]/g, function(s) {
393393
return entityMap[s];
394394
});
395395
};
@@ -412,8 +412,8 @@ HTMLBuilder.prototype._escapeHtml = function(string) {
412412
**/
413413
function RendererOptions(options) {
414414
options = options || {};
415-
this.indentSize = options.indentSize ?
416-
this._parseEmVal(options.indentSize) : 1.2;
415+
this.indentSize =
416+
options.indentSize ? this._parseEmVal(options.indentSize) : 1.2;
417417
this.commentDelimiter = options.commentDelimiter || ' // ';
418418
this.lineNumberPunc = options.lineNumberPunc || ':';
419419
this.lineNumber = options.lineNumber !== undefined ? options.lineNumber : false;
@@ -505,11 +505,12 @@ Renderer.prototype._newLine = function() {
505505

506506
this._html.beginP('ps-line ps-code', this._globalTextStyle.toCSS());
507507
if (this._options.lineNumber) {
508-
this._html.beginSpan('ps-linenum', {
509-
'left': -((this._blockLevel - 1) * (indentSize * 1.25)) + 'em',
510-
})
511-
.putText(this._numLOC + this._options.lineNumberPunc)
512-
.endSpan();
508+
this._html
509+
.beginSpan('ps-linenum', {
510+
'left': -((this._blockLevel - 1) * (indentSize * 1.25)) + 'em',
511+
})
512+
.putText(this._numLOC + this._options.lineNumberPunc)
513+
.endSpan();
513514
}
514515
}
515516
// if this line is for pre-conditions (e.g. \REQUIRE)
@@ -797,7 +798,7 @@ Renderer.prototype._buildTree = function(node) {
797798
// ------------------- Text -------------------
798799
case 'open-text':
799800
var openTextEnv = new TextEnvironment(node.children,
800-
this._globalTextStyle);
801+
this._globalTextStyle);
801802
this._html.putSpan(openTextEnv.renderToHTML());
802803
break;
803804
case 'close-text':

0 commit comments

Comments
 (0)