Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 9e17d0b

Browse files
authored
Chore: Minor cleanup, fix jQuery foundation copyright (#383)
1 parent 5576fb4 commit 9e17d0b

14 files changed

+40
-61
lines changed

lib/ast-converter.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @fileoverview Converts TypeScript AST into ESTree format.
33
* @author Nicholas C. Zakas
4+
* @author James Henry <https://github.com/JamesHenry>
45
* @copyright jQuery Foundation and other contributors, https://jquery.org/
56
* MIT License
67
*/

lib/ast-node-types.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @fileoverview The AST node types produced by the parser.
33
* @author Nicholas C. Zakas
4+
* @author James Henry <https://github.com/JamesHenry>
45
* @copyright jQuery Foundation and other contributors, https://jquery.org/
56
* MIT License
67
*/

lib/convert-comments.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @fileoverview Convert comment using TypeScript token scanner
3-
* @author James Henry
3+
* @author James Henry <https://github.com/JamesHenry>
44
* @copyright jQuery Foundation and other contributors, https://jquery.org/
55
* MIT License
66
*/

lib/convert.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @fileoverview Converts TypeScript AST into ESTree format.
33
* @author Nicholas C. Zakas
4+
* @author James Henry <https://github.com/JamesHenry>
45
* @copyright jQuery Foundation and other contributors, https://jquery.org/
56
* MIT License
67
*/

lib/node-utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @fileoverview Utilities for finding and converting TSNodes into ESTreeNodes
3-
* @author James Henry
3+
* @author James Henry <https://github.com/JamesHenry>
44
* @copyright jQuery Foundation and other contributors, https://jquery.org/
55
* MIT License
66
*/

tests/ast-alignment/known-issues.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
"use strict";
2+
13
/**
24
* ==================================================
35
* KNOWN/DIAGNOSED ISSUES
46
* ==================================================
57
*/
68

7-
// const fixturePatternsToTest = [
9+
module.exports = [
810
/**
911
* "ExperimentalSpreadProperty" in espree/typescript-eslint-parser vs "SpreadElement" in Babylon
1012
* comes up a lot in this section
@@ -41,7 +43,7 @@
4143
* Babylon parse error because of more strict spec enforcement than other parsers.
4244
*/
4345

44-
/**
46+
/**
4547
* super() is being used outside of constructor. Other parsers (e.g. espree, acorn) do not error on this.
4648
*/
4749
// "ecma-features/classes/class-one-method-super.src.js", // babylon parse errors
@@ -78,11 +80,11 @@
7880
// pattern: "ecma-features/modules/error-delete.src.js",
7981
// config: { babylonParserOptions: { sourceType: "module" } }
8082
// },
81-
/**
83+
/**
8284
* 'with' in strict mode
8385
*/
8486
// {
8587
// pattern: "ecma-features/modules/error-strict.src.js",
8688
// config: { babylonParserOptions: { sourceType: "module" } }
8789
// },
88-
// ];
90+
];

tests/ast-alignment/spec.js

+20-33
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ const fixturePatternsToTest = [
226226
* so we have to specify the "sourceType" we want to use.
227227
*
228228
* By default we have configured babylon to use "script", but for the examples below we need "module".
229-
* Maybe fixed by https://github.com/babel/babylon/commit/00ad6d8310ce826dcdd59c7a819dbd50955058d7?
230229
*/
231230
{
232231
pattern: "comments/export-default-anonymous-class.src.js",
@@ -637,6 +636,14 @@ fixturePatternsToTest.forEach(fixturePattern => {
637636
});
638637
});
639638

639+
/* eslint-disable */
640+
/**
641+
* Common predicates for Babylon AST preprocessing
642+
*/
643+
const always = () => true;
644+
const ifNumber = (val) => typeof val === "number";
645+
/* eslint-enable */
646+
640647
/**
641648
* - Babylon wraps the "Program" node in an extra "File" node, normalize this for simplicity for now...
642649
* - 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) {
649656
return parseUtils.omitDeep(ast.program, [
650657
{
651658
key: "start",
652-
predicate(val) {
653-
// only remove the "start" number (not the "start" object within loc)
654-
return typeof val === "number";
655-
}
659+
// only remove the "start" number (not the "start" object within loc)
660+
predicate: ifNumber
656661
},
657662
{
658663
key: "end",
659-
predicate(val) {
660-
// only remove the "end" number (not the "end" object within loc)
661-
return typeof val === "number";
662-
}
664+
// only remove the "end" number (not the "end" object within loc)
665+
predicate: ifNumber
663666
},
664667
{
665668
key: "identifierName",
666-
predicate() {
667-
return true;
668-
}
669+
predicate: always
669670
},
670671
{
671672
key: "extra",
672-
predicate() {
673-
return true;
674-
}
673+
predicate: always
675674
},
676675
{
677676
key: "directives",
678-
predicate() {
679-
return true;
680-
}
677+
predicate: always
681678
},
682679
{
683680
key: "directive",
684-
predicate() {
685-
return true;
686-
}
681+
predicate: always
687682
},
688683
{
689684
key: "innerComments",
690-
predicate() {
691-
return true;
692-
}
685+
predicate: always
693686
},
694687
{
695688
key: "leadingComments",
696-
predicate() {
697-
return true;
698-
}
689+
predicate: always
699690
},
700691
{
701692
key: "trailingComments",
702-
predicate() {
703-
return true;
704-
}
693+
predicate: always
705694
},
706695
{
707696
key: "guardedHandlers",
708-
predicate() {
709-
return true;
710-
}
697+
predicate: always
711698
}
712699
]);
713700
}

tests/lib/basics.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @fileoverview Tests for basic expressions
33
* @author Nicholas C. Zakas
4+
* @author James Henry <https://github.com/JamesHenry>
45
* @copyright jQuery Foundation and other contributors, https://jquery.org/
56
* MIT License
67
*/

tests/lib/comments.js

+3-21
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
11
/**
22
* @fileoverview Tests for parsing and attaching comments.
33
* @author Nicholas C. Zakas
4-
* @copyright 2014 Nicholas C. Zakas. All rights reserved.
5-
*
6-
* Redistribution and use in source and binary forms, with or without
7-
* modification, are permitted provided that the following conditions are met:
8-
*
9-
* * Redistributions of source code must retain the above copyright
10-
* notice, this list of conditions and the following disclaimer.
11-
* * Redistributions in binary form must reproduce the above copyright
12-
* notice, this list of conditions and the following disclaimer in the
13-
* documentation and/or other materials provided with the distribution.
14-
*
15-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18-
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19-
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24-
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4+
* @author James Henry <https://github.com/JamesHenry>
5+
* @copyright jQuery Foundation and other contributors, https://jquery.org/
6+
* MIT License
257
*/
268

279
"use strict";

tests/lib/ecma-features.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @fileoverview Tests for ECMA feature flags
33
* @author Nicholas C. Zakas
4+
* @author James Henry <https://github.com/JamesHenry>
45
* @copyright jQuery Foundation and other contributors, https://jquery.org/
56
* MIT License
67
*/

tests/lib/jsx.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @fileoverview Tests for ECMA feature flags
33
* @author Nicholas C. Zakas
4+
* @author James Henry <https://github.com/JamesHenry>
45
* @copyright jQuery Foundation and other contributors, https://jquery.org/
56
* MIT License
67
*/

tests/lib/parse.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @fileoverview Tests for tokenize().
33
* @author Nicholas C. Zakas
4+
* @author James Henry <https://github.com/JamesHenry>
45
* @copyright jQuery Foundation and other contributors, https://jquery.org/
56
* MIT License
67
*/

tests/lib/typescript.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @fileoverview Tests for ECMA feature flags
33
* @author Nicholas C. Zakas
4+
* @author James Henry <https://github.com/JamesHenry>
45
* @copyright jQuery Foundation and other contributors, https://jquery.org/
56
* MIT License
67
*/

tools/test-utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @fileoverview Tools for running test cases
33
* @author Nicholas C. Zakas
4+
* @author James Henry <https://github.com/JamesHenry>
45
* @copyright jQuery Foundation and other contributors, https://jquery.org/
56
* MIT License
67
*/
@@ -29,7 +30,6 @@ function getRaw(ast) {
2930
if ((key === "start" || key === "end") && typeof value === "number") {
3031
return undefined;
3132
}
32-
3333
return value;
3434
}));
3535
}

0 commit comments

Comments
 (0)