forked from typescript-eslint/typescript-eslint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
312aebc
commit c5cbeb6
Showing
576 changed files
with
214,395 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* text=auto | ||
*.js eol=lf | ||
*.ts eol=lf | ||
*.yml eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
**What version of TypeScript are you using?** | ||
|
||
|
||
**What version of `typescript-estree` are you using?** | ||
|
||
|
||
**What code were you trying to parse?** | ||
|
||
```ts | ||
// Put your code here | ||
``` | ||
|
||
**What did you expect to happen?** | ||
|
||
|
||
**What actually happened?** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
build | ||
coverage | ||
node_modules | ||
npm-debug.log | ||
_test.js | ||
.DS_Store | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
language: node_js | ||
cache: | ||
yarn: true | ||
directories: | ||
- node_modules | ||
notifications: | ||
email: false | ||
node_js: | ||
- '10' | ||
- '9' | ||
- '8' | ||
- '6' | ||
install: | ||
- yarn --ignore-engines | ||
script: | ||
- yarn test | ||
after_success: | ||
- npm run travis-deploy-once "npm run semantic-release" | ||
branches: | ||
only: | ||
- master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
TypeScript ESTree | ||
|
||
Originally extracted from: | ||
|
||
TypeScript ESLint Parser | ||
Copyright JS Foundation and other contributors, https://js.foundation | ||
|
||
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 <COPYRIGHT HOLDER> 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h1>DO NOT USE - POC ONLY</h1> | ||
|
||
# TypeScript ESTree | ||
|
||
A parser that converts TypeScript source code into an [ESTree](https://github.com/estree/estree)-compatible form. | ||
|
||
More docs to follow here soon... (PRs welcome!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* @fileoverview Converts TypeScript AST into ESTree format. | ||
* @author Nicholas C. Zakas | ||
* @author James Henry <https://github.com/JamesHenry> | ||
* @copyright jQuery Foundation and other contributors, https://jquery.org/ | ||
* MIT License | ||
*/ | ||
|
||
"use strict"; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Requirements | ||
//------------------------------------------------------------------------------ | ||
|
||
const convert = require("./convert"), | ||
convertComments = require("./convert-comments").convertComments, | ||
nodeUtils = require("./node-utils"); | ||
|
||
//------------------------------------------------------------------------------ | ||
// Private | ||
//------------------------------------------------------------------------------ | ||
|
||
/** | ||
* Extends and formats a given error object | ||
* @param {Object} error the error object | ||
* @returns {Object} converted error object | ||
*/ | ||
function convertError(error) { | ||
return nodeUtils.createError(error.file, error.start, error.message || error.messageText); | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
// Public | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = (ast, extra) => { | ||
|
||
/** | ||
* The TypeScript compiler produced fundamental parse errors when parsing the | ||
* source. | ||
*/ | ||
if (ast.parseDiagnostics.length) { | ||
throw convertError(ast.parseDiagnostics[0]); | ||
} | ||
|
||
/** | ||
* Recursively convert the TypeScript AST into an ESTree-compatible AST | ||
*/ | ||
const estree = convert({ | ||
node: ast, | ||
parent: null, | ||
ast, | ||
additionalOptions: { | ||
errorOnUnknownASTType: extra.errorOnUnknownASTType || false, | ||
useJSXTextNode: extra.useJSXTextNode || false | ||
} | ||
}); | ||
|
||
/** | ||
* Optionally convert and include all tokens in the AST | ||
*/ | ||
if (extra.tokens) { | ||
estree.tokens = nodeUtils.convertTokens(ast); | ||
} | ||
|
||
/** | ||
* Optionally convert and include all comments in the AST | ||
*/ | ||
if (extra.comment) { | ||
estree.comments = convertComments(ast, extra.code); | ||
} | ||
|
||
return estree; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
/** | ||
* @fileoverview The AST node types produced by the parser. | ||
* @author Nicholas C. Zakas | ||
* @author James Henry <https://github.com/JamesHenry> | ||
* @copyright jQuery Foundation and other contributors, https://jquery.org/ | ||
* MIT License | ||
*/ | ||
|
||
"use strict"; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Requirements | ||
//------------------------------------------------------------------------------ | ||
|
||
// None! | ||
|
||
//------------------------------------------------------------------------------ | ||
// Public | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = { | ||
ArrayExpression: "ArrayExpression", | ||
ArrayPattern: "ArrayPattern", | ||
ArrowFunctionExpression: "ArrowFunctionExpression", | ||
AssignmentExpression: "AssignmentExpression", | ||
AssignmentPattern: "AssignmentPattern", | ||
AwaitExpression: "AwaitExpression", | ||
BinaryExpression: "BinaryExpression", | ||
BlockStatement: "BlockStatement", | ||
BreakStatement: "BreakStatement", | ||
CallExpression: "CallExpression", | ||
CatchClause: "CatchClause", | ||
ClassBody: "ClassBody", | ||
ClassDeclaration: "ClassDeclaration", | ||
ClassExpression: "ClassExpression", | ||
ClassImplements: "ClassImplements", | ||
ClassProperty: "ClassProperty", | ||
ConditionalExpression: "ConditionalExpression", | ||
ContinueStatement: "ContinueStatement", | ||
DebuggerStatement: "DebuggerStatement", | ||
DeclareFunction: "DeclareFunction", | ||
Decorator: "Decorator", | ||
DoWhileStatement: "DoWhileStatement", | ||
EmptyStatement: "EmptyStatement", | ||
ExportAllDeclaration: "ExportAllDeclaration", | ||
ExportDefaultDeclaration: "ExportDefaultDeclaration", | ||
ExportNamedDeclaration: "ExportNamedDeclaration", | ||
ExportSpecifier: "ExportSpecifier", | ||
ExpressionStatement: "ExpressionStatement", | ||
ForInStatement: "ForInStatement", | ||
ForOfStatement: "ForOfStatement", | ||
ForStatement: "ForStatement", | ||
FunctionDeclaration: "FunctionDeclaration", | ||
FunctionExpression: "FunctionExpression", | ||
GenericTypeAnnotation: "GenericTypeAnnotation", | ||
Identifier: "Identifier", | ||
IfStatement: "IfStatement", | ||
Import: "Import", | ||
ImportDeclaration: "ImportDeclaration", | ||
ImportDefaultSpecifier: "ImportDefaultSpecifier", | ||
ImportNamespaceSpecifier: "ImportNamespaceSpecifier", | ||
ImportSpecifier: "ImportSpecifier", | ||
JSXAttribute: "JSXAttribute", | ||
JSXClosingElement: "JSXClosingElement", | ||
JSXElement: "JSXElement", | ||
JSXEmptyExpression: "JSXEmptyExpression", | ||
JSXExpressionContainer: "JSXExpressionContainer", | ||
JSXIdentifier: "JSXIdentifier", | ||
JSXMemberExpression: "JSXMemberExpression", | ||
JSXNamespacedName: "JSXNamespacedName", | ||
JSXOpeningElement: "JSXOpeningElement", | ||
JSXSpreadAttribute: "JSXSpreadAttribute", | ||
JSXSpreadChild: "JSXSpreadChild", | ||
JSXText: "JSXText", | ||
LabeledStatement: "LabeledStatement", | ||
Literal: "Literal", | ||
LogicalExpression: "LogicalExpression", | ||
MemberExpression: "MemberExpression", | ||
MetaProperty: "MetaProperty", | ||
MethodDefinition: "MethodDefinition", | ||
NewExpression: "NewExpression", | ||
ObjectExpression: "ObjectExpression", | ||
ObjectPattern: "ObjectPattern", | ||
Program: "Program", | ||
Property: "Property", | ||
RestElement: "RestElement", | ||
ReturnStatement: "ReturnStatement", | ||
SequenceExpression: "SequenceExpression", | ||
SpreadElement: "SpreadElement", | ||
Super: "Super", | ||
SwitchCase: "SwitchCase", | ||
SwitchStatement: "SwitchStatement", | ||
TaggedTemplateExpression: "TaggedTemplateExpression", | ||
TemplateElement: "TemplateElement", | ||
TemplateLiteral: "TemplateLiteral", | ||
ThisExpression: "ThisExpression", | ||
ThrowStatement: "ThrowStatement", | ||
TryStatement: "TryStatement", | ||
/** | ||
* TS-prefixed nodes | ||
*/ | ||
TSAbstractClassProperty: "TSAbstractClassProperty", | ||
TSAbstractKeyword: "TSAbstractKeyword", | ||
TSAbstractMethodDefinition: "TSAbstractMethodDefinition", | ||
TSAnyKeyword: "TSAnyKeyword", | ||
TSArrayType: "TSArrayType", | ||
TSAsyncKeyword: "TSAsyncKeyword", | ||
TSBooleanKeyword: "TSBooleanKeyword", | ||
TSConstructorType: "TSConstructorType", | ||
TSConstructSignature: "TSConstructSignature", | ||
TSDeclareKeyword: "TSDeclareKeyword", | ||
TSEnumDeclaration: "TSEnumDeclaration", | ||
TSEnumMember: "TSEnumMember", | ||
TSExportAssignment: "TSExportAssignment", | ||
TSExportKeyword: "TSExportKeyword", | ||
TSImportType: "TSImportType", | ||
TSLiteralType: "TSLiteralType", | ||
TSIndexSignature: "TSIndexSignature", | ||
TSInterfaceBody: "TSInterfaceBody", | ||
TSInterfaceDeclaration: "TSInterfaceDeclaration", | ||
TSInterfaceHeritage: "TSInterfaceHeritage", | ||
TSFunctionType: "TSFunctionType", | ||
TSMethodSignature: "TSMethodSignature", | ||
TSModuleBlock: "TSModuleBlock", | ||
TSModuleDeclaration: "TSModuleDeclaration", | ||
TSNamespaceFunctionDeclaration: "TSNamespaceFunctionDeclaration", | ||
TSNonNullExpression: "TSNonNullExpression", | ||
TSNeverKeyword: "TSNeverKeyword", | ||
TSNullKeyword: "TSNullKeyword", | ||
TSNumberKeyword: "TSNumberKeyword", | ||
TSObjectKeyword: "TSObjectKeyword", | ||
TSParameterProperty: "TSParameterProperty", | ||
TSPrivateKeyword: "TSPrivateKeyword", | ||
TSPropertySignature: "TSPropertySignature", | ||
TSProtectedKeyword: "TSProtectedKeyword", | ||
TSPublicKeyword: "TSPublicKeyword", | ||
TSQualifiedName: "TSQualifiedName", | ||
TSQuestionToken: "TSQuestionToken", | ||
TSReadonlyKeyword: "TSReadonlyKeyword", | ||
TSStaticKeyword: "TSStaticKeyword", | ||
TSStringKeyword: "TSStringKeyword", | ||
TSSymbolKeyword: "TSSymbolKeyword", | ||
TSTypeAnnotation: "TSTypeAnnotation", | ||
TSTypeLiteral: "TSTypeLiteral", | ||
TSTypeOperator: "TSTypeOperator", | ||
TSTypeParameter: "TSTypeParameter", | ||
TSTypeParameterDeclaration: "TSTypeParameterDeclaration", | ||
TSTypeParameterInstantiation: "TSTypeParameterInstantiation", | ||
TSTypePredicate: "TSTypePredicate", | ||
TSTypeReference: "TSTypeReference", | ||
TSUnionType: "TSUnionType", | ||
TSUndefinedKeyword: "TSUndefinedKeyword", | ||
TSVoidKeyword: "TSVoidKeyword", | ||
UnaryExpression: "UnaryExpression", | ||
UpdateExpression: "UpdateExpression", | ||
VariableDeclaration: "VariableDeclaration", | ||
VariableDeclarator: "VariableDeclarator", | ||
WhileStatement: "WhileStatement", | ||
WithStatement: "WithStatement", | ||
YieldExpression: "YieldExpression" | ||
}; |
Oops, something went wrong.