diff --git a/.eslintrc b/.eslintrc index 8146c443..e09da909 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,12 @@ { "parser": "babel-eslint", + "plugins": [ + "flowtype" + ], + "extends": [ + "eslint:recommended", + "plugin:flowtype/recommended" + ], "rules": { "arrow-spacing": 2, "brace-style": [2, "1tbs", { "allowSingleLine": true }], @@ -12,7 +19,8 @@ "eol-last": 2, "eqeqeq": [2, "allow-null"], "guard-for-in": 2, - "indent": [2, 4, {"SwitchCase": 1}], + "indent": "off", + "indent-legacy": [2, 4, {"SwitchCase": 1}], "keyword-spacing": 2, "linebreak-style": [2, "unix"], "max-len": [2, 84, 4, { "ignoreUrls": true, "ignorePattern": "\\brequire\\([\"']|eslint-disable" }], @@ -79,6 +87,5 @@ "node": true, "browser": true }, - "extends": "eslint:recommended", "root": true } diff --git a/package.json b/package.json index ecfc6ec0..facab45f 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "babelify": "^7.3.0", "browserify": "^13.3.0", "clean-css": "^3.4.23", - "eslint": "^3.13.0", + "eslint": "^4.6.1", + "eslint-plugin-flowtype": "^2.35.1", "express": "^4.14.0", "flow-bin": "^0.54.0", "glob": "^7.1.1", diff --git a/src/ParseError.js b/src/ParseError.js index 39457471..48791946 100644 --- a/src/ParseError.js +++ b/src/ParseError.js @@ -11,11 +11,12 @@ import {Token} from "./Token"; * about where in the source string the problem occurred. */ class ParseError { - position: number|void; // Error position based on passed-in Token or ParseNode. + position: number | void; + // Error position based on passed-in Token or ParseNode. constructor( - message: string, // The error message - token?: Token|ParseNode, // An object providing position information + message: string, // The error message + token?: Token | ParseNode, // An object providing position information ) { let error = "KaTeX parse error: " + message; let start; diff --git a/src/ParseNode.js b/src/ParseNode.js index cb562126..f399ae1c 100644 --- a/src/ParseNode.js +++ b/src/ParseNode.js @@ -16,9 +16,9 @@ export default class ParseNode { // TODO: We should combine these to ({lexer, start, end}|void) as they // should all exist together or not exist at all. That way, only a single // void check needs to be done to see if we have metadata. - lexer: LexerInterface|void; - start: number|void; - end: number|void; + lexer: LexerInterface | void; + start: number | void; + end: number | void; constructor( type: string, // type of node, like e.g. "ordgroup" diff --git a/src/Parser.js b/src/Parser.js index 2728eb96..e706d024 100644 --- a/src/Parser.js +++ b/src/Parser.js @@ -847,7 +847,7 @@ class Parser { } return new ParseFuncOrArgument( new ParseNode("ordgroup", expression, this.mode, - firstToken, lastToken), + firstToken, lastToken), false); } else { // Otherwise, just return a nucleus, or nothing for an optional group diff --git a/src/macros.js b/src/macros.js index e04ea40c..f08c95fe 100644 --- a/src/macros.js +++ b/src/macros.js @@ -216,7 +216,7 @@ defineMacro("\\dotsi", "\\!\\cdots"); // amsmath doesn't actually define \dotsx, but \dots followed by a macro // starting with \DOTSX implies \dotso, and then \extra@ detects this case // and forces the added `\,`. -defineMacro("\\dotsx", "\\ldots\,"); +defineMacro("\\dotsx", "\\ldots\\,"); // \let\DOTSI\relax // \let\DOTSB\relax diff --git a/test/errors-spec.js b/test/errors-spec.js index 823a0949..93a2a982 100644 --- a/test/errors-spec.js +++ b/test/errors-spec.js @@ -286,7 +286,7 @@ describe("environments.js:", function() { }); it("rejects incorrectly scoped \\end", function() { expect("{\\begin{matrix}1}\\end{matrix}").toFailWithParseError( - "Expected & or \\\\\ or \\end at position 17:" + + "Expected & or \\\\ or \\end at position 17:" + " …\\begin{matrix}1}̲\\end{matrix}"); }); }); diff --git a/test/katex-spec.js b/test/katex-spec.js index 21201442..99cbb097 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -2384,8 +2384,8 @@ describe("A macro expander", function() { it("should expand the \\overset macro as expected", function() { expect("\\overset?=").toParseLike("\\mathop{=}\\limits^{?}"); - expect("\\overset{x=y}{\sqrt{ab}}") - .toParseLike("\\mathop{\sqrt{ab}}\\limits^{x=y}"); + expect("\\overset{x=y}{\\sqrt{ab}}") + .toParseLike("\\mathop{\\sqrt{ab}}\\limits^{x=y}"); expect("\\overset {?} =").toParseLike("\\mathop{=}\\limits^{?}"); });