From f7c7a21fc0d20aac99e67a75e3c114aeb9a19740 Mon Sep 17 00:00:00 2001 From: James Henry Date: Thu, 7 Sep 2017 11:09:55 +0100 Subject: [PATCH] Chore: Minor cleanup, fix jQuery foundation copyright --- lib/ast-converter.js | 1 + lib/ast-node-types.js | 1 + lib/convert-comments.js | 2 +- lib/convert.js | 1 + lib/node-utils.js | 2 +- tests/ast-alignment/known-issues.js | 10 +++--- tests/ast-alignment/spec.js | 53 +++++++++++------------------ tests/lib/basics.js | 1 + tests/lib/comments.js | 24 ++----------- tests/lib/ecma-features.js | 1 + tests/lib/jsx.js | 1 + tests/lib/parse.js | 1 + tests/lib/typescript.js | 1 + tools/test-utils.js | 2 +- 14 files changed, 40 insertions(+), 61 deletions(-) diff --git a/lib/ast-converter.js b/lib/ast-converter.js index 066dc47..4bc072b 100644 --- a/lib/ast-converter.js +++ b/lib/ast-converter.js @@ -1,6 +1,7 @@ /** * @fileoverview Converts TypeScript AST into ESTree format. * @author Nicholas C. Zakas + * @author James Henry * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ diff --git a/lib/ast-node-types.js b/lib/ast-node-types.js index 29d3377..1e048da 100644 --- a/lib/ast-node-types.js +++ b/lib/ast-node-types.js @@ -1,6 +1,7 @@ /** * @fileoverview The AST node types produced by the parser. * @author Nicholas C. Zakas + * @author James Henry * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ diff --git a/lib/convert-comments.js b/lib/convert-comments.js index e51cec9..866aa44 100644 --- a/lib/convert-comments.js +++ b/lib/convert-comments.js @@ -1,6 +1,6 @@ /** * @fileoverview Convert comment using TypeScript token scanner - * @author James Henry + * @author James Henry * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ diff --git a/lib/convert.js b/lib/convert.js index 11e572c..c6a3deb 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -1,6 +1,7 @@ /** * @fileoverview Converts TypeScript AST into ESTree format. * @author Nicholas C. Zakas + * @author James Henry * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ diff --git a/lib/node-utils.js b/lib/node-utils.js index da5ffdf..928ff14 100644 --- a/lib/node-utils.js +++ b/lib/node-utils.js @@ -1,6 +1,6 @@ /** * @fileoverview Utilities for finding and converting TSNodes into ESTreeNodes - * @author James Henry + * @author James Henry * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ diff --git a/tests/ast-alignment/known-issues.js b/tests/ast-alignment/known-issues.js index e00cd9b..ab98bbf 100644 --- a/tests/ast-alignment/known-issues.js +++ b/tests/ast-alignment/known-issues.js @@ -1,10 +1,12 @@ +"use strict"; + /** * ================================================== * KNOWN/DIAGNOSED ISSUES * ================================================== */ -// const fixturePatternsToTest = [ +module.exports = [ /** * "ExperimentalSpreadProperty" in espree/typescript-eslint-parser vs "SpreadElement" in Babylon * comes up a lot in this section @@ -41,7 +43,7 @@ * Babylon parse error because of more strict spec enforcement than other parsers. */ - /** + /** * super() is being used outside of constructor. Other parsers (e.g. espree, acorn) do not error on this. */ // "ecma-features/classes/class-one-method-super.src.js", // babylon parse errors @@ -78,11 +80,11 @@ // pattern: "ecma-features/modules/error-delete.src.js", // config: { babylonParserOptions: { sourceType: "module" } } // }, - /** + /** * 'with' in strict mode */ // { // pattern: "ecma-features/modules/error-strict.src.js", // config: { babylonParserOptions: { sourceType: "module" } } // }, -// ]; +]; diff --git a/tests/ast-alignment/spec.js b/tests/ast-alignment/spec.js index d07bbb3..4f2c5ff 100644 --- a/tests/ast-alignment/spec.js +++ b/tests/ast-alignment/spec.js @@ -226,7 +226,6 @@ const fixturePatternsToTest = [ * so we have to specify the "sourceType" we want to use. * * By default we have configured babylon to use "script", but for the examples below we need "module". - * Maybe fixed by https://github.com/babel/babylon/commit/00ad6d8310ce826dcdd59c7a819dbd50955058d7? */ { pattern: "comments/export-default-anonymous-class.src.js", @@ -637,6 +636,14 @@ fixturePatternsToTest.forEach(fixturePattern => { }); }); +/* eslint-disable */ +/** + * Common predicates for Babylon AST preprocessing + */ +const always = () => true; +const ifNumber = (val) => typeof val === "number"; +/* eslint-enable */ + /** * - Babylon wraps the "Program" node in an extra "File" node, normalize this for simplicity for now... * - Remove "start" and "end" values from Babylon nodes to reduce unimportant noise in diffs ("loc" data will still be in @@ -649,65 +656,45 @@ function preprocessBabylonAST(ast) { return parseUtils.omitDeep(ast.program, [ { key: "start", - predicate(val) { - // only remove the "start" number (not the "start" object within loc) - return typeof val === "number"; - } + // only remove the "start" number (not the "start" object within loc) + predicate: ifNumber }, { key: "end", - predicate(val) { - // only remove the "end" number (not the "end" object within loc) - return typeof val === "number"; - } + // only remove the "end" number (not the "end" object within loc) + predicate: ifNumber }, { key: "identifierName", - predicate() { - return true; - } + predicate: always }, { key: "extra", - predicate() { - return true; - } + predicate: always }, { key: "directives", - predicate() { - return true; - } + predicate: always }, { key: "directive", - predicate() { - return true; - } + predicate: always }, { key: "innerComments", - predicate() { - return true; - } + predicate: always }, { key: "leadingComments", - predicate() { - return true; - } + predicate: always }, { key: "trailingComments", - predicate() { - return true; - } + predicate: always }, { key: "guardedHandlers", - predicate() { - return true; - } + predicate: always } ]); } diff --git a/tests/lib/basics.js b/tests/lib/basics.js index 7f3f4d0..8a727e8 100644 --- a/tests/lib/basics.js +++ b/tests/lib/basics.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for basic expressions * @author Nicholas C. Zakas + * @author James Henry * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ diff --git a/tests/lib/comments.js b/tests/lib/comments.js index 36f7987..ec54992 100644 --- a/tests/lib/comments.js +++ b/tests/lib/comments.js @@ -1,27 +1,9 @@ /** * @fileoverview Tests for parsing and attaching comments. * @author Nicholas C. Zakas - * @copyright 2014 Nicholas C. Zakas. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * @author James Henry + * @copyright jQuery Foundation and other contributors, https://jquery.org/ + * MIT License */ "use strict"; diff --git a/tests/lib/ecma-features.js b/tests/lib/ecma-features.js index b7b1521..8e41717 100644 --- a/tests/lib/ecma-features.js +++ b/tests/lib/ecma-features.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for ECMA feature flags * @author Nicholas C. Zakas + * @author James Henry * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ diff --git a/tests/lib/jsx.js b/tests/lib/jsx.js index edc705d..fc0a720 100644 --- a/tests/lib/jsx.js +++ b/tests/lib/jsx.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for ECMA feature flags * @author Nicholas C. Zakas + * @author James Henry * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ diff --git a/tests/lib/parse.js b/tests/lib/parse.js index edeeaa8..c844992 100644 --- a/tests/lib/parse.js +++ b/tests/lib/parse.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for tokenize(). * @author Nicholas C. Zakas + * @author James Henry * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ diff --git a/tests/lib/typescript.js b/tests/lib/typescript.js index 3710605..8e2d6a6 100644 --- a/tests/lib/typescript.js +++ b/tests/lib/typescript.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for ECMA feature flags * @author Nicholas C. Zakas + * @author James Henry * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ diff --git a/tools/test-utils.js b/tools/test-utils.js index 8ae9660..1321d98 100644 --- a/tools/test-utils.js +++ b/tools/test-utils.js @@ -1,6 +1,7 @@ /** * @fileoverview Tools for running test cases * @author Nicholas C. Zakas + * @author James Henry * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ @@ -29,7 +30,6 @@ function getRaw(ast) { if ((key === "start" || key === "end") && typeof value === "number") { return undefined; } - return value; })); }