From c9f9435445bb30041f9191a760986acc1e204106 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sun, 14 Feb 2016 23:25:14 +0000 Subject: [PATCH] Switch to klint, fix some lint rules --- bin/babylon.js | 1 + src/parser/comments.js | 1 + src/parser/expression.js | 5 ++++- src/parser/index.js | 2 +- src/parser/lval.js | 2 ++ src/parser/statement.js | 3 +++ src/plugins/flow.js | 8 +++++--- src/plugins/jsx/index.js | 2 ++ src/tokenizer/context.js | 5 +++-- src/tokenizer/index.js | 2 ++ src/util/identifier.js | 2 ++ 11 files changed, 26 insertions(+), 7 deletions(-) diff --git a/bin/babylon.js b/bin/babylon.js index db5d8bc96d..449ddfed00 100755 --- a/bin/babylon.js +++ b/bin/babylon.js @@ -1,4 +1,5 @@ #!/usr/bin/env node +/* eslint no-var: 0 */ var babylon = require(".."); var fs = require("fs"); diff --git a/src/parser/comments.js b/src/parser/comments.js index 38f2081322..9fabbed737 100644 --- a/src/parser/comments.js +++ b/src/parser/comments.js @@ -1,4 +1,5 @@ /* @flow */ +/* eslint max-len: 0 */ /** * Based on the comment attachment algorithm used in espree and estraverse. diff --git a/src/parser/expression.js b/src/parser/expression.js index ae299c7175..bc89b4bdf5 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -1,3 +1,6 @@ +/* eslint indent: 0 */ +/* eslint max-len: 0 */ + // A recursive descent parser operates by defining functions for all // syntactic elements, and recursively calling those, each function // advancing the input stream and returning an AST node. Precedence @@ -969,7 +972,7 @@ pp.parseAwait = function (node) { this.unexpected(); } if (this.match(tt.star)) { - this.raise(node.start, "await* has been removed from the async functions proposal. Use Promise.all() instead.") + this.raise(node.start, "await* has been removed from the async functions proposal. Use Promise.all() instead."); } node.argument = this.parseMaybeUnary(); return this.finishNode(node, "AwaitExpression"); diff --git a/src/parser/index.js b/src/parser/index.js index 14a3ff4b72..bc034e0549 100644 --- a/src/parser/index.js +++ b/src/parser/index.js @@ -36,7 +36,7 @@ export default class Parser extends Tokenizer { if (plugins.indexOf("flow") >= 0) { // ensure flow plugin loads last - plugins = plugins.filter(plugin => plugin !== "flow"); + plugins = plugins.filter((plugin) => plugin !== "flow"); plugins.push("flow"); } diff --git a/src/parser/lval.js b/src/parser/lval.js index 895323f8df..fe3e6bb34e 100644 --- a/src/parser/lval.js +++ b/src/parser/lval.js @@ -1,3 +1,5 @@ +/* eslint indent: 0 */ + import { types as tt } from "../tokenizer/types"; import Parser from "./index"; import { reservedWords } from "../util/identifier"; diff --git a/src/parser/statement.js b/src/parser/statement.js index 1d5f112ab9..5a9c2ae9df 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -1,3 +1,6 @@ +/* eslint indent: 0 */ +/* eslint max-len: 0 */ + import { types as tt } from "../tokenizer/types"; import Parser from "./index"; import { lineBreak } from "../util/whitespace"; diff --git a/src/plugins/flow.js b/src/plugins/flow.js index 9111361904..f856955176 100644 --- a/src/plugins/flow.js +++ b/src/plugins/flow.js @@ -1,3 +1,6 @@ +/* eslint indent: 0 */ +/* eslint max-len: 0 */ + import { types as tt } from "../tokenizer/types"; import Parser from "../parser"; @@ -115,8 +118,7 @@ pp.flowParseDeclareInterface = function (node) { this.next(); this.flowParseInterfaceish(node); return this.finishNode(node, "DeclareInterface"); -} - +}; // Interfaces @@ -920,7 +922,7 @@ export default function (instance) { node.typeParameters = null; } implemented.push(this.finishNode(node, "ClassImplements")); - } while (this.eat(tt.comma)) + } while (this.eat(tt.comma)); } }; }); diff --git a/src/plugins/jsx/index.js b/src/plugins/jsx/index.js index 28d1ce2ee8..ea371a8fab 100644 --- a/src/plugins/jsx/index.js +++ b/src/plugins/jsx/index.js @@ -1,3 +1,5 @@ +/* eslint indent: 0 */ + import XHTMLEntities from "./xhtml"; import { TokenType, types as tt } from "../../tokenizer/types"; import { TokContext, types as tc } from "../../tokenizer/context"; diff --git a/src/tokenizer/context.js b/src/tokenizer/context.js index fb1bcc57f6..bd35e67860 100644 --- a/src/tokenizer/context.js +++ b/src/tokenizer/context.js @@ -34,7 +34,7 @@ export const types: { b_tmpl: new TokContext("${", true), p_stat: new TokContext("(", false), p_expr: new TokContext("(", true), - q_tmpl: new TokContext("`", true, true, p => p.readTmplToken()), + q_tmpl: new TokContext("`", true, true, (p) => p.readTmplToken()), f_expr: new TokContext("function", true) }; @@ -78,7 +78,8 @@ tt.dollarBraceL.updateContext = function () { }; tt.parenL.updateContext = function (prevType) { - let statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while; + let statementParens = prevType === tt._if || prevType === tt._for || + prevType === tt._with || prevType === tt._while; this.state.context.push(statementParens ? types.p_stat : types.p_expr); this.state.exprAllowed = true; }; diff --git a/src/tokenizer/index.js b/src/tokenizer/index.js index 7203e30aac..504bfa80c3 100644 --- a/src/tokenizer/index.js +++ b/src/tokenizer/index.js @@ -1,4 +1,6 @@ /* @noflow */ +/* eslint max-len: 0 */ +/* eslint indent: 0 */ import type { TokenType } from "./types"; import { isIdentifierStart, isIdentifierChar, isKeyword } from "../util/identifier"; diff --git a/src/util/identifier.js b/src/util/identifier.js index 7df2faada3..ff74f604d4 100644 --- a/src/util/identifier.js +++ b/src/util/identifier.js @@ -1,3 +1,5 @@ +/* eslint max-len: 0 */ + // This is a trick taken from Esprima. It turns out that, on // non-Chrome browsers, to check whether a string is in a set, a // predicate containing a big ugly `switch` statement is faster than