mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-08 20:48:41 +00:00
Migrate to eslint
Summary We'd like contributors to use the same linter and lint rules that we use internally. This diff swaps out eslint for jshint and fixes all lint failures except for the max-len failures in the test suites. Test Plan: - ka-lint src - make lint - make test Reviewers: emily
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/* eslint no-constant-condition:0 */
|
||||
var fontMetrics = require("./fontMetrics");
|
||||
var parseData = require("./parseData");
|
||||
var ParseError = require("./ParseError");
|
||||
@@ -10,7 +11,9 @@ var ParseNode = parseData.ParseNode;
|
||||
* with one group per cell.
|
||||
*/
|
||||
function parseArray(parser, result) {
|
||||
var row = [], body = [row], rowGaps = [];
|
||||
var row = [];
|
||||
var body = [row];
|
||||
var rowGaps = [];
|
||||
while (true) {
|
||||
var cell = parser.parseExpression(false, null);
|
||||
row.push(new ParseNode("ordgroup", cell, parser.mode));
|
||||
@@ -74,7 +77,7 @@ function defineEnvironment(names, props, handler) {
|
||||
greediness: 1,
|
||||
allowedInText: !!props.allowedInText,
|
||||
numOptionalArgs: props.numOptionalArgs || 0,
|
||||
handler: handler
|
||||
handler: handler,
|
||||
};
|
||||
for (var i = 0; i < names.length; ++i) {
|
||||
module.exports[names[i]] = data;
|
||||
@@ -84,7 +87,7 @@ function defineEnvironment(names, props, handler) {
|
||||
// Arrays are part of LaTeX, defined in lttab.dtx so its documentation
|
||||
// is part of the source2e.pdf file of LaTeX2e source documentation.
|
||||
defineEnvironment("array", {
|
||||
numArgs: 1
|
||||
numArgs: 1,
|
||||
}, function(context, args) {
|
||||
var colalign = args[0];
|
||||
colalign = colalign.value.map ? colalign.value : [colalign];
|
||||
@@ -93,12 +96,12 @@ defineEnvironment("array", {
|
||||
if ("lcr".indexOf(ca) !== -1) {
|
||||
return {
|
||||
type: "align",
|
||||
align: ca
|
||||
align: ca,
|
||||
};
|
||||
} else if (ca === "|") {
|
||||
return {
|
||||
type: "separator",
|
||||
separator: "|"
|
||||
separator: "|",
|
||||
};
|
||||
}
|
||||
throw new ParseError(
|
||||
@@ -108,7 +111,7 @@ defineEnvironment("array", {
|
||||
var res = {
|
||||
type: "array",
|
||||
cols: cols,
|
||||
hskipBeforeAndAfter: true // \@preamble in lttab.dtx
|
||||
hskipBeforeAndAfter: true, // \@preamble in lttab.dtx
|
||||
};
|
||||
res = parseArray(context.parser, res);
|
||||
return res;
|
||||
@@ -122,7 +125,7 @@ defineEnvironment([
|
||||
"bmatrix",
|
||||
"Bmatrix",
|
||||
"vmatrix",
|
||||
"Vmatrix"
|
||||
"Vmatrix",
|
||||
], {
|
||||
}, function(context) {
|
||||
var delimiters = {
|
||||
@@ -131,18 +134,18 @@ defineEnvironment([
|
||||
"bmatrix": ["[", "]"],
|
||||
"Bmatrix": ["\\{", "\\}"],
|
||||
"vmatrix": ["|", "|"],
|
||||
"Vmatrix": ["\\Vert", "\\Vert"]
|
||||
"Vmatrix": ["\\Vert", "\\Vert"],
|
||||
}[context.envName];
|
||||
var res = {
|
||||
type: "array",
|
||||
hskipBeforeAndAfter: false // \hskip -\arraycolsep in amsmath
|
||||
hskipBeforeAndAfter: false, // \hskip -\arraycolsep in amsmath
|
||||
};
|
||||
res = parseArray(context.parser, res);
|
||||
if (delimiters) {
|
||||
res = new ParseNode("leftright", {
|
||||
body: [res],
|
||||
left: delimiters[0],
|
||||
right: delimiters[1]
|
||||
right: delimiters[1],
|
||||
}, context.mode);
|
||||
}
|
||||
return res;
|
||||
@@ -160,19 +163,19 @@ defineEnvironment("cases", {
|
||||
type: "align",
|
||||
align: "l",
|
||||
pregap: 0,
|
||||
postgap: fontMetrics.metrics.quad
|
||||
postgap: fontMetrics.metrics.quad,
|
||||
}, {
|
||||
type: "align",
|
||||
align: "l",
|
||||
pregap: 0,
|
||||
postgap: 0
|
||||
}]
|
||||
postgap: 0,
|
||||
}],
|
||||
};
|
||||
res = parseArray(context.parser, res);
|
||||
res = new ParseNode("leftright", {
|
||||
body: [res],
|
||||
left: "\\{",
|
||||
right: "."
|
||||
right: ".",
|
||||
}, context.mode);
|
||||
return res;
|
||||
});
|
||||
@@ -185,7 +188,7 @@ defineEnvironment("aligned", {
|
||||
}, function(context) {
|
||||
var res = {
|
||||
type: "array",
|
||||
cols: []
|
||||
cols: [],
|
||||
};
|
||||
res = parseArray(context.parser, res);
|
||||
var emptyGroup = new ParseNode("ordgroup", [], context.mode);
|
||||
@@ -211,7 +214,7 @@ defineEnvironment("aligned", {
|
||||
type: "align",
|
||||
align: align,
|
||||
pregap: pregap,
|
||||
postgap: 0
|
||||
postgap: 0,
|
||||
};
|
||||
}
|
||||
return res;
|
||||
|
Reference in New Issue
Block a user