This commit is contained in:
Iliyan Angelov
2025-09-14 23:24:25 +03:00
commit c67067a2a4
71311 changed files with 6800714 additions and 0 deletions

22
frontend/node_modules/@babel/eslint-parser/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

19
frontend/node_modules/@babel/eslint-parser/README.md generated vendored Normal file
View File

@@ -0,0 +1,19 @@
# @babel/eslint-parser
> allows you to lint all valid Babel code with the fantastic ESLint
See our website [@babel/eslint-parser](https://babeljs.io/docs/babel-eslint-parser) for more information or the [issues](https://github.com/babel/babel/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22area%3A%20eslint%22) associated with this package.
## Install
Using npm:
```sh
npm install --save-dev @babel/eslint-parser
```
or using yarn:
```sh
yarn add @babel/eslint-parser --dev
```

View File

@@ -0,0 +1,325 @@
"use strict";
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
const {
Definition,
PatternVisitor: OriginalPatternVisitor,
Referencer: OriginalReferencer,
Scope,
ScopeManager
} = require("@nicolo-ribaudo/eslint-scope-5-internals");
const {
getKeys: fallback
} = require("eslint-visitor-keys");
let visitorKeysMap;
function getVisitorValues(nodeType, client) {
if (visitorKeysMap) return visitorKeysMap[nodeType];
const {
FLOW_FLIPPED_ALIAS_KEYS,
VISITOR_KEYS
} = client.getTypesInfo();
const flowFlippedAliasKeys = new Set(FLOW_FLIPPED_ALIAS_KEYS.concat(["ArrayPattern", "ClassDeclaration", "ClassExpression", "FunctionDeclaration", "FunctionExpression", "Identifier", "ObjectPattern", "RestElement"]));
visitorKeysMap = (Object.entries || (o => Object.keys(o).map(k => [k, o[k]])))(VISITOR_KEYS).reduce((acc, [key, value]) => {
if (!flowFlippedAliasKeys.has(value)) {
acc[key] = value;
}
return acc;
}, {});
return visitorKeysMap[nodeType];
}
const propertyTypes = {
callProperties: {
type: "loop",
values: ["value"]
},
indexers: {
type: "loop",
values: ["key", "value"]
},
properties: {
type: "loop",
values: ["argument", "value"]
},
types: {
type: "loop"
},
params: {
type: "loop"
},
argument: {
type: "single"
},
elementType: {
type: "single"
},
qualification: {
type: "single"
},
rest: {
type: "single"
},
returnType: {
type: "single"
},
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);
}
}
var _client = new WeakMap();
class Referencer extends OriginalReferencer {
constructor(options, scopeManager, client) {
super(options, scopeManager);
_classPrivateFieldInitSpec(this, _client, void 0);
_classPrivateFieldSet(_client, this, client);
}
visitPattern(node, options, callback) {
if (!node) {
return;
}
this._checkIdentifierOrVisit(node.typeAnnotation);
if (node.type === "AssignmentPattern") {
this._checkIdentifierOrVisit(node.left.typeAnnotation);
}
if (typeof options === "function") {
callback = options;
options = {
processRightHandNodes: false
};
}
const visitor = new PatternVisitor(this.options, node, callback);
visitor.visit(node);
if (options.processRightHandNodes) {
visitor.rightHandNodes.forEach(this.visit, this);
}
}
visitClass(node) {
var _ref;
this._visitArray(node.decorators);
const typeParamScope = this._nestTypeParamScope(node);
this._visitTypeAnnotation(node.implements);
this._visitTypeAnnotation((_ref = node.superTypeParameters) == null ? void 0 : _ref.params);
super.visitClass(node);
if (typeParamScope) {
this.close(node);
}
}
visitFunction(node) {
const typeParamScope = this._nestTypeParamScope(node);
this._checkIdentifierOrVisit(node.returnType);
super.visitFunction(node);
if (typeParamScope) {
this.close(node);
}
}
visitProperty(node) {
var _node$value;
if (((_node$value = node.value) == null ? void 0 : _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);
this._visitArray(node.extends);
this.visit(node.body);
if (typeParamScope) {
this.close(node);
}
}
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);
}
AccessorProperty(node) {
this._visitClassProperty(node);
}
ClassAccessorProperty(node) {
this._visitClassProperty(node);
}
PropertyDefinition(node) {
this._visitClassProperty(node);
}
ClassPrivateMethod(node) {
super.MethodDefinition(node);
}
DeclareModule(node) {
this._visitDeclareX(node);
}
DeclareFunction(node) {
this._visitDeclareX(node);
}
DeclareVariable(node) {
this._visitDeclareX(node);
}
DeclareClass(node) {
this._visitDeclareX(node);
}
OptionalMemberExpression(node) {
super.MemberExpression(node);
}
_visitClassProperty(node) {
const {
computed,
key,
typeAnnotation,
decorators,
value
} = node;
this._visitArray(decorators);
if (computed) this.visit(key);
this._visitTypeAnnotation(typeAnnotation);
if (value) {
if (this.scopeManager.__nestClassFieldInitializerScope) {
this.scopeManager.__nestClassFieldInitializerScope(value);
} else {
this.scopeManager.__nestScope(new Scope(this.scopeManager, "function", this.scopeManager.__currentScope, value, true));
}
this.visit(value);
this.close(value);
}
}
_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 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 = parentScope.__define.bind(parentScope);
return scope;
}
_visitTypeAnnotation(node) {
if (!node) {
return;
}
if (Array.isArray(node)) {
node.forEach(this._visitTypeAnnotation, this);
return;
}
const visitorValues = getVisitorValues(node.type, _classPrivateFieldGet(_client, this));
if (!visitorValues) {
return;
}
for (let i = 0; i < visitorValues.length; i++) {
const visitorValue = visitorValues[i];
const propertyType = propertyTypes[visitorValue];
const nodeProperty = node[visitorValue];
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 != null && node.typeAnnotation) {
this._visitTypeAnnotation(node.typeAnnotation);
} else if ((node == null ? void 0 : 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 analyzeScope(ast, parserOptions, client) {
var _parserOptions$ecmaFe;
const options = {
ignoreEval: true,
optimistic: false,
directive: false,
nodejsScope: ast.sourceType === "script" && ((_parserOptions$ecmaFe = parserOptions.ecmaFeatures) == null ? void 0 : _parserOptions$ecmaFe.globalReturn) === true,
impliedStrict: false,
sourceType: ast.sourceType,
ecmaVersion: parserOptions.ecmaVersion,
fallback,
childVisitorKeys: client.getVisitorKeys()
};
const scopeManager = new ScopeManager(options);
const referencer = new Referencer(options, scopeManager, client);
referencer.visit(ast);
return scopeManager;
};
//# sourceMappingURL=analyze-scope.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,106 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.WorkerClient = exports.Client = exports.ACTIONS = void 0;
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
const path = require("path");
const ACTIONS = exports.ACTIONS = {
GET_VERSION: "GET_VERSION",
GET_TYPES_INFO: "GET_TYPES_INFO",
GET_VISITOR_KEYS: "GET_VISITOR_KEYS",
GET_TOKEN_LABELS: "GET_TOKEN_LABELS",
MAYBE_PARSE: "MAYBE_PARSE",
MAYBE_PARSE_SYNC: "MAYBE_PARSE_SYNC"
};
var _send = new WeakMap();
var _vCache = new WeakMap();
var _tiCache = new WeakMap();
var _vkCache = new WeakMap();
var _tlCache = new WeakMap();
class Client {
constructor(send) {
_classPrivateFieldInitSpec(this, _send, void 0);
_classPrivateFieldInitSpec(this, _vCache, void 0);
_classPrivateFieldInitSpec(this, _tiCache, void 0);
_classPrivateFieldInitSpec(this, _vkCache, void 0);
_classPrivateFieldInitSpec(this, _tlCache, void 0);
_classPrivateFieldSet(_send, this, send);
}
getVersion() {
var _classPrivateFieldGet2;
return (_classPrivateFieldGet2 = _classPrivateFieldGet(_vCache, this)) != null ? _classPrivateFieldGet2 : _classPrivateFieldSet(_vCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_VERSION, undefined));
}
getTypesInfo() {
var _classPrivateFieldGet3;
return (_classPrivateFieldGet3 = _classPrivateFieldGet(_tiCache, this)) != null ? _classPrivateFieldGet3 : _classPrivateFieldSet(_tiCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_TYPES_INFO, undefined));
}
getVisitorKeys() {
var _classPrivateFieldGet4;
return (_classPrivateFieldGet4 = _classPrivateFieldGet(_vkCache, this)) != null ? _classPrivateFieldGet4 : _classPrivateFieldSet(_vkCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_VISITOR_KEYS, undefined));
}
getTokLabels() {
var _classPrivateFieldGet5;
return (_classPrivateFieldGet5 = _classPrivateFieldGet(_tlCache, this)) != null ? _classPrivateFieldGet5 : _classPrivateFieldSet(_tlCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_TOKEN_LABELS, undefined));
}
maybeParse(code, options) {
return _classPrivateFieldGet(_send, this).call(this, ACTIONS.MAYBE_PARSE, {
code,
options
});
}
}
exports.Client = Client;
var _worker = new WeakMap();
class WorkerClient extends Client {
constructor() {
super((action, payload) => {
const signal = new Int32Array(new SharedArrayBuffer(8));
const subChannel = new (_get_worker_threads(WorkerClient).MessageChannel)();
_classPrivateFieldGet(_worker, this).postMessage({
signal,
port: subChannel.port1,
action,
payload
}, [subChannel.port1]);
Atomics.wait(signal, 0, 0);
const {
message
} = _get_worker_threads(WorkerClient).receiveMessageOnPort(subChannel.port2);
if (message.error) throw Object.assign(message.error, message.errorData);else return message.result;
});
_classPrivateFieldInitSpec(this, _worker, new (_get_worker_threads(WorkerClient).Worker)(path.resolve(__dirname, "../lib/worker/index.cjs"), {
env: _get_worker_threads(WorkerClient).SHARE_ENV
}));
_classPrivateFieldGet(_worker, this).unref();
}
}
exports.WorkerClient = WorkerClient;
function _get_worker_threads(_this) {
var _worker_threads_cache2;
return (_worker_threads_cache2 = _worker_threads_cache._) != null ? _worker_threads_cache2 : _worker_threads_cache._ = require("worker_threads");
}
var _worker_threads_cache = {
_: void 0
};
{
var _LocalClient, _handleMessage;
exports.LocalClient = (_LocalClient = class LocalClient extends Client {
constructor() {
var _assertClassBrand$_;
(_assertClassBrand$_ = _assertClassBrand(_LocalClient, LocalClient, _handleMessage)._) != null ? _assertClassBrand$_ : _handleMessage._ = _assertClassBrand(_LocalClient, LocalClient, require("./worker/handle-message.cjs"));
super((action, payload) => {
return _assertClassBrand(_LocalClient, LocalClient, _handleMessage)._.call(LocalClient, action === ACTIONS.MAYBE_PARSE ? ACTIONS.MAYBE_PARSE_SYNC : action, payload);
});
}
}, _handleMessage = {
_: void 0
}, _LocalClient);
}
//# sourceMappingURL=client.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,23 @@
"use strict";
const _excluded = ["babelOptions", "ecmaVersion", "sourceType", "requireConfigFile"];
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
module.exports = function normalizeESLintConfig(options) {
const {
babelOptions = {},
ecmaVersion = "latest",
sourceType = "module",
requireConfigFile = true
} = options,
otherOptions = _objectWithoutPropertiesLoose(options, _excluded);
return Object.assign({
babelOptions: Object.assign({
cwd: process.cwd()
}, babelOptions),
ecmaVersion: ecmaVersion === "latest" ? 1e8 : ecmaVersion,
sourceType,
requireConfigFile
}, otherOptions);
};
//# sourceMappingURL=configuration.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["normalizeESLintConfig","options","babelOptions","ecmaVersion","sourceType","requireConfigFile","otherOptions","_objectWithoutPropertiesLoose","_excluded","Object","assign","cwd","process"],"sources":["../src/configuration.cts"],"sourcesContent":["import type { Options } from \"./types.cts\";\n\nexport = function normalizeESLintConfig(options: any) {\n const {\n babelOptions = {},\n // ESLint sets ecmaVersion: undefined when ecmaVersion is not set in the config.\n ecmaVersion = \"latest\",\n sourceType = \"module\",\n requireConfigFile = true,\n ...otherOptions\n } = options;\n\n return {\n babelOptions: { cwd: process.cwd(), ...babelOptions },\n ecmaVersion: ecmaVersion === \"latest\" ? 1e8 : ecmaVersion,\n sourceType,\n requireConfigFile,\n ...otherOptions,\n } as Options;\n};\n"],"mappings":";;;;iBAES,SAASA,qBAAqBA,CAACC,OAAY,EAAE;EACpD,MAAM;MACJC,YAAY,GAAG,CAAC,CAAC;MAEjBC,WAAW,GAAG,QAAQ;MACtBC,UAAU,GAAG,QAAQ;MACrBC,iBAAiB,GAAG;IAEtB,CAAC,GAAGJ,OAAO;IADNK,YAAY,GAAAC,6BAAA,CACbN,OAAO,EAAAO,SAAA;EAEX,OAAAC,MAAA,CAAAC,MAAA;IACER,YAAY,EAAAO,MAAA,CAAAC,MAAA;MAAIC,GAAG,EAAEC,OAAO,CAACD,GAAG,CAAC;IAAC,GAAKT,YAAY,CAAE;IACrDC,WAAW,EAAEA,WAAW,KAAK,QAAQ,GAAG,GAAG,GAAGA,WAAW;IACzDC,UAAU;IACVC;EAAiB,GACdC,YAAY;AAEnB,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,136 @@
"use strict";
const ESLINT_VERSION = require("../utils/eslint-version.cjs");
function* it(children) {
if (Array.isArray(children)) yield* children;else yield children;
}
function traverse(node, visitorKeys, visitor) {
const {
type
} = node;
if (!type) return;
const keys = visitorKeys[type];
if (!keys) return;
for (const key of keys) {
for (const child of it(node[key])) {
if (child && typeof child === "object") {
visitor.enter(child);
traverse(child, visitorKeys, visitor);
visitor.exit(child);
}
}
}
}
const convertNodesVisitor = {
enter(node) {
if (node.innerComments) {
delete node.innerComments;
}
if (node.trailingComments) {
delete node.trailingComments;
}
if (node.leadingComments) {
delete node.leadingComments;
}
},
exit(node) {
if (node.extra) {
delete node.extra;
}
{
if (node.loc.identifierName) {
delete node.loc.identifierName;
}
}
if (node.type === "TypeParameter") {
node.type = "Identifier";
node.typeAnnotation = node.bound;
delete node.bound;
}
if (node.type === "QualifiedTypeIdentifier") {
delete node.id;
}
if (node.type === "ObjectTypeProperty") {
delete node.key;
}
if (node.type === "ObjectTypeIndexer") {
delete node.id;
}
if (node.type === "FunctionTypeParam") {
delete node.name;
}
if (node.type === "ImportDeclaration") {
delete node.isType;
}
if (node.type === "TemplateLiteral" || node.type === "TSTemplateLiteralType") {
for (let i = 0; i < node.quasis.length; i++) {
const q = node.quasis[i];
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;
}
if (ESLINT_VERSION >= 8) {
q.start -= 1;
if (q.tail) {
q.end += 1;
} else {
q.end += 2;
}
}
}
}
}
};
function convertNodes(ast, visitorKeys) {
traverse(ast, visitorKeys, convertNodesVisitor);
}
function convertProgramNode(ast) {
const body = ast.program.body;
Object.assign(ast, {
type: "Program",
sourceType: ast.program.sourceType,
body
});
delete ast.program;
delete ast.errors;
if (ast.comments.length) {
const lastComment = ast.comments[ast.comments.length - 1];
if (ast.tokens.length) {
const lastToken = ast.tokens[ast.tokens.length - 1];
if (lastComment.end > lastToken.end) {
ast.range[1] = lastToken.end;
ast.loc.end.line = lastToken.loc.end.line;
ast.loc.end.column = lastToken.loc.end.column;
if (ESLINT_VERSION >= 8) {
ast.end = lastToken.end;
}
}
}
} else {
if (!ast.tokens.length) {
ast.loc.start.line = 1;
ast.loc.end.line = 1;
}
}
if (body != null && body.length) {
ast.loc.start.line = body[0].loc.start.line;
ast.range[0] = body[0].start;
if (ESLINT_VERSION >= 8) {
ast.start = body[0].start;
}
}
}
module.exports = function convertAST(ast, visitorKeys) {
convertNodes(ast, visitorKeys);
convertProgramNode(ast);
};
//# sourceMappingURL=convertAST.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
"use strict";
module.exports = function convertComments(comments) {
for (const comment of comments) {
comment.type = comment.type === "CommentBlock" ? "Block" : "Line";
comment.range || (comment.range = [comment.start, comment.end]);
}
};
//# sourceMappingURL=convertComments.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["convertComments","comments","comment","type","range","start","end"],"sources":["../../src/convert/convertComments.cts"],"sourcesContent":["import type { Comment } from \"@babel/types\";\n\nexport = function convertComments(comments: Comment[]) {\n for (const comment of comments) {\n // @ts-expect-error eslint\n comment.type = comment.type === \"CommentBlock\" ? \"Block\" : \"Line\";\n\n // sometimes comments don't get ranges computed,\n // even with options.ranges === true\n\n // @ts-expect-error eslint\n comment.range ||= [comment.start, comment.end];\n }\n};\n"],"mappings":";;iBAES,SAASA,eAAeA,CAACC,QAAmB,EAAE;EACrD,KAAK,MAAMC,OAAO,IAAID,QAAQ,EAAE;IAE9BC,OAAO,CAACC,IAAI,GAAGD,OAAO,CAACC,IAAI,KAAK,cAAc,GAAG,OAAO,GAAG,MAAM;IAMjED,OAAO,CAACE,KAAK,KAAbF,OAAO,CAACE,KAAK,GAAK,CAACF,OAAO,CAACG,KAAK,EAAEH,OAAO,CAACI,GAAG,CAAC;EAChD;AACF,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,161 @@
"use strict";
const ESLINT_VERSION = require("../utils/eslint-version.cjs");
function convertTemplateType(tokens, tl) {
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.label !== tl.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.label) {
case tl.backQuote:
if (curlyBrace) {
result.push(curlyBrace);
curlyBrace = null;
}
templateTokens.push(token);
if (templateTokens.length > 1) {
addTemplateType();
}
break;
case tl.dollarBraceL:
templateTokens.push(token);
addTemplateType();
break;
case tl.braceR:
if (curlyBrace) {
result.push(curlyBrace);
}
curlyBrace = token;
break;
case tl.template:
if (curlyBrace) {
templateTokens.push(curlyBrace);
curlyBrace = null;
}
templateTokens.push(token);
break;
default:
if (curlyBrace) {
result.push(curlyBrace);
curlyBrace = null;
}
result.push(token);
}
});
return result;
}
function convertToken(token, source, tl) {
const {
type
} = token;
const {
label
} = type;
const newToken = token;
newToken.range = [token.start, token.end];
if (label === tl.name) {
const tokenValue = token.value;
if (tokenValue === "let" || tokenValue === "static" || tokenValue === "yield") {
newToken.type = "Keyword";
} else {
newToken.type = "Identifier";
}
} else if (label === tl.semi || label === tl.comma || label === tl.parenL || label === tl.parenR || label === tl.braceL || label === tl.braceR || label === tl.slash || label === tl.dot || label === tl.bracketL || label === tl.bracketR || label === tl.ellipsis || label === tl.arrow || label === tl.pipeline || label === tl.star || label === tl.incDec || label === tl.colon || label === tl.question || label === tl.template || label === tl.backQuote || label === tl.dollarBraceL || label === tl.at || label === tl.logicalOR || label === tl.logicalAND || label === tl.nullishCoalescing || label === tl.bitwiseOR || label === tl.bitwiseXOR || label === tl.bitwiseAND || label === tl.equality || label === tl.relational || label === tl.bitShift || label === tl.plusMin || label === tl.modulo || label === tl.exponent || label === tl.bang || label === tl.tilde || label === tl.doubleColon || label === tl.hash || label === tl.questionDot || label === tl.braceHashL || label === tl.braceBarL || label === tl.braceBarR || label === tl.bracketHashL || label === tl.bracketBarL || label === tl.bracketBarR || label === tl.doubleCaret || label === tl.doubleAt || type.isAssign) {
var _newToken$value;
newToken.type = "Punctuator";
(_newToken$value = newToken.value) != null ? _newToken$value : newToken.value = label;
} else if (label === tl.jsxTagStart) {
newToken.type = "Punctuator";
newToken.value = "<";
} else if (label === tl.jsxTagEnd) {
newToken.type = "Punctuator";
newToken.value = ">";
} else if (label === tl.jsxName) {
newToken.type = "JSXIdentifier";
} else if (label === tl.jsxText) {
newToken.type = "JSXText";
} else if (type.keyword === "null") {
newToken.type = "Null";
} else if (type.keyword === "false" || type.keyword === "true") {
newToken.type = "Boolean";
} else if (type.keyword) {
newToken.type = "Keyword";
} else if (label === tl.num) {
newToken.type = "Numeric";
newToken.value = source.slice(token.start, token.end);
} else if (label === tl.string) {
newToken.type = "String";
newToken.value = source.slice(token.start, token.end);
} else if (label === tl.regexp) {
newToken.type = "RegularExpression";
const value = token.value;
newToken.regex = {
pattern: value.pattern,
flags: value.flags
};
newToken.value = `/${value.pattern}/${value.flags}`;
} else if (label === tl.bigint) {
newToken.type = "Numeric";
newToken.value = `${token.value}n`;
} else if (label === tl.privateName) {
newToken.type = "PrivateIdentifier";
} else if (label === tl.templateNonTail || label === tl.templateTail || label === tl.Template) {
newToken.type = "Template";
}
;
return newToken;
}
module.exports = function convertTokens(tokens, code, tokLabels) {
const result = [];
const templateTypeMergedTokens = convertTemplateType(tokens, tokLabels);
for (let i = 0, {
length
} = templateTypeMergedTokens; i < length - 1; i++) {
const token = templateTypeMergedTokens[i];
const tokenType = token.type;
if (tokenType === "CommentLine" || tokenType === "CommentBlock") {
continue;
}
{
if (ESLINT_VERSION >= 8 && i + 1 < length && tokenType.label === tokLabels.hash) {
const nextToken = templateTypeMergedTokens[i + 1];
if (nextToken.type.label === tokLabels.name && token.end === nextToken.start) {
i++;
nextToken.type = "PrivateIdentifier";
nextToken.start -= 1;
nextToken.loc.start.column -= 1;
nextToken.range = [nextToken.start, nextToken.end];
result.push(nextToken);
continue;
}
}
}
result.push(convertToken(token, code, tokLabels));
}
return result;
};
//# sourceMappingURL=convertTokens.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.convertError = convertError;
exports.convertFile = convertFile;
const convertTokens = require("./convertTokens.cjs");
const convertComments = require("./convertComments.cjs");
const convertAST = require("./convertAST.cjs");
function convertFile(ast, code, tokLabels, visitorKeys) {
ast.tokens = convertTokens(ast.tokens, code, tokLabels);
convertComments(ast.comments);
convertAST(ast, visitorKeys);
return ast;
}
function convertError(err) {
if (err instanceof SyntaxError) {
err.lineNumber = err.loc.line;
err.column = err.loc.column;
}
return err;
}
//# sourceMappingURL=index.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["convertTokens","require","convertComments","convertAST","convertFile","ast","code","tokLabels","visitorKeys","tokens","comments","convertError","err","SyntaxError","lineNumber","loc","line","column"],"sources":["../../src/convert/index.cts"],"sourcesContent":["import convertTokens = require(\"./convertTokens.cts\");\nimport convertComments = require(\"./convertComments.cts\");\nimport convertAST = require(\"./convertAST.cts\");\nimport type { AST, ParseResult } from \"../types.cts\";\n\nexport function convertFile(\n ast: ParseResult,\n code: string,\n tokLabels: Record<string, any>,\n visitorKeys: Record<string, string[]>,\n) {\n ast.tokens = convertTokens(ast.tokens as any, code, tokLabels);\n convertComments(ast.comments);\n convertAST(ast, visitorKeys);\n return ast as unknown as AST.Program;\n}\n\nexport function convertError(err: Error) {\n if (err instanceof SyntaxError) {\n // @ts-expect-error eslint\n err.lineNumber = err.loc.line;\n // @ts-expect-error eslint\n err.column = err.loc.column;\n }\n return err;\n}\n"],"mappings":";;;;;;;MAAOA,aAAa,GAAAC,OAAA,CAAW,qBAAqB;AAAA,MAC7CC,eAAe,GAAAD,OAAA,CAAW,uBAAuB;AAAA,MACjDE,UAAU,GAAAF,OAAA,CAAW,kBAAkB;AAGvC,SAASG,WAAWA,CACzBC,GAAgB,EAChBC,IAAY,EACZC,SAA8B,EAC9BC,WAAqC,EACrC;EACAH,GAAG,CAACI,MAAM,GAAGT,aAAa,CAACK,GAAG,CAACI,MAAM,EAASH,IAAI,EAAEC,SAAS,CAAC;EAC9DL,eAAe,CAACG,GAAG,CAACK,QAAQ,CAAC;EAC7BP,UAAU,CAACE,GAAG,EAAEG,WAAW,CAAC;EAC5B,OAAOH,GAAG;AACZ;AAEO,SAASM,YAAYA,CAACC,GAAU,EAAE;EACvC,IAAIA,GAAG,YAAYC,WAAW,EAAE;IAE9BD,GAAG,CAACE,UAAU,GAAGF,GAAG,CAACG,GAAG,CAACC,IAAI;IAE7BJ,GAAG,CAACK,MAAM,GAAGL,GAAG,CAACG,GAAG,CAACE,MAAM;EAC7B;EACA,OAAOL,GAAG;AACZ","ignoreList":[]}

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.meta = void 0;
exports.parseForESLint = parseForESLint;
const [major, minor] = process.versions.node.split(".").map(Number);
if (major < 12 || major === 12 && minor < 3) {
throw new Error("@babel/eslint-parser/experimental-worker requires Node.js >= 12.3.0");
}
const normalizeESLintConfig = require("./configuration.cjs");
const analyzeScope = require("./analyze-scope.cjs");
const baseParse = require("./parse.cjs");
const Clients = require("./client.cjs");
const client = new Clients.WorkerClient();
const meta = exports.meta = {
name: "@babel/eslint-parser/experimental-worker",
version: "7.28.4"
};
function parseForESLint(code, options = {}) {
const normalizedOptions = normalizeESLintConfig(options);
const ast = baseParse(code, normalizedOptions, client);
const scopeManager = analyzeScope(ast, normalizedOptions, client);
return {
ast,
scopeManager,
visitorKeys: client.getVisitorKeys()
};
}
//# sourceMappingURL=experimental-worker.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["major","minor","process","versions","node","split","map","Number","Error","normalizeESLintConfig","require","analyzeScope","baseParse","Clients","client","WorkerClient","meta","exports","name","version","parseForESLint","code","options","normalizedOptions","ast","scopeManager","visitorKeys","getVisitorKeys"],"sources":["../src/experimental-worker.cts"],"sourcesContent":["const [major, minor] = process.versions.node.split(\".\").map(Number);\n\nif (major < 12 || (major === 12 && minor < 3)) {\n throw new Error(\n \"@babel/eslint-parser/experimental-worker requires Node.js >= 12.3.0\",\n );\n}\n\nimport normalizeESLintConfig = require(\"./configuration.cts\");\nimport analyzeScope = require(\"./analyze-scope.cts\");\nimport baseParse = require(\"./parse.cts\");\n\nimport Clients = require(\"./client.cts\");\n\nconst client = new Clients.WorkerClient();\n\nexport const meta = {\n name: \"@babel/eslint-parser/experimental-worker\",\n version: PACKAGE_JSON.version,\n};\n\nexport function parseForESLint(code: string, options = {}) {\n const normalizedOptions = normalizeESLintConfig(options);\n const ast = baseParse(code, normalizedOptions, client);\n const scopeManager = analyzeScope(ast, normalizedOptions, client);\n\n return { ast, scopeManager, visitorKeys: client.getVisitorKeys() };\n}\n"],"mappings":";;;;;;;AAAA,MAAM,CAACA,KAAK,EAAEC,KAAK,CAAC,GAAGC,OAAO,CAACC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;AAEnE,IAAIP,KAAK,GAAG,EAAE,IAAKA,KAAK,KAAK,EAAE,IAAIC,KAAK,GAAG,CAAE,EAAE;EAC7C,MAAM,IAAIO,KAAK,CACb,qEACF,CAAC;AACH;AAAC,MAEMC,qBAAqB,GAAAC,OAAA,CAAW,qBAAqB;AAAA,MACrDC,YAAY,GAAAD,OAAA,CAAW,qBAAqB;AAAA,MAC5CE,SAAS,GAAAF,OAAA,CAAW,aAAa;AAAA,MAEjCG,OAAO,GAAAH,OAAA,CAAW,cAAc;AAEvC,MAAMI,MAAM,GAAG,IAAID,OAAO,CAACE,YAAY,CAAC,CAAC;AAElC,MAAMC,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG;EAClBE,IAAI,EAAE,0CAA0C;EAChDC,OAAO;AACT,CAAC;AAEM,SAASC,cAAcA,CAACC,IAAY,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EACzD,MAAMC,iBAAiB,GAAGd,qBAAqB,CAACa,OAAO,CAAC;EACxD,MAAME,GAAG,GAAGZ,SAAS,CAACS,IAAI,EAAEE,iBAAiB,EAAET,MAAM,CAAC;EACtD,MAAMW,YAAY,GAAGd,YAAY,CAACa,GAAG,EAAED,iBAAiB,EAAET,MAAM,CAAC;EAEjE,OAAO;IAAEU,GAAG;IAAEC,YAAY;IAAEC,WAAW,EAAEZ,MAAM,CAACa,cAAc,CAAC;EAAE,CAAC;AACpE","ignoreList":[]}

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.meta = void 0;
exports.parse = parse;
exports.parseForESLint = parseForESLint;
var _client = require("./client.cjs");
const normalizeESLintConfig = require("./configuration.cjs");
const analyzeScope = require("./analyze-scope.cjs");
const baseParse = require("./parse.cjs");
const client = new _client.LocalClient();
const meta = exports.meta = {
name: "@babel/eslint-parser",
version: "7.28.4"
};
function parse(code, options = {}) {
return baseParse(code, normalizeESLintConfig(options), client);
}
function parseForESLint(code, options = {}) {
const normalizedOptions = normalizeESLintConfig(options);
const ast = baseParse(code, normalizedOptions, client);
const scopeManager = analyzeScope(ast, normalizedOptions, client);
return {
ast,
scopeManager,
visitorKeys: client.getVisitorKeys()
};
}
//# sourceMappingURL=index.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_client","require","normalizeESLintConfig","analyzeScope","baseParse","client","LocalClient","meta","exports","name","version","parse","code","options","parseForESLint","normalizedOptions","ast","scopeManager","visitorKeys","getVisitorKeys"],"sources":["../src/index.cts"],"sourcesContent":["import normalizeESLintConfig = require(\"./configuration.cts\");\nimport analyzeScope = require(\"./analyze-scope.cts\");\nimport baseParse = require(\"./parse.cts\");\n\n// @ts-expect-error LocalClient only exists in the cjs build\nimport { LocalClient, WorkerClient } from \"./client.cts\";\nconst client = new (USE_ESM ? WorkerClient : LocalClient)();\n\nexport const meta = {\n name: PACKAGE_JSON.name,\n version: PACKAGE_JSON.version,\n};\n\nexport function parse(code: string, options = {}) {\n return baseParse(code, normalizeESLintConfig(options), client);\n}\n\nexport function parseForESLint(code: string, options = {}) {\n const normalizedOptions = normalizeESLintConfig(options);\n const ast = baseParse(code, normalizedOptions, client);\n const scopeManager = analyzeScope(ast, normalizedOptions, client);\n\n return { ast, scopeManager, visitorKeys: client.getVisitorKeys() };\n}\n"],"mappings":";;;;;;;;AAKA,IAAAA,OAAA,GAAAC,OAAA;AAAyD,MALlDC,qBAAqB,GAAAD,OAAA,CAAW,qBAAqB;AAAA,MACrDE,YAAY,GAAAF,OAAA,CAAW,qBAAqB;AAAA,MAC5CG,SAAS,GAAAH,OAAA,CAAW,aAAa;AAIxC,MAAMI,MAAM,GAAG,IAA8BC,mBAAW,CAAE,CAAC;AAEpD,MAAMC,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG;EAClBE,IAAI,wBAAmB;EACvBC,OAAO;AACT,CAAC;AAEM,SAASC,KAAKA,CAACC,IAAY,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAChD,OAAOT,SAAS,CAACQ,IAAI,EAAEV,qBAAqB,CAACW,OAAO,CAAC,EAAER,MAAM,CAAC;AAChE;AAEO,SAASS,cAAcA,CAACF,IAAY,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EACzD,MAAME,iBAAiB,GAAGb,qBAAqB,CAACW,OAAO,CAAC;EACxD,MAAMG,GAAG,GAAGZ,SAAS,CAACQ,IAAI,EAAEG,iBAAiB,EAAEV,MAAM,CAAC;EACtD,MAAMY,YAAY,GAAGd,YAAY,CAACa,GAAG,EAAED,iBAAiB,EAAEV,MAAM,CAAC;EAEjE,OAAO;IAAEW,GAAG;IAAEC,YAAY;IAAEC,WAAW,EAAEb,MAAM,CAACc,cAAc,CAAC;EAAE,CAAC;AACpE","ignoreList":[]}

View File

@@ -0,0 +1,37 @@
"use strict";
const semver = require("semver");
const convert = require("./convert/index.cjs");
const babelParser = require((((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "8.9") ? require.resolve : (r, {
paths: [b]
}, M = require("module")) => {
let f = M._findPath(r, M._nodeModulePaths(b).concat(b));
if (f) return f;
f = new Error(`Cannot resolve module '${r}'`);
f.code = "MODULE_NOT_FOUND";
throw f;
})("@babel/parser", {
paths: [require.resolve("@babel/core/package.json")]
}));
let isRunningMinSupportedCoreVersion = null;
module.exports = function parse(code, options, client) {
const minSupportedCoreVersion = ">=7.2.0";
if (typeof isRunningMinSupportedCoreVersion !== "boolean") {
isRunningMinSupportedCoreVersion = semver.satisfies(client.getVersion(), minSupportedCoreVersion);
}
if (!isRunningMinSupportedCoreVersion) {
throw new Error(`@babel/eslint-parser@${"7.28.4"} does not support @babel/core@${client.getVersion()}. Please upgrade to @babel/core@${minSupportedCoreVersion}.`);
}
const {
ast,
parserOptions
} = client.maybeParse(code, options);
if (ast) return ast;
try {
return convert.convertFile(babelParser.parse(code, parserOptions), code, client.getTokLabels(), client.getVisitorKeys());
} catch (err) {
throw convert.convertError(err);
}
};
//# sourceMappingURL=parse.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["semver","require","convert","babelParser","v","w","split","process","versions","node","resolve","r","paths","b","M","f","_findPath","_nodeModulePaths","concat","Error","code","isRunningMinSupportedCoreVersion","module","exports","parse","options","client","minSupportedCoreVersion","satisfies","getVersion","ast","parserOptions","maybeParse","convertFile","getTokLabels","getVisitorKeys","err","convertError"],"sources":["../src/parse.cts"],"sourcesContent":["\"use strict\";\n\nimport semver = require(\"semver\");\nimport convert = require(\"./convert/index.cts\");\nimport type { Options } from \"./types.cts\";\nimport type { Client } from \"./client.cts\";\n\nconst babelParser = require(\n require.resolve(\"@babel/parser\", {\n paths: [require.resolve(\"@babel/core/package.json\")],\n }),\n);\n\nlet isRunningMinSupportedCoreVersion: boolean = null;\n\nexport = function parse(code: string, options: Options, client: Client) {\n // Ensure we're using a version of `@babel/core` that includes `parse()` and `tokTypes`.\n const minSupportedCoreVersion = REQUIRED_VERSION(\">=7.2.0\");\n\n if (typeof isRunningMinSupportedCoreVersion !== \"boolean\") {\n isRunningMinSupportedCoreVersion = semver.satisfies(\n client.getVersion(),\n minSupportedCoreVersion,\n );\n }\n\n if (!isRunningMinSupportedCoreVersion) {\n throw new Error(\n `@babel/eslint-parser@${\n PACKAGE_JSON.version\n } does not support @babel/core@${client.getVersion()}. Please upgrade to @babel/core@${minSupportedCoreVersion}.`,\n );\n }\n\n const { ast, parserOptions } = client.maybeParse(code, options);\n\n if (ast) return ast;\n\n try {\n return convert.convertFile(\n babelParser.parse(code, parserOptions),\n code,\n client.getTokLabels(),\n client.getVisitorKeys(),\n );\n } catch (err) {\n throw convert.convertError(err);\n }\n};\n"],"mappings":"AAAA,YAAY;;AAAC,MAENA,MAAM,GAAAC,OAAA,CAAW,QAAQ;AAAA,MACzBC,OAAO,GAAAD,OAAA,CAAW,qBAAqB;AAI9C,MAAME,WAAW,GAAGF,OAAO,CACzB,GAAAG,CAAA,EAAAC,CAAA,MAAAD,CAAA,GAAAA,CAAA,CAAAE,KAAA,OAAAD,CAAA,GAAAA,CAAA,CAAAC,KAAA,QAAAF,CAAA,OAAAC,CAAA,OAAAD,CAAA,OAAAC,CAAA,QAAAD,CAAA,QAAAC,CAAA,MAAAE,OAAA,CAAAC,QAAA,CAAAC,IAAA,WAAAR,OAAA,CAAAS,OAAA,IAAAC,CAAA;EAAAC,KAAA,GAAAC,CAAA;AAAA,GAAAC,CAAA,GAAAb,OAAA;EAAA,IAAAc,CAAA,GAAAD,CAAA,CAAAE,SAAA,CAAAL,CAAA,EAAAG,CAAA,CAAAG,gBAAA,CAAAJ,CAAA,EAAAK,MAAA,CAAAL,CAAA;EAAA,IAAAE,CAAA,SAAAA,CAAA;EAAAA,CAAA,OAAAI,KAAA,2BAAAR,CAAA;EAAAI,CAAA,CAAAK,IAAA;EAAA,MAAAL,CAAA;AAAA,GAAgB,eAAe,EAAE;EAC/BH,KAAK,EAAE,CAACX,OAAO,CAACS,OAAO,CAAC,0BAA0B,CAAC;AACrD,CAAC,CACH,CAAC;AAED,IAAIW,gCAAyC,GAAG,IAAI;AAACC,MAAA,CAAAC,OAAA,GAE5C,SAASC,KAAKA,CAACJ,IAAY,EAAEK,OAAgB,EAAEC,MAAc,EAAE;EAEtE,MAAMC,uBAAuB,GAAoB,SAAU;EAE3D,IAAI,OAAON,gCAAgC,KAAK,SAAS,EAAE;IACzDA,gCAAgC,GAAGrB,MAAM,CAAC4B,SAAS,CACjDF,MAAM,CAACG,UAAU,CAAC,CAAC,EACnBF,uBACF,CAAC;EACH;EAEA,IAAI,CAACN,gCAAgC,EAAE;IACrC,MAAM,IAAIF,KAAK,CACb,iEAEiCO,MAAM,CAACG,UAAU,CAAC,CAAC,mCAAmCF,uBAAuB,GAChH,CAAC;EACH;EAEA,MAAM;IAAEG,GAAG;IAAEC;EAAc,CAAC,GAAGL,MAAM,CAACM,UAAU,CAACZ,IAAI,EAAEK,OAAO,CAAC;EAE/D,IAAIK,GAAG,EAAE,OAAOA,GAAG;EAEnB,IAAI;IACF,OAAO5B,OAAO,CAAC+B,WAAW,CACxB9B,WAAW,CAACqB,KAAK,CAACJ,IAAI,EAAEW,aAAa,CAAC,EACtCX,IAAI,EACJM,MAAM,CAACQ,YAAY,CAAC,CAAC,EACrBR,MAAM,CAACS,cAAc,CAAC,CACxB,CAAC;EACH,CAAC,CAAC,OAAOC,GAAG,EAAE;IACZ,MAAMlC,OAAO,CAACmC,YAAY,CAACD,GAAG,CAAC;EACjC;AACF,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,5 @@
"use strict";
module.exports = parseInt(require("eslint/package.json").version, 10);
//# sourceMappingURL=eslint-version.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["parseInt","require","version"],"sources":["../../src/utils/eslint-version.cts"],"sourcesContent":["export = parseInt(require(\"eslint/package.json\").version, 10);\n"],"mappings":";;iBAASA,QAAQ,CAACC,OAAO,CAAC,qBAAqB,CAAC,CAACC,OAAO,EAAE,EAAE,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getTokLabels = getTokLabels;
exports.getVisitorKeys = getVisitorKeys;
const _ESLINT_VISITOR_KEYS = require("eslint-visitor-keys");
const babel = require("./babel-core.cjs");
const ESLINT_VISITOR_KEYS = _ESLINT_VISITOR_KEYS.KEYS;
let visitorKeys;
function getVisitorKeys() {
if (!visitorKeys) {
const newTypes = {
ChainExpression: ESLINT_VISITOR_KEYS.ChainExpression,
ImportExpression: ESLINT_VISITOR_KEYS.ImportExpression,
Literal: ESLINT_VISITOR_KEYS.Literal,
MethodDefinition: ["decorators"].concat(ESLINT_VISITOR_KEYS.MethodDefinition),
Property: ["decorators"].concat(ESLINT_VISITOR_KEYS.Property),
PropertyDefinition: ["decorators", "typeAnnotation"].concat(ESLINT_VISITOR_KEYS.PropertyDefinition)
};
const conflictTypes = {
ExportAllDeclaration: ESLINT_VISITOR_KEYS.ExportAllDeclaration
};
visitorKeys = Object.assign({}, newTypes, babel.types.VISITOR_KEYS, conflictTypes, {
ClassPrivateMethod: ["decorators"].concat(ESLINT_VISITOR_KEYS.MethodDefinition)
});
}
return visitorKeys;
}
let tokLabels;
function getTokLabels() {
return tokLabels || (tokLabels = (p => p.reduce((o, [k, v]) => Object.assign({}, o, {
[k]: v
}), {}))((Object.entries || (o => Object.keys(o).map(k => [k, o[k]])))(babel.tokTypes).map(([key, tok]) => [key, tok.label])));
}
//# sourceMappingURL=ast-info.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_ESLINT_VISITOR_KEYS","require","babel","ESLINT_VISITOR_KEYS","KEYS","visitorKeys","getVisitorKeys","newTypes","ChainExpression","ImportExpression","Literal","MethodDefinition","concat","Property","PropertyDefinition","conflictTypes","ExportAllDeclaration","Object","assign","types","VISITOR_KEYS","ClassPrivateMethod","tokLabels","getTokLabels","p","reduce","o","k","v","entries","keys","map","tokTypes","key","tok","label"],"sources":["../../src/worker/ast-info.cts"],"sourcesContent":["// @ts-expect-error no types\nimport _ESLINT_VISITOR_KEYS = require(\"eslint-visitor-keys\");\nimport babel = require(\"./babel-core.cts\");\n\nconst ESLINT_VISITOR_KEYS = _ESLINT_VISITOR_KEYS.KEYS;\n\nlet visitorKeys: Record<string, string[]>;\nexport function getVisitorKeys() {\n if (!visitorKeys) {\n // AST Types that are not presented in Babel AST\n const newTypes = {\n ChainExpression: ESLINT_VISITOR_KEYS.ChainExpression,\n ImportExpression: ESLINT_VISITOR_KEYS.ImportExpression,\n Literal: ESLINT_VISITOR_KEYS.Literal,\n MethodDefinition: [\"decorators\"].concat(\n ESLINT_VISITOR_KEYS.MethodDefinition,\n ),\n Property: [\"decorators\"].concat(ESLINT_VISITOR_KEYS.Property),\n PropertyDefinition: [\"decorators\", \"typeAnnotation\"].concat(\n ESLINT_VISITOR_KEYS.PropertyDefinition,\n ),\n };\n\n // AST Types that shares `\"type\"` property with Babel but have different shape\n const conflictTypes = {\n ExportAllDeclaration: ESLINT_VISITOR_KEYS.ExportAllDeclaration,\n };\n\n visitorKeys = {\n ...newTypes,\n ...babel.types.VISITOR_KEYS,\n ...conflictTypes,\n ...(process.env.BABEL_8_BREAKING\n ? {}\n : {\n ClassPrivateMethod: [\"decorators\"].concat(\n ESLINT_VISITOR_KEYS.MethodDefinition,\n ),\n }),\n };\n }\n return visitorKeys;\n}\n\nlet tokLabels;\nexport function getTokLabels() {\n return (tokLabels ||= (\n process.env.BABEL_8_BREAKING\n ? Object.fromEntries\n : (p: any[]) => p.reduce((o, [k, v]) => ({ ...o, [k]: v }), {})\n )(Object.entries(babel.tokTypes).map(([key, tok]) => [key, tok.label])));\n}\n"],"mappings":";;;;;;;MACOA,oBAAoB,GAAAC,OAAA,CAAW,qBAAqB;AAAA,MACpDC,KAAK,GAAAD,OAAA,CAAW,kBAAkB;AAEzC,MAAME,mBAAmB,GAAGH,oBAAoB,CAACI,IAAI;AAErD,IAAIC,WAAqC;AAClC,SAASC,cAAcA,CAAA,EAAG;EAC/B,IAAI,CAACD,WAAW,EAAE;IAEhB,MAAME,QAAQ,GAAG;MACfC,eAAe,EAAEL,mBAAmB,CAACK,eAAe;MACpDC,gBAAgB,EAAEN,mBAAmB,CAACM,gBAAgB;MACtDC,OAAO,EAAEP,mBAAmB,CAACO,OAAO;MACpCC,gBAAgB,EAAE,CAAC,YAAY,CAAC,CAACC,MAAM,CACrCT,mBAAmB,CAACQ,gBACtB,CAAC;MACDE,QAAQ,EAAE,CAAC,YAAY,CAAC,CAACD,MAAM,CAACT,mBAAmB,CAACU,QAAQ,CAAC;MAC7DC,kBAAkB,EAAE,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAACF,MAAM,CACzDT,mBAAmB,CAACW,kBACtB;IACF,CAAC;IAGD,MAAMC,aAAa,GAAG;MACpBC,oBAAoB,EAAEb,mBAAmB,CAACa;IAC5C,CAAC;IAEDX,WAAW,GAAAY,MAAA,CAAAC,MAAA,KACNX,QAAQ,EACRL,KAAK,CAACiB,KAAK,CAACC,YAAY,EACxBL,aAAa,EAGZ;MACEM,kBAAkB,EAAE,CAAC,YAAY,CAAC,CAACT,MAAM,CACvCT,mBAAmB,CAACQ,gBACtB;IACF,CAAC,CACN;EACH;EACA,OAAON,WAAW;AACpB;AAEA,IAAIiB,SAAS;AACN,SAASC,YAAYA,CAAA,EAAG;EAC7B,OAAQD,SAAS,KAATA,SAAS,GAAK,CAGfE,CAAQ,IAAKA,CAAC,CAACC,MAAM,CAAC,CAACC,CAAC,EAAE,CAACC,CAAC,EAAEC,CAAC,CAAC,KAAAX,MAAA,CAAAC,MAAA,KAAWQ,CAAC;IAAE,CAACC,CAAC,GAAGC;EAAC,EAAG,EAAE,CAAC,CAAC,CAAC,EACjE,CAAAX,MAAA,CAAAY,OAAA,KAAAH,CAAA,IAAAT,MAAA,CAAAa,IAAA,CAAAJ,CAAA,EAAAK,GAAA,CAAAJ,CAAA,KAAAA,CAAA,EAAAD,CAAA,CAAAC,CAAA,MAAezB,KAAK,CAAC8B,QAAQ,CAAC,CAACD,GAAG,CAAC,CAAC,CAACE,GAAG,EAAEC,GAAG,CAAC,KAAK,CAACD,GAAG,EAAEC,GAAG,CAACC,KAAK,CAAC,CAAC,CAAC;AACzE","ignoreList":[]}

View File

@@ -0,0 +1,23 @@
"use strict";
module.exports = exports;
function initialize(babel) {
exports.init = null;
exports.version = babel.version;
exports.traverse = babel.traverse;
exports.types = babel.types;
exports.tokTypes = babel.tokTypes;
exports.parseSync = babel.parseSync;
exports.parseAsync = babel.parseAsync;
exports.loadPartialConfigSync = babel.loadPartialConfigSync;
exports.loadPartialConfigAsync = babel.loadPartialConfigAsync;
exports.createConfigItemAsync = babel.createConfigItemAsync;
{
exports.createConfigItemSync = babel.createConfigItemSync || babel.createConfigItem;
}
}
{
initialize(require("@babel/core"));
}
//# sourceMappingURL=babel-core.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["exports","initialize","babel","init","version","traverse","types","tokTypes","parseSync","parseAsync","loadPartialConfigSync","loadPartialConfigAsync","createConfigItemAsync","createConfigItemSync","createConfigItem","require"],"sources":["../../src/worker/babel-core.cts"],"sourcesContent":["export = exports as typeof import(\"@babel/core\") & {\n init: Promise<void> | null;\n};\n\nfunction initialize(babel: typeof import(\"@babel/core\")) {\n exports.init = null;\n exports.version = babel.version;\n exports.traverse = babel.traverse;\n exports.types = babel.types;\n exports.tokTypes = babel.tokTypes;\n exports.parseSync = babel.parseSync;\n exports.parseAsync = babel.parseAsync;\n exports.loadPartialConfigSync = babel.loadPartialConfigSync;\n exports.loadPartialConfigAsync = babel.loadPartialConfigAsync;\n exports.createConfigItemAsync = babel.createConfigItemAsync;\n\n if (process.env.BABEL_8_BREAKING) {\n exports.createConfigItemSync = babel.createConfigItemSync;\n } else {\n // babel.createConfigItemSync is available on 7.13+\n // we support Babel 7.11+\n exports.createConfigItemSync =\n babel.createConfigItemSync || babel.createConfigItem;\n }\n}\n\nif (USE_ESM) {\n exports.init = import(\"@babel/core\").then(initialize);\n} else {\n initialize(require(\"@babel/core\"));\n}\n"],"mappings":";;iBAASA,OAAO;AAIhB,SAASC,UAAUA,CAACC,KAAmC,EAAE;EACvDF,OAAO,CAACG,IAAI,GAAG,IAAI;EACnBH,OAAO,CAACI,OAAO,GAAGF,KAAK,CAACE,OAAO;EAC/BJ,OAAO,CAACK,QAAQ,GAAGH,KAAK,CAACG,QAAQ;EACjCL,OAAO,CAACM,KAAK,GAAGJ,KAAK,CAACI,KAAK;EAC3BN,OAAO,CAACO,QAAQ,GAAGL,KAAK,CAACK,QAAQ;EACjCP,OAAO,CAACQ,SAAS,GAAGN,KAAK,CAACM,SAAS;EACnCR,OAAO,CAACS,UAAU,GAAGP,KAAK,CAACO,UAAU;EACrCT,OAAO,CAACU,qBAAqB,GAAGR,KAAK,CAACQ,qBAAqB;EAC3DV,OAAO,CAACW,sBAAsB,GAAGT,KAAK,CAACS,sBAAsB;EAC7DX,OAAO,CAACY,qBAAqB,GAAGV,KAAK,CAACU,qBAAqB;EAIpD;IAGLZ,OAAO,CAACa,oBAAoB,GAC1BX,KAAK,CAACW,oBAAoB,IAAIX,KAAK,CAACY,gBAAgB;EACxD;AACF;AAIO;EACLb,UAAU,CAACc,OAAO,CAAC,aAAa,CAAC,CAAC;AACpC","ignoreList":[]}

View File

@@ -0,0 +1,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.normalizeBabelParseConfig = normalizeBabelParseConfig;
exports.normalizeBabelParseConfigSync = normalizeBabelParseConfigSync;
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
const babel = require("./babel-core.cjs");
const semver = require("semver");
const ESLINT_VERSION = require("../utils/eslint-version.cjs");
function getParserPlugins(babelOptions) {
var _babelOptions$parserO, _babelOptions$parserO2;
const babelParserPlugins = (_babelOptions$parserO = (_babelOptions$parserO2 = babelOptions.parserOpts) == null ? void 0 : _babelOptions$parserO2.plugins) != null ? _babelOptions$parserO : [];
const estreeOptions = {
classFeatures: ESLINT_VERSION >= 8
};
for (const plugin of babelParserPlugins) {
if (Array.isArray(plugin) && plugin[0] === "estree") {
Object.assign(estreeOptions, plugin[1]);
break;
}
}
return [["estree", estreeOptions], ...babelParserPlugins];
}
function normalizeParserOptions(options, version) {
var _options$allowImportE, _options$ecmaFeatures2, _options$ecmaFeatures3;
if (options.sourceType === "commonjs" && !semver.satisfies(version, ">=7.28.0")) {
var _options$ecmaFeatures;
options.sourceType = "script";
options.ecmaFeatures = Object.assign({}, (_options$ecmaFeatures = options.ecmaFeatures) != null ? _options$ecmaFeatures : {}, {
globalReturn: true
});
}
return Object.assign({
sourceType: options.sourceType,
filename: options.filePath
}, options.babelOptions, {
parserOpts: Object.assign({}, {
allowImportExportEverywhere: (_options$allowImportE = options.allowImportExportEverywhere) != null ? _options$allowImportE : false,
allowSuperOutsideMethod: true
}, options.sourceType !== "commonjs" ? {
allowReturnOutsideFunction: (_options$ecmaFeatures2 = (_options$ecmaFeatures3 = options.ecmaFeatures) == null ? void 0 : _options$ecmaFeatures3.globalReturn) != null ? _options$ecmaFeatures2 : true
} : {}, options.babelOptions.parserOpts, {
plugins: getParserPlugins(options.babelOptions),
attachComment: false,
ranges: true,
tokens: true
}),
caller: Object.assign({
name: "@babel/eslint-parser"
}, options.babelOptions.caller)
});
}
function validateResolvedConfig(config, options, parseOptions) {
if (config !== null) {
if (options.requireConfigFile !== false) {
if (!config.hasFilesystemConfig()) {
let error = `No Babel config file detected for ${config.options.filename}. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.`;
if (config.options.filename.includes("node_modules")) {
error += `\nIf you have a .babelrc.js file or use package.json#babel, keep in mind that it's not used when parsing dependencies. If you want your config to be applied to your whole app, consider using babel.config.js or babel.config.json instead.`;
}
throw new Error(error);
}
}
if (config.options) return config.options;
}
return getDefaultParserOptions(parseOptions);
}
function getDefaultParserOptions(options) {
return Object.assign({
plugins: []
}, options, {
babelrc: false,
configFile: false,
browserslistConfigFile: false,
ignore: null,
only: null
});
}
function normalizeBabelParseConfig(_x) {
return _normalizeBabelParseConfig.apply(this, arguments);
}
function _normalizeBabelParseConfig() {
_normalizeBabelParseConfig = _asyncToGenerator(function* (options) {
const parseOptions = normalizeParserOptions(options, babel.version);
const config = yield babel.loadPartialConfigAsync(parseOptions);
return validateResolvedConfig(config, options, parseOptions);
});
return _normalizeBabelParseConfig.apply(this, arguments);
}
function normalizeBabelParseConfigSync(options) {
const parseOptions = normalizeParserOptions(options, babel.version);
const config = babel.loadPartialConfigSync(parseOptions);
return validateResolvedConfig(config, options, parseOptions);
}
//# sourceMappingURL=configuration.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
"use strict";
module.exports = function extractParserOptionsPlugin() {
return {
parserOverride(code, opts) {
return opts;
}
};
};
//# sourceMappingURL=extract-parser-options-plugin.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["extractParserOptionsPlugin","parserOverride","code","opts"],"sources":["../../src/worker/extract-parser-options-plugin.cts"],"sourcesContent":["export = function extractParserOptionsPlugin() {\n return {\n parserOverride(code: string, opts: any) {\n return opts;\n },\n };\n};\n"],"mappings":";;iBAAS,SAASA,0BAA0BA,CAAA,EAAG;EAC7C,OAAO;IACLC,cAAcA,CAACC,IAAY,EAAEC,IAAS,EAAE;MACtC,OAAOA,IAAI;IACb;EACF,CAAC;AACH,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,33 @@
"use strict";
const babel = require("./babel-core.cjs");
const maybeParse = require("./maybeParse.cjs");
const maybeParseSync = require("./maybeParseSync.cjs");
const astInfo = require("./ast-info.cjs");
const config = require("./configuration.cjs");
const Clients = require("../client.cjs");
var ACTIONS = Clients.ACTIONS;
module.exports = function handleMessage(action, payload) {
switch (action) {
case ACTIONS.GET_VERSION:
return babel.version;
case ACTIONS.GET_TYPES_INFO:
return {
FLOW_FLIPPED_ALIAS_KEYS: babel.types.FLIPPED_ALIAS_KEYS.Flow,
VISITOR_KEYS: babel.types.VISITOR_KEYS
};
case ACTIONS.GET_TOKEN_LABELS:
return astInfo.getTokLabels();
case ACTIONS.GET_VISITOR_KEYS:
return astInfo.getVisitorKeys();
case ACTIONS.MAYBE_PARSE:
return config.normalizeBabelParseConfig(payload.options).then(options => maybeParse(payload.code, options));
case ACTIONS.MAYBE_PARSE_SYNC:
{
return maybeParseSync(payload.code, config.normalizeBabelParseConfigSync(payload.options));
}
}
throw new Error(`Unknown internal parser worker action: ${action}`);
};
//# sourceMappingURL=handle-message.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["babel","require","maybeParse","maybeParseSync","astInfo","config","Clients","ACTIONS","module","exports","handleMessage","action","payload","GET_VERSION","version","GET_TYPES_INFO","FLOW_FLIPPED_ALIAS_KEYS","types","FLIPPED_ALIAS_KEYS","Flow","VISITOR_KEYS","GET_TOKEN_LABELS","getTokLabels","GET_VISITOR_KEYS","getVisitorKeys","MAYBE_PARSE","normalizeBabelParseConfig","options","then","code","MAYBE_PARSE_SYNC","normalizeBabelParseConfigSync","Error"],"sources":["../../src/worker/handle-message.cts"],"sourcesContent":["import babel = require(\"./babel-core.cts\");\nimport maybeParse = require(\"./maybeParse.cts\");\nimport maybeParseSync = require(\"./maybeParseSync.cts\");\nimport astInfo = require(\"./ast-info.cts\");\nimport config = require(\"./configuration.cts\");\n\nimport Clients = require(\"../client.cts\");\nimport ACTIONS = Clients.ACTIONS;\n\nexport = function handleMessage(action: ACTIONS, payload: any) {\n switch (action) {\n case ACTIONS.GET_VERSION:\n return babel.version;\n case ACTIONS.GET_TYPES_INFO:\n return {\n FLOW_FLIPPED_ALIAS_KEYS: babel.types.FLIPPED_ALIAS_KEYS.Flow,\n VISITOR_KEYS: babel.types.VISITOR_KEYS,\n };\n case ACTIONS.GET_TOKEN_LABELS:\n return astInfo.getTokLabels();\n case ACTIONS.GET_VISITOR_KEYS:\n return astInfo.getVisitorKeys();\n case ACTIONS.MAYBE_PARSE:\n return config\n .normalizeBabelParseConfig(payload.options)\n .then(options => maybeParse(payload.code, options));\n case ACTIONS.MAYBE_PARSE_SYNC:\n if (!USE_ESM) {\n return maybeParseSync(\n payload.code,\n config.normalizeBabelParseConfigSync(payload.options),\n );\n }\n }\n\n throw new Error(`Unknown internal parser worker action: ${action}`);\n};\n"],"mappings":";;MAAOA,KAAK,GAAAC,OAAA,CAAW,kBAAkB;AAAA,MAClCC,UAAU,GAAAD,OAAA,CAAW,kBAAkB;AAAA,MACvCE,cAAc,GAAAF,OAAA,CAAW,sBAAsB;AAAA,MAC/CG,OAAO,GAAAH,OAAA,CAAW,gBAAgB;AAAA,MAClCI,MAAM,GAAAJ,OAAA,CAAW,qBAAqB;AAAA,MAEtCK,OAAO,GAAAL,OAAA,CAAW,eAAe;AAAA,IACjCM,OAAO,GAAGD,OAAO,CAACC,OAAO;AAAAC,MAAA,CAAAC,OAAA,GAEvB,SAASC,aAAaA,CAACC,MAAe,EAAEC,OAAY,EAAE;EAC7D,QAAQD,MAAM;IACZ,KAAKJ,OAAO,CAACM,WAAW;MACtB,OAAOb,KAAK,CAACc,OAAO;IACtB,KAAKP,OAAO,CAACQ,cAAc;MACzB,OAAO;QACLC,uBAAuB,EAAEhB,KAAK,CAACiB,KAAK,CAACC,kBAAkB,CAACC,IAAI;QAC5DC,YAAY,EAAEpB,KAAK,CAACiB,KAAK,CAACG;MAC5B,CAAC;IACH,KAAKb,OAAO,CAACc,gBAAgB;MAC3B,OAAOjB,OAAO,CAACkB,YAAY,CAAC,CAAC;IAC/B,KAAKf,OAAO,CAACgB,gBAAgB;MAC3B,OAAOnB,OAAO,CAACoB,cAAc,CAAC,CAAC;IACjC,KAAKjB,OAAO,CAACkB,WAAW;MACtB,OAAOpB,MAAM,CACVqB,yBAAyB,CAACd,OAAO,CAACe,OAAO,CAAC,CAC1CC,IAAI,CAACD,OAAO,IAAIzB,UAAU,CAACU,OAAO,CAACiB,IAAI,EAAEF,OAAO,CAAC,CAAC;IACvD,KAAKpB,OAAO,CAACuB,gBAAgB;MACb;QACZ,OAAO3B,cAAc,CACnBS,OAAO,CAACiB,IAAI,EACZxB,MAAM,CAAC0B,6BAA6B,CAACnB,OAAO,CAACe,OAAO,CACtD,CAAC;MACH;EACJ;EAEA,MAAM,IAAIK,KAAK,CAAC,0CAA0CrB,MAAM,EAAE,CAAC;AACrE,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,39 @@
"use strict";
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
const babel = require("./babel-core.cjs");
const handleMessage = require("./handle-message.cjs");
const worker_threads = require("worker_threads");
worker_threads.parentPort.addListener("message", _asyncToGenerator(function* ({
signal,
port,
action,
payload
}) {
let response;
try {
if (babel.init) yield babel.init;
response = {
result: yield handleMessage(action, payload)
};
} catch (error) {
response = {
error,
errorData: Object.assign({}, error)
};
}
try {
port.postMessage(response);
} catch (_unused) {
port.postMessage({
error: new Error("Cannot serialize worker response")
});
} finally {
port.close();
Atomics.store(signal, 0, 1);
Atomics.notify(signal, 0);
}
}));
//# sourceMappingURL=index.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["babel","require","handleMessage","worker_threads","parentPort","addListener","_asyncToGenerator","signal","port","action","payload","response","init","result","error","errorData","Object","assign","postMessage","_unused","Error","close","Atomics","store","notify"],"sources":["../../src/worker/index.cts"],"sourcesContent":["import babel = require(\"./babel-core.cts\");\nimport handleMessage = require(\"./handle-message.cts\");\n\nimport worker_threads = require(\"worker_threads\");\n\nworker_threads.parentPort.addListener(\n \"message\",\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async ({ signal, port, action, payload }) => {\n let response;\n\n try {\n if (babel.init) await babel.init;\n\n response = { result: await handleMessage(action, payload) };\n } catch (error) {\n response = { error, errorData: { ...error } };\n }\n\n try {\n port.postMessage(response);\n } catch {\n port.postMessage({\n error: new Error(\"Cannot serialize worker response\"),\n });\n } finally {\n port.close();\n Atomics.store(signal, 0, 1);\n Atomics.notify(signal, 0);\n }\n },\n);\n"],"mappings":";;;;MAAOA,KAAK,GAAAC,OAAA,CAAW,kBAAkB;AAAA,MAClCC,aAAa,GAAAD,OAAA,CAAW,sBAAsB;AAAA,MAE9CE,cAAc,GAAAF,OAAA,CAAW,gBAAgB;AAEhDE,cAAc,CAACC,UAAU,CAACC,WAAW,CACnC,SAAS,EAAAC,iBAAA,CAET,WAAO;EAAEC,MAAM;EAAEC,IAAI;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAK;EAC3C,IAAIC,QAAQ;EAEZ,IAAI;IACF,IAAIX,KAAK,CAACY,IAAI,EAAE,MAAMZ,KAAK,CAACY,IAAI;IAEhCD,QAAQ,GAAG;MAAEE,MAAM,QAAQX,aAAa,CAACO,MAAM,EAAEC,OAAO;IAAE,CAAC;EAC7D,CAAC,CAAC,OAAOI,KAAK,EAAE;IACdH,QAAQ,GAAG;MAAEG,KAAK;MAAEC,SAAS,EAAAC,MAAA,CAAAC,MAAA,KAAOH,KAAK;IAAG,CAAC;EAC/C;EAEA,IAAI;IACFN,IAAI,CAACU,WAAW,CAACP,QAAQ,CAAC;EAC5B,CAAC,CAAC,OAAAQ,OAAA,EAAM;IACNX,IAAI,CAACU,WAAW,CAAC;MACfJ,KAAK,EAAE,IAAIM,KAAK,CAAC,kCAAkC;IACrD,CAAC,CAAC;EACJ,CAAC,SAAS;IACRZ,IAAI,CAACa,KAAK,CAAC,CAAC;IACZC,OAAO,CAACC,KAAK,CAAChB,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAC3Be,OAAO,CAACE,MAAM,CAACjB,MAAM,EAAE,CAAC,CAAC;EAC3B;AACF,CAAC,CACH,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,56 @@
"use strict";
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
const babel = require("./babel-core.cjs");
const convert = require("../convert/index.cjs");
const astInfo = require("./ast-info.cjs");
const extractParserOptionsPlugin = require("./extract-parser-options-plugin.cjs");
const {
getVisitorKeys,
getTokLabels
} = astInfo;
const ref = {};
let extractParserOptionsConfigItem;
const MULTIPLE_OVERRIDES = /More than one plugin attempted to override parsing/;
module.exports = function () {
var _asyncMaybeParse = _asyncToGenerator(function* (code, options) {
if (!extractParserOptionsConfigItem) {
extractParserOptionsConfigItem = yield babel.createConfigItemAsync([extractParserOptionsPlugin, ref], {
dirname: __dirname,
type: "plugin"
});
}
const {
plugins
} = options;
options.plugins = plugins.concat(extractParserOptionsConfigItem);
let ast;
try {
return {
parserOptions: yield babel.parseAsync(code, options),
ast: null
};
} catch (err) {
if (!MULTIPLE_OVERRIDES.test(err.message)) {
throw err;
}
}
options.plugins = plugins;
try {
ast = yield babel.parseAsync(code, options);
} catch (err) {
throw convert.convertError(err);
}
return {
ast: convert.convertFile(ast, code, getTokLabels(), getVisitorKeys()),
parserOptions: null
};
});
function asyncMaybeParse(_x, _x2) {
return _asyncMaybeParse.apply(this, arguments);
}
return asyncMaybeParse;
}();
//# sourceMappingURL=maybeParse.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["babel","require","convert","astInfo","extractParserOptionsPlugin","getVisitorKeys","getTokLabels","ref","extractParserOptionsConfigItem","MULTIPLE_OVERRIDES","module","exports","_asyncMaybeParse","_asyncToGenerator","code","options","createConfigItemAsync","dirname","__dirname","type","plugins","concat","ast","parserOptions","parseAsync","err","test","message","convertError","convertFile","asyncMaybeParse","_x","_x2","apply","arguments"],"sources":["../../src/worker/maybeParse.cts"],"sourcesContent":["import babel = require(\"./babel-core.cts\");\nimport convert = require(\"../convert/index.cts\");\nimport astInfo = require(\"./ast-info.cts\");\nimport extractParserOptionsPlugin = require(\"./extract-parser-options-plugin.cjs\");\n\nimport type { InputOptions, ConfigItem } from \"@babel/core\";\nimport type { AST, ParseResult } from \"../types.cts\";\n\nconst { getVisitorKeys, getTokLabels } = astInfo;\n\nconst ref = {};\nlet extractParserOptionsConfigItem: ConfigItem<any>;\n\nconst MULTIPLE_OVERRIDES = /More than one plugin attempted to override parsing/;\n\nexport = async function asyncMaybeParse(\n code: string,\n options: InputOptions,\n): Promise<{\n ast: AST.Program | null;\n parserOptions: ParseResult | null;\n}> {\n if (!extractParserOptionsConfigItem) {\n extractParserOptionsConfigItem = await babel.createConfigItemAsync(\n [extractParserOptionsPlugin, ref],\n { dirname: __dirname, type: \"plugin\" },\n );\n }\n const { plugins } = options;\n options.plugins = plugins.concat(extractParserOptionsConfigItem);\n\n let ast;\n\n try {\n return {\n parserOptions: await babel.parseAsync(code, options),\n ast: null,\n };\n } catch (err) {\n if (!MULTIPLE_OVERRIDES.test(err.message)) {\n throw err;\n }\n }\n\n // There was already a parserOverride, so remove our plugin.\n options.plugins = plugins;\n\n try {\n ast = await babel.parseAsync(code, options);\n } catch (err) {\n throw convert.convertError(err);\n }\n\n return {\n ast: convert.convertFile(ast, code, getTokLabels(), getVisitorKeys()),\n parserOptions: null,\n };\n};\n"],"mappings":";;;;MAAOA,KAAK,GAAAC,OAAA,CAAW,kBAAkB;AAAA,MAClCC,OAAO,GAAAD,OAAA,CAAW,sBAAsB;AAAA,MACxCE,OAAO,GAAAF,OAAA,CAAW,gBAAgB;AAAA,MAClCG,0BAA0B,GAAAH,OAAA,CAAW,qCAAqC;AAKjF,MAAM;EAAEI,cAAc;EAAEC;AAAa,CAAC,GAAGH,OAAO;AAEhD,MAAMI,GAAG,GAAG,CAAC,CAAC;AACd,IAAIC,8BAA+C;AAEnD,MAAMC,kBAAkB,GAAG,oDAAoD;AAACC,MAAA,CAAAC,OAAA;EAAA,IAAAC,gBAAA,GAAAC,iBAAA,CAEvE,WACPC,IAAY,EACZC,OAAqB,EAIpB;IACD,IAAI,CAACP,8BAA8B,EAAE;MACnCA,8BAA8B,SAASR,KAAK,CAACgB,qBAAqB,CAChE,CAACZ,0BAA0B,EAAEG,GAAG,CAAC,EACjC;QAAEU,OAAO,EAAEC,SAAS;QAAEC,IAAI,EAAE;MAAS,CACvC,CAAC;IACH;IACA,MAAM;MAAEC;IAAQ,CAAC,GAAGL,OAAO;IAC3BA,OAAO,CAACK,OAAO,GAAGA,OAAO,CAACC,MAAM,CAACb,8BAA8B,CAAC;IAEhE,IAAIc,GAAG;IAEP,IAAI;MACF,OAAO;QACLC,aAAa,QAAQvB,KAAK,CAACwB,UAAU,CAACV,IAAI,EAAEC,OAAO,CAAC;QACpDO,GAAG,EAAE;MACP,CAAC;IACH,CAAC,CAAC,OAAOG,GAAG,EAAE;MACZ,IAAI,CAAChB,kBAAkB,CAACiB,IAAI,CAACD,GAAG,CAACE,OAAO,CAAC,EAAE;QACzC,MAAMF,GAAG;MACX;IACF;IAGAV,OAAO,CAACK,OAAO,GAAGA,OAAO;IAEzB,IAAI;MACFE,GAAG,SAAStB,KAAK,CAACwB,UAAU,CAACV,IAAI,EAAEC,OAAO,CAAC;IAC7C,CAAC,CAAC,OAAOU,GAAG,EAAE;MACZ,MAAMvB,OAAO,CAAC0B,YAAY,CAACH,GAAG,CAAC;IACjC;IAEA,OAAO;MACLH,GAAG,EAAEpB,OAAO,CAAC2B,WAAW,CAACP,GAAG,EAAER,IAAI,EAAER,YAAY,CAAC,CAAC,EAAED,cAAc,CAAC,CAAC,CAAC;MACrEkB,aAAa,EAAE;IACjB,CAAC;EACH,CAAC;EAAA,SA1CuBO,eAAeA,CAAAC,EAAA,EAAAC,GAAA;IAAA,OAAApB,gBAAA,CAAAqB,KAAA,OAAAC,SAAA;EAAA;EAAA,OAAfJ,eAAe;AAAA","ignoreList":[]}

View File

@@ -0,0 +1,48 @@
"use strict";
const babel = require("./babel-core.cjs");
const convert = require("../convert/index.cjs");
const astInfo = require("./ast-info.cjs");
const extractParserOptionsPlugin = require("./extract-parser-options-plugin.cjs");
const {
getVisitorKeys,
getTokLabels
} = astInfo;
const ref = {};
let extractParserOptionsConfigItem;
const MULTIPLE_OVERRIDES = /More than one plugin attempted to override parsing/;
module.exports = function maybeParseSync(code, options) {
if (!extractParserOptionsConfigItem) {
extractParserOptionsConfigItem = babel.createConfigItemSync([extractParserOptionsPlugin, ref], {
dirname: __dirname,
type: "plugin"
});
}
const {
plugins
} = options;
options.plugins = plugins.concat(extractParserOptionsConfigItem);
let ast;
try {
return {
parserOptions: babel.parseSync(code, options),
ast: null
};
} catch (err) {
if (!MULTIPLE_OVERRIDES.test(err.message)) {
throw err;
}
}
options.plugins = plugins;
try {
ast = babel.parseSync(code, options);
} catch (err) {
throw convert.convertError(err);
}
return {
ast: convert.convertFile(ast, code, getTokLabels(), getVisitorKeys()),
parserOptions: null
};
};
//# sourceMappingURL=maybeParseSync.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["babel","require","convert","astInfo","extractParserOptionsPlugin","getVisitorKeys","getTokLabels","ref","extractParserOptionsConfigItem","MULTIPLE_OVERRIDES","module","exports","maybeParseSync","code","options","createConfigItemSync","dirname","__dirname","type","plugins","concat","ast","parserOptions","parseSync","err","test","message","convertError","convertFile"],"sources":["../../src/worker/maybeParseSync.cts"],"sourcesContent":["import babel = require(\"./babel-core.cts\");\nimport convert = require(\"../convert/index.cts\");\nimport astInfo = require(\"./ast-info.cts\");\nimport extractParserOptionsPlugin = require(\"./extract-parser-options-plugin.cjs\");\n\nimport type { InputOptions, ConfigItem } from \"@babel/core\";\nimport type { AST, ParseResult } from \"../types.cts\";\n\nconst { getVisitorKeys, getTokLabels } = astInfo;\n\nconst ref = {};\nlet extractParserOptionsConfigItem: ConfigItem<any>;\n\nconst MULTIPLE_OVERRIDES = /More than one plugin attempted to override parsing/;\n\nexport = function maybeParseSync(\n code: string,\n options: InputOptions,\n): {\n ast: AST.Program | null;\n parserOptions: ParseResult | null;\n} {\n if (!extractParserOptionsConfigItem) {\n extractParserOptionsConfigItem = babel.createConfigItemSync(\n [extractParserOptionsPlugin, ref],\n { dirname: __dirname, type: \"plugin\" },\n );\n }\n const { plugins } = options;\n options.plugins = plugins.concat(extractParserOptionsConfigItem);\n\n let ast;\n\n try {\n return {\n parserOptions: babel.parseSync(code, options),\n ast: null,\n };\n } catch (err) {\n if (!MULTIPLE_OVERRIDES.test(err.message)) {\n throw err;\n }\n }\n\n // There was already a parserOverride, so remove our plugin.\n options.plugins = plugins;\n\n try {\n ast = babel.parseSync(code, options);\n } catch (err) {\n throw convert.convertError(err);\n }\n\n return {\n ast: convert.convertFile(ast, code, getTokLabels(), getVisitorKeys()),\n parserOptions: null,\n };\n};\n"],"mappings":";;MAAOA,KAAK,GAAAC,OAAA,CAAW,kBAAkB;AAAA,MAClCC,OAAO,GAAAD,OAAA,CAAW,sBAAsB;AAAA,MACxCE,OAAO,GAAAF,OAAA,CAAW,gBAAgB;AAAA,MAClCG,0BAA0B,GAAAH,OAAA,CAAW,qCAAqC;AAKjF,MAAM;EAAEI,cAAc;EAAEC;AAAa,CAAC,GAAGH,OAAO;AAEhD,MAAMI,GAAG,GAAG,CAAC,CAAC;AACd,IAAIC,8BAA+C;AAEnD,MAAMC,kBAAkB,GAAG,oDAAoD;AAACC,MAAA,CAAAC,OAAA,GAEvE,SAASC,cAAcA,CAC9BC,IAAY,EACZC,OAAqB,EAIrB;EACA,IAAI,CAACN,8BAA8B,EAAE;IACnCA,8BAA8B,GAAGR,KAAK,CAACe,oBAAoB,CACzD,CAACX,0BAA0B,EAAEG,GAAG,CAAC,EACjC;MAAES,OAAO,EAAEC,SAAS;MAAEC,IAAI,EAAE;IAAS,CACvC,CAAC;EACH;EACA,MAAM;IAAEC;EAAQ,CAAC,GAAGL,OAAO;EAC3BA,OAAO,CAACK,OAAO,GAAGA,OAAO,CAACC,MAAM,CAACZ,8BAA8B,CAAC;EAEhE,IAAIa,GAAG;EAEP,IAAI;IACF,OAAO;MACLC,aAAa,EAAEtB,KAAK,CAACuB,SAAS,CAACV,IAAI,EAAEC,OAAO,CAAC;MAC7CO,GAAG,EAAE;IACP,CAAC;EACH,CAAC,CAAC,OAAOG,GAAG,EAAE;IACZ,IAAI,CAACf,kBAAkB,CAACgB,IAAI,CAACD,GAAG,CAACE,OAAO,CAAC,EAAE;MACzC,MAAMF,GAAG;IACX;EACF;EAGAV,OAAO,CAACK,OAAO,GAAGA,OAAO;EAEzB,IAAI;IACFE,GAAG,GAAGrB,KAAK,CAACuB,SAAS,CAACV,IAAI,EAAEC,OAAO,CAAC;EACtC,CAAC,CAAC,OAAOU,GAAG,EAAE;IACZ,MAAMtB,OAAO,CAACyB,YAAY,CAACH,GAAG,CAAC;EACjC;EAEA,OAAO;IACLH,GAAG,EAAEnB,OAAO,CAAC0B,WAAW,CAACP,GAAG,EAAER,IAAI,EAAEP,YAAY,CAAC,CAAC,EAAED,cAAc,CAAC,CAAC,CAAC;IACrEiB,aAAa,EAAE;EACjB,CAAC;AACH,CAAC","ignoreList":[]}

View File

@@ -0,0 +1 @@
../semver/bin/semver.js

View File

@@ -0,0 +1,36 @@
v2.1.0 - May 3, 2021
* [`908fdf8`](https://github.com/eslint/eslint-visitor-keys/commit/908fdf8c0d9a352c696c8c1f4901280d1a0795f7) Update: add PrivateIdentifier and PropertyDefinition (#20) (Toru Nagashima)
* [`2d7be11`](https://github.com/eslint/eslint-visitor-keys/commit/2d7be11e4d13ac702c9fe3c529cadbd75b370146) Chore: No longer test in Node.js 13 (#17) (Michaël De Boey)
* [`b41b509`](https://github.com/eslint/eslint-visitor-keys/commit/b41b509b153ecd8d47af46a421122f64e93d4c67) Docs: Update required Node.js version (#15) (Michaël De Boey)
v2.0.0 - August 14, 2020
* [`fb86ca3`](https://github.com/eslint/eslint-visitor-keys/commit/fb86ca315daafc84e23ed9005db40b0892b972a6) Breaking: drop support for Node <10 (#13) (Kai Cataldo)
* [`69383b3`](https://github.com/eslint/eslint-visitor-keys/commit/69383b372915e33ada094880ecc6b6e8f8c7ca4e) Chore: move to GitHub Actions (#14) (Kai Cataldo)
v1.3.0 - June 19, 2020
* [`c92dd7f`](https://github.com/eslint/eslint-visitor-keys/commit/c92dd7ff96f0044dba12d681406a025b92b4c437) Update: add `ChainExpression` node (#12) (Toru Nagashima)
v1.2.0 - June 4, 2020
* [`21f28bf`](https://github.com/eslint/eslint-visitor-keys/commit/21f28bf11be5329d740a8bf6bdbcd0ef13bbf1a2) Update: added exported in exportAllDeclaration key (#10) (Anix)
v1.1.0 - August 13, 2019
* [`9331cc0`](https://github.com/eslint/eslint-visitor-keys/commit/9331cc09e756e65b9044c9186445a474b037fac6) Update: add ImportExpression (#8) (Toru Nagashima)
* [`5967f58`](https://github.com/eslint/eslint-visitor-keys/commit/5967f583b04f17fba9226aaa394e45d476d2b8af) Chore: add supported Node.js versions to CI (#7) (Kai Cataldo)
* [`6f7c60f`](https://github.com/eslint/eslint-visitor-keys/commit/6f7c60fef2ceec9f6323202df718321cec45cab0) Upgrade: eslint-release@1.0.0 (#5) (Teddy Katz)
v1.0.0 - December 18, 2017
* 1f6bd38 Breaking: update keys (#4) (Toru Nagashima)
v0.1.0 - November 17, 2017
* 17b4a88 Chore: update `repository` field in package.json (#3) (Toru Nagashima)
* a5a026b New: eslint-visitor-keys (#1) (Toru Nagashima)
* a1a48b8 Update: Change license to Apache 2 (#2) (Ilya Volodin)
* 2204715 Initial commit (Toru Nagashima)

View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,98 @@
# eslint-visitor-keys
[![npm version](https://img.shields.io/npm/v/eslint-visitor-keys.svg)](https://www.npmjs.com/package/eslint-visitor-keys)
[![Downloads/month](https://img.shields.io/npm/dm/eslint-visitor-keys.svg)](http://www.npmtrends.com/eslint-visitor-keys)
[![Build Status](https://travis-ci.org/eslint/eslint-visitor-keys.svg?branch=master)](https://travis-ci.org/eslint/eslint-visitor-keys)
[![Dependency Status](https://david-dm.org/eslint/eslint-visitor-keys.svg)](https://david-dm.org/eslint/eslint-visitor-keys)
Constants and utilities about visitor keys to traverse AST.
## 💿 Installation
Use [npm] to install.
```bash
$ npm install eslint-visitor-keys
```
### Requirements
- [Node.js] 10.0.0 or later.
## 📖 Usage
```js
const evk = require("eslint-visitor-keys")
```
### evk.KEYS
> type: `{ [type: string]: string[] | undefined }`
Visitor keys. This keys are frozen.
This is an object. Keys are the type of [ESTree] nodes. Their values are an array of property names which have child nodes.
For example:
```
console.log(evk.KEYS.AssignmentExpression) // → ["left", "right"]
```
### evk.getKeys(node)
> type: `(node: object) => string[]`
Get the visitor keys of a given AST node.
This is similar to `Object.keys(node)` of ES Standard, but some keys are excluded: `parent`, `leadingComments`, `trailingComments`, and names which start with `_`.
This will be used to traverse unknown nodes.
For example:
```
const node = {
type: "AssignmentExpression",
left: { type: "Identifier", name: "foo" },
right: { type: "Literal", value: 0 }
}
console.log(evk.getKeys(node)) // → ["type", "left", "right"]
```
### evk.unionWith(additionalKeys)
> type: `(additionalKeys: object) => { [type: string]: string[] | undefined }`
Make the union set with `evk.KEYS` and the given keys.
- The order of keys is, `additionalKeys` is at first, then `evk.KEYS` is concatenated after that.
- It removes duplicated keys as keeping the first one.
For example:
```
console.log(evk.unionWith({
MethodDefinition: ["decorators"]
})) // → { ..., MethodDefinition: ["decorators", "key", "value"], ... }
```
## 📰 Change log
See [GitHub releases](https://github.com/eslint/eslint-visitor-keys/releases).
## 🍻 Contributing
Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer-guide/contributing/).
### Development commands
- `npm test` runs tests and measures code coverage.
- `npm run lint` checks source codes with ESLint.
- `npm run coverage` opens the code coverage report of the previous test with your default browser.
- `npm run release` publishes this package to [npm] registory.
[npm]: https://www.npmjs.com/
[Node.js]: https://nodejs.org/en/
[ESTree]: https://github.com/estree/estree

View File

@@ -0,0 +1,81 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict";
const KEYS = require("./visitor-keys.json");
// Types.
const NODE_TYPES = Object.freeze(Object.keys(KEYS));
// Freeze the keys.
for (const type of NODE_TYPES) {
Object.freeze(KEYS[type]);
}
Object.freeze(KEYS);
// List to ignore keys.
const KEY_BLACKLIST = new Set([
"parent",
"leadingComments",
"trailingComments"
]);
/**
* Check whether a given key should be used or not.
* @param {string} key The key to check.
* @returns {boolean} `true` if the key should be used.
*/
function filterKey(key) {
return !KEY_BLACKLIST.has(key) && key[0] !== "_";
}
//------------------------------------------------------------------------------
// Public interfaces
//------------------------------------------------------------------------------
module.exports = Object.freeze({
/**
* Visitor keys.
* @type {{ [type: string]: string[] | undefined }}
*/
KEYS,
/**
* Get visitor keys of a given node.
* @param {Object} node The AST node to get keys.
* @returns {string[]} Visitor keys of the node.
*/
getKeys(node) {
return Object.keys(node).filter(filterKey);
},
// Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
// eslint-disable-next-line valid-jsdoc
/**
* Make the union set with `KEYS` and given keys.
* @param {Object} additionalKeys The additional keys.
* @returns {{ [type: string]: string[] | undefined }} The union set.
*/
unionWith(additionalKeys) {
const retv = Object.assign({}, KEYS);
for (const type of Object.keys(additionalKeys)) {
if (retv.hasOwnProperty(type)) {
const keys = new Set(additionalKeys[type]);
for (const key of retv[type]) {
keys.add(key);
}
retv[type] = Object.freeze(Array.from(keys));
} else {
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
}
}
return Object.freeze(retv);
}
});

View File

@@ -0,0 +1,289 @@
{
"AssignmentExpression": [
"left",
"right"
],
"AssignmentPattern": [
"left",
"right"
],
"ArrayExpression": [
"elements"
],
"ArrayPattern": [
"elements"
],
"ArrowFunctionExpression": [
"params",
"body"
],
"AwaitExpression": [
"argument"
],
"BlockStatement": [
"body"
],
"BinaryExpression": [
"left",
"right"
],
"BreakStatement": [
"label"
],
"CallExpression": [
"callee",
"arguments"
],
"CatchClause": [
"param",
"body"
],
"ChainExpression": [
"expression"
],
"ClassBody": [
"body"
],
"ClassDeclaration": [
"id",
"superClass",
"body"
],
"ClassExpression": [
"id",
"superClass",
"body"
],
"ConditionalExpression": [
"test",
"consequent",
"alternate"
],
"ContinueStatement": [
"label"
],
"DebuggerStatement": [],
"DoWhileStatement": [
"body",
"test"
],
"EmptyStatement": [],
"ExportAllDeclaration": [
"exported",
"source"
],
"ExportDefaultDeclaration": [
"declaration"
],
"ExportNamedDeclaration": [
"declaration",
"specifiers",
"source"
],
"ExportSpecifier": [
"exported",
"local"
],
"ExpressionStatement": [
"expression"
],
"ExperimentalRestProperty": [
"argument"
],
"ExperimentalSpreadProperty": [
"argument"
],
"ForStatement": [
"init",
"test",
"update",
"body"
],
"ForInStatement": [
"left",
"right",
"body"
],
"ForOfStatement": [
"left",
"right",
"body"
],
"FunctionDeclaration": [
"id",
"params",
"body"
],
"FunctionExpression": [
"id",
"params",
"body"
],
"Identifier": [],
"IfStatement": [
"test",
"consequent",
"alternate"
],
"ImportDeclaration": [
"specifiers",
"source"
],
"ImportDefaultSpecifier": [
"local"
],
"ImportExpression": [
"source"
],
"ImportNamespaceSpecifier": [
"local"
],
"ImportSpecifier": [
"imported",
"local"
],
"JSXAttribute": [
"name",
"value"
],
"JSXClosingElement": [
"name"
],
"JSXElement": [
"openingElement",
"children",
"closingElement"
],
"JSXEmptyExpression": [],
"JSXExpressionContainer": [
"expression"
],
"JSXIdentifier": [],
"JSXMemberExpression": [
"object",
"property"
],
"JSXNamespacedName": [
"namespace",
"name"
],
"JSXOpeningElement": [
"name",
"attributes"
],
"JSXSpreadAttribute": [
"argument"
],
"JSXText": [],
"JSXFragment": [
"openingFragment",
"children",
"closingFragment"
],
"Literal": [],
"LabeledStatement": [
"label",
"body"
],
"LogicalExpression": [
"left",
"right"
],
"MemberExpression": [
"object",
"property"
],
"MetaProperty": [
"meta",
"property"
],
"MethodDefinition": [
"key",
"value"
],
"NewExpression": [
"callee",
"arguments"
],
"ObjectExpression": [
"properties"
],
"ObjectPattern": [
"properties"
],
"PrivateIdentifier": [],
"Program": [
"body"
],
"Property": [
"key",
"value"
],
"PropertyDefinition": [
"key",
"value"
],
"RestElement": [
"argument"
],
"ReturnStatement": [
"argument"
],
"SequenceExpression": [
"expressions"
],
"SpreadElement": [
"argument"
],
"Super": [],
"SwitchStatement": [
"discriminant",
"cases"
],
"SwitchCase": [
"test",
"consequent"
],
"TaggedTemplateExpression": [
"tag",
"quasi"
],
"TemplateElement": [],
"TemplateLiteral": [
"quasis",
"expressions"
],
"ThisExpression": [],
"ThrowStatement": [
"argument"
],
"TryStatement": [
"block",
"handler",
"finalizer"
],
"UnaryExpression": [
"argument"
],
"UpdateExpression": [
"argument"
],
"VariableDeclaration": [
"declarations"
],
"VariableDeclarator": [
"id",
"init"
],
"WhileStatement": [
"test",
"body"
],
"WithStatement": [
"object",
"body"
],
"YieldExpression": [
"argument"
]
}

View File

@@ -0,0 +1,39 @@
{
"name": "eslint-visitor-keys",
"version": "2.1.0",
"description": "Constants and utilities about visitor keys to traverse AST.",
"main": "lib/index.js",
"files": [
"lib"
],
"engines": {
"node": ">=10"
},
"dependencies": {},
"devDependencies": {
"eslint": "^4.7.2",
"eslint-config-eslint": "^4.0.0",
"eslint-release": "^1.0.0",
"mocha": "^3.5.3",
"nyc": "^11.2.1",
"opener": "^1.4.3"
},
"scripts": {
"lint": "eslint lib tests/lib",
"test": "nyc mocha tests/lib",
"coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
"generate-release": "eslint-generate-release",
"generate-alpharelease": "eslint-generate-prerelease alpha",
"generate-betarelease": "eslint-generate-prerelease beta",
"generate-rcrelease": "eslint-generate-prerelease rc",
"publish-release": "eslint-publish-release"
},
"repository": "eslint/eslint-visitor-keys",
"keywords": [],
"author": "Toru Nagashima (https://github.com/mysticatea)",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/eslint/eslint-visitor-keys/issues"
},
"homepage": "https://github.com/eslint/eslint-visitor-keys#readme"
}

View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@@ -0,0 +1,443 @@
semver(1) -- The semantic versioner for npm
===========================================
## Install
```bash
npm install semver
````
## Usage
As a node module:
```js
const semver = require('semver')
semver.valid('1.2.3') // '1.2.3'
semver.valid('a.b.c') // null
semver.clean(' =v1.2.3 ') // '1.2.3'
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
semver.gt('1.2.3', '9.8.7') // false
semver.lt('1.2.3', '9.8.7') // true
semver.minVersion('>=1.0.0') // '1.0.0'
semver.valid(semver.coerce('v2')) // '2.0.0'
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
```
As a command-line utility:
```
$ semver -h
A JavaScript implementation of the https://semver.org/ specification
Copyright Isaac Z. Schlueter
Usage: semver [options] <version> [<version> [...]]
Prints valid versions sorted by SemVer precedence
Options:
-r --range <range>
Print versions that match the specified range.
-i --increment [<level>]
Increment a version by the specified level. Level can
be one of: major, minor, patch, premajor, preminor,
prepatch, or prerelease. Default level is 'patch'.
Only one version may be specified.
--preid <identifier>
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.
-l --loose
Interpret versions and ranges loosely
-p --include-prerelease
Always include prerelease versions in range matching
-c --coerce
Coerce a string into SemVer if possible
(does not imply --loose)
--rtl
Coerce version strings right to left
--ltr
Coerce version strings left to right (default)
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
If no satisfying versions are found, then exits failure.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.
```
## Versions
A "version" is described by the `v2.0.0` specification found at
<https://semver.org/>.
A leading `"="` or `"v"` character is stripped off and ignored.
## Ranges
A `version range` is a set of `comparators` which specify versions
that satisfy the range.
A `comparator` is composed of an `operator` and a `version`. The set
of primitive `operators` is:
* `<` Less than
* `<=` Less than or equal to
* `>` Greater than
* `>=` Greater than or equal to
* `=` Equal. If no operator is specified, then equality is assumed,
so this operator is optional, but MAY be included.
For example, the comparator `>=1.2.7` would match the versions
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
or `1.1.0`.
Comparators can be joined by whitespace to form a `comparator set`,
which is satisfied by the **intersection** of all of the comparators
it includes.
A range is composed of one or more comparator sets, joined by `||`. A
version matches a range if and only if every comparator in at least
one of the `||`-separated comparator sets is satisfied by the version.
For example, the range `>=1.2.7 <1.3.0` would match the versions
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
or `1.1.0`.
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
### Prerelease Tags
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
it will only be allowed to satisfy comparator sets if at least one
comparator with the same `[major, minor, patch]` tuple also has a
prerelease tag.
For example, the range `>1.2.3-alpha.3` would be allowed to match the
version `1.2.3-alpha.7`, but it would *not* be satisfied by
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
range only accepts prerelease tags on the `1.2.3` version. The
version `3.4.5` *would* satisfy the range, because it does not have a
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
The purpose for this behavior is twofold. First, prerelease versions
frequently are updated very quickly, and contain many breaking changes
that are (by the author's design) not yet fit for public consumption.
Therefore, by default, they are excluded from range matching
semantics.
Second, a user who has opted into using a prerelease version has
clearly indicated the intent to use *that specific* set of
alpha/beta/rc versions. By including a prerelease tag in the range,
the user is indicating that they are aware of the risk. However, it
is still not appropriate to assume that they have opted into taking a
similar risk on the *next* set of prerelease versions.
Note that this behavior can be suppressed (treating all prerelease
versions as if they were normal versions, for the purpose of range
matching) by setting the `includePrerelease` flag on the options
object to any
[functions](https://github.com/npm/node-semver#functions) that do
range matching.
#### Prerelease Identifiers
The method `.inc` takes an additional `identifier` string argument that
will append the value of the string as a prerelease identifier:
```javascript
semver.inc('1.2.3', 'prerelease', 'beta')
// '1.2.4-beta.0'
```
command-line example:
```bash
$ semver 1.2.3 -i prerelease --preid beta
1.2.4-beta.0
```
Which then can be used to increment further:
```bash
$ semver 1.2.4-beta.0 -i prerelease
1.2.4-beta.1
```
### Advanced Range Syntax
Advanced range syntax desugars to primitive comparators in
deterministic ways.
Advanced ranges may be combined in the same way as primitive
comparators using white space or `||`.
#### Hyphen Ranges `X.Y.Z - A.B.C`
Specifies an inclusive set.
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
If a partial version is provided as the first version in the inclusive
range, then the missing pieces are replaced with zeroes.
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
If a partial version is provided as the second version in the
inclusive range, then all versions that start with the supplied parts
of the tuple are accepted, but nothing that would be greater than the
provided tuple parts.
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
numeric values in the `[major, minor, patch]` tuple.
* `*` := `>=0.0.0` (Any version satisfies)
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
A partial version range is treated as an X-Range, so the special
character is in fact optional.
* `""` (empty string) := `*` := `>=0.0.0`
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
Allows patch-level changes if a minor version is specified on the
comparator. Allows minor-level changes if not.
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
Allows changes that do not modify the left-most non-zero element in the
`[major, minor, patch]` tuple. In other words, this allows patch and
minor updates for versions `1.0.0` and above, patch updates for
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
Many authors treat a `0.x` version as if the `x` were the major
"breaking-change" indicator.
Caret ranges are ideal when an author may make breaking changes
between `0.2.4` and `0.3.0` releases, which is a common practice.
However, it presumes that there will *not* be breaking changes between
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
additive (but non-breaking), according to commonly observed practices.
* `^1.2.3` := `>=1.2.3 <2.0.0`
* `^0.2.3` := `>=0.2.3 <0.3.0`
* `^0.0.3` := `>=0.0.3 <0.0.4`
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
`0.0.3` version *only* will be allowed, if they are greater than or
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
When parsing caret ranges, a missing `patch` value desugars to the
number `0`, but will allow flexibility within that value, even if the
major and minor versions are both `0`.
* `^1.2.x` := `>=1.2.0 <2.0.0`
* `^0.0.x` := `>=0.0.0 <0.1.0`
* `^0.0` := `>=0.0.0 <0.1.0`
A missing `minor` and `patch` values will desugar to zero, but also
allow flexibility within those values, even if the major version is
zero.
* `^1.x` := `>=1.0.0 <2.0.0`
* `^0.x` := `>=0.0.0 <1.0.0`
### Range Grammar
Putting all this together, here is a Backus-Naur grammar for ranges,
for the benefit of parser authors:
```bnf
range-set ::= range ( logical-or range ) *
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' - ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+
```
## Functions
All methods and classes take a final `options` object argument. All
options in this object are `false` by default. The options supported
are:
- `loose` Be more forgiving about not-quite-valid semver strings.
(Any resulting output will always be 100% strict compliant, of
course.) For backwards compatibility reasons, if the `options`
argument is a boolean value instead of an object, it is interpreted
to be the `loose` param.
- `includePrerelease` Set to suppress the [default
behavior](https://github.com/npm/node-semver#prerelease-tags) of
excluding prerelease tagged versions from ranges unless they are
explicitly opted into.
Strict-mode Comparators and Ranges will be strict about the SemVer
strings that they parse.
* `valid(v)`: Return the parsed version, or null if it's not valid.
* `inc(v, release)`: Return the version incremented by the release
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
`prepatch`, or `prerelease`), or null if it's not valid
* `premajor` in one call will bump the version up to the next major
version and down to a prerelease of that major version.
`preminor`, and `prepatch` work the same way.
* If called from a non-prerelease version, the `prerelease` will work the
same as `prepatch`. It increments the patch version, then makes a
prerelease. If the input version is already a prerelease it simply
increments it.
* `prerelease(v)`: Returns an array of prerelease components, or null
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
* `major(v)`: Return the major version number.
* `minor(v)`: Return the minor version number.
* `patch(v)`: Return the patch version number.
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
or comparators intersect.
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
a `SemVer` object or `null`.
### Comparison
* `gt(v1, v2)`: `v1 > v2`
* `gte(v1, v2)`: `v1 >= v2`
* `lt(v1, v2)`: `v1 < v2`
* `lte(v1, v2)`: `v1 <= v2`
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
even if they're not the exact same string. You already know how to
compare strings.
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
the corresponding function above. `"==="` and `"!=="` do simple
string comparison, but are included for completeness. Throws if an
invalid comparison string is provided.
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
in descending order when passed to `Array.sort()`.
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
are equal. Sorts in ascending order if passed to `Array.sort()`.
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `diff(v1, v2)`: Returns difference between two versions by the release type
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
or null if the versions are the same.
### Comparators
* `intersects(comparator)`: Return true if the comparators intersect
### Ranges
* `validRange(range)`: Return the valid range or null if it's not valid
* `satisfies(version, range)`: Return true if the version satisfies the
range.
* `maxSatisfying(versions, range)`: Return the highest version in the list
that satisfies the range, or `null` if none of them do.
* `minSatisfying(versions, range)`: Return the lowest version in the list
that satisfies the range, or `null` if none of them do.
* `minVersion(range)`: Return the lowest version that can possibly match
the given range.
* `gtr(version, range)`: Return `true` if version is greater than all the
versions possible in the range.
* `ltr(version, range)`: Return `true` if version is less than all the
versions possible in the range.
* `outside(version, range, hilo)`: Return true if the version is outside
the bounds of the range in either the high or low direction. The
`hilo` argument must be either the string `'>'` or `'<'`. (This is
the function called by `gtr` and `ltr`.)
* `intersects(range)`: Return true if any of the ranges comparators intersect
Note that, since ranges may be non-contiguous, a version might not be
greater than a range, less than a range, *or* satisfy a range! For
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
until `2.0.0`, so the version `1.2.10` would not be greater than the
range (because `2.0.1` satisfies, which is higher), nor less than the
range (since `1.2.8` satisfies, which is lower), and it also does not
satisfy the range.
If you want to know if a version satisfies or does not satisfy a
range, use the `satisfies(version, range)` function.
### Coercion
* `coerce(version, options)`: Coerces a string to semver if possible
This aims to provide a very forgiving translation of a non-semver string to
semver. It looks for the first digit in a string, and consumes all
remaining characters which satisfy at least a partial semver (e.g., `1`,
`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
`3.4.0`). Only text which lacks digits will fail coercion (`version one`
is not valid). The maximum length for any semver component considered for
coercion is 16 characters; longer components will be ignored
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
components are invalid (`9999999999999999.4.7.4` is likely invalid).
If the `options.rtl` flag is set, then `coerce` will return the right-most
coercible tuple that does not share an ending index with a longer coercible
tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not
`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of
any other overlapping SemVer tuple.
### Clean
* `clean(version)`: Clean a string to be a valid semver if possible
This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges.
ex.
* `s.clean(' = v 2.1.5foo')`: `null`
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
* `s.clean(' = v 2.1.5-foo')`: `null`
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
* `s.clean('=v2.1.5')`: `'2.1.5'`
* `s.clean(' =v2.1.5')`: `2.1.5`
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
* `s.clean('~1.0.0')`: `null`

View File

@@ -0,0 +1,174 @@
#!/usr/bin/env node
// Standalone semver comparison program.
// Exits successfully and prints matching version(s) if
// any supplied version is valid and passes all tests.
var argv = process.argv.slice(2)
var versions = []
var range = []
var inc = null
var version = require('../package.json').version
var loose = false
var includePrerelease = false
var coerce = false
var rtl = false
var identifier
var semver = require('../semver')
var reverse = false
var options = {}
main()
function main () {
if (!argv.length) return help()
while (argv.length) {
var a = argv.shift()
var indexOfEqualSign = a.indexOf('=')
if (indexOfEqualSign !== -1) {
a = a.slice(0, indexOfEqualSign)
argv.unshift(a.slice(indexOfEqualSign + 1))
}
switch (a) {
case '-rv': case '-rev': case '--rev': case '--reverse':
reverse = true
break
case '-l': case '--loose':
loose = true
break
case '-p': case '--include-prerelease':
includePrerelease = true
break
case '-v': case '--version':
versions.push(argv.shift())
break
case '-i': case '--inc': case '--increment':
switch (argv[0]) {
case 'major': case 'minor': case 'patch': case 'prerelease':
case 'premajor': case 'preminor': case 'prepatch':
inc = argv.shift()
break
default:
inc = 'patch'
break
}
break
case '--preid':
identifier = argv.shift()
break
case '-r': case '--range':
range.push(argv.shift())
break
case '-c': case '--coerce':
coerce = true
break
case '--rtl':
rtl = true
break
case '--ltr':
rtl = false
break
case '-h': case '--help': case '-?':
return help()
default:
versions.push(a)
break
}
}
var options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
versions = versions.map(function (v) {
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
}).filter(function (v) {
return semver.valid(v)
})
if (!versions.length) return fail()
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
for (var i = 0, l = range.length; i < l; i++) {
versions = versions.filter(function (v) {
return semver.satisfies(v, range[i], options)
})
if (!versions.length) return fail()
}
return success(versions)
}
function failInc () {
console.error('--inc can only be used on a single version with no range')
fail()
}
function fail () { process.exit(1) }
function success () {
var compare = reverse ? 'rcompare' : 'compare'
versions.sort(function (a, b) {
return semver[compare](a, b, options)
}).map(function (v) {
return semver.clean(v, options)
}).map(function (v) {
return inc ? semver.inc(v, inc, options, identifier) : v
}).forEach(function (v, i, _) { console.log(v) })
}
function help () {
console.log(['SemVer ' + version,
'',
'A JavaScript implementation of the https://semver.org/ specification',
'Copyright Isaac Z. Schlueter',
'',
'Usage: semver [options] <version> [<version> [...]]',
'Prints valid versions sorted by SemVer precedence',
'',
'Options:',
'-r --range <range>',
' Print versions that match the specified range.',
'',
'-i --increment [<level>]',
' Increment a version by the specified level. Level can',
' be one of: major, minor, patch, premajor, preminor,',
" prepatch, or prerelease. Default level is 'patch'.",
' Only one version may be specified.',
'',
'--preid <identifier>',
' Identifier to be used to prefix premajor, preminor,',
' prepatch or prerelease version increments.',
'',
'-l --loose',
' Interpret versions and ranges loosely',
'',
'-p --include-prerelease',
' Always include prerelease versions in range matching',
'',
'-c --coerce',
' Coerce a string into SemVer if possible',
' (does not imply --loose)',
'',
'--rtl',
' Coerce version strings right to left',
'',
'--ltr',
' Coerce version strings left to right (default)',
'',
'Program exits successfully if any valid version satisfies',
'all supplied ranges, and prints all satisfying versions.',
'',
'If no satisfying versions are found, then exits failure.',
'',
'Versions are printed in ascending order, so supplying',
'multiple versions to the utility will just sort them.'
].join('\n'))
}

View File

@@ -0,0 +1,38 @@
{
"name": "semver",
"version": "6.3.1",
"description": "The semantic version parser used by npm.",
"main": "semver.js",
"scripts": {
"test": "tap test/ --100 --timeout=30",
"lint": "echo linting disabled",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force",
"lintfix": "npm run lint -- --fix",
"snap": "tap test/ --100 --timeout=30",
"posttest": "npm run lint"
},
"devDependencies": {
"@npmcli/template-oss": "4.17.0",
"tap": "^12.7.0"
},
"license": "ISC",
"repository": {
"type": "git",
"url": "https://github.com/npm/node-semver.git"
},
"bin": {
"semver": "./bin/semver.js"
},
"files": [
"bin",
"range.bnf",
"semver.js"
],
"author": "GitHub Inc.",
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"content": "./scripts/template-oss",
"version": "4.17.0"
}
}

View File

@@ -0,0 +1,16 @@
range-set ::= range ( logical-or range ) *
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' - ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | [1-9] ( [0-9] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
{
"name": "@babel/eslint-parser",
"version": "7.28.4",
"description": "ESLint parser that allows for linting of experimental syntax transformed by Babel",
"author": "The Babel Team (https://babel.dev/team)",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "eslint/babel-eslint-parser"
},
"publishConfig": {
"access": "public"
},
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"homepage": "https://babel.dev/",
"engines": {
"node": "^10.13.0 || ^12.13.0 || >=14.0.0"
},
"main": "./lib/index.cjs",
"type": "module",
"types": "./types.d.cts",
"exports": {
".": {
"default": "./lib/index.cjs",
"types": "./types.d.cts"
},
"./experimental-worker": {
"default": "./lib/experimental-worker.cjs",
"types": "./types.d.cts"
},
"./package.json": "./package.json"
},
"peerDependencies": {
"@babel/core": "^7.11.0",
"eslint": "^7.5.0 || ^8.0.0 || ^9.0.0"
},
"dependencies": {
"@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1",
"eslint-visitor-keys": "^2.1.0",
"semver": "^6.3.1"
},
"devDependencies": {
"@babel/core": "^7.28.4",
"@babel/helper-fixtures": "^7.28.0",
"@types/eslint": "^8.56.2",
"@types/estree": "^1.0.5",
"@typescript-eslint/scope-manager": "^6.19.0",
"dedent": "^1.5.3",
"eslint": "^9.21.0",
"typescript-eslint": "8.39.1"
}
}

View File

@@ -0,0 +1,9 @@
import type { ESLint, Linter, AST } from "eslint";
export declare const meta: ESLint.ObjectMetaProperties["meta"];
export declare const parse: (text: string, options?: any) => AST.Program;
export declare const parseForESLint: (
text: string,
options?: any
) => Linter.ESLintParseResult;