mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 21:52:19 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
346
web/node_modules/babel-eslint/lib/analyze-scope.js
generated
vendored
Normal file
346
web/node_modules/babel-eslint/lib/analyze-scope.js
generated
vendored
Normal file
|
@ -0,0 +1,346 @@
|
|||
"use strict";
|
||||
|
||||
const t = require("@babel/types");
|
||||
const requireFromESLint = require("./require-from-eslint");
|
||||
|
||||
const escope = requireFromESLint("eslint-scope");
|
||||
const Definition = requireFromESLint("eslint-scope/lib/definition").Definition;
|
||||
const OriginalPatternVisitor = requireFromESLint(
|
||||
"eslint-scope/lib/pattern-visitor"
|
||||
);
|
||||
const OriginalReferencer = requireFromESLint("eslint-scope/lib/referencer");
|
||||
const fallback = require("eslint-visitor-keys").getKeys;
|
||||
const childVisitorKeys = require("./visitor-keys");
|
||||
|
||||
const flowFlippedAliasKeys = t.FLIPPED_ALIAS_KEYS.Flow.concat([
|
||||
"ArrayPattern",
|
||||
"ClassDeclaration",
|
||||
"ClassExpression",
|
||||
"FunctionDeclaration",
|
||||
"FunctionExpression",
|
||||
"Identifier",
|
||||
"ObjectPattern",
|
||||
"RestElement",
|
||||
]);
|
||||
const visitorKeysMap = Object.keys(t.VISITOR_KEYS).reduce(function(acc, key) {
|
||||
const value = t.VISITOR_KEYS[key];
|
||||
if (flowFlippedAliasKeys.indexOf(value) === -1) {
|
||||
acc[key] = value;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const propertyTypes = {
|
||||
// loops
|
||||
callProperties: { type: "loop", values: ["value"] },
|
||||
indexers: { type: "loop", values: ["key", "value"] },
|
||||
properties: { type: "loop", values: ["argument", "value"] },
|
||||
types: { type: "loop" },
|
||||
params: { type: "loop" },
|
||||
// single property
|
||||
argument: { type: "single" },
|
||||
elementType: { type: "single" },
|
||||
qualification: { type: "single" },
|
||||
rest: { type: "single" },
|
||||
returnType: { type: "single" },
|
||||
// others
|
||||
typeAnnotation: { type: "typeAnnotation" },
|
||||
typeParameters: { type: "typeParameters" },
|
||||
id: { type: "id" },
|
||||
};
|
||||
|
||||
class PatternVisitor extends OriginalPatternVisitor {
|
||||
ArrayPattern(node) {
|
||||
node.elements.forEach(this.visit, this);
|
||||
}
|
||||
|
||||
ObjectPattern(node) {
|
||||
node.properties.forEach(this.visit, this);
|
||||
}
|
||||
}
|
||||
|
||||
class Referencer extends OriginalReferencer {
|
||||
// inherits.
|
||||
visitPattern(node, options, callback) {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Visit type annotations.
|
||||
this._checkIdentifierOrVisit(node.typeAnnotation);
|
||||
if (t.isAssignmentPattern(node)) {
|
||||
this._checkIdentifierOrVisit(node.left.typeAnnotation);
|
||||
}
|
||||
|
||||
// Overwrite `super.visitPattern(node, options, callback)` in order to not visit `ArrayPattern#typeAnnotation` and `ObjectPattern#typeAnnotation`.
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
options = { processRightHandNodes: false };
|
||||
}
|
||||
|
||||
const visitor = new PatternVisitor(this.options, node, callback);
|
||||
visitor.visit(node);
|
||||
|
||||
// Process the right hand nodes recursively.
|
||||
if (options.processRightHandNodes) {
|
||||
visitor.rightHandNodes.forEach(this.visit, this);
|
||||
}
|
||||
}
|
||||
|
||||
// inherits.
|
||||
visitClass(node) {
|
||||
// Decorators.
|
||||
this._visitArray(node.decorators);
|
||||
|
||||
// Flow type parameters.
|
||||
const typeParamScope = this._nestTypeParamScope(node);
|
||||
|
||||
// Flow super types.
|
||||
this._visitTypeAnnotation(node.implements);
|
||||
this._visitTypeAnnotation(
|
||||
node.superTypeParameters && node.superTypeParameters.params
|
||||
);
|
||||
|
||||
// Basic.
|
||||
super.visitClass(node);
|
||||
|
||||
// Close the type parameter scope.
|
||||
if (typeParamScope) {
|
||||
this.close(node);
|
||||
}
|
||||
}
|
||||
|
||||
// inherits.
|
||||
visitFunction(node) {
|
||||
const typeParamScope = this._nestTypeParamScope(node);
|
||||
|
||||
// Flow return types.
|
||||
this._checkIdentifierOrVisit(node.returnType);
|
||||
|
||||
// Basic.
|
||||
super.visitFunction(node);
|
||||
|
||||
// Close the type parameter scope.
|
||||
if (typeParamScope) {
|
||||
this.close(node);
|
||||
}
|
||||
}
|
||||
|
||||
// inherits.
|
||||
visitProperty(node) {
|
||||
if (node.value && node.value.type === "TypeCastExpression") {
|
||||
this._visitTypeAnnotation(node.value);
|
||||
}
|
||||
this._visitArray(node.decorators);
|
||||
super.visitProperty(node);
|
||||
}
|
||||
|
||||
InterfaceDeclaration(node) {
|
||||
this._createScopeVariable(node, node.id);
|
||||
|
||||
const typeParamScope = this._nestTypeParamScope(node);
|
||||
|
||||
// TODO: Handle mixins
|
||||
this._visitArray(node.extends);
|
||||
this.visit(node.body);
|
||||
|
||||
if (typeParamScope) {
|
||||
this.close(node);
|
||||
}
|
||||
}
|
||||
|
||||
EnumDeclaration(node) {
|
||||
this._createScopeVariable(node, node.id);
|
||||
}
|
||||
|
||||
TypeAlias(node) {
|
||||
this._createScopeVariable(node, node.id);
|
||||
|
||||
const typeParamScope = this._nestTypeParamScope(node);
|
||||
|
||||
this.visit(node.right);
|
||||
|
||||
if (typeParamScope) {
|
||||
this.close(node);
|
||||
}
|
||||
}
|
||||
|
||||
ClassProperty(node) {
|
||||
this._visitClassProperty(node);
|
||||
}
|
||||
|
||||
ClassPrivateProperty(node) {
|
||||
this._visitClassProperty(node);
|
||||
}
|
||||
|
||||
DeclareModule(node) {
|
||||
this._visitDeclareX(node);
|
||||
}
|
||||
|
||||
DeclareFunction(node) {
|
||||
this._visitDeclareX(node);
|
||||
}
|
||||
|
||||
DeclareVariable(node) {
|
||||
this._visitDeclareX(node);
|
||||
}
|
||||
|
||||
DeclareClass(node) {
|
||||
this._visitDeclareX(node);
|
||||
}
|
||||
|
||||
// visit OptionalMemberExpression as a MemberExpression.
|
||||
OptionalMemberExpression(node) {
|
||||
super.MemberExpression(node);
|
||||
}
|
||||
|
||||
_visitClassProperty(node) {
|
||||
this._visitTypeAnnotation(node.typeAnnotation);
|
||||
this.visitProperty(node);
|
||||
}
|
||||
|
||||
_visitDeclareX(node) {
|
||||
if (node.id) {
|
||||
this._createScopeVariable(node, node.id);
|
||||
}
|
||||
|
||||
const typeParamScope = this._nestTypeParamScope(node);
|
||||
if (typeParamScope) {
|
||||
this.close(node);
|
||||
}
|
||||
}
|
||||
|
||||
_createScopeVariable(node, name) {
|
||||
this.currentScope().variableScope.__define(
|
||||
name,
|
||||
new Definition("Variable", name, node, null, null, null)
|
||||
);
|
||||
}
|
||||
|
||||
_nestTypeParamScope(node) {
|
||||
if (!node.typeParameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const parentScope = this.scopeManager.__currentScope;
|
||||
const scope = new escope.Scope(
|
||||
this.scopeManager,
|
||||
"type-parameters",
|
||||
parentScope,
|
||||
node,
|
||||
false
|
||||
);
|
||||
|
||||
this.scopeManager.__nestScope(scope);
|
||||
for (let j = 0; j < node.typeParameters.params.length; j++) {
|
||||
const name = node.typeParameters.params[j];
|
||||
scope.__define(name, new Definition("TypeParameter", name, name));
|
||||
if (name.typeAnnotation) {
|
||||
this._checkIdentifierOrVisit(name);
|
||||
}
|
||||
}
|
||||
scope.__define = function() {
|
||||
return parentScope.__define.apply(parentScope, arguments);
|
||||
};
|
||||
|
||||
return scope;
|
||||
}
|
||||
|
||||
_visitTypeAnnotation(node) {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(node)) {
|
||||
node.forEach(this._visitTypeAnnotation, this);
|
||||
return;
|
||||
}
|
||||
|
||||
// get property to check (params, id, etc...)
|
||||
const visitorValues = visitorKeysMap[node.type];
|
||||
if (!visitorValues) {
|
||||
return;
|
||||
}
|
||||
|
||||
// can have multiple properties
|
||||
for (let i = 0; i < visitorValues.length; i++) {
|
||||
const visitorValue = visitorValues[i];
|
||||
const propertyType = propertyTypes[visitorValue];
|
||||
const nodeProperty = node[visitorValue];
|
||||
// check if property or type is defined
|
||||
if (propertyType == null || nodeProperty == null) {
|
||||
continue;
|
||||
}
|
||||
if (propertyType.type === "loop") {
|
||||
for (let j = 0; j < nodeProperty.length; j++) {
|
||||
if (Array.isArray(propertyType.values)) {
|
||||
for (let k = 0; k < propertyType.values.length; k++) {
|
||||
const loopPropertyNode = nodeProperty[j][propertyType.values[k]];
|
||||
if (loopPropertyNode) {
|
||||
this._checkIdentifierOrVisit(loopPropertyNode);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this._checkIdentifierOrVisit(nodeProperty[j]);
|
||||
}
|
||||
}
|
||||
} else if (propertyType.type === "single") {
|
||||
this._checkIdentifierOrVisit(nodeProperty);
|
||||
} else if (propertyType.type === "typeAnnotation") {
|
||||
this._visitTypeAnnotation(node.typeAnnotation);
|
||||
} else if (propertyType.type === "typeParameters") {
|
||||
for (let l = 0; l < node.typeParameters.params.length; l++) {
|
||||
this._checkIdentifierOrVisit(node.typeParameters.params[l]);
|
||||
}
|
||||
} else if (propertyType.type === "id") {
|
||||
if (node.id.type === "Identifier") {
|
||||
this._checkIdentifierOrVisit(node.id);
|
||||
} else {
|
||||
this._visitTypeAnnotation(node.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_checkIdentifierOrVisit(node) {
|
||||
if (node && node.typeAnnotation) {
|
||||
this._visitTypeAnnotation(node.typeAnnotation);
|
||||
} else if (node && node.type === "Identifier") {
|
||||
this.visit(node);
|
||||
} else {
|
||||
this._visitTypeAnnotation(node);
|
||||
}
|
||||
}
|
||||
|
||||
_visitArray(nodeList) {
|
||||
if (nodeList) {
|
||||
for (const node of nodeList) {
|
||||
this.visit(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function(ast, parserOptions) {
|
||||
const options = {
|
||||
ignoreEval: true,
|
||||
optimistic: false,
|
||||
directive: false,
|
||||
nodejsScope:
|
||||
ast.sourceType === "script" &&
|
||||
(parserOptions.ecmaFeatures &&
|
||||
parserOptions.ecmaFeatures.globalReturn) === true,
|
||||
impliedStrict: false,
|
||||
sourceType: ast.sourceType,
|
||||
ecmaVersion: parserOptions.ecmaVersion || 2018,
|
||||
fallback,
|
||||
};
|
||||
|
||||
options.childVisitorKeys = childVisitorKeys;
|
||||
|
||||
const scopeManager = new escope.ScopeManager(options);
|
||||
const referencer = new Referencer(options, scopeManager);
|
||||
|
||||
referencer.visit(ast);
|
||||
|
||||
return scopeManager;
|
||||
};
|
59
web/node_modules/babel-eslint/lib/babylon-to-espree/attachComments.js
generated
vendored
Normal file
59
web/node_modules/babel-eslint/lib/babylon-to-espree/attachComments.js
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
"use strict";
|
||||
|
||||
// comment fixes
|
||||
module.exports = function(ast, comments, tokens) {
|
||||
if (comments.length) {
|
||||
var firstComment = comments[0];
|
||||
var lastComment = comments[comments.length - 1];
|
||||
// fixup program start
|
||||
if (!tokens.length) {
|
||||
// if no tokens, the program starts at the end of the last comment
|
||||
ast.start = lastComment.end;
|
||||
ast.loc.start.line = lastComment.loc.end.line;
|
||||
ast.loc.start.column = lastComment.loc.end.column;
|
||||
|
||||
if (ast.leadingComments === null && ast.innerComments.length) {
|
||||
ast.leadingComments = ast.innerComments;
|
||||
}
|
||||
} else if (firstComment.start < tokens[0].start) {
|
||||
// if there are comments before the first token, the program starts at the first token
|
||||
var token = tokens[0];
|
||||
// ast.start = token.start;
|
||||
// ast.loc.start.line = token.loc.start.line;
|
||||
// ast.loc.start.column = token.loc.start.column;
|
||||
|
||||
// estraverse do not put leading comments on first node when the comment
|
||||
// appear before the first token
|
||||
if (ast.body.length) {
|
||||
var node = ast.body[0];
|
||||
node.leadingComments = [];
|
||||
var firstTokenStart = token.start;
|
||||
var len = comments.length;
|
||||
for (var i = 0; i < len && comments[i].start < firstTokenStart; i++) {
|
||||
node.leadingComments.push(comments[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// fixup program end
|
||||
if (tokens.length) {
|
||||
var lastToken = tokens[tokens.length - 1];
|
||||
if (lastComment.end > lastToken.end) {
|
||||
// If there is a comment after the last token, the program ends at the
|
||||
// last token and not the comment
|
||||
// ast.end = lastToken.end;
|
||||
ast.range[1] = lastToken.end;
|
||||
ast.loc.end.line = lastToken.loc.end.line;
|
||||
ast.loc.end.column = lastToken.loc.end.column;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!tokens.length) {
|
||||
ast.loc.start.line = 1;
|
||||
ast.loc.end.line = 1;
|
||||
}
|
||||
}
|
||||
if (ast.body && ast.body.length > 0) {
|
||||
ast.loc.start.line = ast.body[0].loc.start.line;
|
||||
ast.range[0] = ast.body[0].start;
|
||||
}
|
||||
};
|
17
web/node_modules/babel-eslint/lib/babylon-to-espree/convertComments.js
generated
vendored
Normal file
17
web/node_modules/babel-eslint/lib/babylon-to-espree/convertComments.js
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = function(comments) {
|
||||
for (var i = 0; i < comments.length; i++) {
|
||||
var comment = comments[i];
|
||||
if (comment.type === "CommentBlock") {
|
||||
comment.type = "Block";
|
||||
} else if (comment.type === "CommentLine") {
|
||||
comment.type = "Line";
|
||||
}
|
||||
// sometimes comments don't get ranges computed,
|
||||
// even with options.ranges === true
|
||||
if (!comment.range) {
|
||||
comment.range = [comment.start, comment.end];
|
||||
}
|
||||
}
|
||||
};
|
92
web/node_modules/babel-eslint/lib/babylon-to-espree/convertTemplateType.js
generated
vendored
Normal file
92
web/node_modules/babel-eslint/lib/babylon-to-espree/convertTemplateType.js
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = function(tokens, tt) {
|
||||
let curlyBrace = null;
|
||||
let templateTokens = [];
|
||||
const result = [];
|
||||
|
||||
function addTemplateType() {
|
||||
const start = templateTokens[0];
|
||||
const end = templateTokens[templateTokens.length - 1];
|
||||
|
||||
const value = templateTokens.reduce((result, token) => {
|
||||
if (token.value) {
|
||||
result += token.value;
|
||||
} else if (token.type !== tt.template) {
|
||||
result += token.type.label;
|
||||
}
|
||||
|
||||
return result;
|
||||
}, "");
|
||||
|
||||
result.push({
|
||||
type: "Template",
|
||||
value: value,
|
||||
start: start.start,
|
||||
end: end.end,
|
||||
loc: {
|
||||
start: start.loc.start,
|
||||
end: end.loc.end,
|
||||
},
|
||||
});
|
||||
|
||||
templateTokens = [];
|
||||
}
|
||||
|
||||
tokens.forEach(token => {
|
||||
switch (token.type) {
|
||||
case tt.backQuote:
|
||||
if (curlyBrace) {
|
||||
result.push(curlyBrace);
|
||||
curlyBrace = null;
|
||||
}
|
||||
|
||||
templateTokens.push(token);
|
||||
|
||||
if (templateTokens.length > 1) {
|
||||
addTemplateType();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case tt.dollarBraceL:
|
||||
templateTokens.push(token);
|
||||
addTemplateType();
|
||||
break;
|
||||
|
||||
case tt.braceR:
|
||||
if (curlyBrace) {
|
||||
result.push(curlyBrace);
|
||||
}
|
||||
|
||||
curlyBrace = token;
|
||||
break;
|
||||
|
||||
case tt.template:
|
||||
if (curlyBrace) {
|
||||
templateTokens.push(curlyBrace);
|
||||
curlyBrace = null;
|
||||
}
|
||||
|
||||
templateTokens.push(token);
|
||||
break;
|
||||
|
||||
case tt.eof:
|
||||
if (curlyBrace) {
|
||||
result.push(curlyBrace);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if (curlyBrace) {
|
||||
result.push(curlyBrace);
|
||||
curlyBrace = null;
|
||||
}
|
||||
|
||||
result.push(token);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
30
web/node_modules/babel-eslint/lib/babylon-to-espree/index.js
generated
vendored
Normal file
30
web/node_modules/babel-eslint/lib/babylon-to-espree/index.js
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
"use strict";
|
||||
|
||||
var attachComments = require("./attachComments");
|
||||
var convertComments = require("./convertComments");
|
||||
var toTokens = require("./toTokens");
|
||||
var toAST = require("./toAST");
|
||||
|
||||
module.exports = function(ast, traverse, tt, code) {
|
||||
// convert tokens
|
||||
ast.tokens = toTokens(ast.tokens, tt, code);
|
||||
|
||||
// add comments
|
||||
convertComments(ast.comments);
|
||||
|
||||
// transform esprima and acorn divergent nodes
|
||||
toAST(ast, traverse, code);
|
||||
|
||||
// ast.program.tokens = ast.tokens;
|
||||
// ast.program.comments = ast.comments;
|
||||
// ast = ast.program;
|
||||
|
||||
// remove File
|
||||
ast.type = "Program";
|
||||
ast.sourceType = ast.program.sourceType;
|
||||
ast.directives = ast.program.directives;
|
||||
ast.body = ast.program.body;
|
||||
delete ast.program;
|
||||
|
||||
attachComments(ast, ast.comments, ast.tokens);
|
||||
};
|
118
web/node_modules/babel-eslint/lib/babylon-to-espree/toAST.js
generated
vendored
Normal file
118
web/node_modules/babel-eslint/lib/babylon-to-espree/toAST.js
generated
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
"use strict";
|
||||
|
||||
var t = require("@babel/types");
|
||||
var convertComments = require("./convertComments");
|
||||
|
||||
module.exports = function(ast, traverse, code) {
|
||||
var state = { source: code };
|
||||
|
||||
// Monkey patch visitor keys in order to be able to traverse the estree nodes
|
||||
t.VISITOR_KEYS.Property = t.VISITOR_KEYS.ObjectProperty;
|
||||
t.VISITOR_KEYS.MethodDefinition = [
|
||||
"key",
|
||||
"value",
|
||||
"decorators",
|
||||
"returnType",
|
||||
"typeParameters",
|
||||
];
|
||||
|
||||
traverse(ast, astTransformVisitor, null, state);
|
||||
|
||||
delete t.VISITOR_KEYS.Property;
|
||||
delete t.VISITOR_KEYS.MethodDefinition;
|
||||
};
|
||||
|
||||
var astTransformVisitor = {
|
||||
noScope: true,
|
||||
enter(path) {
|
||||
var node = path.node;
|
||||
|
||||
// private var to track original node type
|
||||
node._babelType = node.type;
|
||||
|
||||
if (node.innerComments) {
|
||||
node.trailingComments = node.innerComments;
|
||||
delete node.innerComments;
|
||||
}
|
||||
|
||||
if (node.trailingComments) {
|
||||
convertComments(node.trailingComments);
|
||||
}
|
||||
|
||||
if (node.leadingComments) {
|
||||
convertComments(node.leadingComments);
|
||||
}
|
||||
},
|
||||
exit(path) {
|
||||
var node = path.node;
|
||||
|
||||
if (path.isJSXText()) {
|
||||
node.type = "Literal";
|
||||
}
|
||||
|
||||
if (
|
||||
path.isRestElement() &&
|
||||
path.parent &&
|
||||
path.parent.type === "ObjectPattern"
|
||||
) {
|
||||
node.type = "ExperimentalRestProperty";
|
||||
}
|
||||
|
||||
if (
|
||||
path.isSpreadElement() &&
|
||||
path.parent &&
|
||||
path.parent.type === "ObjectExpression"
|
||||
) {
|
||||
node.type = "ExperimentalSpreadProperty";
|
||||
}
|
||||
|
||||
if (path.isTypeParameter()) {
|
||||
node.type = "Identifier";
|
||||
node.typeAnnotation = node.bound;
|
||||
delete node.bound;
|
||||
}
|
||||
|
||||
// flow: prevent "no-undef"
|
||||
// for "Component" in: "let x: React.Component"
|
||||
if (path.isQualifiedTypeIdentifier()) {
|
||||
delete node.id;
|
||||
}
|
||||
// for "b" in: "var a: { b: Foo }"
|
||||
if (path.isObjectTypeProperty()) {
|
||||
delete node.key;
|
||||
}
|
||||
// for "indexer" in: "var a: {[indexer: string]: number}"
|
||||
if (path.isObjectTypeIndexer()) {
|
||||
delete node.id;
|
||||
}
|
||||
// for "param" in: "var a: { func(param: Foo): Bar };"
|
||||
if (path.isFunctionTypeParam()) {
|
||||
delete node.name;
|
||||
}
|
||||
|
||||
// modules
|
||||
|
||||
if (path.isImportDeclaration()) {
|
||||
delete node.isType;
|
||||
}
|
||||
|
||||
// template string range fixes
|
||||
if (path.isTemplateLiteral()) {
|
||||
for (var j = 0; j < node.quasis.length; j++) {
|
||||
var q = node.quasis[j];
|
||||
q.range[0] -= 1;
|
||||
if (q.tail) {
|
||||
q.range[1] += 1;
|
||||
} else {
|
||||
q.range[1] += 2;
|
||||
}
|
||||
q.loc.start.column -= 1;
|
||||
if (q.tail) {
|
||||
q.loc.end.column += 1;
|
||||
} else {
|
||||
q.loc.end.column += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
84
web/node_modules/babel-eslint/lib/babylon-to-espree/toToken.js
generated
vendored
Normal file
84
web/node_modules/babel-eslint/lib/babylon-to-espree/toToken.js
generated
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = function(token, tt, source) {
|
||||
var type = token.type;
|
||||
token.range = [token.start, token.end];
|
||||
|
||||
if (type === tt.name) {
|
||||
token.type = "Identifier";
|
||||
} else if (
|
||||
type === tt.semi ||
|
||||
type === tt.comma ||
|
||||
type === tt.parenL ||
|
||||
type === tt.parenR ||
|
||||
type === tt.braceL ||
|
||||
type === tt.braceR ||
|
||||
type === tt.slash ||
|
||||
type === tt.dot ||
|
||||
type === tt.bracketL ||
|
||||
type === tt.bracketR ||
|
||||
type === tt.ellipsis ||
|
||||
type === tt.arrow ||
|
||||
type === tt.pipeline ||
|
||||
type === tt.star ||
|
||||
type === tt.incDec ||
|
||||
type === tt.colon ||
|
||||
type === tt.question ||
|
||||
type === tt.questionDot ||
|
||||
type === tt.template ||
|
||||
type === tt.backQuote ||
|
||||
type === tt.dollarBraceL ||
|
||||
type === tt.at ||
|
||||
type === tt.logicalOR ||
|
||||
type === tt.logicalAND ||
|
||||
type === tt.nullishCoalescing ||
|
||||
type === tt.bitwiseOR ||
|
||||
type === tt.bitwiseXOR ||
|
||||
type === tt.bitwiseAND ||
|
||||
type === tt.equality ||
|
||||
type === tt.relational ||
|
||||
type === tt.bitShift ||
|
||||
type === tt.plusMin ||
|
||||
type === tt.modulo ||
|
||||
type === tt.exponent ||
|
||||
type === tt.bang ||
|
||||
type === tt.tilde ||
|
||||
type === tt.doubleColon ||
|
||||
type.isAssign
|
||||
) {
|
||||
token.type = "Punctuator";
|
||||
if (!token.value) token.value = type.label;
|
||||
} else if (type === tt.jsxTagStart) {
|
||||
token.type = "Punctuator";
|
||||
token.value = "<";
|
||||
} else if (type === tt.jsxTagEnd) {
|
||||
token.type = "Punctuator";
|
||||
token.value = ">";
|
||||
} else if (type === tt.jsxName) {
|
||||
token.type = "JSXIdentifier";
|
||||
} else if (type === tt.jsxText) {
|
||||
token.type = "JSXText";
|
||||
} else if (type.keyword === "null") {
|
||||
token.type = "Null";
|
||||
} else if (type.keyword === "false" || type.keyword === "true") {
|
||||
token.type = "Boolean";
|
||||
} else if (type.keyword) {
|
||||
token.type = "Keyword";
|
||||
} else if (type === tt.num) {
|
||||
token.type = "Numeric";
|
||||
token.value = source.slice(token.start, token.end);
|
||||
} else if (type === tt.string) {
|
||||
token.type = "String";
|
||||
token.value = source.slice(token.start, token.end);
|
||||
} else if (type === tt.regexp) {
|
||||
token.type = "RegularExpression";
|
||||
var value = token.value;
|
||||
token.regex = {
|
||||
pattern: value.pattern,
|
||||
flags: value.flags,
|
||||
};
|
||||
token.value = `/${value.pattern}/${value.flags}`;
|
||||
}
|
||||
|
||||
return token;
|
||||
};
|
10
web/node_modules/babel-eslint/lib/babylon-to-espree/toTokens.js
generated
vendored
Normal file
10
web/node_modules/babel-eslint/lib/babylon-to-espree/toTokens.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
"use strict";
|
||||
|
||||
var convertTemplateType = require("./convertTemplateType");
|
||||
var toToken = require("./toToken");
|
||||
|
||||
module.exports = function(tokens, tt, code) {
|
||||
return convertTemplateType(tokens, tt)
|
||||
.filter(t => t.type !== "CommentLine" && t.type !== "CommentBlock")
|
||||
.map(t => toToken(t, tt, code));
|
||||
};
|
19
web/node_modules/babel-eslint/lib/index.js
generated
vendored
Normal file
19
web/node_modules/babel-eslint/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
exports.parse = function(code, options) {
|
||||
return exports.parseForESLint(code, options).ast;
|
||||
};
|
||||
|
||||
exports.parseForESLint = function(code, options) {
|
||||
options = options || {};
|
||||
options.ecmaVersion = options.ecmaVersion || 2018;
|
||||
options.sourceType = options.sourceType || "module";
|
||||
options.allowImportExportEverywhere =
|
||||
options.allowImportExportEverywhere || false;
|
||||
|
||||
return require("./parse-with-scope")(code, options);
|
||||
};
|
||||
|
||||
exports.parseNoPatch = function(code, options) {
|
||||
return require("./parse")(code, options);
|
||||
};
|
12
web/node_modules/babel-eslint/lib/parse-with-scope.js
generated
vendored
Normal file
12
web/node_modules/babel-eslint/lib/parse-with-scope.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
const visitorKeys = require("./visitor-keys");
|
||||
const analyzeScope = require("./analyze-scope");
|
||||
const parse = require("./parse");
|
||||
|
||||
module.exports = function(code, options) {
|
||||
const ast = parse(code, options);
|
||||
const scopeManager = analyzeScope(ast, options);
|
||||
|
||||
return { ast, scopeManager, visitorKeys };
|
||||
};
|
93
web/node_modules/babel-eslint/lib/parse.js
generated
vendored
Normal file
93
web/node_modules/babel-eslint/lib/parse.js
generated
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
"use strict";
|
||||
|
||||
var babylonToEspree = require("./babylon-to-espree");
|
||||
var parse = require("@babel/parser").parse;
|
||||
var tt = require("@babel/parser").tokTypes;
|
||||
var traverse = require("@babel/traverse").default;
|
||||
var codeFrameColumns = require("@babel/code-frame").codeFrameColumns;
|
||||
|
||||
module.exports = function(code, options) {
|
||||
const legacyDecorators =
|
||||
options.ecmaFeatures && options.ecmaFeatures.legacyDecorators;
|
||||
|
||||
var opts = {
|
||||
codeFrame: options.hasOwnProperty("codeFrame") ? options.codeFrame : true,
|
||||
sourceType: options.sourceType,
|
||||
allowImportExportEverywhere: options.allowImportExportEverywhere, // consistent with espree
|
||||
allowReturnOutsideFunction: true,
|
||||
allowSuperOutsideMethod: true,
|
||||
ranges: true,
|
||||
tokens: true,
|
||||
plugins: [
|
||||
["flow", { all: true, enums: true }],
|
||||
"jsx",
|
||||
"estree",
|
||||
"asyncFunctions",
|
||||
"asyncGenerators",
|
||||
"classConstructorCall",
|
||||
"classProperties",
|
||||
legacyDecorators
|
||||
? "decorators-legacy"
|
||||
: ["decorators", { decoratorsBeforeExport: false }],
|
||||
"doExpressions",
|
||||
"exponentiationOperator",
|
||||
"exportDefaultFrom",
|
||||
"exportNamespaceFrom",
|
||||
"functionBind",
|
||||
"functionSent",
|
||||
"objectRestSpread",
|
||||
"trailingFunctionCommas",
|
||||
"dynamicImport",
|
||||
"numericSeparator",
|
||||
"optionalChaining",
|
||||
"importMeta",
|
||||
"classPrivateProperties",
|
||||
"bigInt",
|
||||
"optionalCatchBinding",
|
||||
"throwExpressions",
|
||||
["pipelineOperator", { proposal: "minimal" }],
|
||||
"nullishCoalescingOperator",
|
||||
"logicalAssignment",
|
||||
],
|
||||
};
|
||||
|
||||
var ast;
|
||||
try {
|
||||
ast = parse(code, opts);
|
||||
} catch (err) {
|
||||
if (err instanceof SyntaxError) {
|
||||
err.lineNumber = err.loc.line;
|
||||
err.column = err.loc.column;
|
||||
|
||||
if (opts.codeFrame) {
|
||||
err.lineNumber = err.loc.line;
|
||||
err.column = err.loc.column + 1;
|
||||
|
||||
// remove trailing "(LINE:COLUMN)" acorn message and add in esprima syntax error message start
|
||||
err.message =
|
||||
"Line " +
|
||||
err.lineNumber +
|
||||
": " +
|
||||
err.message.replace(/ \((\d+):(\d+)\)$/, "") +
|
||||
// add codeframe
|
||||
"\n\n" +
|
||||
codeFrameColumns(
|
||||
code,
|
||||
{
|
||||
start: {
|
||||
line: err.lineNumber,
|
||||
column: err.column,
|
||||
},
|
||||
},
|
||||
{ highlightCode: true }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
babylonToEspree(ast, traverse, tt, code);
|
||||
|
||||
return ast;
|
||||
};
|
9
web/node_modules/babel-eslint/lib/require-from-eslint.js
generated
vendored
Normal file
9
web/node_modules/babel-eslint/lib/require-from-eslint.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
"use strict";
|
||||
|
||||
const resolve = require("resolve");
|
||||
const eslintBase = require.resolve("eslint");
|
||||
|
||||
module.exports = function requireFromESLint(id) {
|
||||
const path = resolve.sync(id, { basedir: eslintBase });
|
||||
return require(path);
|
||||
};
|
15
web/node_modules/babel-eslint/lib/visitor-keys.js
generated
vendored
Normal file
15
web/node_modules/babel-eslint/lib/visitor-keys.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
|
||||
const BABEL_VISITOR_KEYS = require("@babel/types").VISITOR_KEYS;
|
||||
const ESLINT_VISITOR_KEYS = require("eslint-visitor-keys").KEYS;
|
||||
|
||||
module.exports = Object.assign(
|
||||
{
|
||||
Literal: ESLINT_VISITOR_KEYS.Literal,
|
||||
MethodDefinition: ["decorators"].concat(
|
||||
ESLINT_VISITOR_KEYS.MethodDefinition
|
||||
),
|
||||
Property: ["decorators"].concat(ESLINT_VISITOR_KEYS.Property),
|
||||
},
|
||||
BABEL_VISITOR_KEYS
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue