Skip to content

Commit c5cbeb6

Browse files
committed
feat(*): Initial commit
1 parent 312aebc commit c5cbeb6

File tree

576 files changed

+214395
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

576 files changed

+214395
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text=auto
2+
*.js eol=lf
3+
*.ts eol=lf
4+
*.yml eol=lf
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
**What version of TypeScript are you using?**
2+
3+
4+
**What version of `typescript-estree` are you using?**
5+
6+
7+
**What code were you trying to parse?**
8+
9+
```ts
10+
// Put your code here
11+
```
12+
13+
**What did you expect to happen?**
14+
15+
16+
**What actually happened?**

packages/typescript-estree/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
build
2+
coverage
3+
node_modules
4+
npm-debug.log
5+
_test.js
6+
.DS_Store
7+
.vscode

packages/typescript-estree/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: node_js
2+
cache:
3+
yarn: true
4+
directories:
5+
- node_modules
6+
notifications:
7+
email: false
8+
node_js:
9+
- '10'
10+
- '9'
11+
- '8'
12+
- '6'
13+
install:
14+
- yarn --ignore-engines
15+
script:
16+
- yarn test
17+
after_success:
18+
- npm run travis-deploy-once "npm run semantic-release"
19+
branches:
20+
only:
21+
- master

packages/typescript-estree/LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
TypeScript ESTree
2+
3+
Originally extracted from:
4+
5+
TypeScript ESLint Parser
6+
Copyright JS Foundation and other contributors, https://js.foundation
7+
8+
Redistribution and use in source and binary forms, with or without
9+
modification, are permitted provided that the following conditions are met:
10+
11+
* Redistributions of source code must retain the above copyright
12+
notice, this list of conditions and the following disclaimer.
13+
* Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in the
15+
documentation and/or other materials provided with the distribution.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

packages/typescript-estree/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h1>DO NOT USE - POC ONLY</h1>
2+
3+
# TypeScript ESTree
4+
5+
A parser that converts TypeScript source code into an [ESTree](https://github.com/estree/estree)-compatible form.
6+
7+
More docs to follow here soon... (PRs welcome!)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* @fileoverview Converts TypeScript AST into ESTree format.
3+
* @author Nicholas C. Zakas
4+
* @author James Henry <https://github.com/JamesHenry>
5+
* @copyright jQuery Foundation and other contributors, https://jquery.org/
6+
* MIT License
7+
*/
8+
9+
"use strict";
10+
11+
//------------------------------------------------------------------------------
12+
// Requirements
13+
//------------------------------------------------------------------------------
14+
15+
const convert = require("./convert"),
16+
convertComments = require("./convert-comments").convertComments,
17+
nodeUtils = require("./node-utils");
18+
19+
//------------------------------------------------------------------------------
20+
// Private
21+
//------------------------------------------------------------------------------
22+
23+
/**
24+
* Extends and formats a given error object
25+
* @param {Object} error the error object
26+
* @returns {Object} converted error object
27+
*/
28+
function convertError(error) {
29+
return nodeUtils.createError(error.file, error.start, error.message || error.messageText);
30+
}
31+
32+
//------------------------------------------------------------------------------
33+
// Public
34+
//------------------------------------------------------------------------------
35+
36+
module.exports = (ast, extra) => {
37+
38+
/**
39+
* The TypeScript compiler produced fundamental parse errors when parsing the
40+
* source.
41+
*/
42+
if (ast.parseDiagnostics.length) {
43+
throw convertError(ast.parseDiagnostics[0]);
44+
}
45+
46+
/**
47+
* Recursively convert the TypeScript AST into an ESTree-compatible AST
48+
*/
49+
const estree = convert({
50+
node: ast,
51+
parent: null,
52+
ast,
53+
additionalOptions: {
54+
errorOnUnknownASTType: extra.errorOnUnknownASTType || false,
55+
useJSXTextNode: extra.useJSXTextNode || false
56+
}
57+
});
58+
59+
/**
60+
* Optionally convert and include all tokens in the AST
61+
*/
62+
if (extra.tokens) {
63+
estree.tokens = nodeUtils.convertTokens(ast);
64+
}
65+
66+
/**
67+
* Optionally convert and include all comments in the AST
68+
*/
69+
if (extra.comment) {
70+
estree.comments = convertComments(ast, extra.code);
71+
}
72+
73+
return estree;
74+
75+
};
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/**
2+
* @fileoverview The AST node types produced by the parser.
3+
* @author Nicholas C. Zakas
4+
* @author James Henry <https://github.com/JamesHenry>
5+
* @copyright jQuery Foundation and other contributors, https://jquery.org/
6+
* MIT License
7+
*/
8+
9+
"use strict";
10+
11+
//------------------------------------------------------------------------------
12+
// Requirements
13+
//------------------------------------------------------------------------------
14+
15+
// None!
16+
17+
//------------------------------------------------------------------------------
18+
// Public
19+
//------------------------------------------------------------------------------
20+
21+
module.exports = {
22+
ArrayExpression: "ArrayExpression",
23+
ArrayPattern: "ArrayPattern",
24+
ArrowFunctionExpression: "ArrowFunctionExpression",
25+
AssignmentExpression: "AssignmentExpression",
26+
AssignmentPattern: "AssignmentPattern",
27+
AwaitExpression: "AwaitExpression",
28+
BinaryExpression: "BinaryExpression",
29+
BlockStatement: "BlockStatement",
30+
BreakStatement: "BreakStatement",
31+
CallExpression: "CallExpression",
32+
CatchClause: "CatchClause",
33+
ClassBody: "ClassBody",
34+
ClassDeclaration: "ClassDeclaration",
35+
ClassExpression: "ClassExpression",
36+
ClassImplements: "ClassImplements",
37+
ClassProperty: "ClassProperty",
38+
ConditionalExpression: "ConditionalExpression",
39+
ContinueStatement: "ContinueStatement",
40+
DebuggerStatement: "DebuggerStatement",
41+
DeclareFunction: "DeclareFunction",
42+
Decorator: "Decorator",
43+
DoWhileStatement: "DoWhileStatement",
44+
EmptyStatement: "EmptyStatement",
45+
ExportAllDeclaration: "ExportAllDeclaration",
46+
ExportDefaultDeclaration: "ExportDefaultDeclaration",
47+
ExportNamedDeclaration: "ExportNamedDeclaration",
48+
ExportSpecifier: "ExportSpecifier",
49+
ExpressionStatement: "ExpressionStatement",
50+
ForInStatement: "ForInStatement",
51+
ForOfStatement: "ForOfStatement",
52+
ForStatement: "ForStatement",
53+
FunctionDeclaration: "FunctionDeclaration",
54+
FunctionExpression: "FunctionExpression",
55+
GenericTypeAnnotation: "GenericTypeAnnotation",
56+
Identifier: "Identifier",
57+
IfStatement: "IfStatement",
58+
Import: "Import",
59+
ImportDeclaration: "ImportDeclaration",
60+
ImportDefaultSpecifier: "ImportDefaultSpecifier",
61+
ImportNamespaceSpecifier: "ImportNamespaceSpecifier",
62+
ImportSpecifier: "ImportSpecifier",
63+
JSXAttribute: "JSXAttribute",
64+
JSXClosingElement: "JSXClosingElement",
65+
JSXElement: "JSXElement",
66+
JSXEmptyExpression: "JSXEmptyExpression",
67+
JSXExpressionContainer: "JSXExpressionContainer",
68+
JSXIdentifier: "JSXIdentifier",
69+
JSXMemberExpression: "JSXMemberExpression",
70+
JSXNamespacedName: "JSXNamespacedName",
71+
JSXOpeningElement: "JSXOpeningElement",
72+
JSXSpreadAttribute: "JSXSpreadAttribute",
73+
JSXSpreadChild: "JSXSpreadChild",
74+
JSXText: "JSXText",
75+
LabeledStatement: "LabeledStatement",
76+
Literal: "Literal",
77+
LogicalExpression: "LogicalExpression",
78+
MemberExpression: "MemberExpression",
79+
MetaProperty: "MetaProperty",
80+
MethodDefinition: "MethodDefinition",
81+
NewExpression: "NewExpression",
82+
ObjectExpression: "ObjectExpression",
83+
ObjectPattern: "ObjectPattern",
84+
Program: "Program",
85+
Property: "Property",
86+
RestElement: "RestElement",
87+
ReturnStatement: "ReturnStatement",
88+
SequenceExpression: "SequenceExpression",
89+
SpreadElement: "SpreadElement",
90+
Super: "Super",
91+
SwitchCase: "SwitchCase",
92+
SwitchStatement: "SwitchStatement",
93+
TaggedTemplateExpression: "TaggedTemplateExpression",
94+
TemplateElement: "TemplateElement",
95+
TemplateLiteral: "TemplateLiteral",
96+
ThisExpression: "ThisExpression",
97+
ThrowStatement: "ThrowStatement",
98+
TryStatement: "TryStatement",
99+
/**
100+
* TS-prefixed nodes
101+
*/
102+
TSAbstractClassProperty: "TSAbstractClassProperty",
103+
TSAbstractKeyword: "TSAbstractKeyword",
104+
TSAbstractMethodDefinition: "TSAbstractMethodDefinition",
105+
TSAnyKeyword: "TSAnyKeyword",
106+
TSArrayType: "TSArrayType",
107+
TSAsyncKeyword: "TSAsyncKeyword",
108+
TSBooleanKeyword: "TSBooleanKeyword",
109+
TSConstructorType: "TSConstructorType",
110+
TSConstructSignature: "TSConstructSignature",
111+
TSDeclareKeyword: "TSDeclareKeyword",
112+
TSEnumDeclaration: "TSEnumDeclaration",
113+
TSEnumMember: "TSEnumMember",
114+
TSExportAssignment: "TSExportAssignment",
115+
TSExportKeyword: "TSExportKeyword",
116+
TSImportType: "TSImportType",
117+
TSLiteralType: "TSLiteralType",
118+
TSIndexSignature: "TSIndexSignature",
119+
TSInterfaceBody: "TSInterfaceBody",
120+
TSInterfaceDeclaration: "TSInterfaceDeclaration",
121+
TSInterfaceHeritage: "TSInterfaceHeritage",
122+
TSFunctionType: "TSFunctionType",
123+
TSMethodSignature: "TSMethodSignature",
124+
TSModuleBlock: "TSModuleBlock",
125+
TSModuleDeclaration: "TSModuleDeclaration",
126+
TSNamespaceFunctionDeclaration: "TSNamespaceFunctionDeclaration",
127+
TSNonNullExpression: "TSNonNullExpression",
128+
TSNeverKeyword: "TSNeverKeyword",
129+
TSNullKeyword: "TSNullKeyword",
130+
TSNumberKeyword: "TSNumberKeyword",
131+
TSObjectKeyword: "TSObjectKeyword",
132+
TSParameterProperty: "TSParameterProperty",
133+
TSPrivateKeyword: "TSPrivateKeyword",
134+
TSPropertySignature: "TSPropertySignature",
135+
TSProtectedKeyword: "TSProtectedKeyword",
136+
TSPublicKeyword: "TSPublicKeyword",
137+
TSQualifiedName: "TSQualifiedName",
138+
TSQuestionToken: "TSQuestionToken",
139+
TSReadonlyKeyword: "TSReadonlyKeyword",
140+
TSStaticKeyword: "TSStaticKeyword",
141+
TSStringKeyword: "TSStringKeyword",
142+
TSSymbolKeyword: "TSSymbolKeyword",
143+
TSTypeAnnotation: "TSTypeAnnotation",
144+
TSTypeLiteral: "TSTypeLiteral",
145+
TSTypeOperator: "TSTypeOperator",
146+
TSTypeParameter: "TSTypeParameter",
147+
TSTypeParameterDeclaration: "TSTypeParameterDeclaration",
148+
TSTypeParameterInstantiation: "TSTypeParameterInstantiation",
149+
TSTypePredicate: "TSTypePredicate",
150+
TSTypeReference: "TSTypeReference",
151+
TSUnionType: "TSUnionType",
152+
TSUndefinedKeyword: "TSUndefinedKeyword",
153+
TSVoidKeyword: "TSVoidKeyword",
154+
UnaryExpression: "UnaryExpression",
155+
UpdateExpression: "UpdateExpression",
156+
VariableDeclaration: "VariableDeclaration",
157+
VariableDeclarator: "VariableDeclarator",
158+
WhileStatement: "WhileStatement",
159+
WithStatement: "WithStatement",
160+
YieldExpression: "YieldExpression"
161+
};

0 commit comments

Comments
 (0)